diff --git a/experimental/desktop_photo_search/lib/main.dart b/experimental/desktop_photo_search/lib/main.dart index db9921b51..18dbace99 100644 --- a/experimental/desktop_photo_search/lib/main.dart +++ b/experimental/desktop_photo_search/lib/main.dart @@ -15,6 +15,7 @@ import 'package:provider/provider.dart'; import 'src/model/photo_search_model.dart'; import 'src/unsplash/unsplash.dart'; +import 'src/widgets/about_dialog.dart'; import 'src/widgets/photo_details.dart'; import 'src/widgets/photo_search_dialog.dart'; import 'src/widgets/split.dart'; @@ -75,6 +76,17 @@ class UnsplashHomePage extends StatelessWidget { ); }, ), + ]), + menubar.Submenu(label: 'About', children: [ + menubar.MenuItem( + label: 'About ...', + onClicked: () { + showDialog( + context: context, + builder: (context) => PolicyDialog(), + ); + }, + ), ]) ]); diff --git a/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart b/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart new file mode 100644 index 000000000..b7a39d94a --- /dev/null +++ b/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart @@ -0,0 +1,98 @@ +// Copyright 2019 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart' as url_launcher; + +class PolicyDialog extends StatelessWidget { + PolicyDialog({ + Key key, + this.radius = 8, + }) : super(key: key); + + final double radius; + + @override + Widget build(BuildContext context) { + return AlertDialog( + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius)), + content: Builder( + builder: (context) { + var height = MediaQuery.of(context).size.height; + var width = MediaQuery.of(context).size.width; + return Container( + height: height / 4, + width: width / 4, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: 'Terms & Conditions:\n', + style: Theme.of(context).textTheme.headline5, + ), + ), + RichText( + textAlign: TextAlign.left, + text: TextSpan( + text: '• ', + style: TextStyle(color: Colors.black, fontSize: 18), + children: [ + TextSpan( + text: 'https://policies.google.com/terms', + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.lightBlue), + recognizer: TapGestureRecognizer() + ..onTap = () async { + final url = 'https://policies.google.com/terms'; + if (await url_launcher.canLaunch(url)) { + await url_launcher.launch(url); + } + }, + ) + ], + ), + ), + RichText( + textAlign: TextAlign.left, + text: TextSpan( + text: '• ', + style: TextStyle(color: Colors.black, fontSize: 18), + children: [ + TextSpan( + text: 'https://unsplash.com/terms', + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.lightBlue), + recognizer: TapGestureRecognizer() + ..onTap = () async { + final url = 'https://unsplash.com/terms'; + if (await url_launcher.canLaunch(url)) { + await url_launcher.launch(url); + } + }, + ) + ], + ), + ), + ], + ), + ); + }, + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text( + 'CLOSE'.toUpperCase(), + style: TextStyle(fontSize: 20), + ), + ), + ], + ); + } +} diff --git a/experimental/desktop_photo_search/pubspec.lock b/experimental/desktop_photo_search/pubspec.lock index a29c9133b..f0ac7f557 100644 --- a/experimental/desktop_photo_search/pubspec.lock +++ b/experimental/desktop_photo_search/pubspec.lock @@ -739,4 +739,4 @@ packages: version: "2.2.1" sdks: dart: ">=2.12.0-0.0 <3.0.0" - flutter: ">=1.22.0 <2.0.0" + flutter: ">=1.22.0" diff --git a/experimental/desktop_photo_search/windows/flutter/CMakeLists.txt b/experimental/desktop_photo_search/windows/flutter/CMakeLists.txt index c7a8c7607..744f08a93 100644 --- a/experimental/desktop_photo_search/windows/flutter/CMakeLists.txt +++ b/experimental/desktop_photo_search/windows/flutter/CMakeLists.txt @@ -91,6 +91,7 @@ add_custom_command( ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ + VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}"