feat: add region and terms to intro
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"sortBy": "Sort by"
|
||||
},
|
||||
"intro": {
|
||||
"termsAndPolicyCaution(rich)": "by continuing you agree with ${tap(@:about.termsAndConditions)}",
|
||||
"start": "Start"
|
||||
},
|
||||
"home": {
|
||||
@@ -104,10 +105,17 @@
|
||||
},
|
||||
"settings": {
|
||||
"pageTitle": "Settings",
|
||||
"requiresRestartMsg": "for this to take effect restart the app",
|
||||
"requiresRestartMsg": "For this to take effect restart the app",
|
||||
"general": {
|
||||
"sectionTitle": "General",
|
||||
"locale": "Language",
|
||||
"region": "Region",
|
||||
"regionMsg": "Helps set default options to bypass domestic addresses",
|
||||
"regions": {
|
||||
"ir": "Iran (ir)",
|
||||
"cn": "China (cn)",
|
||||
"other": "Other"
|
||||
},
|
||||
"themeMode": "Theme Mode",
|
||||
"themeModes": {
|
||||
"system": "Follow system theme",
|
||||
@@ -182,7 +190,9 @@
|
||||
"version": "Version",
|
||||
"sourceCode": "Source Code",
|
||||
"telegramChannel": "Telegram Channel",
|
||||
"checkForUpdate": "Check for update"
|
||||
"checkForUpdate": "Check for update",
|
||||
"privacyPolicy": "Privacy policy",
|
||||
"termsAndConditions": "Terms and conditions"
|
||||
},
|
||||
"appUpdate": {
|
||||
"dialogTitle": "Update Available",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"sortBy": "مرتبسازی براساس"
|
||||
},
|
||||
"intro": {
|
||||
"termsAndPolicyCaution(rich)": "در صورت ادامه با ${tap(@:about.termsAndConditions)} موافقت میکنید",
|
||||
"start": "شروع"
|
||||
},
|
||||
"home": {
|
||||
@@ -108,6 +109,13 @@
|
||||
"general": {
|
||||
"sectionTitle": "اصلی",
|
||||
"locale": "زبان",
|
||||
"region": "منطقه",
|
||||
"regionMsg": "به انتخاب تنظیمات پیشفرض برای دورزدن آدرسهای داخلی کمک میکند",
|
||||
"regions": {
|
||||
"ir": "ایران (ir)",
|
||||
"cn": "چین (cn)",
|
||||
"other": "سایر"
|
||||
},
|
||||
"themeMode": "تم مود",
|
||||
"themeModes": {
|
||||
"system": "پیروی از تم دستگاه",
|
||||
@@ -182,7 +190,9 @@
|
||||
"version": "ورژن",
|
||||
"sourceCode": "سورس کد",
|
||||
"telegramChannel": "کانال تلگرام",
|
||||
"checkForUpdate": "بررسی آپدیت جدید"
|
||||
"checkForUpdate": "بررسی آپدیت جدید",
|
||||
"privacyPolicy": "سیاست حفظ حریم خصوصی",
|
||||
"termsAndConditions": "شرایط و ضوابط استفاده"
|
||||
},
|
||||
"appUpdate": {
|
||||
"dialogTitle": "نسخه جدید موجود است",
|
||||
|
||||
@@ -24,6 +24,25 @@ class IntroCompleted extends _$IntroCompleted {
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class RegionNotifier extends _$RegionNotifier {
|
||||
late final _pref = Pref(
|
||||
ref.watch(sharedPreferencesProvider),
|
||||
"region",
|
||||
Region.other,
|
||||
mapFrom: Region.values.byName,
|
||||
mapTo: (value) => value.name,
|
||||
);
|
||||
|
||||
@override
|
||||
Region build() => _pref.getValue();
|
||||
|
||||
Future<void> update(Region value) {
|
||||
state = value;
|
||||
return _pref.update(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class SilentStartNotifier extends _$SilentStartNotifier {
|
||||
late final _pref =
|
||||
|
||||
@@ -13,7 +13,7 @@ class LocaleNotifier extends _$LocaleNotifier {
|
||||
late final _pref = Pref(
|
||||
ref.watch(sharedPreferencesProvider),
|
||||
"locale",
|
||||
AppLocale.en,
|
||||
AppLocaleUtils.findDeviceLocale(),
|
||||
mapFrom: AppLocale.values.byName,
|
||||
mapTo: (value) => value.name,
|
||||
);
|
||||
|
||||
@@ -10,6 +10,8 @@ abstract class Constants {
|
||||
static const githubLatestReleaseUrl =
|
||||
"https://github.com/hiddify/hiddify-next/releases/latest";
|
||||
static const telegramChannelUrl = "https://t.me/hiddify";
|
||||
static const privacyPolicyUrl = "https://hiddify.com/en/privacy-policy/";
|
||||
static const termsAndConditionsUrl = "https://hiddify.com/terms/";
|
||||
}
|
||||
|
||||
abstract class Defaults {
|
||||
|
||||
@@ -22,3 +22,15 @@ enum PerAppProxyMode {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
enum Region {
|
||||
ir,
|
||||
cn,
|
||||
other;
|
||||
|
||||
String present(TranslationsEn t) => switch (this) {
|
||||
ir => t.settings.general.regions.ir,
|
||||
cn => t.settings.general.regions.cn,
|
||||
other => t.settings.general.regions.other,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_localized_locales/flutter_localized_locales.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/prefs/prefs.dart';
|
||||
import 'package:hiddify/domain/singbox/singbox.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
class LocalePrefTile extends HookConsumerWidget {
|
||||
@@ -54,6 +55,48 @@ class LocalePrefTile extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class RegionPrefTile extends HookConsumerWidget {
|
||||
const RegionPrefTile({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
|
||||
final region = ref.watch(regionNotifierProvider);
|
||||
|
||||
return ListTile(
|
||||
title: Text(t.settings.general.region),
|
||||
subtitle: Text(region.present(t)),
|
||||
leading: const Icon(Icons.my_location),
|
||||
onTap: () async {
|
||||
final selectedRegion = await showDialog<Region>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SimpleDialog(
|
||||
title: Text(t.settings.general.region),
|
||||
children: Region.values
|
||||
.map(
|
||||
(e) => RadioListTile(
|
||||
title: Text(e.present(t)),
|
||||
value: e,
|
||||
groupValue: region,
|
||||
onChanged: (e) => context.pop(e),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (selectedRegion != null) {
|
||||
await ref
|
||||
.read(regionNotifierProvider.notifier)
|
||||
.update(selectedRegion);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EnableAnalyticsPrefTile extends HookConsumerWidget {
|
||||
const EnableAnalyticsPrefTile({
|
||||
super.key,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/prefs/prefs.dart';
|
||||
import 'package:hiddify/domain/constants.dart';
|
||||
import 'package:hiddify/features/common/common.dart';
|
||||
import 'package:hiddify/gen/assets.gen.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
@@ -37,7 +39,28 @@ class IntroPage extends HookConsumerWidget with PresLogger {
|
||||
children: [
|
||||
const LocalePrefTile(),
|
||||
const SliverGap(8),
|
||||
const RegionPrefTile(),
|
||||
const SliverGap(8),
|
||||
const EnableAnalyticsPrefTile(),
|
||||
const SliverGap(8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text.rich(
|
||||
t.intro.termsAndPolicyCaution(
|
||||
tap: (text) => TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(color: Colors.blue),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
await UriUtils.tryLaunch(
|
||||
Uri.parse(Constants.termsAndConditionsUrl),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
|
||||
Reference in New Issue
Block a user