2023-09-13 23:19:16 +03:30
|
|
|
import 'dart:io';
|
|
|
|
|
|
2024-02-15 15:23:02 +03:30
|
|
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
2023-09-01 15:00:41 +03:30
|
|
|
import 'package:flutter/material.dart';
|
2023-12-01 12:56:24 +03:30
|
|
|
import 'package:hiddify/core/localization/translations.dart';
|
|
|
|
|
import 'package:hiddify/core/preferences/general_preferences.dart';
|
2023-11-01 20:36:16 +03:30
|
|
|
import 'package:hiddify/core/router/router.dart';
|
2023-11-09 15:23:48 +03:30
|
|
|
import 'package:hiddify/features/common/general_pref_tiles.dart';
|
2023-12-01 12:56:24 +03:30
|
|
|
import 'package:hiddify/features/per_app_proxy/model/per_app_proxy_mode.dart';
|
2024-01-18 22:53:17 +03:30
|
|
|
import 'package:hiddify/features/settings/notifier/platform_settings_notifier.dart';
|
2023-09-01 15:00:41 +03:30
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
|
|
|
|
|
|
class AdvancedSettingTiles extends HookConsumerWidget {
|
|
|
|
|
const AdvancedSettingTiles({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final t = ref.watch(translationsProvider);
|
|
|
|
|
|
2023-09-07 13:43:46 +03:30
|
|
|
final debug = ref.watch(debugModeNotifierProvider);
|
2023-09-13 23:19:16 +03:30
|
|
|
final perAppProxy = ref.watch(perAppProxyModeNotifierProvider).enabled;
|
2023-10-26 15:16:25 +03:30
|
|
|
final disableMemoryLimit = ref.watch(disableMemoryLimitProvider);
|
2023-09-01 15:00:41 +03:30
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
2023-10-24 11:26:57 +02:00
|
|
|
const RegionPrefTile(),
|
2023-11-17 21:30:09 +03:30
|
|
|
ListTile(
|
|
|
|
|
title: Text(t.settings.geoAssets.pageTitle),
|
2024-02-15 15:23:02 +03:30
|
|
|
leading: const Icon(
|
|
|
|
|
FluentIcons.arrow_routing_rectangle_multiple_24_regular,
|
|
|
|
|
),
|
2023-11-17 21:30:09 +03:30
|
|
|
onTap: () async {
|
|
|
|
|
await const GeoAssetsRoute().push(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
2023-09-13 23:19:16 +03:30
|
|
|
if (Platform.isAndroid) ...[
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(t.settings.network.perAppProxyPageTitle),
|
2024-02-15 15:23:02 +03:30
|
|
|
leading: const Icon(FluentIcons.apps_list_detail_24_regular),
|
2023-09-13 23:19:16 +03:30
|
|
|
trailing: Switch(
|
|
|
|
|
value: perAppProxy,
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
final newMode =
|
|
|
|
|
perAppProxy ? PerAppProxyMode.off : PerAppProxyMode.exclude;
|
|
|
|
|
await ref
|
|
|
|
|
.read(perAppProxyModeNotifierProvider.notifier)
|
|
|
|
|
.update(newMode);
|
|
|
|
|
if (!perAppProxy && context.mounted) {
|
|
|
|
|
await const PerAppProxyRoute().push(context);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (!perAppProxy) {
|
|
|
|
|
await ref
|
|
|
|
|
.read(perAppProxyModeNotifierProvider.notifier)
|
|
|
|
|
.update(PerAppProxyMode.exclude);
|
|
|
|
|
}
|
|
|
|
|
if (context.mounted) await const PerAppProxyRoute().push(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
2024-01-13 16:16:49 +03:30
|
|
|
SwitchListTile(
|
|
|
|
|
title: Text(t.settings.advanced.memoryLimit),
|
|
|
|
|
subtitle: Text(t.settings.advanced.memoryLimitMsg),
|
|
|
|
|
value: !disableMemoryLimit,
|
2024-02-15 15:23:02 +03:30
|
|
|
secondary: const Icon(FluentIcons.developer_board_24_regular),
|
2024-01-13 16:16:49 +03:30
|
|
|
onChanged: (value) async {
|
|
|
|
|
await ref.read(disableMemoryLimitProvider.notifier).update(!value);
|
|
|
|
|
},
|
|
|
|
|
),
|
2024-01-18 22:53:17 +03:30
|
|
|
if (Platform.isIOS)
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(t.settings.advanced.resetTunnel),
|
2024-02-15 15:23:02 +03:30
|
|
|
leading: const Icon(FluentIcons.arrow_reset_24_regular),
|
2024-01-18 22:53:17 +03:30
|
|
|
onTap: () async {
|
|
|
|
|
await ref.read(resetTunnelProvider.notifier).run();
|
|
|
|
|
},
|
|
|
|
|
),
|
2023-09-01 15:00:41 +03:30
|
|
|
SwitchListTile(
|
|
|
|
|
title: Text(t.settings.advanced.debugMode),
|
|
|
|
|
value: debug,
|
2024-02-15 15:23:02 +03:30
|
|
|
secondary: const Icon(FluentIcons.window_dev_tools_24_regular),
|
2023-09-01 15:00:41 +03:30
|
|
|
onChanged: (value) async {
|
|
|
|
|
if (value) {
|
|
|
|
|
await showDialog<bool>(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
title: Text(t.settings.advanced.debugMode),
|
|
|
|
|
content: Text(t.settings.advanced.debugModeMsg),
|
|
|
|
|
actions: [
|
|
|
|
|
TextButton(
|
2023-12-28 10:43:57 +03:30
|
|
|
onPressed: () => Navigator.of(context).maybePop(true),
|
2023-09-01 15:00:41 +03:30
|
|
|
child: Text(
|
|
|
|
|
MaterialLocalizations.of(context).okButtonLabel,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-09-07 13:43:46 +03:30
|
|
|
await ref.read(debugModeNotifierProvider.notifier).update(value);
|
2023-09-01 15:00:41 +03:30
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|