feat: add region and terms to intro
This commit is contained in:
@@ -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