Skip to content

Commit

Permalink
new: add use xray core option
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Aug 6, 2024
1 parent aa99fab commit 27a1374
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions assets/translations/strings_en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@
"reconnectMsg": "Reconnecting for taking into account the changes..."
},
"config": {
"useXrayCoreWhenPossible":{
"Label":"Use Xray-core When Possible",
"Description":"Use Xray-core during parsing sub links. You need to reimport the sub link to enable this option."
},
"resetBtn": "Reset Options",
"serviceMode": "Service Mode",
"quickSettings": "Quick Settings",
Expand Down
4 changes: 4 additions & 0 deletions assets/translations/strings_fa.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@
"reconnectMsg": "در حال اتصال مجدد برای اعمال تغییرات..."
},
"config": {
"useXrayCoreWhenPossible":{
"Label":"استفاده از Xray-core در صورت ممکن",
"Description":"برای استفاده از Xray-core باید دوباره لینک ساب را وارد کنید تا این گزینه فعال شود."
},
"resetBtn": "بازنشانی تنظیمات",
"serviceMode": "حالت سرویس",
"quickSettings": "تنظیمات سریع",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ abstract class ConfigOptions {
mapFrom: Region.values.byName,
mapTo: (value) => value.name,
);

static final useXrayCoreWhenPossible = PreferencesNotifier.create<bool, bool>(
"use-xray-core-when-possible",
false,
);
static final blockAds = PreferencesNotifier.create<bool, bool>(
"block-ads",
false,
Expand Down Expand Up @@ -329,6 +332,7 @@ abstract class ConfigOptions {
static final Map<String, StateNotifierProvider<PreferencesNotifier, dynamic>> preferences = {
"region": region,
"block-ads": blockAds,
"use-xray-core-when-possible": useXrayCoreWhenPossible,
"service-mode": serviceMode,
"log-level": logLevel,
"resolve-destination": resolveDestination,
Expand Down Expand Up @@ -432,6 +436,7 @@ abstract class ConfigOptions {
return SingboxConfigOption(
region: ref.watch(region).name,
blockAds: ref.watch(blockAds),
useXrayCoreWhenPossible: ref.watch(useXrayCoreWhenPossible),
executeConfigAsIs: false,
logLevel: ref.watch(logLevel),
resolveDestination: ref.watch(resolveDestination),
Expand Down
7 changes: 7 additions & 0 deletions lib/features/config_option/overview/config_options_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class ConfigOptionsPage extends HookConsumerWidget {
title: t.config.logLevel,
presentChoice: (value) => value.name.toUpperCase(),
),

const SettingsDivider(),
SettingsSection(t.config.section.route),
ChoicePreferenceWidget(
Expand Down Expand Up @@ -358,6 +359,12 @@ class ConfigOptionsPage extends HookConsumerWidget {
inputToValue: int.tryParse,
),
const Gap(24),
SwitchListTile(
title: Text(experimental(t.config.useXrayCoreWhenPossible.Label)),
subtitle: Text(t.config.useXrayCoreWhenPossible.Description),
value: ref.watch(ConfigOptions.useXrayCoreWhenPossible),
onChanged: ref.watch(ConfigOptions.useXrayCoreWhenPossible.notifier).update,
),
],
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/singbox/model/singbox_config_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SingboxConfigOption with _$SingboxConfigOption {
const factory SingboxConfigOption({
required String region,
required bool blockAds,
required bool useXrayCoreWhenPossible,
required bool executeConfigAsIs,
required LogLevel logLevel,
required bool resolveDestination,
Expand Down
2 changes: 1 addition & 1 deletion libcore

0 comments on commit 27a1374

Please sign in to comment.