mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-16 06:53:00 +00:00
Changed dns addresses modal
This commit is contained in:
parent
dcad63fe5c
commit
7a89aea3a5
2 changed files with 76 additions and 44 deletions
|
@ -1,54 +1,71 @@
|
|||
import 'package:flutter/material.dart';
|
||||
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/list_bottom_sheet.dart';
|
||||
|
||||
class DnsAddressesModal extends StatelessWidget {
|
||||
final bool isDialog;
|
||||
final List<String> dnsAddresses;
|
||||
|
||||
const DnsAddressesModal({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.isDialog,
|
||||
required this.dnsAddresses,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.route_rounded,
|
||||
color: Theme.of(context).listTileTheme.iconColor
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.dnsAddresses,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface
|
||||
if (isDialog == true) {
|
||||
return AlertDialog(
|
||||
title: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.route_rounded,
|
||||
color: Theme.of(context).listTileTheme.iconColor
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.dnsAddresses,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
content: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: SingleChildScrollView(
|
||||
child: Wrap(
|
||||
children: dnsAddresses.map((address) => ListTile(
|
||||
title: Text(
|
||||
address,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context).listTileTheme.textColor
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(AppLocalizations.of(context)!.close)
|
||||
)
|
||||
],
|
||||
),
|
||||
content: SizedBox(
|
||||
height: dnsAddresses.length*56 < 500
|
||||
? dnsAddresses.length*56 : 500,
|
||||
width: double.minPositive,
|
||||
child: ListView(
|
||||
children: dnsAddresses.map((address) => ListTile(
|
||||
title: Text(
|
||||
address,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context).listTileTheme.textColor
|
||||
),
|
||||
),
|
||||
)).toList(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(AppLocalizations.of(context)!.close)
|
||||
)
|
||||
],
|
||||
);
|
||||
);
|
||||
}
|
||||
else {
|
||||
return ListBottomSheet(
|
||||
icon: Icons.route_rounded,
|
||||
title: AppLocalizations.of(context)!.dnsAddresses,
|
||||
children: dnsAddresses.map((address) => CustomListTile(
|
||||
title: address,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,12 +86,27 @@ class _ServerInformationState extends State<ServerInformation> {
|
|||
title: AppLocalizations.of(context)!.dnsAddresses,
|
||||
subtitle: AppLocalizations.of(context)!.seeDnsAddresses,
|
||||
onTap: () {
|
||||
showModal(
|
||||
context: context,
|
||||
builder: (context) => DnsAddressesModal(
|
||||
dnsAddresses: serverInfo.data!.dnsAddresses
|
||||
)
|
||||
);
|
||||
if (width > 700) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => DnsAddressesModal(
|
||||
dnsAddresses: serverInfo.data!.dnsAddresses,
|
||||
isDialog: true,
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => DnsAddressesModal(
|
||||
dnsAddresses: serverInfo.data!.dnsAddresses,
|
||||
isDialog: false,
|
||||
),
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
useSafeArea: true
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
CustomListTile(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue