mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Responsive navigation settings
This commit is contained in:
parent
aefdac5650
commit
ef43f8b5dd
11 changed files with 273 additions and 113 deletions
|
@ -89,6 +89,10 @@ class BottomNavBar extends StatelessWidget {
|
|||
if (value != 2) {
|
||||
logsProvider.resetFilters();
|
||||
}
|
||||
// Reset settings selected screen
|
||||
if (value != screens.length-1) {
|
||||
appConfigProvider.setSelectedSettingsScreen(null);
|
||||
}
|
||||
appConfigProvider.setSelectedScreen(value);
|
||||
},
|
||||
);
|
||||
|
|
120
lib/widgets/custom_settings_tile.dart
Normal file
120
lib/widgets/custom_settings_tile.dart
Normal file
|
@ -0,0 +1,120 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomSettingsTile extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget? subtitleWidget;
|
||||
final void Function()? onTap;
|
||||
final IconData? icon;
|
||||
final Widget? trailing;
|
||||
final EdgeInsets? padding;
|
||||
final int thisItem;
|
||||
final int? selectedItem;
|
||||
|
||||
const CustomSettingsTile({
|
||||
Key? key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.subtitleWidget,
|
||||
this.onTap,
|
||||
this.icon,
|
||||
this.trailing,
|
||||
this.padding,
|
||||
required this.thisItem,
|
||||
required this.selectedItem,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
|
||||
Widget tileBody = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(
|
||||
icon,
|
||||
size: 24,
|
||||
color: Theme.of(context).listTileTheme.iconColor,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (subtitle != null || subtitleWidget != null) ...[
|
||||
const SizedBox(height: 5),
|
||||
if (subtitle == null && subtitleWidget != null) subtitleWidget!,
|
||||
if (subtitle != null && subtitleWidget == null) Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).listTileTheme.textColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400
|
||||
),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[
|
||||
const SizedBox(width: 10),
|
||||
trailing!
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
if (width < 700) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: tileBody,
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: double.maxFinite,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
color: thisItem == selectedItem
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: null
|
||||
),
|
||||
child: tileBody
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/providers/logs_provider.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';
|
||||
|
@ -14,6 +15,7 @@ class SideNavigationRail extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||
final logsProvider = Provider.of<LogsProvider>(context);
|
||||
|
||||
List<AppScreen> screens = serversProvider.selectedServer != null
|
||||
? screensServerConnected
|
||||
|
@ -56,6 +58,18 @@ class SideNavigationRail extends StatelessWidget {
|
|||
label: Text(translatedName(screen.name))
|
||||
)).toList(),
|
||||
onDestinationSelected: (value) {
|
||||
// Reset clients tab to 0 when changing screen
|
||||
if (value != 1) {
|
||||
appConfigProvider.setSelectedClientsTab(0);
|
||||
}
|
||||
// Reset logs filters when changing screen
|
||||
if (value != 2) {
|
||||
logsProvider.resetFilters();
|
||||
}
|
||||
// Reset settings selected screen
|
||||
if (value != screens.length-1) {
|
||||
appConfigProvider.setSelectedSettingsScreen(null);
|
||||
}
|
||||
appConfigProvider.setSelectedScreen(value);
|
||||
},
|
||||
labelType: NavigationRailLabelType.all,
|
||||
|
|
|
@ -23,9 +23,17 @@ class DeleteModal extends StatelessWidget {
|
|||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||
|
||||
void removeServer() async {
|
||||
final previouslySelectedServer = serversProvider.selectedServer;
|
||||
|
||||
final deleted = await serversProvider.removeServer(serverToDelete);
|
||||
|
||||
Navigator.pop(context);
|
||||
|
||||
if (deleted == true) {
|
||||
if (previouslySelectedServer != null && previouslySelectedServer.id == serverToDelete.id) {
|
||||
appConfigProvider.setSelectedScreen(0);
|
||||
}
|
||||
|
||||
showSnacbkar(
|
||||
context: context,
|
||||
appConfigProvider: appConfigProvider,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue