Add separate page for clash overrides
This commit is contained in:
@@ -20,7 +20,12 @@ part 'desktop_routes.g.dart';
|
|||||||
),
|
),
|
||||||
TypedGoRoute<ProxiesRoute>(path: ProxiesRoute.path),
|
TypedGoRoute<ProxiesRoute>(path: ProxiesRoute.path),
|
||||||
TypedGoRoute<LogsRoute>(path: LogsRoute.path),
|
TypedGoRoute<LogsRoute>(path: LogsRoute.path),
|
||||||
TypedGoRoute<SettingsRoute>(path: SettingsRoute.path),
|
TypedGoRoute<SettingsRoute>(
|
||||||
|
path: SettingsRoute.path,
|
||||||
|
routes: [
|
||||||
|
TypedGoRoute<ClashOverridesRoute>(path: ClashOverridesRoute.path),
|
||||||
|
],
|
||||||
|
),
|
||||||
TypedGoRoute<AboutRoute>(path: AboutRoute.path),
|
TypedGoRoute<AboutRoute>(path: AboutRoute.path),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,7 +46,12 @@ class LogsRoute extends GoRouteData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TypedGoRoute<SettingsRoute>(path: SettingsRoute.path)
|
@TypedGoRoute<SettingsRoute>(
|
||||||
|
path: SettingsRoute.path,
|
||||||
|
routes: [
|
||||||
|
TypedGoRoute<ClashOverridesRoute>(path: ClashOverridesRoute.path),
|
||||||
|
],
|
||||||
|
)
|
||||||
class SettingsRoute extends GoRouteData {
|
class SettingsRoute extends GoRouteData {
|
||||||
const SettingsRoute();
|
const SettingsRoute();
|
||||||
static const path = '/settings';
|
static const path = '/settings';
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:hiddify/features/home/view/view.dart';
|
|||||||
import 'package:hiddify/features/profile_detail/view/view.dart';
|
import 'package:hiddify/features/profile_detail/view/view.dart';
|
||||||
import 'package:hiddify/features/profiles/view/view.dart';
|
import 'package:hiddify/features/profiles/view/view.dart';
|
||||||
import 'package:hiddify/features/proxies/view/view.dart';
|
import 'package:hiddify/features/proxies/view/view.dart';
|
||||||
|
import 'package:hiddify/features/settings/view/view.dart';
|
||||||
import 'package:hiddify/utils/utils.dart';
|
import 'package:hiddify/utils/utils.dart';
|
||||||
|
|
||||||
part 'shared_routes.g.dart';
|
part 'shared_routes.g.dart';
|
||||||
@@ -102,3 +103,16 @@ class ProfileDetailsRoute extends GoRouteData {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ClashOverridesRoute extends GoRouteData {
|
||||||
|
const ClashOverridesRoute();
|
||||||
|
static const path = 'clash-overrides';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||||
|
return const MaterialPage(
|
||||||
|
fullscreenDialog: true,
|
||||||
|
child: ClashOverridesPage(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
103
lib/features/settings/view/clash_overrides_page.dart
Normal file
103
lib/features/settings/view/clash_overrides_page.dart
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hiddify/core/core_providers.dart';
|
||||||
|
import 'package:hiddify/core/prefs/prefs.dart';
|
||||||
|
import 'package:hiddify/domain/clash/clash.dart';
|
||||||
|
import 'package:hiddify/features/settings/widgets/widgets.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:recase/recase.dart';
|
||||||
|
|
||||||
|
class ClashOverridesPage extends HookConsumerWidget {
|
||||||
|
const ClashOverridesPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final t = ref.watch(translationsProvider);
|
||||||
|
|
||||||
|
final overrides =
|
||||||
|
ref.watch(prefsControllerProvider.select((value) => value.clash));
|
||||||
|
final notifier = ref.watch(prefsControllerProvider.notifier);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverAppBar(
|
||||||
|
title: Text(t.settings.clash.sectionTitle.titleCase),
|
||||||
|
pinned: true,
|
||||||
|
),
|
||||||
|
SliverList.list(
|
||||||
|
children: [
|
||||||
|
InputOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.httpPort,
|
||||||
|
value: overrides.httpPort,
|
||||||
|
resetValue: ClashConfig.initial.httpPort,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(httpPort: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InputOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.socksPort,
|
||||||
|
value: overrides.socksPort,
|
||||||
|
resetValue: ClashConfig.initial.socksPort,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(socksPort: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InputOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.redirPort,
|
||||||
|
value: overrides.redirPort,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(redirPort: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InputOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.tproxyPort,
|
||||||
|
value: overrides.tproxyPort,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(tproxyPort: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InputOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.mixedPort,
|
||||||
|
value: overrides.mixedPort,
|
||||||
|
resetValue: ClashConfig.initial.mixedPort,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(mixedPort: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ToggleOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.allowLan,
|
||||||
|
value: overrides.allowLan,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(allowLan: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ToggleOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.ipv6,
|
||||||
|
value: overrides.ipv6,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(ipv6: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ChoiceOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.mode,
|
||||||
|
value: overrides.mode,
|
||||||
|
options: TunnelMode.values,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(mode: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ChoiceOverrideTile(
|
||||||
|
title: t.settings.clash.overrides.logLevel,
|
||||||
|
value: overrides.logLevel,
|
||||||
|
options: LogLevel.values,
|
||||||
|
onChange: (value) => notifier.patchClashOverrides(
|
||||||
|
ClashConfigPatch(logLevel: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hiddify/core/core_providers.dart';
|
import 'package:hiddify/core/core_providers.dart';
|
||||||
|
import 'package:hiddify/core/router/router.dart';
|
||||||
import 'package:hiddify/features/settings/widgets/widgets.dart';
|
import 'package:hiddify/features/settings/widgets/widgets.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:recase/recase.dart';
|
import 'package:recase/recase.dart';
|
||||||
@@ -32,8 +33,14 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
_SettingsSectionHeader(t.settings.network.sectionTitle.titleCase),
|
_SettingsSectionHeader(t.settings.network.sectionTitle.titleCase),
|
||||||
const NetworkSettingTiles(),
|
const NetworkSettingTiles(),
|
||||||
divider,
|
divider,
|
||||||
_SettingsSectionHeader(t.settings.clash.sectionTitle.titleCase),
|
ListTile(
|
||||||
const ClashSettingTiles(),
|
title: Text(t.settings.clash.sectionTitle.titleCase),
|
||||||
|
leading: const Icon(Icons.edit_document),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
onTap: () async {
|
||||||
|
await const ClashOverridesRoute().push(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
export 'clash_overrides_page.dart';
|
||||||
export 'settings_page.dart';
|
export 'settings_page.dart';
|
||||||
|
|||||||
@@ -1,98 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fpdart/fpdart.dart';
|
import 'package:fpdart/fpdart.dart';
|
||||||
import 'package:hiddify/core/core_providers.dart';
|
import 'package:hiddify/core/core_providers.dart';
|
||||||
import 'package:hiddify/core/prefs/prefs.dart';
|
|
||||||
import 'package:hiddify/domain/clash/clash.dart';
|
|
||||||
import 'package:hiddify/features/settings/widgets/settings_input_dialog.dart';
|
import 'package:hiddify/features/settings/widgets/settings_input_dialog.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:recase/recase.dart';
|
import 'package:recase/recase.dart';
|
||||||
|
|
||||||
class ClashSettingTiles extends HookConsumerWidget {
|
|
||||||
const ClashSettingTiles({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final t = ref.watch(translationsProvider);
|
|
||||||
|
|
||||||
final overrides =
|
|
||||||
ref.watch(prefsControllerProvider.select((value) => value.clash));
|
|
||||||
final notifier = ref.watch(prefsControllerProvider.notifier);
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
InputOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.httpPort,
|
|
||||||
value: overrides.httpPort,
|
|
||||||
resetValue: ClashConfig.initial.httpPort,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(httpPort: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
InputOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.socksPort,
|
|
||||||
value: overrides.socksPort,
|
|
||||||
resetValue: ClashConfig.initial.socksPort,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(socksPort: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
InputOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.redirPort,
|
|
||||||
value: overrides.redirPort,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(redirPort: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
InputOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.tproxyPort,
|
|
||||||
value: overrides.tproxyPort,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(tproxyPort: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
InputOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.mixedPort,
|
|
||||||
value: overrides.mixedPort,
|
|
||||||
resetValue: ClashConfig.initial.mixedPort,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(mixedPort: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ToggleOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.allowLan,
|
|
||||||
value: overrides.allowLan,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(allowLan: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ToggleOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.ipv6,
|
|
||||||
value: overrides.ipv6,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(ipv6: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ChoiceOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.mode,
|
|
||||||
value: overrides.mode,
|
|
||||||
options: TunnelMode.values,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(mode: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ChoiceOverrideTile(
|
|
||||||
title: t.settings.clash.overrides.logLevel,
|
|
||||||
value: overrides.logLevel,
|
|
||||||
options: LogLevel.values,
|
|
||||||
onChange: (value) => notifier.patchClashOverrides(
|
|
||||||
ClashConfigPatch(logLevel: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InputOverrideTile extends HookConsumerWidget {
|
class InputOverrideTile extends HookConsumerWidget {
|
||||||
const InputOverrideTile({
|
const InputOverrideTile({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export 'clash_setting_tiles.dart';
|
|
||||||
export 'general_setting_tiles.dart';
|
export 'general_setting_tiles.dart';
|
||||||
export 'network_setting_tiles.dart';
|
export 'network_setting_tiles.dart';
|
||||||
|
export 'override_tiles.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user