mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-09 08:07:45 +00:00
Modified dhcp leases
This commit is contained in:
parent
c3690902c8
commit
1832d3d374
2 changed files with 74 additions and 71 deletions
|
@ -6,7 +6,7 @@ import 'package:bottom_sheet/bottom_sheet.dart';
|
|||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/screens/settings/section_label.dart';
|
||||
import 'package:adguard_home_manager/screens/settings/dhcp/dhcp_static.dart';
|
||||
import 'package:adguard_home_manager/screens/settings/dhcp/dhcp_leases.dart';
|
||||
import 'package:adguard_home_manager/screens/settings/dhcp/select_interface_modal.dart';
|
||||
|
||||
import 'package:adguard_home_manager/functions/snackbar.dart';
|
||||
|
@ -601,60 +601,47 @@ class _DhcpWidgetState extends State<DhcpWidget> {
|
|||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 20),
|
||||
SectionLabel(
|
||||
label: AppLocalizations.of(context)!.dhcpLeases,
|
||||
),
|
||||
if (serversProvider.dhcp.data!.dhcpStatus.leases.isNotEmpty) ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: serversProvider.dhcp.data!.dhcpStatus.leases.length,
|
||||
itemBuilder: (context, index) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
serversProvider.dhcp.data!.dhcpStatus.leases[index].ip,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
serversProvider.dhcp.data!.dhcpStatus.leases[index].mac,
|
||||
style: const TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 14
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
serversProvider.dhcp.data!.dhcpStatus.leases[index].hostname,
|
||||
style: const TextStyle(
|
||||
fontSize: 14
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
if (serversProvider.dhcp.data!.dhcpStatus.leases.isEmpty) Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.noLeases,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => DhcpStatic(
|
||||
items: serversProvider.dhcp.data!.dhcpStatus.staticLeases
|
||||
builder: (context) => DhcpLeases(
|
||||
items: serversProvider.dhcp.data!.dhcpStatus.leases,
|
||||
staticLeases: false,
|
||||
)
|
||||
));
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.dhcpLeases,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 16
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_rounded)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => DhcpLeases(
|
||||
items: serversProvider.dhcp.data!.dhcpStatus.staticLeases,
|
||||
staticLeases: true,
|
||||
)
|
||||
));
|
||||
},
|
||||
|
@ -676,6 +663,7 @@ class _DhcpWidgetState extends State<DhcpWidget> {
|
|||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@ import 'package:adguard_home_manager/classes/process_modal.dart';
|
|||
import 'package:adguard_home_manager/models/dhcp.dart';
|
||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||
|
||||
class DhcpStatic extends StatelessWidget {
|
||||
class DhcpLeases extends StatelessWidget {
|
||||
final List<Lease> items;
|
||||
final bool staticLeases;
|
||||
|
||||
const DhcpStatic({
|
||||
const DhcpLeases({
|
||||
Key? key,
|
||||
required this.items,
|
||||
required this.staticLeases,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -129,7 +131,11 @@ class DhcpStatic extends StatelessWidget {
|
|||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.dhcpStatic),
|
||||
title: Text(
|
||||
staticLeases == true
|
||||
? AppLocalizations.of(context)!.dhcpStatic
|
||||
: AppLocalizations.of(context)!.dhcpLeases,
|
||||
),
|
||||
),
|
||||
body: items.isNotEmpty
|
||||
? ListView.builder(
|
||||
|
@ -145,7 +151,8 @@ class DhcpStatic extends StatelessWidget {
|
|||
Text(items[index].hostname),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
trailing: staticLeases == true
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
showModal(
|
||||
context: context,
|
||||
|
@ -155,12 +162,17 @@ class DhcpStatic extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
icon: const Icon(Icons.delete)
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
)
|
||||
: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.noDhcpStaticLeases,
|
||||
staticLeases == true
|
||||
? AppLocalizations.of(context)!.noDhcpStaticLeases
|
||||
: AppLocalizations.of(context)!.noLeases,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.grey,
|
||||
|
@ -168,10 +180,13 @@ class DhcpStatic extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
),
|
||||
floatingActionButton: staticLeases == true
|
||||
? FloatingActionButton(
|
||||
onPressed: openAddStaticLease,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue