alexeyinkin commented on code in PR #24820: URL: https://github.com/apache/beam/pull/24820#discussion_r1059066253
########## playground/frontend/lib/components/link_button.dart: ########## @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../constants/assets.dart'; + +class LinkButton extends StatelessWidget { + final String iconPath; + final String text; + final String url; + + const LinkButton({ + required this.iconPath, + required this.text, + required this.url, + }); + + factory LinkButton.colab(String url) { + return LinkButton( + iconPath: kColabIconAsset, + text: 'intents.playground.openGoogleColab'.tr(), + url: url, + ); + } + + factory LinkButton.github(String url) { + return LinkButton( + iconPath: kGithubIconAsset, + text: 'intents.playground.viewOnGithub'.tr(), + url: url, + ); + } + + @override + Widget build(BuildContext context) { + return TextButton.icon( + icon: SvgPicture.asset(iconPath), + onPressed: () { + launchUrl(Uri.parse(url)); + }, + label: Text(text), + ); + } +} Review Comment: Newline. ########## playground/frontend/assets/github.svg: ########## @@ -17,7 +17,7 @@ under the License. --> -<svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"> +<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> Review Comment: It is off-center now. ########## playground/frontend/lib/components/link_button.dart: ########## @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../constants/assets.dart'; + +class LinkButton extends StatelessWidget { + final String iconPath; + final String text; + final String url; + + const LinkButton({ + required this.iconPath, + required this.text, + required this.url, + }); + + factory LinkButton.colab(String url) { + return LinkButton( + iconPath: kColabIconAsset, + text: 'intents.playground.openGoogleColab'.tr(), + url: url, + ); + } + + factory LinkButton.github(String url) { + return LinkButton( + iconPath: kGithubIconAsset, + text: 'intents.playground.viewOnGithub'.tr(), + url: url, + ); + } + + @override + Widget build(BuildContext context) { + return TextButton.icon( + icon: SvgPicture.asset(iconPath), Review Comment: Make the Colab icon grey to match GitHub? ########## playground/frontend/playground_components/lib/src/models/example.dart: ########## @@ -39,7 +39,8 @@ class Example extends ExampleBase { super.contextLine, super.description, super.isMultiFile, - super.link, + super.urlNotebook, + super.urlVcs, super.pipelineOptions, super.tags, super.viewOptions, Review Comment: Sort? Here and below. ########## playground/frontend/playground_components/lib/src/repositories/example_client/grpc_example_client.dart: ########## @@ -333,7 +333,8 @@ class GrpcExampleClient implements ExampleClient { contextLine: example.contextLine, pipelineOptions: example.pipelineOptions, isMultiFile: example.multifile, - link: example.link, + urlNotebook: example.urlNotebook, + urlVcs: example.urlVcs, complexity: example.complexity.model, Review Comment: Sort all fields? ########## playground/frontend/lib/constants/assets.dart: ########## @@ -23,6 +23,7 @@ const kOutputRightIconAsset = 'output_right.svg'; const kOutputLeftIconAsset = 'output_left.svg'; const kShortcutsIconAsset = 'shortcuts.svg'; const kGithubIconAsset = 'github.svg'; +const kColabIconAsset = 'colab.svg'; Review Comment: On some (unmerged?) branch we were dropping these constants in favor of flutter_gen. Can this PR be done on that branch? ########## playground/frontend/playground_components/lib/src/models/example_base.dart: ########## @@ -55,7 +55,8 @@ class ExampleBase with Comparable<ExampleBase>, EquatableMixin { final int contextLine; final String description; final bool isMultiFile; - final String? link; + final String? urlNotebook; + final String? urlVcs; Review Comment: Sort? Here and below. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
