Added server management modal

This commit is contained in:
Juan Gilsanz Polo 2022-09-27 18:42:23 +02:00
parent 3bb3f36ecb
commit 3ccdff9e9f
8 changed files with 207 additions and 17 deletions

View file

@ -7,6 +7,7 @@ import 'package:adguard_home_manager/screens/connect/connect.dart';
import 'package:adguard_home_manager/screens/home/home.dart';
import 'package:adguard_home_manager/screens/settings/appbar.dart';
import 'package:adguard_home_manager/screens/settings/settings.dart';
import 'package:adguard_home_manager/screens/home/fab.dart';
import 'package:adguard_home_manager/models/app_screen.dart';
@ -31,7 +32,8 @@ List<AppScreen> screensServerConnected = [
name: "home",
icon: Icons.home_rounded,
appBar: HomeAppBar(),
body: Home()
body: Home(),
fab: HomeFab()
),
const AppScreen(
name: "settings",

View file

@ -45,10 +45,14 @@
"save": "Save",
"serverStatus": "Server status",
"connectionNotUpdated": "Connection not updated",
"ruleFiltering": "Rule\nfiltering",
"safeBrowsing": "Safe\nbrowsing",
"parentalFiltering": "Parental\nfiltering",
"safeSearch": "Safe\nsearch",
"ruleFilteringWidget": "Rule\nfiltering",
"safeBrowsingWidget": "Safe\nbrowsing",
"parentalFilteringWidget": "Parental\nfiltering",
"safeSearchWidget": "Safe\nsearch",
"ruleFiltering": "Rule filtering",
"safeBrowsing": "Safe browsing",
"parentalFiltering": "Parental filtering",
"safeSearch": "Safe search",
"serverStatusNotRefreshed": "Server status could not be refreshed",
"loadingStatus": "Loading status...",
"errorLoadServerStatus": "Server status could not be loaded",
@ -64,5 +68,7 @@
"close": "Close",
"connectedTo": "Connected to:",
"selectedServer": "Selected server:",
"noServerSelected": "No server selected"
"noServerSelected": "No server selected",
"manageServer": "Manage server",
"allProtections": "All protections"
}

View file

@ -45,10 +45,14 @@
"save": "Guardar",
"connectionNotUpdated": "Conexión no actualizada",
"serverStatus": "Estado del servidor",
"ruleFiltering": "Bloqueo por\nfiltros",
"safeBrowsing": "Navegación\nsegura",
"parentalFiltering": "Control\nparental",
"safeSearch": "Búsqueda\nsegura",
"ruleFilteringWidget": "Bloqueo por\nfiltros",
"safeBrowsingWidget": "Navegación\nsegura",
"parentalFilteringWidget": "Control\nparental",
"safeSearchWidget": "Búsqueda\nsegura",
"ruleFiltering": "Bloqueo por filtros",
"safeBrowsing": "Navegación segura",
"parentalFiltering": "Control parental",
"safeSearch": "Búsqueda segura",
"serverStatusNotRefreshed": "No se ha podido actualizar el estado del servidor",
"loadingStatus": "Cargando estado...",
"errorLoadServerStatus": "Error al cargar el estado",
@ -64,5 +68,7 @@
"close": "Cerrar",
"connectedTo": "Conectado a:",
"selectedServer": "Servidor seleccionado:",
"noServerSelected": "No hay servidor seleccionado"
"noServerSelected": "No hay servidor seleccionado",
"manageServer": "Gestión del servidor",
"allProtections": "Todas las protecciones"
}

25
lib/screens/home/fab.dart Normal file
View 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),
);
}
}

View file

@ -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
],
);

View 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),
),
],
),
)
],
),
);
}
}

View file

@ -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
),
],

View file

@ -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,