mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Added top items
This commit is contained in:
parent
b16a1a2a0e
commit
91ec08614c
4 changed files with 124 additions and 3 deletions
|
@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
|
|||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/screens/home/server_status.dart';
|
||||
import 'package:adguard_home_manager/screens/home/top_items.dart';
|
||||
|
||||
import 'package:adguard_home_manager/services/http_requests.dart';
|
||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||
|
@ -48,7 +49,37 @@ class Home extends StatelessWidget {
|
|||
child: Divider(
|
||||
thickness: 1,
|
||||
),
|
||||
)
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
TopItems(
|
||||
label: AppLocalizations.of(context)!.topQueriedDomains,
|
||||
data: serversProvider.serverStatus.data!.stats.topQueriedDomains
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Divider(
|
||||
thickness: 1,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
TopItems(
|
||||
label: AppLocalizations.of(context)!.topBlockedDomains,
|
||||
data: serversProvider.serverStatus.data!.stats.topBlockedDomains
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Divider(
|
||||
thickness: 1,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
TopItems(
|
||||
label: AppLocalizations.of(context)!.topClients,
|
||||
data: serversProvider.serverStatus.data!.stats.topClients
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
|
82
lib/screens/home/top_items.dart
Normal file
82
lib/screens/home/top_items.dart
Normal file
|
@ -0,0 +1,82 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class TopItems extends StatelessWidget {
|
||||
final String label;
|
||||
final List<Map<String, dynamic>> data;
|
||||
|
||||
const TopItems({
|
||||
Key? key,
|
||||
required this.label,
|
||||
required this.data,
|
||||
}) : super(key: key);
|
||||
|
||||
Widget rowItem(Map<String, dynamic> item) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 8
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
item.keys.toList()[0],
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
),
|
||||
Text(item.values.toList()[0].toString())
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (data.isNotEmpty) rowItem(data[0]),
|
||||
if (data.length >= 2) rowItem(data[1]),
|
||||
if (data.length >= 3) rowItem(data[2]),
|
||||
if (data.length >= 4) rowItem(data[3]),
|
||||
if (data.length >= 5) rowItem(data[4]),
|
||||
if (data.length > 5) ...[
|
||||
const SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => {},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.viewMore),
|
||||
const SizedBox(width: 10),
|
||||
const Icon(
|
||||
Icons.arrow_forward,
|
||||
size: 20,
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue