mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-20 13:59: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",
|
||||
"errorTestUpstreamDns": "Error when testing upstream DNS servers.",
|
||||
"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",
|
||||
"errorTestUpstreamDns": "Error al probar los servidores DNS de subida.",
|
||||
"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/providers/status_provider.dart';
|
||||
|
||||
enum _SortingOptions { highestToLowest, lowestToHighest }
|
||||
|
||||
class TopItemsScreen extends StatefulWidget {
|
||||
final HomeTopItems type;
|
||||
final String title;
|
||||
|
@ -44,6 +46,7 @@ class TopItemsScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||
_SortingOptions _sortingOptions = _SortingOptions.highestToLowest;
|
||||
bool searchActive = false;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
|
@ -68,6 +71,10 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
for (var element in data) {
|
||||
total = total + double.parse(element.values.toList()[0].toString());
|
||||
}
|
||||
|
||||
final sortedValues = _sortingOptions == _SortingOptions.lowestToHighest
|
||||
? screenData.reversed.toList()
|
||||
: screenData.toList();
|
||||
|
||||
if (widget.isFullscreen == true) {
|
||||
return Dialog.fullscreen(
|
||||
|
@ -119,6 +126,53 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
icon: const Icon(Icons.clear_rounded),
|
||||
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)
|
||||
],
|
||||
),
|
||||
|
@ -128,7 +182,7 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
isClient: widget.isClient,
|
||||
onTapEntry: widget.onTapEntry,
|
||||
options: widget.options,
|
||||
screenData: screenData,
|
||||
screenData: sortedValues,
|
||||
total: total,
|
||||
withProgressBar: widget.withProgressBar,
|
||||
),
|
||||
|
@ -193,7 +247,7 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
isClient: widget.isClient,
|
||||
onTapEntry: widget.onTapEntry,
|
||||
options: widget.options,
|
||||
screenData: screenData,
|
||||
screenData: sortedValues,
|
||||
total: total,
|
||||
withProgressBar: widget.withProgressBar,
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue