mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Added server management modal
This commit is contained in:
parent
3bb3f36ecb
commit
3ccdff9e9f
8 changed files with 207 additions and 17 deletions
25
lib/screens/home/fab.dart
Normal file
25
lib/screens/home/fab.dart
Normal file
|
@ -0,0 +1,25 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adguard_home_manager/screens/home/management_modal.dart';
|
||||
|
||||
class HomeFab extends StatelessWidget {
|
||||
const HomeFab({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
void openManagementBottomSheet() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => const ManagementModal(),
|
||||
backgroundColor: Colors.transparent,
|
||||
);
|
||||
}
|
||||
|
||||
return FloatingActionButton(
|
||||
onPressed: openManagementBottomSheet,
|
||||
child: const Icon(Icons.shield_rounded),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -80,6 +80,8 @@ class Home extends StatelessWidget {
|
|||
label: AppLocalizations.of(context)!.topClients,
|
||||
data: serversProvider.serverStatus.data!.stats.topClients
|
||||
),
|
||||
|
||||
const SizedBox(height: 70) // To avoid content under fab
|
||||
],
|
||||
);
|
||||
|
||||
|
|
151
lib/screens/home/management_modal.dart
Normal file
151
lib/screens/home/management_modal.dart
Normal file
|
@ -0,0 +1,151 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||
|
||||
class ManagementModal extends StatelessWidget {
|
||||
const ManagementModal({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
|
||||
Widget mainSwitch() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Material(
|
||||
color: Theme.of(context).primaryColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
child: InkWell(
|
||||
onTap: () => {},
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 12
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.allProtections,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: serversProvider.serverStatus.data!.generalEnabled,
|
||||
onChanged: (value) => {},
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget smallSwitch(String label, bool value, Function(bool) onChange) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => {},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 35,
|
||||
vertical: 5
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: value,
|
||||
onChanged: onChange,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.maxFinite,
|
||||
height: 540,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(28),
|
||||
topRight: Radius.circular(28)
|
||||
)
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
child: Icon(
|
||||
Icons.shield,
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.manageServer,
|
||||
style: const TextStyle(
|
||||
fontSize: 22
|
||||
),
|
||||
),
|
||||
),
|
||||
mainSwitch(),
|
||||
const SizedBox(height: 10),
|
||||
smallSwitch(
|
||||
AppLocalizations.of(context)!.ruleFiltering,
|
||||
false,
|
||||
(p0) => null
|
||||
),
|
||||
smallSwitch(
|
||||
AppLocalizations.of(context)!.safeBrowsing,
|
||||
false,
|
||||
(p0) => null
|
||||
),
|
||||
smallSwitch(
|
||||
AppLocalizations.of(context)!.parentalFiltering,
|
||||
false,
|
||||
(p0) => null
|
||||
),
|
||||
smallSwitch(
|
||||
AppLocalizations.of(context)!.safeSearch,
|
||||
false,
|
||||
(p0) => null
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(AppLocalizations.of(context)!.close),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -40,22 +40,22 @@ class ServerStatus extends StatelessWidget {
|
|||
children: [
|
||||
StatusBox(
|
||||
icon: Icons.filter_list_rounded,
|
||||
label: AppLocalizations.of(context)!.ruleFiltering,
|
||||
label: AppLocalizations.of(context)!.ruleFilteringWidget,
|
||||
isEnabled: serverStatus.filteringEnabled
|
||||
),
|
||||
StatusBox(
|
||||
icon: Icons.vpn_lock_rounded,
|
||||
label: AppLocalizations.of(context)!.safeBrowsing,
|
||||
label: AppLocalizations.of(context)!.safeBrowsingWidget,
|
||||
isEnabled: serverStatus.safeBrowsingEnabled
|
||||
),
|
||||
StatusBox(
|
||||
icon: Icons.block,
|
||||
label: AppLocalizations.of(context)!.parentalFiltering,
|
||||
label: AppLocalizations.of(context)!.parentalFilteringWidget,
|
||||
isEnabled: serverStatus.parentalControlEnabled
|
||||
),
|
||||
StatusBox(
|
||||
icon: Icons.search_rounded,
|
||||
label: AppLocalizations.of(context)!.safeSearch,
|
||||
label: AppLocalizations.of(context)!.safeSearchWidget,
|
||||
isEnabled: serverStatus.safeSearchEnabled
|
||||
),
|
||||
],
|
||||
|
|
|
@ -14,8 +14,6 @@ class StatusBox extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
width: double.maxFinite,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue