Skip to content

Commit 4cae764

Browse files
committed
feature: open privacy policy in default browser
1 parent 08172a1 commit 4cae764

3 files changed

Lines changed: 82 additions & 2 deletions

File tree

lib/widget/settings.dart

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:fluttertoast/fluttertoast.dart';
33
import 'package:nhk_easy/error_reporter.dart';
44
import 'package:nhk_easy/repository/base_repository.dart';
55
import 'package:settings_ui/settings_ui.dart';
6+
import 'package:url_launcher/url_launcher.dart';
67

78
class Settings extends StatelessWidget {
89
final _baseRepository = BaseRepository();
@@ -28,7 +29,9 @@ class Settings extends StatelessWidget {
2829
SettingsTile(
2930
title: 'Privacy Policy',
3031
leading: Icon(Icons.description),
31-
onTap: () {},
32+
onTap: () {
33+
_openPrivacyPolicy(context);
34+
},
3235
)
3336
],
3437
)
@@ -74,4 +77,31 @@ class Settings extends StatelessWidget {
7477
},
7578
);
7679
}
80+
81+
void _openPrivacyPolicy(BuildContext context) async {
82+
final url = 'https://github.com/Frederick-S/nhk-easy-mobile-privacy-policy';
83+
84+
if (await canLaunch(url)) {
85+
await launch(url);
86+
} else {
87+
final okButton = FlatButton(
88+
child: Text('Ok'),
89+
onPressed: () {
90+
Navigator.pop(context);
91+
},
92+
);
93+
final alertDialog = AlertDialog(
94+
content: Text(
95+
'Failed to open privacy policy in your default browser, you can view it at $url'),
96+
actions: <Widget>[okButton],
97+
);
98+
99+
showDialog(
100+
context: context,
101+
builder: (BuildContext context) {
102+
return alertDialog;
103+
},
104+
);
105+
}
106+
}
77107
}

pubspec.lock

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@ packages:
149149
url: "https://pub.flutter-io.cn"
150150
source: hosted
151151
version: "2.4.0"
152+
platform_detect:
153+
dependency: transitive
154+
description:
155+
name: platform_detect
156+
url: "https://pub.flutter-io.cn"
157+
source: hosted
158+
version: "1.4.0"
159+
plugin_platform_interface:
160+
dependency: transitive
161+
description:
162+
name: plugin_platform_interface
163+
url: "https://pub.flutter-io.cn"
164+
source: hosted
165+
version: "1.0.2"
166+
pub_semver:
167+
dependency: transitive
168+
description:
169+
name: pub_semver
170+
url: "https://pub.flutter-io.cn"
171+
source: hosted
172+
version: "1.4.4"
152173
pull_to_refresh:
153174
dependency: "direct main"
154175
description:
@@ -252,6 +273,34 @@ packages:
252273
url: "https://pub.flutter-io.cn"
253274
source: hosted
254275
version: "1.1.6"
276+
url_launcher:
277+
dependency: "direct main"
278+
description:
279+
name: url_launcher
280+
url: "https://pub.flutter-io.cn"
281+
source: hosted
282+
version: "5.4.10"
283+
url_launcher_macos:
284+
dependency: transitive
285+
description:
286+
name: url_launcher_macos
287+
url: "https://pub.flutter-io.cn"
288+
source: hosted
289+
version: "0.0.1+7"
290+
url_launcher_platform_interface:
291+
dependency: transitive
292+
description:
293+
name: url_launcher_platform_interface
294+
url: "https://pub.flutter-io.cn"
295+
source: hosted
296+
version: "1.0.7"
297+
url_launcher_web:
298+
dependency: transitive
299+
description:
300+
name: url_launcher_web
301+
url: "https://pub.flutter-io.cn"
302+
source: hosted
303+
version: "0.1.1+6"
255304
usage:
256305
dependency: transitive
257306
description:

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: A new Flutter application.
1111
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14-
version: 1.1.1+4
14+
version: 1.1.2+5
1515

1616
environment:
1717
sdk: ">=2.2.0 <3.0.0"
@@ -32,6 +32,7 @@ dependencies:
3232
sentry: ^3.0.1
3333
global_configuration: ^1.5.0
3434
settings_ui: ^0.3.0
35+
url_launcher: ^5.4.10
3536

3637
dev_dependencies:
3738
flutter_test:

0 commit comments

Comments
 (0)