Skip to content

Commit 192dc62

Browse files
authored
[ Fixed Issue #667 ] Add Google and Unsplash terms links to experimental/desktop_photo_search (#678)
1 parent 9b631a2 commit 192dc62

File tree

4 files changed

+112
-1
lines changed

4 files changed

+112
-1
lines changed

experimental/desktop_photo_search/lib/main.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:provider/provider.dart';
1515

1616
import 'src/model/photo_search_model.dart';
1717
import 'src/unsplash/unsplash.dart';
18+
import 'src/widgets/about_dialog.dart';
1819
import 'src/widgets/photo_details.dart';
1920
import 'src/widgets/photo_search_dialog.dart';
2021
import 'src/widgets/split.dart';
@@ -75,6 +76,17 @@ class UnsplashHomePage extends StatelessWidget {
7576
);
7677
},
7778
),
79+
]),
80+
menubar.Submenu(label: 'About', children: [
81+
menubar.MenuItem(
82+
label: 'About ...',
83+
onClicked: () {
84+
showDialog<void>(
85+
context: context,
86+
builder: (context) => PolicyDialog(),
87+
);
88+
},
89+
),
7890
])
7991
]);
8092

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Copyright 2019 The Flutter team. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/gestures.dart';
6+
import 'package:flutter/material.dart';
7+
import 'package:url_launcher/url_launcher.dart' as url_launcher;
8+
9+
class PolicyDialog extends StatelessWidget {
10+
PolicyDialog({
11+
Key key,
12+
this.radius = 8,
13+
}) : super(key: key);
14+
15+
final double radius;
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return AlertDialog(
20+
shape:
21+
RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius)),
22+
content: Builder(
23+
builder: (context) {
24+
var height = MediaQuery.of(context).size.height;
25+
var width = MediaQuery.of(context).size.width;
26+
return Container(
27+
height: height / 4,
28+
width: width / 4,
29+
child: Column(
30+
mainAxisAlignment: MainAxisAlignment.center,
31+
crossAxisAlignment: CrossAxisAlignment.start,
32+
children: [
33+
RichText(
34+
textAlign: TextAlign.center,
35+
text: TextSpan(
36+
text: 'Terms & Conditions:\n',
37+
style: Theme.of(context).textTheme.headline5,
38+
),
39+
),
40+
RichText(
41+
textAlign: TextAlign.left,
42+
text: TextSpan(
43+
text: '• ',
44+
style: TextStyle(color: Colors.black, fontSize: 18),
45+
children: <TextSpan>[
46+
TextSpan(
47+
text: 'https://policies.google.com/terms',
48+
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.lightBlue),
49+
recognizer: TapGestureRecognizer()
50+
..onTap = () async {
51+
final url = 'https://policies.google.com/terms';
52+
if (await url_launcher.canLaunch(url)) {
53+
await url_launcher.launch(url);
54+
}
55+
},
56+
)
57+
],
58+
),
59+
),
60+
RichText(
61+
textAlign: TextAlign.left,
62+
text: TextSpan(
63+
text: '• ',
64+
style: TextStyle(color: Colors.black, fontSize: 18),
65+
children: <TextSpan>[
66+
TextSpan(
67+
text: 'https://unsplash.com/terms',
68+
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.lightBlue),
69+
recognizer: TapGestureRecognizer()
70+
..onTap = () async {
71+
final url = 'https://unsplash.com/terms';
72+
if (await url_launcher.canLaunch(url)) {
73+
await url_launcher.launch(url);
74+
}
75+
},
76+
)
77+
],
78+
),
79+
),
80+
],
81+
),
82+
);
83+
},
84+
),
85+
actions: <Widget>[
86+
TextButton(
87+
onPressed: () {
88+
Navigator.of(context).pop();
89+
},
90+
child: Text(
91+
'CLOSE'.toUpperCase(),
92+
style: TextStyle(fontSize: 20),
93+
),
94+
),
95+
],
96+
);
97+
}
98+
}

experimental/desktop_photo_search/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,4 +739,4 @@ packages:
739739
version: "2.2.1"
740740
sdks:
741741
dart: ">=2.12.0-0.0 <3.0.0"
742-
flutter: ">=1.22.0 <2.0.0"
742+
flutter: ">=1.22.0"

experimental/desktop_photo_search/windows/flutter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ add_custom_command(
9191
${FLUTTER_TOOL_ENVIRONMENT}
9292
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
9393
windows-x64 $<CONFIG>
94+
VERBATIM
9495
)
9596
add_custom_target(flutter_assemble DEPENDS
9697
"${FLUTTER_LIBRARY}"

0 commit comments

Comments
 (0)