Change routing setup
This commit is contained in:
@@ -50,29 +50,30 @@ GoRouter router(RouterRef ref) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final tabLocations = [
|
||||||
|
const HomeRoute().location,
|
||||||
|
const ProxiesRoute().location,
|
||||||
|
const ConfigOptionsRoute().location,
|
||||||
|
const SettingsRoute().location,
|
||||||
|
const LogsOverviewRoute().location,
|
||||||
|
const AboutRoute().location,
|
||||||
|
];
|
||||||
|
|
||||||
int getCurrentIndex(BuildContext context) {
|
int getCurrentIndex(BuildContext context) {
|
||||||
final String location = GoRouterState.of(context).uri.path;
|
final String location = GoRouterState.of(context).uri.path;
|
||||||
if (location == const HomeRoute().location) return 0;
|
if (location == const HomeRoute().location) return 0;
|
||||||
if (location.startsWith(const ProxiesRoute().location)) return 1;
|
var index = 0;
|
||||||
if (location.startsWith(const LogsOverviewRoute().location)) return 2;
|
for (final tab in tabLocations.sublist(1)) {
|
||||||
if (location.startsWith(const SettingsRoute().location)) return 3;
|
index++;
|
||||||
if (location.startsWith(const AboutRoute().location)) return 4;
|
if (location.startsWith(tab)) return index;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchTab(int index, BuildContext context) {
|
void switchTab(int index, BuildContext context) {
|
||||||
switch (index) {
|
assert(index >= 0 && index < tabLocations.length);
|
||||||
case 0:
|
final location = tabLocations[index];
|
||||||
const HomeRoute().go(context);
|
return context.go(location);
|
||||||
case 1:
|
|
||||||
const ProxiesRoute().go(context);
|
|
||||||
case 2:
|
|
||||||
const LogsOverviewRoute().go(context);
|
|
||||||
case 3:
|
|
||||||
const SettingsRoute().go(context);
|
|
||||||
case 4:
|
|
||||||
const AboutRoute().go(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@riverpod
|
@riverpod
|
||||||
|
|||||||
@@ -43,18 +43,14 @@ GlobalKey<NavigatorState>? _dynamicRootKey =
|
|||||||
path: "profiles/:id",
|
path: "profiles/:id",
|
||||||
name: ProfileDetailsRoute.name,
|
name: ProfileDetailsRoute.name,
|
||||||
),
|
),
|
||||||
TypedGoRoute<LogsOverviewRoute>(
|
TypedGoRoute<ConfigOptionsRoute>(
|
||||||
path: "logs",
|
path: "config-options",
|
||||||
name: LogsOverviewRoute.name,
|
name: ConfigOptionsRoute.name,
|
||||||
),
|
),
|
||||||
TypedGoRoute<SettingsRoute>(
|
TypedGoRoute<SettingsRoute>(
|
||||||
path: "settings",
|
path: "settings",
|
||||||
name: SettingsRoute.name,
|
name: SettingsRoute.name,
|
||||||
routes: [
|
routes: [
|
||||||
TypedGoRoute<ConfigOptionsRoute>(
|
|
||||||
path: "config-options",
|
|
||||||
name: ConfigOptionsRoute.name,
|
|
||||||
),
|
|
||||||
TypedGoRoute<PerAppProxyRoute>(
|
TypedGoRoute<PerAppProxyRoute>(
|
||||||
path: "per-app-proxy",
|
path: "per-app-proxy",
|
||||||
name: PerAppProxyRoute.name,
|
name: PerAppProxyRoute.name,
|
||||||
@@ -65,6 +61,10 @@ GlobalKey<NavigatorState>? _dynamicRootKey =
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
TypedGoRoute<LogsOverviewRoute>(
|
||||||
|
path: "logs",
|
||||||
|
name: LogsOverviewRoute.name,
|
||||||
|
),
|
||||||
TypedGoRoute<AboutRoute>(
|
TypedGoRoute<AboutRoute>(
|
||||||
path: "about",
|
path: "about",
|
||||||
name: AboutRoute.name,
|
name: AboutRoute.name,
|
||||||
@@ -114,24 +114,24 @@ class MobileWrapperRoute extends ShellRouteData {
|
|||||||
path: "/proxies",
|
path: "/proxies",
|
||||||
name: ProxiesRoute.name,
|
name: ProxiesRoute.name,
|
||||||
),
|
),
|
||||||
TypedGoRoute<LogsOverviewRoute>(
|
TypedGoRoute<ConfigOptionsRoute>(
|
||||||
path: "/logs",
|
path: "/config-options",
|
||||||
name: LogsOverviewRoute.name,
|
name: ConfigOptionsRoute.name,
|
||||||
),
|
),
|
||||||
TypedGoRoute<SettingsRoute>(
|
TypedGoRoute<SettingsRoute>(
|
||||||
path: "/settings",
|
path: "/settings",
|
||||||
name: SettingsRoute.name,
|
name: SettingsRoute.name,
|
||||||
routes: [
|
routes: [
|
||||||
TypedGoRoute<ConfigOptionsRoute>(
|
|
||||||
path: "config-options",
|
|
||||||
name: ConfigOptionsRoute.name,
|
|
||||||
),
|
|
||||||
TypedGoRoute<GeoAssetsRoute>(
|
TypedGoRoute<GeoAssetsRoute>(
|
||||||
path: "routing-assets",
|
path: "routing-assets",
|
||||||
name: GeoAssetsRoute.name,
|
name: GeoAssetsRoute.name,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
TypedGoRoute<LogsOverviewRoute>(
|
||||||
|
path: "/logs",
|
||||||
|
name: LogsOverviewRoute.name,
|
||||||
|
),
|
||||||
TypedGoRoute<AboutRoute>(
|
TypedGoRoute<AboutRoute>(
|
||||||
path: "/about",
|
path: "/about",
|
||||||
name: AboutRoute.name,
|
name: AboutRoute.name,
|
||||||
@@ -309,11 +309,7 @@ class ConfigOptionsRoute extends GoRouteData {
|
|||||||
child: ConfigOptionsPage(),
|
child: ConfigOptionsPage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const MaterialPage(
|
return const NoTransitionPage(name: name, child: ConfigOptionsPage());
|
||||||
fullscreenDialog: true,
|
|
||||||
name: name,
|
|
||||||
child: ConfigOptionsPage(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
||||||
import 'package:hiddify/core/localization/translations.dart';
|
import 'package:hiddify/core/localization/translations.dart';
|
||||||
@@ -25,23 +26,27 @@ class AdaptiveRootScaffold extends HookConsumerWidget {
|
|||||||
|
|
||||||
final destinations = [
|
final destinations = [
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.power_settings_new),
|
icon: const Icon(FluentIcons.power_20_filled),
|
||||||
label: t.home.pageTitle,
|
label: t.home.pageTitle,
|
||||||
),
|
),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.filter_list),
|
icon: const Icon(FluentIcons.filter_20_filled),
|
||||||
label: t.proxies.pageTitle,
|
label: t.proxies.pageTitle,
|
||||||
),
|
),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.article),
|
icon: const Icon(FluentIcons.box_edit_20_filled),
|
||||||
label: t.logs.pageTitle,
|
label: t.settings.config.pageTitle,
|
||||||
),
|
),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.settings),
|
icon: const Icon(FluentIcons.settings_20_filled),
|
||||||
label: t.settings.pageTitle,
|
label: t.settings.pageTitle,
|
||||||
),
|
),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.info),
|
icon: const Icon(FluentIcons.document_text_20_filled),
|
||||||
|
label: t.logs.pageTitle,
|
||||||
|
),
|
||||||
|
NavigationDestination(
|
||||||
|
icon: const Icon(FluentIcons.info_20_filled),
|
||||||
label: t.about.pageTitle,
|
label: t.about.pageTitle,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:hiddify/core/localization/translations.dart';
|
|||||||
import 'package:hiddify/core/model/failures.dart';
|
import 'package:hiddify/core/model/failures.dart';
|
||||||
import 'package:hiddify/core/model/range.dart';
|
import 'package:hiddify/core/model/range.dart';
|
||||||
import 'package:hiddify/core/widget/tip_card.dart';
|
import 'package:hiddify/core/widget/tip_card.dart';
|
||||||
|
import 'package:hiddify/features/common/nested_app_bar.dart';
|
||||||
import 'package:hiddify/features/config_option/model/config_option_entity.dart';
|
import 'package:hiddify/features/config_option/model/config_option_entity.dart';
|
||||||
import 'package:hiddify/features/config_option/model/config_option_patch.dart';
|
import 'package:hiddify/features/config_option/model/config_option_patch.dart';
|
||||||
import 'package:hiddify/features/config_option/notifier/config_option_notifier.dart';
|
import 'package:hiddify/features/config_option/notifier/config_option_notifier.dart';
|
||||||
@@ -37,447 +38,470 @@ class ConfigOptionsPage extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
body: CustomScrollView(
|
||||||
title: Text(t.settings.config.pageTitle),
|
slivers: [
|
||||||
actions: [
|
NestedAppBar(
|
||||||
if (asyncOptions case AsyncData(value: final options))
|
title: Text(t.settings.config.pageTitle),
|
||||||
PopupMenuButton(
|
actions: [
|
||||||
itemBuilder: (context) {
|
if (asyncOptions case AsyncData(value: final options))
|
||||||
return [
|
PopupMenuButton(
|
||||||
PopupMenuItem(
|
itemBuilder: (context) {
|
||||||
child: Text(t.general.addToClipboard),
|
return [
|
||||||
onTap: () {
|
PopupMenuItem(
|
||||||
Clipboard.setData(
|
child: Text(t.general.addToClipboard),
|
||||||
ClipboardData(text: options.format()),
|
onTap: () {
|
||||||
|
Clipboard.setData(
|
||||||
|
ClipboardData(text: options.format()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(t.settings.config.resetBtn),
|
||||||
|
onTap: () async {
|
||||||
|
await ref
|
||||||
|
.read(configOptionNotifierProvider.notifier)
|
||||||
|
.resetOption();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
switch (asyncOptions) {
|
||||||
|
AsyncData(value: final options) => SliverList.list(
|
||||||
|
children: [
|
||||||
|
TipCard(message: t.settings.experimentalMsg),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.logLevel),
|
||||||
|
subtitle: Text(options.logLevel.name.toUpperCase()),
|
||||||
|
onTap: () async {
|
||||||
|
final logLevel = await SettingsPickerDialog(
|
||||||
|
title: t.settings.config.logLevel,
|
||||||
|
selected: options.logLevel,
|
||||||
|
options: LogLevel.choices,
|
||||||
|
getTitle: (e) => e.name.toUpperCase(),
|
||||||
|
resetValue: defaultOptions.logLevel,
|
||||||
|
).show(context);
|
||||||
|
if (logLevel == null) return;
|
||||||
|
await changeOption(ConfigOptionPatch(logLevel: logLevel));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(t.settings.config.section.route),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(experimental(t.settings.config.bypassLan)),
|
||||||
|
value: options.bypassLan,
|
||||||
|
onChanged: (value) async =>
|
||||||
|
changeOption(ConfigOptionPatch(bypassLan: value)),
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(t.settings.config.resolveDestination),
|
||||||
|
value: options.resolveDestination,
|
||||||
|
onChanged: (value) async => changeOption(
|
||||||
|
ConfigOptionPatch(resolveDestination: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.ipv6Mode),
|
||||||
|
subtitle: Text(options.ipv6Mode.present(t)),
|
||||||
|
onTap: () async {
|
||||||
|
final ipv6Mode = await SettingsPickerDialog(
|
||||||
|
title: t.settings.config.ipv6Mode,
|
||||||
|
selected: options.ipv6Mode,
|
||||||
|
options: IPv6Mode.values,
|
||||||
|
getTitle: (e) => e.present(t),
|
||||||
|
resetValue: defaultOptions.ipv6Mode,
|
||||||
|
).show(context);
|
||||||
|
if (ipv6Mode == null) return;
|
||||||
|
await changeOption(ConfigOptionPatch(ipv6Mode: ipv6Mode));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(t.settings.config.section.dns),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.remoteDnsAddress),
|
||||||
|
subtitle: Text(options.remoteDnsAddress),
|
||||||
|
onTap: () async {
|
||||||
|
final url = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.remoteDnsAddress,
|
||||||
|
initialValue: options.remoteDnsAddress,
|
||||||
|
resetValue: defaultOptions.remoteDnsAddress,
|
||||||
|
).show(context);
|
||||||
|
if (url == null || url.isEmpty) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(remoteDnsAddress: url),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
ListTile(
|
||||||
child: Text(t.settings.config.resetBtn),
|
title: Text(t.settings.config.remoteDnsDomainStrategy),
|
||||||
|
subtitle: Text(options.remoteDnsDomainStrategy.displayName),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await ref
|
final domainStrategy = await SettingsPickerDialog(
|
||||||
.read(configOptionNotifierProvider.notifier)
|
title: t.settings.config.remoteDnsDomainStrategy,
|
||||||
.resetOption();
|
selected: options.remoteDnsDomainStrategy,
|
||||||
|
options: DomainStrategy.values,
|
||||||
|
getTitle: (e) => e.displayName,
|
||||||
|
resetValue: defaultOptions.remoteDnsDomainStrategy,
|
||||||
|
).show(context);
|
||||||
|
if (domainStrategy == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(
|
||||||
|
remoteDnsDomainStrategy: domainStrategy,
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
];
|
ListTile(
|
||||||
},
|
title: Text(t.settings.config.directDnsAddress),
|
||||||
),
|
subtitle: Text(options.directDnsAddress),
|
||||||
],
|
onTap: () async {
|
||||||
),
|
final url = await SettingsInputDialog(
|
||||||
body: switch (asyncOptions) {
|
title: t.settings.config.directDnsAddress,
|
||||||
AsyncData(value: final options) => ListView(
|
initialValue: options.directDnsAddress,
|
||||||
children: [
|
resetValue: defaultOptions.directDnsAddress,
|
||||||
TipCard(message: t.settings.experimentalMsg),
|
).show(context);
|
||||||
ListTile(
|
if (url == null || url.isEmpty) return;
|
||||||
title: Text(t.settings.config.logLevel),
|
await changeOption(
|
||||||
subtitle: Text(options.logLevel.name.toUpperCase()),
|
ConfigOptionPatch(directDnsAddress: url),
|
||||||
onTap: () async {
|
);
|
||||||
final logLevel = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.logLevel,
|
|
||||||
selected: options.logLevel,
|
|
||||||
options: LogLevel.choices,
|
|
||||||
getTitle: (e) => e.name.toUpperCase(),
|
|
||||||
resetValue: defaultOptions.logLevel,
|
|
||||||
).show(context);
|
|
||||||
if (logLevel == null) return;
|
|
||||||
await changeOption(ConfigOptionPatch(logLevel: logLevel));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(t.settings.config.section.route),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(experimental(t.settings.config.bypassLan)),
|
|
||||||
value: options.bypassLan,
|
|
||||||
onChanged: (value) async =>
|
|
||||||
changeOption(ConfigOptionPatch(bypassLan: value)),
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(t.settings.config.resolveDestination),
|
|
||||||
value: options.resolveDestination,
|
|
||||||
onChanged: (value) async =>
|
|
||||||
changeOption(ConfigOptionPatch(resolveDestination: value)),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.ipv6Mode),
|
|
||||||
subtitle: Text(options.ipv6Mode.present(t)),
|
|
||||||
onTap: () async {
|
|
||||||
final ipv6Mode = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.ipv6Mode,
|
|
||||||
selected: options.ipv6Mode,
|
|
||||||
options: IPv6Mode.values,
|
|
||||||
getTitle: (e) => e.present(t),
|
|
||||||
resetValue: defaultOptions.ipv6Mode,
|
|
||||||
).show(context);
|
|
||||||
if (ipv6Mode == null) return;
|
|
||||||
await changeOption(ConfigOptionPatch(ipv6Mode: ipv6Mode));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(t.settings.config.section.dns),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.remoteDnsAddress),
|
|
||||||
subtitle: Text(options.remoteDnsAddress),
|
|
||||||
onTap: () async {
|
|
||||||
final url = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.remoteDnsAddress,
|
|
||||||
initialValue: options.remoteDnsAddress,
|
|
||||||
resetValue: defaultOptions.remoteDnsAddress,
|
|
||||||
).show(context);
|
|
||||||
if (url == null || url.isEmpty) return;
|
|
||||||
await changeOption(ConfigOptionPatch(remoteDnsAddress: url));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.remoteDnsDomainStrategy),
|
|
||||||
subtitle: Text(options.remoteDnsDomainStrategy.displayName),
|
|
||||||
onTap: () async {
|
|
||||||
final domainStrategy = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.remoteDnsDomainStrategy,
|
|
||||||
selected: options.remoteDnsDomainStrategy,
|
|
||||||
options: DomainStrategy.values,
|
|
||||||
getTitle: (e) => e.displayName,
|
|
||||||
resetValue: defaultOptions.remoteDnsDomainStrategy,
|
|
||||||
).show(context);
|
|
||||||
if (domainStrategy == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(remoteDnsDomainStrategy: domainStrategy),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.directDnsAddress),
|
|
||||||
subtitle: Text(options.directDnsAddress),
|
|
||||||
onTap: () async {
|
|
||||||
final url = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.directDnsAddress,
|
|
||||||
initialValue: options.directDnsAddress,
|
|
||||||
resetValue: defaultOptions.directDnsAddress,
|
|
||||||
).show(context);
|
|
||||||
if (url == null || url.isEmpty) return;
|
|
||||||
await changeOption(ConfigOptionPatch(directDnsAddress: url));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.directDnsDomainStrategy),
|
|
||||||
subtitle: Text(options.directDnsDomainStrategy.displayName),
|
|
||||||
onTap: () async {
|
|
||||||
final domainStrategy = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.directDnsDomainStrategy,
|
|
||||||
selected: options.directDnsDomainStrategy,
|
|
||||||
options: DomainStrategy.values,
|
|
||||||
getTitle: (e) => e.displayName,
|
|
||||||
resetValue: defaultOptions.directDnsDomainStrategy,
|
|
||||||
).show(context);
|
|
||||||
if (domainStrategy == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(directDnsDomainStrategy: domainStrategy),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(t.settings.config.enableDnsRouting),
|
|
||||||
value: options.enableDnsRouting,
|
|
||||||
onChanged: (value) => changeOption(
|
|
||||||
ConfigOptionPatch(enableDnsRouting: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(experimental(t.settings.config.section.mux)),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(t.settings.config.enableMux),
|
|
||||||
value: options.enableMux,
|
|
||||||
onChanged: (value) => changeOption(
|
|
||||||
ConfigOptionPatch(enableMux: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.muxProtocol),
|
|
||||||
subtitle: Text(options.muxProtocol.name),
|
|
||||||
onTap: () async {
|
|
||||||
final pickedProtocol = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.muxProtocol,
|
|
||||||
selected: options.muxProtocol,
|
|
||||||
options: MuxProtocol.values,
|
|
||||||
getTitle: (e) => e.name,
|
|
||||||
resetValue: defaultOptions.muxProtocol,
|
|
||||||
).show(context);
|
|
||||||
if (pickedProtocol == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(muxProtocol: pickedProtocol),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.muxMaxStreams),
|
|
||||||
subtitle: Text(options.muxMaxStreams.toString()),
|
|
||||||
onTap: () async {
|
|
||||||
final maxStreams = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.muxMaxStreams,
|
|
||||||
initialValue: options.muxMaxStreams,
|
|
||||||
resetValue: defaultOptions.muxMaxStreams,
|
|
||||||
mapTo: int.tryParse,
|
|
||||||
digitsOnly: true,
|
|
||||||
).show(context);
|
|
||||||
if (maxStreams == null || maxStreams < 1) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(muxMaxStreams: maxStreams),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(t.settings.config.section.inbound),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.serviceMode),
|
|
||||||
subtitle: Text(options.serviceMode.present(t)),
|
|
||||||
onTap: () async {
|
|
||||||
final pickedMode = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.serviceMode,
|
|
||||||
selected: options.serviceMode,
|
|
||||||
options: ServiceMode.choices,
|
|
||||||
getTitle: (e) => e.present(t),
|
|
||||||
resetValue: ServiceMode.defaultMode,
|
|
||||||
).show(context);
|
|
||||||
if (pickedMode == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(serviceMode: pickedMode),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(t.settings.config.strictRoute),
|
|
||||||
value: options.strictRoute,
|
|
||||||
onChanged: (value) async =>
|
|
||||||
changeOption(ConfigOptionPatch(strictRoute: value)),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.tunImplementation),
|
|
||||||
subtitle: Text(options.tunImplementation.name),
|
|
||||||
onTap: () async {
|
|
||||||
final tunImplementation = await SettingsPickerDialog(
|
|
||||||
title: t.settings.config.tunImplementation,
|
|
||||||
selected: options.tunImplementation,
|
|
||||||
options: TunImplementation.values,
|
|
||||||
getTitle: (e) => e.name,
|
|
||||||
resetValue: defaultOptions.tunImplementation,
|
|
||||||
).show(context);
|
|
||||||
if (tunImplementation == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(tunImplementation: tunImplementation),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.mixedPort),
|
|
||||||
subtitle: Text(options.mixedPort.toString()),
|
|
||||||
onTap: () async {
|
|
||||||
final mixedPort = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.mixedPort,
|
|
||||||
initialValue: options.mixedPort,
|
|
||||||
resetValue: defaultOptions.mixedPort,
|
|
||||||
validator: isPort,
|
|
||||||
mapTo: int.tryParse,
|
|
||||||
digitsOnly: true,
|
|
||||||
).show(context);
|
|
||||||
if (mixedPort == null) return;
|
|
||||||
await changeOption(ConfigOptionPatch(mixedPort: mixedPort));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.localDnsPort),
|
|
||||||
subtitle: Text(options.localDnsPort.toString()),
|
|
||||||
onTap: () async {
|
|
||||||
final localDnsPort = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.localDnsPort,
|
|
||||||
initialValue: options.localDnsPort,
|
|
||||||
resetValue: defaultOptions.localDnsPort,
|
|
||||||
validator: isPort,
|
|
||||||
mapTo: int.tryParse,
|
|
||||||
digitsOnly: true,
|
|
||||||
).show(context);
|
|
||||||
if (localDnsPort == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(localDnsPort: localDnsPort),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(
|
|
||||||
experimental(t.settings.config.allowConnectionFromLan),
|
|
||||||
),
|
|
||||||
value: options.allowConnectionFromLan,
|
|
||||||
onChanged: (value) => changeOption(
|
|
||||||
ConfigOptionPatch(allowConnectionFromLan: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(t.settings.config.section.tlsTricks),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(experimental(t.settings.config.enableTlsFragment)),
|
|
||||||
value: options.enableTlsFragment,
|
|
||||||
onChanged: (value) async =>
|
|
||||||
changeOption(ConfigOptionPatch(enableTlsFragment: value)),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.tlsFragmentSize),
|
|
||||||
subtitle: Text(options.tlsFragmentSize.present(t)),
|
|
||||||
onTap: () async {
|
|
||||||
final range = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.tlsFragmentSize,
|
|
||||||
initialValue: options.tlsFragmentSize.format(),
|
|
||||||
resetValue: defaultOptions.tlsFragmentSize.format(),
|
|
||||||
).show(context);
|
|
||||||
if (range == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(
|
|
||||||
tlsFragmentSize: RangeWithOptionalCeil.tryParse(range),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.tlsFragmentSleep),
|
|
||||||
subtitle: Text(options.tlsFragmentSleep.present(t)),
|
|
||||||
onTap: () async {
|
|
||||||
final range = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.tlsFragmentSleep,
|
|
||||||
initialValue: options.tlsFragmentSleep.format(),
|
|
||||||
resetValue: defaultOptions.tlsFragmentSleep.format(),
|
|
||||||
).show(context);
|
|
||||||
if (range == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(
|
|
||||||
tlsFragmentSleep: RangeWithOptionalCeil.tryParse(range),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title:
|
|
||||||
Text(experimental(t.settings.config.enableTlsMixedSniCase)),
|
|
||||||
value: options.enableTlsMixedSniCase,
|
|
||||||
onChanged: (value) async => changeOption(
|
|
||||||
ConfigOptionPatch(enableTlsMixedSniCase: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
|
||||||
title: Text(experimental(t.settings.config.enableTlsPadding)),
|
|
||||||
value: options.enableTlsPadding,
|
|
||||||
onChanged: (value) async => changeOption(
|
|
||||||
ConfigOptionPatch(enableTlsPadding: value),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.tlsPaddingSize),
|
|
||||||
subtitle: Text(options.tlsPaddingSize.present(t)),
|
|
||||||
onTap: () async {
|
|
||||||
final range = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.tlsPaddingSize,
|
|
||||||
initialValue: options.tlsPaddingSize.format(),
|
|
||||||
resetValue: defaultOptions.tlsPaddingSize.format(),
|
|
||||||
).show(context);
|
|
||||||
if (range == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(
|
|
||||||
tlsPaddingSize: RangeWithOptionalCeil.tryParse(range),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(experimental(t.settings.config.section.warp)),
|
|
||||||
WarpOptionsTiles(
|
|
||||||
options: options,
|
|
||||||
defaultOptions: defaultOptions,
|
|
||||||
onChange: changeOption,
|
|
||||||
),
|
|
||||||
const SettingsDivider(),
|
|
||||||
SettingsSection(t.settings.config.section.misc),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.connectionTestUrl),
|
|
||||||
subtitle: Text(options.connectionTestUrl),
|
|
||||||
onTap: () async {
|
|
||||||
final url = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.connectionTestUrl,
|
|
||||||
initialValue: options.connectionTestUrl,
|
|
||||||
resetValue: defaultOptions.connectionTestUrl,
|
|
||||||
).show(context);
|
|
||||||
if (url == null || url.isEmpty || !isUrl(url)) return;
|
|
||||||
await changeOption(ConfigOptionPatch(connectionTestUrl: url));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.urlTestInterval),
|
|
||||||
subtitle: Text(
|
|
||||||
options.urlTestInterval
|
|
||||||
.toApproximateTime(isRelativeToNow: false),
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
final urlTestInterval = await SettingsSliderDialog(
|
|
||||||
title: t.settings.config.urlTestInterval,
|
|
||||||
initialValue: options.urlTestInterval.inMinutes
|
|
||||||
.coerceIn(0, 60)
|
|
||||||
.toDouble(),
|
|
||||||
resetValue:
|
|
||||||
defaultOptions.urlTestInterval.inMinutes.toDouble(),
|
|
||||||
min: 1,
|
|
||||||
max: 60,
|
|
||||||
divisions: 60,
|
|
||||||
labelGen: (value) => Duration(minutes: value.toInt())
|
|
||||||
.toApproximateTime(isRelativeToNow: false),
|
|
||||||
).show(context);
|
|
||||||
if (urlTestInterval == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(
|
|
||||||
urlTestInterval:
|
|
||||||
Duration(minutes: urlTestInterval.toInt()),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.clashApiPort),
|
|
||||||
subtitle: Text(options.clashApiPort.toString()),
|
|
||||||
onTap: () async {
|
|
||||||
final clashApiPort = await SettingsInputDialog(
|
|
||||||
title: t.settings.config.clashApiPort,
|
|
||||||
initialValue: options.clashApiPort,
|
|
||||||
resetValue: defaultOptions.clashApiPort,
|
|
||||||
validator: isPort,
|
|
||||||
mapTo: int.tryParse,
|
|
||||||
digitsOnly: true,
|
|
||||||
).show(context);
|
|
||||||
if (clashApiPort == null) return;
|
|
||||||
await changeOption(
|
|
||||||
ConfigOptionPatch(clashApiPort: clashApiPort),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Gap(24),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
AsyncError(:final error) => Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.error),
|
|
||||||
const Gap(2),
|
|
||||||
Text(t.presentShortError(error)),
|
|
||||||
const Gap(2),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await ref
|
|
||||||
.read(configOptionNotifierProvider.notifier)
|
|
||||||
.resetOption();
|
|
||||||
},
|
},
|
||||||
child: Text(t.settings.config.resetBtn),
|
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.directDnsDomainStrategy),
|
||||||
|
subtitle: Text(options.directDnsDomainStrategy.displayName),
|
||||||
|
onTap: () async {
|
||||||
|
final domainStrategy = await SettingsPickerDialog(
|
||||||
|
title: t.settings.config.directDnsDomainStrategy,
|
||||||
|
selected: options.directDnsDomainStrategy,
|
||||||
|
options: DomainStrategy.values,
|
||||||
|
getTitle: (e) => e.displayName,
|
||||||
|
resetValue: defaultOptions.directDnsDomainStrategy,
|
||||||
|
).show(context);
|
||||||
|
if (domainStrategy == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(
|
||||||
|
directDnsDomainStrategy: domainStrategy,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(t.settings.config.enableDnsRouting),
|
||||||
|
value: options.enableDnsRouting,
|
||||||
|
onChanged: (value) => changeOption(
|
||||||
|
ConfigOptionPatch(enableDnsRouting: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(experimental(t.settings.config.section.mux)),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(t.settings.config.enableMux),
|
||||||
|
value: options.enableMux,
|
||||||
|
onChanged: (value) => changeOption(
|
||||||
|
ConfigOptionPatch(enableMux: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.muxProtocol),
|
||||||
|
subtitle: Text(options.muxProtocol.name),
|
||||||
|
onTap: () async {
|
||||||
|
final pickedProtocol = await SettingsPickerDialog(
|
||||||
|
title: t.settings.config.muxProtocol,
|
||||||
|
selected: options.muxProtocol,
|
||||||
|
options: MuxProtocol.values,
|
||||||
|
getTitle: (e) => e.name,
|
||||||
|
resetValue: defaultOptions.muxProtocol,
|
||||||
|
).show(context);
|
||||||
|
if (pickedProtocol == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(muxProtocol: pickedProtocol),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.muxMaxStreams),
|
||||||
|
subtitle: Text(options.muxMaxStreams.toString()),
|
||||||
|
onTap: () async {
|
||||||
|
final maxStreams = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.muxMaxStreams,
|
||||||
|
initialValue: options.muxMaxStreams,
|
||||||
|
resetValue: defaultOptions.muxMaxStreams,
|
||||||
|
mapTo: int.tryParse,
|
||||||
|
digitsOnly: true,
|
||||||
|
).show(context);
|
||||||
|
if (maxStreams == null || maxStreams < 1) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(muxMaxStreams: maxStreams),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(t.settings.config.section.inbound),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.serviceMode),
|
||||||
|
subtitle: Text(options.serviceMode.present(t)),
|
||||||
|
onTap: () async {
|
||||||
|
final pickedMode = await SettingsPickerDialog(
|
||||||
|
title: t.settings.config.serviceMode,
|
||||||
|
selected: options.serviceMode,
|
||||||
|
options: ServiceMode.choices,
|
||||||
|
getTitle: (e) => e.present(t),
|
||||||
|
resetValue: ServiceMode.defaultMode,
|
||||||
|
).show(context);
|
||||||
|
if (pickedMode == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(serviceMode: pickedMode),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(t.settings.config.strictRoute),
|
||||||
|
value: options.strictRoute,
|
||||||
|
onChanged: (value) async =>
|
||||||
|
changeOption(ConfigOptionPatch(strictRoute: value)),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.tunImplementation),
|
||||||
|
subtitle: Text(options.tunImplementation.name),
|
||||||
|
onTap: () async {
|
||||||
|
final tunImplementation = await SettingsPickerDialog(
|
||||||
|
title: t.settings.config.tunImplementation,
|
||||||
|
selected: options.tunImplementation,
|
||||||
|
options: TunImplementation.values,
|
||||||
|
getTitle: (e) => e.name,
|
||||||
|
resetValue: defaultOptions.tunImplementation,
|
||||||
|
).show(context);
|
||||||
|
if (tunImplementation == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(tunImplementation: tunImplementation),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.mixedPort),
|
||||||
|
subtitle: Text(options.mixedPort.toString()),
|
||||||
|
onTap: () async {
|
||||||
|
final mixedPort = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.mixedPort,
|
||||||
|
initialValue: options.mixedPort,
|
||||||
|
resetValue: defaultOptions.mixedPort,
|
||||||
|
validator: isPort,
|
||||||
|
mapTo: int.tryParse,
|
||||||
|
digitsOnly: true,
|
||||||
|
).show(context);
|
||||||
|
if (mixedPort == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(mixedPort: mixedPort),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.localDnsPort),
|
||||||
|
subtitle: Text(options.localDnsPort.toString()),
|
||||||
|
onTap: () async {
|
||||||
|
final localDnsPort = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.localDnsPort,
|
||||||
|
initialValue: options.localDnsPort,
|
||||||
|
resetValue: defaultOptions.localDnsPort,
|
||||||
|
validator: isPort,
|
||||||
|
mapTo: int.tryParse,
|
||||||
|
digitsOnly: true,
|
||||||
|
).show(context);
|
||||||
|
if (localDnsPort == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(localDnsPort: localDnsPort),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(
|
||||||
|
experimental(t.settings.config.allowConnectionFromLan),
|
||||||
|
),
|
||||||
|
value: options.allowConnectionFromLan,
|
||||||
|
onChanged: (value) => changeOption(
|
||||||
|
ConfigOptionPatch(allowConnectionFromLan: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(t.settings.config.section.tlsTricks),
|
||||||
|
SwitchListTile(
|
||||||
|
title:
|
||||||
|
Text(experimental(t.settings.config.enableTlsFragment)),
|
||||||
|
value: options.enableTlsFragment,
|
||||||
|
onChanged: (value) async => changeOption(
|
||||||
|
ConfigOptionPatch(enableTlsFragment: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.tlsFragmentSize),
|
||||||
|
subtitle: Text(options.tlsFragmentSize.present(t)),
|
||||||
|
onTap: () async {
|
||||||
|
final range = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.tlsFragmentSize,
|
||||||
|
initialValue: options.tlsFragmentSize.format(),
|
||||||
|
resetValue: defaultOptions.tlsFragmentSize.format(),
|
||||||
|
).show(context);
|
||||||
|
if (range == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(
|
||||||
|
tlsFragmentSize:
|
||||||
|
RangeWithOptionalCeil.tryParse(range),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.tlsFragmentSleep),
|
||||||
|
subtitle: Text(options.tlsFragmentSleep.present(t)),
|
||||||
|
onTap: () async {
|
||||||
|
final range = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.tlsFragmentSleep,
|
||||||
|
initialValue: options.tlsFragmentSleep.format(),
|
||||||
|
resetValue: defaultOptions.tlsFragmentSleep.format(),
|
||||||
|
).show(context);
|
||||||
|
if (range == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(
|
||||||
|
tlsFragmentSleep:
|
||||||
|
RangeWithOptionalCeil.tryParse(range),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title: Text(
|
||||||
|
experimental(t.settings.config.enableTlsMixedSniCase),
|
||||||
|
),
|
||||||
|
value: options.enableTlsMixedSniCase,
|
||||||
|
onChanged: (value) async => changeOption(
|
||||||
|
ConfigOptionPatch(enableTlsMixedSniCase: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title:
|
||||||
|
Text(experimental(t.settings.config.enableTlsPadding)),
|
||||||
|
value: options.enableTlsPadding,
|
||||||
|
onChanged: (value) async => changeOption(
|
||||||
|
ConfigOptionPatch(enableTlsPadding: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.tlsPaddingSize),
|
||||||
|
subtitle: Text(options.tlsPaddingSize.present(t)),
|
||||||
|
onTap: () async {
|
||||||
|
final range = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.tlsPaddingSize,
|
||||||
|
initialValue: options.tlsPaddingSize.format(),
|
||||||
|
resetValue: defaultOptions.tlsPaddingSize.format(),
|
||||||
|
).show(context);
|
||||||
|
if (range == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(
|
||||||
|
tlsPaddingSize: RangeWithOptionalCeil.tryParse(range),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(experimental(t.settings.config.section.warp)),
|
||||||
|
WarpOptionsTiles(
|
||||||
|
options: options,
|
||||||
|
defaultOptions: defaultOptions,
|
||||||
|
onChange: changeOption,
|
||||||
|
),
|
||||||
|
const SettingsDivider(),
|
||||||
|
SettingsSection(t.settings.config.section.misc),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.connectionTestUrl),
|
||||||
|
subtitle: Text(options.connectionTestUrl),
|
||||||
|
onTap: () async {
|
||||||
|
final url = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.connectionTestUrl,
|
||||||
|
initialValue: options.connectionTestUrl,
|
||||||
|
resetValue: defaultOptions.connectionTestUrl,
|
||||||
|
).show(context);
|
||||||
|
if (url == null || url.isEmpty || !isUrl(url)) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(connectionTestUrl: url),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.urlTestInterval),
|
||||||
|
subtitle: Text(
|
||||||
|
options.urlTestInterval
|
||||||
|
.toApproximateTime(isRelativeToNow: false),
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
final urlTestInterval = await SettingsSliderDialog(
|
||||||
|
title: t.settings.config.urlTestInterval,
|
||||||
|
initialValue: options.urlTestInterval.inMinutes
|
||||||
|
.coerceIn(0, 60)
|
||||||
|
.toDouble(),
|
||||||
|
resetValue:
|
||||||
|
defaultOptions.urlTestInterval.inMinutes.toDouble(),
|
||||||
|
min: 1,
|
||||||
|
max: 60,
|
||||||
|
divisions: 60,
|
||||||
|
labelGen: (value) => Duration(minutes: value.toInt())
|
||||||
|
.toApproximateTime(isRelativeToNow: false),
|
||||||
|
).show(context);
|
||||||
|
if (urlTestInterval == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(
|
||||||
|
urlTestInterval:
|
||||||
|
Duration(minutes: urlTestInterval.toInt()),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(t.settings.config.clashApiPort),
|
||||||
|
subtitle: Text(options.clashApiPort.toString()),
|
||||||
|
onTap: () async {
|
||||||
|
final clashApiPort = await SettingsInputDialog(
|
||||||
|
title: t.settings.config.clashApiPort,
|
||||||
|
initialValue: options.clashApiPort,
|
||||||
|
resetValue: defaultOptions.clashApiPort,
|
||||||
|
validator: isPort,
|
||||||
|
mapTo: int.tryParse,
|
||||||
|
digitsOnly: true,
|
||||||
|
).show(context);
|
||||||
|
if (clashApiPort == null) return;
|
||||||
|
await changeOption(
|
||||||
|
ConfigOptionPatch(clashApiPort: clashApiPort),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Gap(24),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
AsyncError(:final error) => SliverFillRemaining(
|
||||||
),
|
hasScrollBody: false,
|
||||||
_ => const SizedBox(),
|
child: Column(
|
||||||
},
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.error),
|
||||||
|
const Gap(2),
|
||||||
|
Text(t.presentShortError(error)),
|
||||||
|
const Gap(2),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await ref
|
||||||
|
.read(configOptionNotifierProvider.notifier)
|
||||||
|
.resetOption();
|
||||||
|
},
|
||||||
|
child: Text(t.settings.config.resetBtn),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_ => const SliverToBoxAdapter(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class _ConnectionButton extends StatelessWidget {
|
|||||||
const Gap(16),
|
const Gap(16),
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,13 +23,6 @@ class AdvancedSettingTiles extends HookConsumerWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
const RegionPrefTile(),
|
const RegionPrefTile(),
|
||||||
ListTile(
|
|
||||||
title: Text(t.settings.config.pageTitle),
|
|
||||||
leading: const Icon(Icons.edit_document),
|
|
||||||
onTap: () async {
|
|
||||||
await const ConfigOptionsRoute().push(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(t.settings.geoAssets.pageTitle),
|
title: Text(t.settings.geoAssets.pageTitle),
|
||||||
leading: const Icon(Icons.folder),
|
leading: const Icon(Icons.folder),
|
||||||
|
|||||||
Reference in New Issue
Block a user