mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-26 16:56:08 +00:00
Change order home and fixes
This commit is contained in:
parent
520a14fcda
commit
d69da88b01
3 changed files with 122 additions and 80 deletions
|
@ -8,4 +8,6 @@ final List<HomeTopItems> homeTopItemsDefaultOrder = [
|
||||||
HomeTopItems.recurrentClients
|
HomeTopItems.recurrentClients
|
||||||
];
|
];
|
||||||
|
|
||||||
final String homeTopItemsDefaultOrderString = jsonEncode(homeTopItemsDefaultOrder);
|
final String homeTopItemsDefaultOrderString = jsonEncode(
|
||||||
|
List<String>.from(homeTopItemsDefaultOrder.map((e) => e.name))
|
||||||
|
);
|
|
@ -175,49 +175,60 @@ class _HomeState extends State<Home> {
|
||||||
child: CombinedHomeChart(),
|
child: CombinedHomeChart(),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (width <= 700) ...[
|
if (width <= 700) ...appConfigProvider.homeTopItemsOrder.asMap().entries.map((item) {
|
||||||
TopItems(
|
Widget list() {
|
||||||
|
switch (item.value) {
|
||||||
|
case HomeTopItems.queriedDomains:
|
||||||
|
return TopItems(
|
||||||
label: AppLocalizations.of(context)!.topQueriedDomains,
|
label: AppLocalizations.of(context)!.topQueriedDomains,
|
||||||
data: statusProvider.serverStatus!.stats.topQueriedDomains,
|
data: statusProvider.serverStatus!.stats.topQueriedDomains,
|
||||||
type: 'topQueriedDomains',
|
type: 'topQueriedDomains',
|
||||||
),
|
);
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
child: Divider(
|
|
||||||
thickness: 1,
|
|
||||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
case HomeTopItems.blockedDomains:
|
||||||
|
return TopItems(
|
||||||
TopItems(
|
|
||||||
label: AppLocalizations.of(context)!.topBlockedDomains,
|
label: AppLocalizations.of(context)!.topBlockedDomains,
|
||||||
data: statusProvider.serverStatus!.stats.topBlockedDomains,
|
data: statusProvider.serverStatus!.stats.topBlockedDomains,
|
||||||
type: 'topBlockedDomains',
|
type: 'topBlockedDomains',
|
||||||
),
|
);
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
child: Divider(
|
|
||||||
thickness: 1,
|
|
||||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
TopItems(
|
case HomeTopItems.recurrentClients:
|
||||||
|
return TopItems(
|
||||||
label: AppLocalizations.of(context)!.topClients,
|
label: AppLocalizations.of(context)!.topClients,
|
||||||
data: statusProvider.serverStatus!.stats.topClients,
|
data: statusProvider.serverStatus!.stats.topClients,
|
||||||
type: 'topClients',
|
type: 'topClients',
|
||||||
clients: true,
|
clients: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
list(),
|
||||||
|
if (item.key < appConfigProvider.homeTopItemsOrder.length - 1) ...[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: Divider(
|
||||||
|
thickness: 1,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.2),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
]
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
if (width > 700) Column(
|
if (width > 700) Column(
|
||||||
children: [
|
children: [
|
||||||
Wrap(
|
Wrap(
|
||||||
alignment: WrapAlignment.center,
|
alignment: WrapAlignment.center,
|
||||||
children: [
|
children: appConfigProvider.homeTopItemsOrder.map((item) {
|
||||||
Padding(
|
switch (item) {
|
||||||
|
case HomeTopItems.queriedDomains:
|
||||||
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
|
@ -229,8 +240,10 @@ class _HomeState extends State<Home> {
|
||||||
type: 'topQueriedDomains',
|
type: 'topQueriedDomains',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
Padding(
|
|
||||||
|
case HomeTopItems.blockedDomains:
|
||||||
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
|
@ -242,8 +255,10 @@ class _HomeState extends State<Home> {
|
||||||
type: 'topBlockedDomains',
|
type: 'topBlockedDomains',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
Padding(
|
|
||||||
|
case HomeTopItems.recurrentClients:
|
||||||
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
|
@ -255,8 +270,12 @@ class _HomeState extends State<Home> {
|
||||||
type: 'topClients',
|
type: 'topClients',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
|
||||||
|
default:
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
}).toList(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -6,6 +8,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
||||||
|
|
||||||
|
import 'package:adguard_home_manager/functions/snackbar.dart';
|
||||||
import 'package:adguard_home_manager/constants/enums.dart';
|
import 'package:adguard_home_manager/constants/enums.dart';
|
||||||
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||||
|
|
||||||
|
@ -151,6 +154,24 @@ class _ReorderableTopItemsHomeState extends State<ReorderableTopItemsHome> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveSettings() async {
|
||||||
|
final result = await appConfigProvider.setHomeTopItemsOrder(homeTopItemsList);
|
||||||
|
if (result == true) {
|
||||||
|
showSnacbkar(
|
||||||
|
appConfigProvider: appConfigProvider,
|
||||||
|
label: AppLocalizations.of(context)!.settingsSaved,
|
||||||
|
color: Colors.green
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
showSnacbkar(
|
||||||
|
appConfigProvider: appConfigProvider,
|
||||||
|
label: AppLocalizations.of(context)!.settingsNotSaved,
|
||||||
|
color: Colors.red
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: onWillPopScope,
|
onWillPop: onWillPopScope,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@ -159,7 +180,7 @@ class _ReorderableTopItemsHomeState extends State<ReorderableTopItemsHome> {
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: !listEquals(appConfigProvider.homeTopItemsOrder, persistHomeTopItemsList)
|
onPressed: !listEquals(appConfigProvider.homeTopItemsOrder, persistHomeTopItemsList)
|
||||||
? () => appConfigProvider.setHomeTopItemsOrder(homeTopItemsList)
|
? () => saveSettings()
|
||||||
: null,
|
: null,
|
||||||
icon: const Icon(Icons.save_rounded),
|
icon: const Icon(Icons.save_rounded),
|
||||||
tooltip: AppLocalizations.of(context)!.save,
|
tooltip: AppLocalizations.of(context)!.save,
|
||||||
|
|
Loading…
Add table
Reference in a new issue