mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-20 13:59:12 +00:00
Added custom menu
This commit is contained in:
parent
eb4462d4d0
commit
b8d2ee9e0d
4 changed files with 135 additions and 38 deletions
|
@ -11,6 +11,7 @@ import 'package:store_checker/store_checker.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:adguard_home_manager/widgets/bottom_nav_bar.dart';
|
||||
import 'package:adguard_home_manager/widgets/menu_bar.dart';
|
||||
import 'package:adguard_home_manager/widgets/update_modal.dart';
|
||||
import 'package:adguard_home_manager/widgets/navigation_rail.dart';
|
||||
|
||||
|
@ -127,43 +128,45 @@ class _BaseState extends State<Base> with WidgetsBindingObserver {
|
|||
? screensServerConnected
|
||||
: screensSelectServer;
|
||||
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarBrightness: Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.light
|
||||
: Brightness.dark,
|
||||
statusBarIconBrightness: Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
systemNavigationBarColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
systemNavigationBarIconBrightness: Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
),
|
||||
child: Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
if (width > 900) const SideNavigationRail(),
|
||||
Expanded(
|
||||
child: PageTransitionSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
transitionBuilder: (
|
||||
(child, primaryAnimation, secondaryAnimation) => FadeThroughTransition(
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
)
|
||||
),
|
||||
child: screens[appConfigProvider.selectedScreen].body,
|
||||
),
|
||||
),
|
||||
],
|
||||
return CustomMenuBar(
|
||||
child: AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarBrightness: Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.light
|
||||
: Brightness.dark,
|
||||
statusBarIconBrightness: Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
systemNavigationBarColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
systemNavigationBarIconBrightness: Theme.of(context).brightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
),
|
||||
bottomNavigationBar: width <= 900
|
||||
? const BottomNavBar()
|
||||
: null,
|
||||
)
|
||||
child: Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
if (width > 900) const SideNavigationRail(),
|
||||
Expanded(
|
||||
child: PageTransitionSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
transitionBuilder: (
|
||||
(child, primaryAnimation, secondaryAnimation) => FadeThroughTransition(
|
||||
animation: primaryAnimation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
)
|
||||
),
|
||||
child: screens[appConfigProvider.selectedScreen].body,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: width <= 900
|
||||
? const BottomNavBar()
|
||||
: null,
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -611,5 +611,6 @@
|
|||
"selectOptionLeftColumn": "Select an option of the left column",
|
||||
"selectClientLeftColumn": "Select a client of the left column",
|
||||
"disableList": "Disable list",
|
||||
"enableList": "Enable list"
|
||||
"enableList": "Enable list",
|
||||
"screens": "Screens"
|
||||
}
|
|
@ -611,5 +611,6 @@
|
|||
"selectOptionLeftColumn": "Selecciona una opción de la columna de la izquierda",
|
||||
"selectClientLeftColumn": "Selecciona un cliente de la columna de la izquierda",
|
||||
"disableList": "Deshabilitar lista",
|
||||
"enableList": "Habilitar lista"
|
||||
"enableList": "Habilitar lista",
|
||||
"screens": "Pantallas"
|
||||
}
|
92
lib/widgets/menu_bar.dart
Normal file
92
lib/widgets/menu_bar.dart
Normal file
|
@ -0,0 +1,92 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/config/app_screens.dart';
|
||||
import 'package:adguard_home_manager/models/app_screen.dart';
|
||||
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||
|
||||
class CustomMenuBar extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const CustomMenuBar({
|
||||
Key? key,
|
||||
required this.child
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||
|
||||
List<AppScreen> screens = serversProvider.selectedServer != null
|
||||
? screensServerConnected
|
||||
: screensSelectServer;
|
||||
|
||||
String translatedName(String key) {
|
||||
switch (key) {
|
||||
case 'connect':
|
||||
return AppLocalizations.of(context)!.connect;
|
||||
|
||||
case 'home':
|
||||
return AppLocalizations.of(context)!.home;
|
||||
|
||||
case 'settings':
|
||||
return AppLocalizations.of(context)!.settings;
|
||||
|
||||
case 'clients':
|
||||
return AppLocalizations.of(context)!.clients;
|
||||
|
||||
case 'logs':
|
||||
return AppLocalizations.of(context)!.logs;
|
||||
|
||||
case 'filters':
|
||||
return AppLocalizations.of(context)!.filters;
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return PlatformMenuBar(
|
||||
menus: [
|
||||
PlatformMenu(
|
||||
label: 'AdGuard Home Manager',
|
||||
menus: <PlatformMenuItem>[
|
||||
if (
|
||||
PlatformProvidedMenuItem.hasMenu(PlatformProvidedMenuItemType.about)
|
||||
) const PlatformMenuItemGroup(
|
||||
members: [
|
||||
PlatformProvidedMenuItem(
|
||||
type: PlatformProvidedMenuItemType.about,
|
||||
),
|
||||
]
|
||||
),
|
||||
if (
|
||||
PlatformProvidedMenuItem.hasMenu(PlatformProvidedMenuItemType.quit)
|
||||
) const PlatformMenuItemGroup(
|
||||
members: [
|
||||
PlatformProvidedMenuItem(
|
||||
type: PlatformProvidedMenuItemType.quit,
|
||||
),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
PlatformMenu(
|
||||
label: AppLocalizations.of(context)!.screens,
|
||||
menus: <PlatformMenuItem>[
|
||||
PlatformMenuItemGroup(
|
||||
members: screens.asMap().entries.map((e) => PlatformMenuItem(
|
||||
label: "${appConfigProvider.selectedScreen == e.key ? '✔' : ''} ${translatedName(e.value.name)}",
|
||||
onSelected: () => appConfigProvider.setSelectedScreen(e.key),
|
||||
)).toList()
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue