2024-03-07 17:04:32 +03:30
|
|
|
|
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:gap/gap.dart';
|
|
|
|
|
|
import 'package:hiddify/core/localization/translations.dart';
|
|
|
|
|
|
import 'package:hiddify/core/router/router.dart';
|
|
|
|
|
|
import 'package:hiddify/features/config_option/data/config_option_repository.dart';
|
|
|
|
|
|
import 'package:hiddify/features/config_option/notifier/warp_option_notifier.dart';
|
2026-01-15 12:28:40 +03:00
|
|
|
|
import 'package:hiddify/features/settings/experimental_features_page.dart';
|
2024-03-07 17:04:32 +03:30
|
|
|
|
import 'package:hiddify/singbox/model/singbox_config_enum.dart';
|
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class QuickSettingsModal extends HookConsumerWidget {
|
|
|
|
|
|
const QuickSettingsModal({super.key});
|
|
|
|
|
|
|
2026-01-15 12:28:40 +03:00
|
|
|
|
void _showHelpDialog(BuildContext context, Translations t) {
|
|
|
|
|
|
showDialog(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
|
|
title: Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
const Icon(FluentIcons.info_24_regular, size: 28),
|
|
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
|
Expanded(child: Text(t.config.quickSettings)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
_buildHelpSection(
|
|
|
|
|
|
icon: FluentIcons.server_20_filled,
|
|
|
|
|
|
title: 'Прокси / VPN',
|
|
|
|
|
|
description: 'Выберите режим подключения:\n\n'
|
|
|
|
|
|
'• Прокси — использует локальный прокси-сервер для перенаправления трафика приложений\n'
|
|
|
|
|
|
'• VPN — создает виртуальную частную сеть для защиты всего трафика устройства',
|
|
|
|
|
|
),
|
|
|
|
|
|
const Divider(height: 24),
|
|
|
|
|
|
_buildHelpSection(
|
|
|
|
|
|
icon: FluentIcons.shield_20_filled,
|
|
|
|
|
|
title: t.config.setupWarp,
|
|
|
|
|
|
description: 'Технология Cloudflare WARP для дополнительной защиты:\n\n'
|
|
|
|
|
|
'• Шифрует DNS-запросы\n'
|
|
|
|
|
|
'• Скрывает ваш IP-адрес\n'
|
|
|
|
|
|
'• Улучшает скорость подключения в некоторых регионах\n'
|
|
|
|
|
|
'• Требует первоначальной настройки с получением лицензионного ключа',
|
|
|
|
|
|
),
|
|
|
|
|
|
const Divider(height: 24),
|
|
|
|
|
|
_buildHelpSection(
|
|
|
|
|
|
icon: FluentIcons.shield_keyhole_20_filled,
|
|
|
|
|
|
title: t.config.enableTlsFragment,
|
|
|
|
|
|
description: 'Разбивает TLS-пакеты на фрагменты для обхода блокировок:\n\n'
|
|
|
|
|
|
'• Помогает обойти DPI (глубокую проверку пакетов)\n'
|
|
|
|
|
|
'• Работает на уровне TLS-рукопожатия\n'
|
|
|
|
|
|
'• Может немного замедлить начальное соединение\n'
|
|
|
|
|
|
'• Эффективно против систем блокировки на основе анализа SNI',
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
actions: [
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
|
child: Text(t.window.close),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildHelpSection({
|
|
|
|
|
|
required IconData icon,
|
|
|
|
|
|
required String title,
|
|
|
|
|
|
required String description,
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Icon(icon, size: 20),
|
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
title,
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
description,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
color: Colors.grey[600],
|
|
|
|
|
|
height: 1.4,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-07 17:04:32 +03:30
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
|
final t = ref.watch(translationsProvider);
|
|
|
|
|
|
|
2024-05-31 13:41:35 +02:00
|
|
|
|
final warpPrefaceCompleted = ref.watch(warpOptionNotifierProvider).consentGiven;
|
2024-03-07 17:04:32 +03:30
|
|
|
|
|
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
2026-01-15 12:28:40 +03:00
|
|
|
|
// Заголовок с кнопкой помощи
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 8, 8, 0),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
t.config.quickSettings,
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
IconButton(
|
|
|
|
|
|
icon: const Icon(FluentIcons.question_circle_24_regular),
|
|
|
|
|
|
onPressed: () => _showHelpDialog(context, t),
|
|
|
|
|
|
tooltip: 'Справка',
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const Gap(8),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
|
|
child: SegmentedButton(
|
|
|
|
|
|
segments: ServiceMode.choices
|
|
|
|
|
|
.map(
|
|
|
|
|
|
(e) => ButtonSegment(
|
|
|
|
|
|
value: e,
|
|
|
|
|
|
label: Text(
|
|
|
|
|
|
e.presentShort(t),
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
),
|
2024-05-31 13:41:35 +02:00
|
|
|
|
tooltip: e.isExperimental ? t.settings.experimental : null,
|
2024-03-07 17:04:32 +03:30
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
.toList(),
|
|
|
|
|
|
selected: {ref.watch(ConfigOptions.serviceMode)},
|
2024-05-31 13:41:35 +02:00
|
|
|
|
onSelectionChanged: (newSet) => ref.read(ConfigOptions.serviceMode.notifier).update(newSet.first),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const Gap(8),
|
|
|
|
|
|
if (warpPrefaceCompleted)
|
2026-01-15 12:28:40 +03:00
|
|
|
|
SwitchListTile(
|
|
|
|
|
|
value: ref.watch(ConfigOptions.enableWarp),
|
|
|
|
|
|
onChanged: ref.watch(ConfigOptions.enableWarp.notifier).update,
|
|
|
|
|
|
title: Text(t.config.enableWarp),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
)
|
|
|
|
|
|
else
|
|
|
|
|
|
ListTile(
|
2024-03-08 17:24:43 +03:30
|
|
|
|
title: Text(t.config.setupWarp),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
trailing: const Icon(FluentIcons.chevron_right_24_regular),
|
2026-01-15 12:28:40 +03:00
|
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const ExperimentalFeaturesPage(),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
),
|
2026-01-15 12:28:40 +03:00
|
|
|
|
SwitchListTile(
|
|
|
|
|
|
value: ref.watch(ConfigOptions.enableTlsFragment),
|
|
|
|
|
|
onChanged: ref.watch(ConfigOptions.enableTlsFragment.notifier).update,
|
|
|
|
|
|
title: Text(t.config.enableTlsFragment),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
),
|
2024-03-17 14:44:57 +01:00
|
|
|
|
// SwitchListTile(
|
|
|
|
|
|
// value: ref.watch(ConfigOptions.enableMux),
|
|
|
|
|
|
// onChanged: ref.watch(ConfigOptions.enableMux.notifier).update,
|
|
|
|
|
|
// title: Text(t.config.enableMux),
|
|
|
|
|
|
// ),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
ListTile(
|
2024-03-08 17:24:43 +03:30
|
|
|
|
title: Text(t.config.allOptions),
|
2024-03-07 17:04:32 +03:30
|
|
|
|
trailing: const Icon(FluentIcons.chevron_right_24_regular),
|
|
|
|
|
|
dense: true,
|
|
|
|
|
|
onTap: () => const ConfigOptionsRoute().go(context),
|
|
|
|
|
|
),
|
|
|
|
|
|
const Gap(16),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|