flutter: Show en_US Privacy Policy web page when locale is not zh_*

This commit is contained in:
Calcitem 2021-04-19 00:59:57 +08:00
parent d4f0a8d224
commit 91c04f75b6
2 changed files with 18 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import 'package:package_info/package_info.dart';
import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/style/app_theme.dart';
import 'package:sanmill/widgets/settings_list_tile.dart';
import 'package:devicelocale/devicelocale.dart';
import 'package:url_launcher/url_launcher.dart';
import 'license_page.dart';
@ -120,11 +121,11 @@ class _AboutPageState extends State<AboutPage> {
),
ListItemDivider(),
SettingsListTile(
context: context,
titleString: S.of(context).privacyPolicy,
onTap: () => _launchURL(
'https://github.com/calcitem/Sanmill/wiki/privacy_policy'),
),
context: context,
titleString: S.of(context).privacyPolicy,
onTap: () {
_launchPrivacyPolicy();
}),
ListItemDivider(),
SettingsListTile(
context: context,
@ -160,6 +161,17 @@ class _AboutPageState extends State<AboutPage> {
await launch(url);
}
_launchPrivacyPolicy() async {
String? locale = await Devicelocale.currentLocale;
print("local = $locale");
if (locale != null && locale.startsWith("zh_")) {
_launchURL('https://gitee.com/calcitem/Sanmill/wikis/privacy_policy_zh');
} else {
_launchURL('https://github.com/calcitem/Sanmill/wiki/privacy_policy');
}
}
_showVersionInfo() {
showDialog(
context: context,

View File

@ -23,6 +23,7 @@ dependencies:
catcher: ^0.6.5
stack_trace: ^1.10.0
device_info_plus_platform_interface: ^1.0.1
devicelocale: ^0.4.1
dev_dependencies:
flutter_test: