Backup before removing hiddify references
This commit is contained in:
@@ -5,7 +5,12 @@ import 'package:hiddify/gen/assets.gen.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/router/router.dart';
|
||||
import 'package:hiddify/features/stats/widget/side_bar_stats_overview.dart';
|
||||
import 'package:hiddify/core/router/routes.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:hiddify/core/theme/theme_preferences.dart';
|
||||
import 'package:hiddify/core/theme/app_theme_mode.dart';
|
||||
import 'package:hiddify/core/localization/locale_preferences.dart';
|
||||
import 'package:hiddify/core/localization/locale_extensions.dart';
|
||||
|
||||
abstract interface class RootScaffold {
|
||||
static final stateKey = GlobalKey<ScaffoldState>();
|
||||
@@ -40,20 +45,13 @@ class AdaptiveRootScaffold extends HookConsumerWidget {
|
||||
selectedIcon: const Icon(FluentIcons.more_vertical_20_filled),
|
||||
label: t.settings.network.excludedDomains.pageTitle,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.box_edit_20_filled),
|
||||
label: t.config.pageTitle,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.settings_20_filled),
|
||||
label: t.settings.pageTitle,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.document_text_20_filled),
|
||||
label: t.logs.pageTitle,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(FluentIcons.info_20_filled),
|
||||
icon: const Icon(FluentIcons.info_20_regular),
|
||||
selectedIcon: const Icon(FluentIcons.info_20_filled),
|
||||
label: t.about.pageTitle,
|
||||
),
|
||||
];
|
||||
@@ -150,28 +148,43 @@ class _CustomAdaptiveScaffold extends HookConsumerWidget {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
children: [
|
||||
// Главная
|
||||
_DrawerMenuItem(
|
||||
icon: FluentIcons.home_20_regular,
|
||||
selectedIcon: FluentIcons.home_20_filled,
|
||||
label: destinationsSlice(drawerDestinationRange)[0].label,
|
||||
isSelected: selectedWithOffset(drawerDestinationRange) == 0,
|
||||
onTap: () => selectWithOffset(0, drawerDestinationRange),
|
||||
),
|
||||
// Остальные пункты
|
||||
...List.generate(
|
||||
destinationsSlice(drawerDestinationRange).length - 1,
|
||||
(index) {
|
||||
final dest = destinationsSlice(drawerDestinationRange)[index + 1];
|
||||
// О программе
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
return _DrawerMenuItem(
|
||||
icon: (dest.icon as Icon).icon!,
|
||||
selectedIcon: dest.selectedIcon != null ? (dest.selectedIcon as Icon).icon! : (dest.icon as Icon).icon!,
|
||||
label: dest.label,
|
||||
isSelected: selectedWithOffset(drawerDestinationRange) == index + 1,
|
||||
onTap: () => selectWithOffset(index + 1, drawerDestinationRange),
|
||||
icon: FluentIcons.info_24_regular,
|
||||
selectedIcon: FluentIcons.info_24_filled,
|
||||
label: t.about.pageTitle,
|
||||
isSelected: false,
|
||||
onTap: () {
|
||||
RootScaffold.stateKey.currentState?.closeDrawer();
|
||||
const AboutRoute().push(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
// Настройки
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
return _DrawerMenuItem(
|
||||
icon: FluentIcons.settings_24_regular,
|
||||
selectedIcon: FluentIcons.settings_24_filled,
|
||||
label: t.settings.pageTitle,
|
||||
isSelected: false,
|
||||
onTap: () {
|
||||
RootScaffold.stateKey.currentState?.closeDrawer();
|
||||
const SettingsRoute().push(context);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(),
|
||||
const _DrawerThemeItem(),
|
||||
const _DrawerLanguageItem(),
|
||||
const _DrawerLicensesItem(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -267,3 +280,93 @@ class _DrawerMenuItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Виджет для выбора темы в боковом меню
|
||||
class _DrawerThemeItem extends ConsumerWidget {
|
||||
const _DrawerThemeItem();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
final themeMode = ref.watch(themePreferencesProvider);
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(FluentIcons.weather_moon_20_regular, size: 24),
|
||||
title: Text(t.settings.general.themeMode),
|
||||
subtitle: Text(themeMode.present(t)),
|
||||
onTap: () async {
|
||||
final selectedThemeMode = await showDialog<AppThemeMode>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: Text(t.settings.general.themeMode),
|
||||
children: AppThemeMode.values
|
||||
.map((e) => RadioListTile(
|
||||
title: Text(e.present(t)),
|
||||
value: e,
|
||||
groupValue: themeMode,
|
||||
onChanged: Navigator.of(context).maybePop,
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
if (selectedThemeMode != null) {
|
||||
await ref.read(themePreferencesProvider.notifier).changeThemeMode(selectedThemeMode);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Виджет для выбора языка в боковом меню
|
||||
class _DrawerLanguageItem extends ConsumerWidget {
|
||||
const _DrawerLanguageItem();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
final locale = ref.watch(localePreferencesProvider);
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(FluentIcons.local_language_24_regular, size: 24),
|
||||
title: Text(t.settings.general.locale),
|
||||
subtitle: Text(locale.localeName),
|
||||
onTap: () async {
|
||||
final selectedLocale = await showDialog<AppLocale>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: Text(t.settings.general.locale),
|
||||
children: AppLocale.values
|
||||
.map((e) => RadioListTile(
|
||||
title: Text(e.localeName),
|
||||
value: e,
|
||||
groupValue: locale,
|
||||
onChanged: Navigator.of(context).maybePop,
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
if (selectedLocale != null) {
|
||||
await ref.read(localePreferencesProvider.notifier).changeLocale(selectedLocale);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Виджет для открытия лицензий
|
||||
class _DrawerLicensesItem extends ConsumerWidget {
|
||||
const _DrawerLicensesItem();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(FluentIcons.document_text_20_regular, size: 24),
|
||||
title: Text(MaterialLocalizations.of(context).licensesPageTitle),
|
||||
onTap: () {
|
||||
showLicensePage(context: context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user