mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-22 23:09:12 +00:00
Sort top items
This commit is contained in:
parent
6973eae0de
commit
c3530f17ab
3 changed files with 64 additions and 4 deletions
|
@ -699,5 +699,8 @@
|
||||||
"testUpstreamDnsServers": "Test upstream DNS servers",
|
"testUpstreamDnsServers": "Test upstream DNS servers",
|
||||||
"errorTestUpstreamDns": "Error when testing upstream DNS servers.",
|
"errorTestUpstreamDns": "Error when testing upstream DNS servers.",
|
||||||
"useCustomIpEdns": "Use custom IP for EDNS",
|
"useCustomIpEdns": "Use custom IP for EDNS",
|
||||||
"useCustomIpEdnsDescription": "Allow to use custom IP for EDNS"
|
"useCustomIpEdnsDescription": "Allow to use custom IP for EDNS",
|
||||||
|
"sortingOptions": "Sorting options",
|
||||||
|
"fromHighestToLowest": "From highest to lowest",
|
||||||
|
"fromLowestToHighest": "From lowest to highest"
|
||||||
}
|
}
|
|
@ -699,5 +699,8 @@
|
||||||
"testUpstreamDnsServers": "Probar servidores DNS de subida",
|
"testUpstreamDnsServers": "Probar servidores DNS de subida",
|
||||||
"errorTestUpstreamDns": "Error al probar los servidores DNS de subida.",
|
"errorTestUpstreamDns": "Error al probar los servidores DNS de subida.",
|
||||||
"useCustomIpEdns": "Usar IP personalizada para EDNS",
|
"useCustomIpEdns": "Usar IP personalizada para EDNS",
|
||||||
"useCustomIpEdnsDescription": "Permitir usar IP personalizada para EDNS"
|
"useCustomIpEdnsDescription": "Permitir usar IP personalizada para EDNS",
|
||||||
|
"sortingOptions": "Opciones de ordenación",
|
||||||
|
"fromHighestToLowest": "De mayor a menor",
|
||||||
|
"fromLowestToHighest": "De menor a mayor"
|
||||||
}
|
}
|
|
@ -15,6 +15,8 @@ import 'package:adguard_home_manager/constants/enums.dart';
|
||||||
import 'package:adguard_home_manager/functions/number_format.dart';
|
import 'package:adguard_home_manager/functions/number_format.dart';
|
||||||
import 'package:adguard_home_manager/providers/status_provider.dart';
|
import 'package:adguard_home_manager/providers/status_provider.dart';
|
||||||
|
|
||||||
|
enum _SortingOptions { highestToLowest, lowestToHighest }
|
||||||
|
|
||||||
class TopItemsScreen extends StatefulWidget {
|
class TopItemsScreen extends StatefulWidget {
|
||||||
final HomeTopItems type;
|
final HomeTopItems type;
|
||||||
final String title;
|
final String title;
|
||||||
|
@ -44,6 +46,7 @@ class TopItemsScreen extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TopItemsScreenState extends State<TopItemsScreen> {
|
class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
|
_SortingOptions _sortingOptions = _SortingOptions.highestToLowest;
|
||||||
bool searchActive = false;
|
bool searchActive = false;
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
|
@ -69,6 +72,10 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
total = total + double.parse(element.values.toList()[0].toString());
|
total = total + double.parse(element.values.toList()[0].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final sortedValues = _sortingOptions == _SortingOptions.lowestToHighest
|
||||||
|
? screenData.reversed.toList()
|
||||||
|
: screenData.toList();
|
||||||
|
|
||||||
if (widget.isFullscreen == true) {
|
if (widget.isFullscreen == true) {
|
||||||
return Dialog.fullscreen(
|
return Dialog.fullscreen(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@ -119,6 +126,53 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
icon: const Icon(Icons.clear_rounded),
|
icon: const Icon(Icons.clear_rounded),
|
||||||
tooltip: AppLocalizations.of(context)!.clearSearch,
|
tooltip: AppLocalizations.of(context)!.clearSearch,
|
||||||
),
|
),
|
||||||
|
PopupMenuButton(
|
||||||
|
icon: const Icon(Icons.sort_rounded),
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
onTap: () => setState(() => _sortingOptions = _SortingOptions.highestToLowest),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.arrow_downward_rounded),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(AppLocalizations.of(context)!.fromHighestToLowest)
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Icon(
|
||||||
|
_sortingOptions == _SortingOptions.highestToLowest
|
||||||
|
? Icons.radio_button_checked_rounded
|
||||||
|
: Icons.radio_button_unchecked_rounded,
|
||||||
|
color: _sortingOptions == _SortingOptions.highestToLowest
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
onTap: () => setState(() => _sortingOptions = _SortingOptions.lowestToHighest),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.arrow_upward_rounded),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(AppLocalizations.of(context)!.fromLowestToHighest)
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Icon(
|
||||||
|
_sortingOptions == _SortingOptions.lowestToHighest
|
||||||
|
? Icons.radio_button_checked_rounded
|
||||||
|
: Icons.radio_button_unchecked_rounded,
|
||||||
|
color: _sortingOptions == _SortingOptions.lowestToHighest
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(width: 8)
|
const SizedBox(width: 8)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -128,7 +182,7 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
isClient: widget.isClient,
|
isClient: widget.isClient,
|
||||||
onTapEntry: widget.onTapEntry,
|
onTapEntry: widget.onTapEntry,
|
||||||
options: widget.options,
|
options: widget.options,
|
||||||
screenData: screenData,
|
screenData: sortedValues,
|
||||||
total: total,
|
total: total,
|
||||||
withProgressBar: widget.withProgressBar,
|
withProgressBar: widget.withProgressBar,
|
||||||
),
|
),
|
||||||
|
@ -193,7 +247,7 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
isClient: widget.isClient,
|
isClient: widget.isClient,
|
||||||
onTapEntry: widget.onTapEntry,
|
onTapEntry: widget.onTapEntry,
|
||||||
options: widget.options,
|
options: widget.options,
|
||||||
screenData: screenData,
|
screenData: sortedValues,
|
||||||
total: total,
|
total: total,
|
||||||
withProgressBar: widget.withProgressBar,
|
withProgressBar: widget.withProgressBar,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Reference in a new issue