Files
umbrix/lib/features/config_option/widget/quick_settings_modal.dart
Umbrix Developer 76a374950f feat: mobile-like window size and always-visible stats
- Changed window size to mobile phone format (400x800)
- Removed width condition for ActiveProxyFooter - now always visible
- Added run-umbrix.sh launch script with icon copying
- Stats cards now display on all screen sizes
2026-01-17 13:09:20 +03:00

196 lines
7.5 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:umbrix/core/localization/translations.dart';
import 'package:umbrix/core/router/router.dart';
import 'package:umbrix/features/config_option/data/config_option_repository.dart';
import 'package:umbrix/features/config_option/notifier/warp_option_notifier.dart';
import 'package:umbrix/features/settings/experimental_features_page.dart';
import 'package:umbrix/singbox/model/singbox_config_enum.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class QuickSettingsModal extends HookConsumerWidget {
const QuickSettingsModal({super.key});
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,
),
),
],
);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final warpPrefaceCompleted = ref.watch(warpOptionNotifierProvider).consentGiven;
return SingleChildScrollView(
child: Column(
children: [
// Заголовок с кнопкой помощи
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),
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,
),
tooltip: e.isExperimental ? t.settings.experimental : null,
),
)
.toList(),
selected: {ref.watch(ConfigOptions.serviceMode)},
onSelectionChanged: (newSet) => ref.read(ConfigOptions.serviceMode.notifier).update(newSet.first),
),
),
const Gap(8),
if (warpPrefaceCompleted)
SwitchListTile(
value: ref.watch(ConfigOptions.enableWarp),
onChanged: ref.watch(ConfigOptions.enableWarp.notifier).update,
title: Text(t.config.enableWarp),
)
else
ListTile(
title: Text(t.config.setupWarp),
trailing: const Icon(FluentIcons.chevron_right_24_regular),
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const ExperimentalFeaturesPage(),
),
),
),
SwitchListTile(
value: ref.watch(ConfigOptions.enableTlsFragment),
onChanged: ref.watch(ConfigOptions.enableTlsFragment.notifier).update,
title: Text(t.config.enableTlsFragment),
),
// SwitchListTile(
// value: ref.watch(ConfigOptions.enableMux),
// onChanged: ref.watch(ConfigOptions.enableMux.notifier).update,
// title: Text(t.config.enableMux),
// ),
ListTile(
title: Text(t.config.allOptions),
trailing: const Icon(FluentIcons.chevron_right_24_regular),
dense: true,
onTap: () => const ConfigOptionsRoute().go(context),
),
const Gap(16),
],
),
);
}
}