rework privacy page

This commit is contained in:
Leptopoda-GitHub 2021-11-22 14:15:37 +01:00
parent 385526fa82
commit 110ad64d55
No known key found for this signature in database
GPG Key ID: 661B059EDE309F11
2 changed files with 11 additions and 25 deletions

View File

@ -1264,7 +1264,7 @@ class _GamePageState extends State<GamePage>
Future<void> _showPrivacyDialog() async { Future<void> _showPrivacyDialog() async {
if (!LocalDatabaseService.preferences.isPrivacyPolicyAccepted && if (!LocalDatabaseService.preferences.isPrivacyPolicyAccepted &&
Localizations.localeOf(context).languageCode == "zh") { Localizations.localeOf(context).languageCode.startsWith("zh_")) {
await showPrivacyDialog(context); await showPrivacyDialog(context);
} }
} }
@ -1288,11 +1288,11 @@ class _GamePageState extends State<GamePage>
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
_showPrivacyDialog();
screenPaddingH = _screenPaddingH; screenPaddingH = _screenPaddingH;
ltr = Directionality.of(context) == TextDirection.ltr; ltr = Directionality.of(context) == TextDirection.ltr;
_tip = S.of(context).welcome; _tip = S.of(context).welcome;
_showPrivacyDialog();
} }
@override @override

View File

@ -18,7 +18,6 @@
import 'dart:io'; import 'dart:io';
import 'package:devicelocale/devicelocale.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -40,29 +39,16 @@ class _LinkTextSpan extends TextSpan {
); );
} }
Future<void> showPrivacyDialog( Future<void> showPrivacyDialog(BuildContext context) async {
BuildContext context, assert(Localizations.localeOf(context).languageCode.startsWith("zh_"));
) async {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final TextStyle? aboutTextStyle = themeData.textTheme.bodyText1; final TextStyle aboutTextStyle = themeData.textTheme.bodyText1!;
final TextStyle linkStyle = themeData.textTheme.bodyText1! final TextStyle linkStyle =
.copyWith(color: themeData.colorScheme.secondary); aboutTextStyle.copyWith(color: themeData.colorScheme.secondary);
String? locale = "en_US"; const String eulaURL = Constants.giteeEulaURL;
late String eulaURL; const String privacyPolicyURL = Constants.giteePrivacyPolicyURL;
late String privacyPolicyURL;
if (!Platform.isWindows) {
locale = await Devicelocale.currentLocale;
}
debugPrint("[about] local = $locale");
if (locale != null && locale.startsWith("zh_")) {
eulaURL = Constants.giteeEulaURL;
privacyPolicyURL = Constants.giteePrivacyPolicyURL;
} else {
eulaURL = Constants.githubEulaURL;
privacyPolicyURL = Constants.githubPrivacyPolicyURL;
}
Future<void> _setPrivacyPolicyAccepted({required bool value}) async { Future<void> _setPrivacyPolicyAccepted({required bool value}) async {
LocalDatabaseService.preferences = LocalDatabaseService.preferences LocalDatabaseService.preferences = LocalDatabaseService.preferences