Changed system navigation bar color

This commit is contained in:
Juan Gilsanz Polo 2023-12-09 04:04:14 +01:00
parent 83ea589187
commit b164d520db
47 changed files with 3370 additions and 3207 deletions

View file

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:provider/provider.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
@ -35,6 +36,7 @@ import 'package:adguard_home_manager/services/db/database.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
setWindowMinSize(const Size(500, 500));

View file

@ -185,34 +185,36 @@ class _ClientScreenState extends State<ClientScreen> {
),
actions: actions(),
),
body: ClientForm(
isFullScreen: true,
client: widget.client,
nameController: nameController,
updateValidValues: (v) => setState(() => validValues = v),
identifiersControllers: identifiersControllers,
selectedTags: selectedTags,
useGlobalSettingsFiltering: useGlobalSettingsFiltering,
enableFiltering: enableFiltering,
enableParentalControl: enableParentalControl,
enableSafeBrowsing: enableSafeBrowsing,
enableSafeSearch: enableSafeSearch,
safeSearch: safeSearch,
blockedServices: blockedServices,
updateBlockedServices: (v) => setState(() => blockedServices = v),
upstreamServers: upstreamServers,
updateUpstreamServers: (v) => setState(() => upstreamServers = v),
defaultSafeSearch: defaultSafeSearch,
useGlobalSettingsServices: useGlobalSettingsServices,
updateSelectedTags: (v) => setState(() => selectedTags = v),
updateIdentifiersControllers: (v) => setState(() => identifiersControllers = v),
enableDisableGlobalSettingsFiltering: enableDisableGlobalSettingsFiltering,
updateEnableFiltering: (v) => setState(() => enableFiltering = v),
updateEnableParentalControl: (v) => setState(() => enableParentalControl = v),
updateEnableSafeBrowsing: (v) => setState(() => enableSafeBrowsing = v),
updateEnableSafeSearch: (v) => setState(() => enableSafeSearch = v),
updateSafeSearch: (v) => setState(() => safeSearch = v),
updateUseGlobalSettingsServices: (v) => setState(() => useGlobalSettingsServices = v),
body: SafeArea(
child: ClientForm(
isFullScreen: true,
client: widget.client,
nameController: nameController,
updateValidValues: (v) => setState(() => validValues = v),
identifiersControllers: identifiersControllers,
selectedTags: selectedTags,
useGlobalSettingsFiltering: useGlobalSettingsFiltering,
enableFiltering: enableFiltering,
enableParentalControl: enableParentalControl,
enableSafeBrowsing: enableSafeBrowsing,
enableSafeSearch: enableSafeSearch,
safeSearch: safeSearch,
blockedServices: blockedServices,
updateBlockedServices: (v) => setState(() => blockedServices = v),
upstreamServers: upstreamServers,
updateUpstreamServers: (v) => setState(() => upstreamServers = v),
defaultSafeSearch: defaultSafeSearch,
useGlobalSettingsServices: useGlobalSettingsServices,
updateSelectedTags: (v) => setState(() => selectedTags = v),
updateIdentifiersControllers: (v) => setState(() => identifiersControllers = v),
enableDisableGlobalSettingsFiltering: enableDisableGlobalSettingsFiltering,
updateEnableFiltering: (v) => setState(() => enableFiltering = v),
updateEnableParentalControl: (v) => setState(() => enableParentalControl = v),
updateEnableSafeBrowsing: (v) => setState(() => enableSafeBrowsing = v),
updateEnableSafeSearch: (v) => setState(() => enableSafeSearch = v),
updateSafeSearch: (v) => setState(() => safeSearch = v),
updateUseGlobalSettingsServices: (v) => setState(() => useGlobalSettingsServices = v),
),
),
),
);

View file

@ -149,125 +149,127 @@ class _LogsListClientState extends State<LogsListClient> {
]
],
),
body: Builder(
builder: (context) {
switch (loadStatus) {
case 0:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingLogs,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
body: SafeArea(
child: Builder(
builder: (context) {
switch (loadStatus) {
case 0:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingLogs,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case 1:
if (logsData!.data.isNotEmpty) {
return RefreshIndicator(
onRefresh: fetchLogs,
child: ListView.builder(
controller: scrollController,
padding: const EdgeInsets.only(top: 0),
itemCount: isLoadingMore == true
? logsData!.data.length+1
: logsData!.data.length,
itemBuilder: (context, index) {
if (isLoadingMore == true && index == logsData!.data.length) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 20),
child: Center(
child: CircularProgressIndicator(),
),
);
}
else {
return LogTile(
log: logsData!.data[index],
index: index,
length: logsData!.data.length,
useAlwaysNormalTile: true,
onLogTap: (log) => {
if (width > 700) {
showDialog(
context: context,
builder: (context) => LogDetailsScreen(
log: log,
dialog: true
)
)
}
else {
Navigator.of(context).push(
MaterialPageRoute(
case 1:
if (logsData!.data.isNotEmpty) {
return RefreshIndicator(
onRefresh: fetchLogs,
child: ListView.builder(
controller: scrollController,
padding: const EdgeInsets.only(top: 0),
itemCount: isLoadingMore == true
? logsData!.data.length+1
: logsData!.data.length,
itemBuilder: (context, index) {
if (isLoadingMore == true && index == logsData!.data.length) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 20),
child: Center(
child: CircularProgressIndicator(),
),
);
}
else {
return LogTile(
log: logsData!.data[index],
index: index,
length: logsData!.data.length,
useAlwaysNormalTile: true,
onLogTap: (log) => {
if (width > 700) {
showDialog(
context: context,
builder: (context) => LogDetailsScreen(
log: log,
dialog: false
dialog: true
)
)
)
}
},
twoColumns: widget.splitView,
);
}
else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LogDetailsScreen(
log: log,
dialog: false
)
)
)
}
},
twoColumns: widget.splitView,
);
}
}
}
),
);
}
else {
return Center(
child: Text(
AppLocalizations.of(context)!.noLogsDisplay,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);
}
case 2:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.logsNotLoaded,
);
}
else {
return Center(
child: Text(
AppLocalizations.of(context)!.noLogsDisplay,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
),
);
}
default:
return const SizedBox();
}
},
case 2:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.logsNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -11,7 +11,7 @@ import 'package:adguard_home_manager/providers/servers_provider.dart';
import 'package:adguard_home_manager/providers/app_config_provider.dart';
class Connect extends StatefulWidget {
const Connect({Key? key}) : super(key: key);
const Connect({super.key});
@override
State<Connect> createState() => _ConnectState();
@ -61,26 +61,28 @@ class _ConnectState extends State<Connect> {
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.connect),
),
body: Stack(
children: [
ServersList(
context: context,
controllers: expandableControllerList,
onChange: expandOrContract,
scrollController: scrollController,
breakingWidth: 700,
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: isVisible ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: const FabConnect()
)
],
body: SafeArea(
child: Stack(
children: [
ServersList(
context: context,
controllers: expandableControllerList,
onChange: expandOrContract,
scrollController: scrollController,
breakingWidth: 700,
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: isVisible ?
appConfigProvider.showingSnackbar
? 90 : 20
: -90,
right: 20,
child: const FabConnect()
)
],
),
),
);
}

View file

@ -5,7 +5,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:adguard_home_manager/models/filtering.dart';
class AddListModal extends StatefulWidget {
class AddListModal extends StatelessWidget {
final String type;
final Filter? list;
final void Function({required String name, required String url, required String type})? onConfirm;
@ -13,19 +13,74 @@ class AddListModal extends StatefulWidget {
final bool dialog;
const AddListModal({
Key? key,
super.key,
required this.type,
this.list,
this.onConfirm,
this.onEdit,
required this.dialog
}) : super(key: key);
});
@override
State<AddListModal> createState() => _AddListModalState();
Widget build(BuildContext context) {
if (dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: _Content(
list: list,
onConfirm: onConfirm,
onEdit: onEdit,
type: type,
)
),
);
}
else {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
color: Theme.of(context).dialogBackgroundColor
),
child: SafeArea(
child: _Content(
list: list,
onConfirm: onConfirm,
onEdit: onEdit,
type: type,
),
)
),
);
}
}
}
class _AddListModalState extends State<AddListModal> {
class _Content extends StatefulWidget {
final String type;
final Filter? list;
final void Function({required String name, required String url, required String type})? onConfirm;
final void Function({required Filter list, required String type})? onEdit;
const _Content({
required this.type,
required this.list,
required this.onConfirm,
required this.onEdit,
});
@override
State<_Content> createState() => _ContentState();
}
class _ContentState extends State<_Content> {
final TextEditingController nameController = TextEditingController();
final TextEditingController urlController = TextEditingController();
String? urlError;
@ -70,161 +125,133 @@ class _AddListModalState extends State<AddListModal> {
@override
Widget build(BuildContext context) {
Widget content() {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
widget.type == 'whitelist'
? Icons.verified_user_rounded
: Icons.gpp_bad_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
const SizedBox(height: 16),
Text(
widget.list != null
? widget.type == 'whitelist'
? AppLocalizations.of(context)!.editWhitelist
: AppLocalizations.of(context)!.editBlacklist
: widget.type == 'whitelist'
? AppLocalizations.of(context)!.addWhitelist
: AppLocalizations.of(context)!.addBlacklist,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 16),
],
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: nameController,
onChanged: (_) => checkValidValues(),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.badge_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.name,
),
),
),
Container(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: urlController,
onChanged: validateUrl,
enabled: widget.list != null ? false : true,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: urlError,
labelText: AppLocalizations.of(context)!.urlAbsolutePath,
),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
widget.type == 'whitelist'
? Icons.verified_user_rounded
: Icons.gpp_bad_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
const SizedBox(height: 16),
Text(
widget.list != null
? widget.type == 'whitelist'
? AppLocalizations.of(context)!.editWhitelist
: AppLocalizations.of(context)!.editBlacklist
: widget.type == 'whitelist'
? AppLocalizations.of(context)!.addWhitelist
: AppLocalizations.of(context)!.addBlacklist,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 16),
],
),
],
),
const SizedBox(width: 20),
TextButton(
onPressed: () {
Navigator.pop(context);
if (widget.list != null) {
final Filter newList = Filter(
url: urlController.text,
name: nameController.text,
lastUpdated: widget.list!.lastUpdated,
id: widget.list!.id,
rulesCount: widget.list!.rulesCount,
enabled: widget.list!.enabled
);
widget.onEdit!(
list: newList,
type: widget.type
);
}
else {
widget.onConfirm!(
name: nameController.text,
url: urlController.text,
type: widget.type
);
}
},
child: Text(
widget.list != null
? AppLocalizations.of(context)!.save
: AppLocalizations.of(context)!.confirm
)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: nameController,
onChanged: (_) => checkValidValues(),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.badge_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.name,
),
),
),
Container(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: urlController,
onChanged: validateUrl,
enabled: widget.list != null ? false : true,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: urlError,
labelText: AppLocalizations.of(context)!.urlAbsolutePath,
),
),
),
],
),
),
if (Platform.isIOS) const SizedBox(height: 16)
],
);
}
if (widget.dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: content()
),
);
}
else {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
color: Theme.of(context).dialogBackgroundColor
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel)
),
const SizedBox(width: 20),
TextButton(
onPressed: () {
Navigator.pop(context);
if (widget.list != null) {
final Filter newList = Filter(
url: urlController.text,
name: nameController.text,
lastUpdated: widget.list!.lastUpdated,
id: widget.list!.id,
rulesCount: widget.list!.rulesCount,
enabled: widget.list!.enabled
);
widget.onEdit!(
list: newList,
type: widget.type
);
}
else {
widget.onConfirm!(
name: nameController.text,
url: urlController.text,
type: widget.type
);
}
},
child: Text(
widget.list != null
? AppLocalizations.of(context)!.save
: AppLocalizations.of(context)!.confirm
)
),
],
),
child: content()
),
);
}
if (Platform.isIOS) const SizedBox(height: 16)
],
);
}
}

View file

@ -8,19 +8,55 @@ import 'package:adguard_home_manager/providers/app_config_provider.dart';
import 'package:adguard_home_manager/functions/get_filtered_status.dart';
import 'package:adguard_home_manager/providers/servers_provider.dart';
class CheckHostModal extends StatefulWidget {
class CheckHostModal extends StatelessWidget {
final bool dialog;
const CheckHostModal({
Key? key,
super.key,
required this.dialog
}) : super(key: key);
});
@override
State<CheckHostModal> createState() => _CheckHostModalState();
Widget build(BuildContext context) {
if (dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: const _Content()
),
);
}
else {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28),
),
color: Theme.of(context).dialogBackgroundColor
),
child: const SafeArea(
child: _Content()
)
),
);
}
}
}
class _CheckHostModalState extends State<CheckHostModal> {
class _Content extends StatefulWidget {
const _Content();
@override
State<_Content> createState() => _ContentState();
}
class _ContentState extends State<_Content> {
final TextEditingController domainController = TextEditingController();
String? domainError;
@ -59,17 +95,29 @@ class _CheckHostModalState extends State<CheckHostModal> {
setState(() => resultWidget = checking());
final result = await serversProvider.apiClient2!.checkHostFiltered(host: domainController.text);
if (!mounted) return;
if (mounted) {
if (result.successful == true) {
final status = getFilteredStatus(context, appConfigProvider, result.content['reason'], true);
if (mounted) {
setState(() => resultWidget = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
status['icon'],
size: 18,
if (result.successful == true) {
final status = getFilteredStatus(context, appConfigProvider, result.content['reason'], true);
if (mounted) {
setState(() => resultWidget = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
status['icon'],
size: 18,
color: status['filtered'] == true
? appConfigProvider.useThemeColorForStatus == true
? Colors.grey
: Colors.red
: appConfigProvider.useThemeColorForStatus
? Theme.of(context).colorScheme.primary
: Colors.green,
),
const SizedBox(width: 10),
Text(
status['label'],
style: TextStyle(
color: status['filtered'] == true
? appConfigProvider.useThemeColorForStatus == true
? Colors.grey
@ -77,39 +125,6 @@ class _CheckHostModalState extends State<CheckHostModal> {
: appConfigProvider.useThemeColorForStatus
? Theme.of(context).colorScheme.primary
: Colors.green,
),
const SizedBox(width: 10),
Text(
status['label'],
style: TextStyle(
color: status['filtered'] == true
? appConfigProvider.useThemeColorForStatus == true
? Colors.grey
: Colors.red
: appConfigProvider.useThemeColorForStatus
? Theme.of(context).colorScheme.primary
: Colors.green,
fontWeight: FontWeight.w500
),
)
],
));
}
}
else {
setState(() => resultWidget = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.cancel,
size: 18,
color: Colors.red,
),
const SizedBox(width: 10),
Text(
AppLocalizations.of(context)!.check,
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.w500
),
)
@ -117,143 +132,134 @@ class _CheckHostModalState extends State<CheckHostModal> {
));
}
}
else {
setState(() => resultWidget = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.cancel,
size: 18,
color: Colors.red,
),
const SizedBox(width: 10),
Text(
AppLocalizations.of(context)!.check,
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.w500
),
)
],
));
}
}
Widget content() {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.shield_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.shield_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.checkHostFiltered,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 16),
],
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: domainController,
onChanged: validateDomain,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: domainError,
labelText: AppLocalizations.of(context)!.domain,
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.checkHostFiltered,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 16),
],
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: domainController,
onChanged: validateDomain,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: domainError,
labelText: AppLocalizations.of(context)!.domain,
),
),
),
if (resultWidget != null) Padding(
padding: const EdgeInsets.all(24),
child: resultWidget,
),
if (resultWidget == null) Padding(
padding: const EdgeInsets.all(24),
child: Center(
child: Text(
AppLocalizations.of(context)!.insertDomain,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16,
),
),
),
if (resultWidget != null) Padding(
padding: const EdgeInsets.all(24),
child: resultWidget,
),
],
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(
bottom: 24,
right: 24
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.close),
),
if (resultWidget == null) Padding(
padding: const EdgeInsets.all(24),
child: Center(
child: Text(
AppLocalizations.of(context)!.insertDomain,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16,
),
const SizedBox(width: 20),
TextButton(
onPressed: domainController.text != '' && domainError == null
? () => checkHost()
: null,
child: Text(
AppLocalizations.of(context)!.check,
style: TextStyle(
color: domainController.text != '' && domainError == null
? Theme.of(context).colorScheme.primary
: Colors.grey
),
),
),
],
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(
bottom: 24,
right: 24
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.close),
),
const SizedBox(width: 20),
TextButton(
onPressed: domainController.text != '' && domainError == null
? () => checkHost()
: null,
child: Text(
AppLocalizations.of(context)!.check,
style: TextStyle(
color: domainController.text != '' && domainError == null
? Theme.of(context).colorScheme.primary
: Colors.grey
),
),
),
],
),
)
],
)
],
);
}
if (widget.dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: content()
),
);
}
else {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28),
),
color: Theme.of(context).dialogBackgroundColor
),
child: content()
),
);
}
)
],
)
],
);
}
}

View file

@ -25,11 +25,11 @@ class ListDetailsScreen extends StatefulWidget {
final bool dialog;
const ListDetailsScreen({
Key? key,
super.key,
required this.listId,
required this.type,
required this.dialog
}) : super(key: key);
});
@override
State<ListDetailsScreen> createState() => _ListDetailsScreenState();
@ -367,42 +367,44 @@ class _ListDetailsScreenState extends State<ListDetailsScreen> {
title: Text(AppLocalizations.of(context)!.listDetails),
actions: list != null ? actions() : null,
),
body: Stack(
children: [
if (list != null) ListView(
children: content(),
),
if (list == null) Center(
child: Text(
AppLocalizations.of(context)!.listNotAvailable,
style: const TextStyle(
fontSize: 24,
body: SafeArea(
child: Stack(
children: [
if (list != null) ListView(
children: content(),
),
if (list == null) Center(
child: Text(
AppLocalizations.of(context)!.listNotAvailable,
style: const TextStyle(
fontSize: 24,
),
),
),
),
if (list != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible ?
appConfigProvider.showingSnackbar
? 70 : (Platform.isIOS ? 40 : 20)
: -70,
right: 20,
child: FloatingActionButton(
onPressed: () => updateList(
action: list!.enabled == true
? FilteringListActions.disable
: FilteringListActions.enable,
filterList: list
if (list != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible ?
appConfigProvider.showingSnackbar
? 70 : (Platform.isIOS ? 40 : 20)
: -70,
right: 20,
child: FloatingActionButton(
onPressed: () => updateList(
action: list!.enabled == true
? FilteringListActions.disable
: FilteringListActions.enable,
filterList: list
),
child: Icon(
list.enabled == true
? Icons.gpp_bad_rounded
: Icons.verified_user_rounded,
),
),
child: Icon(
list.enabled == true
? Icons.gpp_bad_rounded
: Icons.verified_user_rounded,
),
),
)
],
)
],
),
),
),
);

View file

@ -10,10 +10,10 @@ class AddCustomRule extends StatefulWidget {
final bool fullScreen;
const AddCustomRule({
Key? key,
super.key,
required this.onConfirm,
required this.fullScreen
}) : super(key: key);
});
@override
State<AddCustomRule> createState() => _AddCustomRuleState();
@ -349,8 +349,10 @@ class _AddCustomRuleState extends State<AddCustomRule> {
const SizedBox(width: 10)
],
),
body: ListView(
children: content(),
body: SafeArea(
child: ListView(
children: content(),
),
)
),
);

View file

@ -17,9 +17,9 @@ class BlockedServicesScreen extends StatefulWidget {
final bool fullScreen;
const BlockedServicesScreen({
Key? key,
super.key,
required this.fullScreen
}) : super(key: key);
});
@override
State<BlockedServicesScreen> createState() => _BlockedServicesScreenStateWidget();
@ -83,105 +83,6 @@ class _BlockedServicesScreenStateWidget extends State<BlockedServicesScreen> {
}
}
Widget body() {
switch (filteringProvider.blockedServicesLoadStatus) {
case LoadStatus.loading:
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingBlockedServicesList,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
return ListView.builder(
itemCount: filteringProvider.blockedServices!.services.length,
itemBuilder: (context, index) => Material(
color: Colors.transparent,
child: InkWell(
onTap: () => updateValues(
values.contains(filteringProvider.blockedServices!.services[index].id),
filteringProvider.blockedServices!.services[index]
),
child: Padding(
padding: const EdgeInsets.only(
top: 6,
bottom: 6,
right: 12,
left: 24
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
filteringProvider.blockedServices!.services[index].name,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface
),
),
Checkbox(
value: values.contains(filteringProvider.blockedServices!.services[index].id),
onChanged: (value) => updateValues(
value!,
filteringProvider.blockedServices!.services[index]
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)
),
)
],
),
),
),
)
);
case LoadStatus.error:
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.blockedServicesListNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
}
if (widget.fullScreen == true) {
return Dialog.fullscreen(
child: Scaffold(
@ -199,18 +100,23 @@ class _BlockedServicesScreenStateWidget extends State<BlockedServicesScreen> {
const SizedBox(width: 10)
],
),
body: RefreshIndicator(
onRefresh: () async {
final result = await filteringProvider.loadBlockedServices();
if (result == false) {
showSnacbkar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.blockedServicesListNotLoaded,
color: Colors.red
);
}
},
child: body()
body: SafeArea(
child: RefreshIndicator(
onRefresh: () async {
final result = await filteringProvider.loadBlockedServices();
if (result == false) {
showSnacbkar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.blockedServicesListNotLoaded,
color: Colors.red
);
}
},
child: _Content(
values: values,
updateValues: updateValues,
)
),
),
),
);
@ -256,7 +162,10 @@ class _BlockedServicesScreenStateWidget extends State<BlockedServicesScreen> {
),
),
Expanded(
child: body()
child: _Content(
values: values,
updateValues: updateValues,
)
),
],
)
@ -266,6 +175,118 @@ class _BlockedServicesScreenStateWidget extends State<BlockedServicesScreen> {
}
}
class _Content extends StatelessWidget {
final List<String> values;
final void Function(bool value, BlockedService item) updateValues;
const _Content({
required this.values,
required this.updateValues,
});
@override
Widget build(BuildContext context) {
final filteringProvider = Provider.of<FilteringProvider>(context);
switch (filteringProvider.blockedServicesLoadStatus) {
case LoadStatus.loading:
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingBlockedServicesList,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
return ListView.builder(
itemCount: filteringProvider.blockedServices!.services.length,
itemBuilder: (context, index) => Material(
color: Colors.transparent,
child: InkWell(
onTap: () => updateValues(
values.contains(filteringProvider.blockedServices!.services[index].id),
filteringProvider.blockedServices!.services[index]
),
child: Padding(
padding: const EdgeInsets.only(
top: 6,
bottom: 6,
right: 12,
left: 24
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
filteringProvider.blockedServices!.services[index].name,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface
),
),
Checkbox(
value: values.contains(filteringProvider.blockedServices!.services[index].id),
onChanged: (value) => updateValues(
value!,
filteringProvider.blockedServices!.services[index]
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)
),
)
],
),
),
),
)
);
case LoadStatus.error:
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.blockedServicesListNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
}
}
void openBlockedServicesModal({
required BuildContext context,
required double width,

View file

@ -5,9 +5,9 @@ class DeleteListModal extends StatelessWidget {
final void Function() onConfirm;
const DeleteListModal({
Key? key,
super.key,
required this.onConfirm
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View file

@ -66,10 +66,12 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
topRight: Radius.circular(28)
),
),
child: _Content(
selectedOption: selectedOption,
onUpdateValue: _updateRadioValue,
onConfirm: () => widget.onChange(selectedOption!),
child: SafeArea(
child: _Content(
selectedOption: selectedOption,
onUpdateValue: _updateRadioValue,
onConfirm: () => widget.onChange(selectedOption!),
),
)
),
);

View file

@ -72,19 +72,18 @@ class SelectionSliverList extends StatelessWidget {
final void Function() unselectAll;
const SelectionSliverList({
Key? key,
super.key,
required this.lists,
required this.selectedLists,
required this.onSelect,
required this.selectAll,
required this.unselectAll,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) {
return CustomScrollView(

View file

@ -19,9 +19,9 @@ class ManagementModal extends StatefulWidget {
final bool dialog;
const ManagementModal({
Key? key,
super.key,
required this.dialog
}) : super(key: key);
});
@override
State<ManagementModal> createState() => _ManagementModalState();
@ -141,33 +141,35 @@ class _ManagementModalState extends State<ManagementModal> with SingleTickerProv
topRight: Radius.circular(28)
)
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: _Modal(
expandableController: expandableController,
updateBlocking: updateBlocking,
disableWithCountdown: disableWithCountdown,
animation: animation,
)
child: SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: _Modal(
expandableController: expandableController,
updateBlocking: updateBlocking,
disableWithCountdown: disableWithCountdown,
animation: animation,
)
),
),
),
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.close),
),
],
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.close),
),
],
),
),
),
if (Platform.isIOS) const SizedBox(height: 16)
],
if (Platform.isIOS) const SizedBox(height: 16)
],
),
),
);
}
@ -201,24 +203,24 @@ class _Modal extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.shield_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(
AppLocalizations.of(context)!.manageServer,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface,
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.shield_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(
AppLocalizations.of(context)!.manageServer,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
),
],
),
],

View file

@ -122,14 +122,16 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
const SizedBox(width: 8)
],
),
body: _Content(
buildValue: widget.buildValue,
isClient: widget.isClient,
onTapEntry: widget.onTapEntry,
options: widget.options,
screenData: screenData,
total: total,
withProgressBar: widget.withProgressBar,
body: SafeArea(
child: _Content(
buildValue: widget.buildValue,
isClient: widget.isClient,
onTapEntry: widget.onTapEntry,
options: widget.options,
screenData: screenData,
total: total,
withProgressBar: widget.withProgressBar,
),
),
),
);

View file

@ -148,36 +148,38 @@ class _LogsConfigModalState extends State<LogsConfigModal> {
),
color: Theme.of(context).dialogBackgroundColor
),
child: Builder(
builder: (context) {
switch (loadStatus) {
case LoadStatus.loading:
return const ConfigLogsLoading();
child: SafeArea(
child: Builder(
builder: (context) {
switch (loadStatus) {
case LoadStatus.loading:
return const ConfigLogsLoading();
case LoadStatus.loaded:
return LogsConfigOptions(
generalSwitch: generalSwitch,
updateGeneralSwitch: (v) => setState(() => generalSwitch = v),
anonymizeClientIp: anonymizeClientIp,
updateAnonymizeClientIp: (v) => setState(() => anonymizeClientIp = v),
retentionItems: retentionItems,
retentionTime: retentionTime,
updateRetentionTime: (v) => setState(() => retentionTime = v),
onClear: () => widget.onClear(),
onConfirm: () => widget.onConfirm({
"enabled": generalSwitch,
"interval": retentionTime,
"anonymize_client_ip": anonymizeClientIp
})
);
case LoadStatus.loaded:
return LogsConfigOptions(
generalSwitch: generalSwitch,
updateGeneralSwitch: (v) => setState(() => generalSwitch = v),
anonymizeClientIp: anonymizeClientIp,
updateAnonymizeClientIp: (v) => setState(() => anonymizeClientIp = v),
retentionItems: retentionItems,
retentionTime: retentionTime,
updateRetentionTime: (v) => setState(() => retentionTime = v),
onClear: () => widget.onClear(),
onConfirm: () => widget.onConfirm({
"enabled": generalSwitch,
"interval": retentionTime,
"anonymize_client_ip": anonymizeClientIp
})
);
case LoadStatus.error:
return const ConfigLogsError();
case LoadStatus.error:
return const ConfigLogsError();
default:
return const SizedBox();
}
},
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -25,10 +25,10 @@ class LogDetailsScreen extends StatelessWidget {
final bool dialog;
const LogDetailsScreen({
Key? key,
super.key,
required this.log,
required this.dialog
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@ -322,7 +322,6 @@ class LogDetailsScreen extends StatelessWidget {
],
body: SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (context) => CustomScrollView(
slivers: [

View file

@ -60,9 +60,11 @@ class _ClientsModalState extends State<ClientsModal> {
),
color: Theme.of(context).dialogBackgroundColor
),
child: _ModalContent(
selectedClients: selectedClients,
onClientsSelected: (v) => setState(() => selectedClients = v),
child: SafeArea(
child: _ModalContent(
selectedClients: selectedClients,
onClientsSelected: (v) => setState(() => selectedClients = v),
),
)
),
);

View file

@ -62,10 +62,12 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
),
color: Theme.of(context).dialogBackgroundColor
),
child: _Content(
onApply: apply,
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
selectedResultStatus: selectedResultStatus,
child: SafeArea(
child: _Content(
onApply: apply,
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
selectedResultStatus: selectedResultStatus,
),
)
);
}

View file

@ -19,9 +19,9 @@ class LogsFiltersModal extends StatefulWidget {
final bool dialog;
const LogsFiltersModal({
Key? key,
super.key,
required this.dialog
}) : super(key: key);
});
@override
State<LogsFiltersModal> createState() => _LogsFiltersModalState();
@ -65,9 +65,11 @@ class _LogsFiltersModalState extends State<LogsFiltersModal> {
topRight: Radius.circular(28)
)
),
child: _FiltersList(
searchController: searchController,
onClearSearch: () => setState(() => searchController.text = "")
child: SafeArea(
child: _FiltersList(
searchController: searchController,
onClearSearch: () => setState(() => searchController.text = "")
),
)
),
);

View file

@ -16,9 +16,9 @@ class Servers extends StatefulWidget {
final double? breakingWidth;
const Servers({
Key? key,
super.key,
this.breakingWidth
}) : super(key: key);
});
@override
State<Servers> createState() => _ServersState();
@ -77,29 +77,31 @@ class _ServersState extends State<Servers> {
title: Text(AppLocalizations.of(context)!.servers),
centerTitle: false,
),
body: Stack(
children: [
ServersList(
context: context,
controllers: expandableControllerList,
onChange: expandOrContract,
scrollController: scrollController,
breakingWidth: widget.breakingWidth ?? 700,
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: isVisible ?
appConfigProvider.showingSnackbar
? 70 : (Platform.isIOS ? 40 : 20)
: -70,
right: 20,
child: FloatingActionButton(
onPressed: openAddServerModal,
child: const Icon(Icons.add),
body: SafeArea(
child: Stack(
children: [
ServersList(
context: context,
controllers: expandableControllerList,
onChange: expandOrContract,
scrollController: scrollController,
breakingWidth: widget.breakingWidth ?? 700,
),
),
],
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: isVisible ?
appConfigProvider.showingSnackbar
? 70 : (Platform.isIOS ? 40 : 20)
: -70,
right: 20,
child: FloatingActionButton(
onPressed: openAddServerModal,
child: const Icon(Icons.add),
),
),
],
),
),
);
}

View file

@ -44,9 +44,11 @@ class AddClientModal extends StatelessWidget {
topRight: Radius.circular(28)
)
),
child: _Content(
type: type,
onConfirm: onConfirm,
child: SafeArea(
child: _Content(
type: type,
onConfirm: onConfirm,
),
)
),
);

View file

@ -11,7 +11,7 @@ import 'package:adguard_home_manager/functions/snackbar.dart';
import 'package:adguard_home_manager/providers/app_config_provider.dart';
class AdvancedSettings extends StatelessWidget {
const AdvancedSettings({Key? key}) : super(key: key);
const AdvancedSettings({super.key});
@override
Widget build(BuildContext context) {
@ -46,31 +46,33 @@ class AdvancedSettings extends StatelessWidget {
title: Text(AppLocalizations.of(context)!.advancedSettings),
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
),
body: ListView(
children: [
CustomListTile(
icon: Icons.lock,
title: AppLocalizations.of(context)!.dontCheckCertificate,
subtitle: AppLocalizations.of(context)!.dontCheckCertificateDescription,
trailing: Switch(
value: appConfigProvider.overrideSslCheck,
onChanged: (value) => updateSettings(
newStatus: value,
body: SafeArea(
child: ListView(
children: [
CustomListTile(
icon: Icons.lock,
title: AppLocalizations.of(context)!.dontCheckCertificate,
subtitle: AppLocalizations.of(context)!.dontCheckCertificateDescription,
trailing: Switch(
value: appConfigProvider.overrideSslCheck,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setOverrideSslCheck
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.overrideSslCheck,
function: appConfigProvider.setOverrideSslCheck
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 20,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.overrideSslCheck,
function: appConfigProvider.setOverrideSslCheck
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 20,
right: 10
)
),
],
],
),
)
);
}

View file

@ -14,7 +14,7 @@ import 'package:adguard_home_manager/providers/app_config_provider.dart';
import 'package:adguard_home_manager/constants/colors.dart';
class Customization extends StatelessWidget {
const Customization({Key? key}) : super(key: key);
const Customization({super.key});
@override
Widget build(BuildContext context) {
@ -65,152 +65,154 @@ class _CustomizationWidgetState extends State<CustomizationWidget> {
centerTitle: false,
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
),
body: ListView(
children: [
SectionLabel(
label: AppLocalizations.of(context)!.theme,
padding: const EdgeInsets.only(top: 10, left: 16, right: 16, bottom: 5),
),
Column(
children: [
CustomSwitchListTile(
value: selectedTheme == 0 ? true : false,
onChanged: (value) {
selectedTheme = value == true ? 0 : 1;
appConfigProvider.setSelectedTheme(value == true ? 0 : 1);
},
title: AppLocalizations.of(context)!.systemDefined,
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ThemeModeButton(
icon: Icons.light_mode,
value: 1,
selected: selectedTheme,
label: AppLocalizations.of(context)!.light,
onChanged: (value) {
selectedTheme = value;
appConfigProvider.setSelectedTheme(value);
},
disabled: selectedTheme == 0 ? true : false,
),
ThemeModeButton(
icon: Icons.dark_mode,
value: 2,
selected: selectedTheme,
label: AppLocalizations.of(context)!.dark,
onChanged: (value) {
selectedTheme = value;
appConfigProvider.setSelectedTheme(value);
},
disabled: selectedTheme == 0 ? true : false,
),
],
),
],
),
SectionLabel(
label: AppLocalizations.of(context)!.color,
padding: const EdgeInsets.only(top: 45, left: 16, right: 16, bottom: 5),
),
if (appConfigProvider.androidDeviceInfo != null && appConfigProvider.androidDeviceInfo!.version.sdkInt >= 31) CustomSwitchListTile(
value: dynamicColor,
onChanged: (value) {
setState(() => dynamicColor = value);
appConfigProvider.setUseDynamicColor(value);
},
title: AppLocalizations.of(context)!.useDynamicTheme,
),
if (!(appConfigProvider.androidDeviceInfo != null && appConfigProvider.androidDeviceInfo!.version.sdkInt >= 31)) const SizedBox(height: 20),
if (dynamicColor == false) ...[
SizedBox(
width: MediaQuery.of(context).size.width,
height: 70,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: colors.length,
itemBuilder: (context, index) {
if (index == 0) {
return Row(
children: [
const SizedBox(width: 15),
ColorItem(
color: colors[index],
numericValue: index,
selectedValue: selectedColor,
onChanged: (value) {
setState(() => selectedColor = value);
appConfigProvider.setStaticColor(value);
}
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
width: 1,
height: 60,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(1)
),
)
],
);
}
else if (index == colors.length-1) {
return Row(
children: [
ColorItem(
color: colors[index],
numericValue: index,
selectedValue: selectedColor,
onChanged: (value) {
setState(() => selectedColor = value);
appConfigProvider.setStaticColor(value);
}
),
const SizedBox(width: 15)
],
);
}
else {
return ColorItem(
color: colors[index],
numericValue: index,
selectedValue: selectedColor,
onChanged: (value) {
setState(() => selectedColor = value);
appConfigProvider.setStaticColor(value);
}
);
}
},
),
body: SafeArea(
child: ListView(
children: [
SectionLabel(
label: AppLocalizations.of(context)!.theme,
padding: const EdgeInsets.only(top: 10, left: 16, right: 16, bottom: 5),
),
Padding(
padding: const EdgeInsets.only(
left: 25,
top: 10
),
child: Text(
colorTranslation(context, selectedColor),
style: TextStyle(
color: Theme.of(context).listTileTheme.iconColor,
fontSize: 16
Column(
children: [
CustomSwitchListTile(
value: selectedTheme == 0 ? true : false,
onChanged: (value) {
selectedTheme = value == true ? 0 : 1;
appConfigProvider.setSelectedTheme(value == true ? 0 : 1);
},
title: AppLocalizations.of(context)!.systemDefined,
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ThemeModeButton(
icon: Icons.light_mode,
value: 1,
selected: selectedTheme,
label: AppLocalizations.of(context)!.light,
onChanged: (value) {
selectedTheme = value;
appConfigProvider.setSelectedTheme(value);
},
disabled: selectedTheme == 0 ? true : false,
),
ThemeModeButton(
icon: Icons.dark_mode,
value: 2,
selected: selectedTheme,
label: AppLocalizations.of(context)!.dark,
onChanged: (value) {
selectedTheme = value;
appConfigProvider.setSelectedTheme(value);
},
disabled: selectedTheme == 0 ? true : false,
),
],
),
],
),
SectionLabel(
label: AppLocalizations.of(context)!.color,
padding: const EdgeInsets.only(top: 45, left: 16, right: 16, bottom: 5),
),
if (appConfigProvider.androidDeviceInfo != null && appConfigProvider.androidDeviceInfo!.version.sdkInt >= 31) CustomSwitchListTile(
value: dynamicColor,
onChanged: (value) {
setState(() => dynamicColor = value);
appConfigProvider.setUseDynamicColor(value);
},
title: AppLocalizations.of(context)!.useDynamicTheme,
),
if (!(appConfigProvider.androidDeviceInfo != null && appConfigProvider.androidDeviceInfo!.version.sdkInt >= 31)) const SizedBox(height: 20),
if (dynamicColor == false) ...[
SizedBox(
width: MediaQuery.of(context).size.width,
height: 70,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: colors.length,
itemBuilder: (context, index) {
if (index == 0) {
return Row(
children: [
const SizedBox(width: 15),
ColorItem(
color: colors[index],
numericValue: index,
selectedValue: selectedColor,
onChanged: (value) {
setState(() => selectedColor = value);
appConfigProvider.setStaticColor(value);
}
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
width: 1,
height: 60,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(1)
),
)
],
);
}
else if (index == colors.length-1) {
return Row(
children: [
ColorItem(
color: colors[index],
numericValue: index,
selectedValue: selectedColor,
onChanged: (value) {
setState(() => selectedColor = value);
appConfigProvider.setStaticColor(value);
}
),
const SizedBox(width: 15)
],
);
}
else {
return ColorItem(
color: colors[index],
numericValue: index,
selectedValue: selectedColor,
onChanged: (value) {
setState(() => selectedColor = value);
appConfigProvider.setStaticColor(value);
}
);
}
},
),
),
Padding(
padding: const EdgeInsets.only(
left: 25,
top: 10
),
child: Text(
colorTranslation(context, selectedColor),
style: TextStyle(
color: Theme.of(context).listTileTheme.iconColor,
fontSize: 16
),
),
)
],
CustomSwitchListTile(
value: useThemeColorInsteadGreenRed,
onChanged: (value) {
setState(() => useThemeColorInsteadGreenRed = value);
appConfigProvider.setUseThemeColorForStatus(value);
},
title: AppLocalizations.of(context)!.useThemeColorStatus,
subtitle: AppLocalizations.of(context)!.useThemeColorStatusDescription,
)
],
CustomSwitchListTile(
value: useThemeColorInsteadGreenRed,
onChanged: (value) {
setState(() => useThemeColorInsteadGreenRed = value);
appConfigProvider.setUseThemeColorForStatus(value);
},
title: AppLocalizations.of(context)!.useThemeColorStatus,
subtitle: AppLocalizations.of(context)!.useThemeColorStatusDescription,
)
],
),
),
);
}

View file

@ -3,7 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:adguard_home_manager/models/dhcp.dart';
class AddStaticLeaseModal extends StatefulWidget {
class AddStaticLeaseModal extends StatelessWidget {
final void Function(Lease) onConfirm;
final bool dialog;
@ -14,10 +14,49 @@ class AddStaticLeaseModal extends StatefulWidget {
});
@override
State<AddStaticLeaseModal> createState() => _AddStaticLeaseModalState();
Widget build(BuildContext context) {
if (dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: _Content(onConfirm: onConfirm)
),
);
}
else {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).dialogBackgroundColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
)
),
child: SafeArea(
child: _Content(onConfirm: onConfirm)
)
),
);
}
}
}
class _AddStaticLeaseModalState extends State<AddStaticLeaseModal> {
class _Content extends StatefulWidget {
final void Function(Lease) onConfirm;
const _Content({
required this.onConfirm
});
@override
State<_Content> createState() => __ContentState();
}
class __ContentState extends State<_Content> {
final TextEditingController macController = TextEditingController();
String? macError;
final TextEditingController ipController = TextEditingController();
@ -67,175 +106,147 @@ class _AddStaticLeaseModalState extends State<AddStaticLeaseModal> {
@override
Widget build(BuildContext context) {
Widget content() {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.add,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.addStaticLease,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, bottom: 12
),
child: TextFormField(
controller: macController,
onChanged: validateMac,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.smartphone_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: macError,
labelText: AppLocalizations.of(context)!.macAddress,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: TextFormField(
controller: ipController,
onChanged: validateIp,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: ipError,
labelText: AppLocalizations.of(context)!.ipAddress,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 12
),
child: TextFormField(
controller: hostNameController,
onChanged: (value) {
if (value != '') {
setState(() => hostNameError = null);
}
else {
setState(() => hostNameError = AppLocalizations.of(context)!.hostNameError);
}
validateData();
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.badge_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: hostNameError,
labelText: AppLocalizations.of(context)!.hostName,
),
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel),
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.add,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.addStaticLease,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
),
],
),
),
const SizedBox(width: 20),
TextButton(
onPressed: validData == true
? () {
Navigator.pop(context);
widget.onConfirm(
Lease(
mac: macController.text,
hostname: hostNameController.text,
ip: ipController.text
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, bottom: 12
),
child: TextFormField(
controller: macController,
onChanged: validateMac,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.smartphone_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
);
}
: null,
child: Text(
AppLocalizations.of(context)!.confirm,
style: TextStyle(
color: validData == true
? Theme.of(context).colorScheme.primary
: Colors.grey
),
errorText: macError,
labelText: AppLocalizations.of(context)!.macAddress,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: TextFormField(
controller: ipController,
onChanged: validateIp,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: ipError,
labelText: AppLocalizations.of(context)!.ipAddress,
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 24, right: 24, top: 12
),
child: TextFormField(
controller: hostNameController,
onChanged: (value) {
if (value != '') {
setState(() => hostNameError = null);
}
else {
setState(() => hostNameError = AppLocalizations.of(context)!.hostNameError);
}
validateData();
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.badge_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: hostNameError,
labelText: AppLocalizations.of(context)!.hostName,
),
),
),
],
),
)
],
);
}
if (widget.dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: content(),
),
);
}
else {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).dialogBackgroundColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
)
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel),
),
const SizedBox(width: 20),
TextButton(
onPressed: validData == true
? () {
Navigator.pop(context);
widget.onConfirm(
Lease(
mac: macController.text,
hostname: hostNameController.text,
ip: ipController.text
)
);
}
: null,
child: Text(
AppLocalizations.of(context)!.confirm,
style: TextStyle(
color: validData == true
? Theme.of(context).colorScheme.primary
: Colors.grey
),
),
),
],
),
child: content()
),
);
}
)
],
);
}
}

View file

@ -411,328 +411,330 @@ class _DhcpScreenState extends State<DhcpScreen> {
const SizedBox(width: 10)
] : null,
),
body: Builder(
builder: (context) {
switch (dhcpProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingDhcp,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
if (selectedInterface != null) {
return SingleChildScrollView(
child: Wrap(
body: SafeArea(
child: Builder(
builder: (context) {
switch (dhcpProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
DhcpMainButton(
selectedInterface: selectedInterface,
enabled: enabled,
setEnabled: (v) => setState(() => enabled = v)
),
if (selectedInterface!.ipv4Addresses.isNotEmpty) ...[
SectionLabel(
label: AppLocalizations.of(context)!.ipv4settings,
padding: const EdgeInsets.only(
top: 24, left: 16, right: 16, bottom: 8
)
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingDhcp,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
_DhcpField(
icon: Icons.skip_previous_rounded,
label: AppLocalizations.of(context)!.startOfRange,
controller: ipv4StartRangeController,
onChanged: (value) => validateIpV4(value, 'ipv4StartRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv4StartRangeError
),
_DhcpField(
icon: Icons.skip_next_rounded,
label: AppLocalizations.of(context)!.endOfRange,
controller: ipv4EndRangeController,
onChanged: (value) => validateIpV4(value, 'ipv4EndRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv4EndRangeError
),
_DhcpField(
icon: Icons.hub_rounded,
label: AppLocalizations.of(context)!.subnetMask,
controller: ipv4SubnetMaskController,
onChanged: (value) => validateIpV4(value, 'ipv4SubnetMaskError', AppLocalizations.of(context)!.subnetMaskNotValid),
error: ipv4SubnetMaskError
),
_DhcpField(
icon: Icons.router_rounded,
label: AppLocalizations.of(context)!.gateway,
controller: ipv4GatewayController,
onChanged: (value) => validateIpV4(value, 'ipv4GatewayError', AppLocalizations.of(context)!.gatewayNotValid),
error: ipv4GatewayError
),
_DhcpField(
icon: Icons.timer,
label: AppLocalizations.of(context)!.leaseTime,
controller: ipv4LeaseTimeController,
onChanged: (value) {
if (int.tryParse(value).runtimeType == int) {
setState(() => ipv4LeaseTimeError = null);
}
else {
setState(() => ipv4LeaseTimeError = AppLocalizations.of(context)!.leaseTimeNotValid);
}
},
error: ipv4LeaseTimeError
),
],
if (selectedInterface!.ipv6Addresses.isNotEmpty) ...[
SectionLabel(
label: AppLocalizations.of(context)!.ipv6settings,
padding: const EdgeInsets.all(16)
),
_DhcpField(
icon: Icons.skip_next_rounded,
label: AppLocalizations.of(context)!.startOfRange,
controller: ipv6StartRangeController,
onChanged: (value) => validateIpV6(value, 'ipv6StartRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv6StartRangeError
),
_DhcpField(
icon: Icons.skip_previous_rounded,
label: AppLocalizations.of(context)!.endOfRange,
controller: ipv6EndRangeController,
onChanged: (value) => validateIpV6(value, 'ipv6EndRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv6EndRangeError
),
_DhcpField(
icon: Icons.timer,
label: AppLocalizations.of(context)!.leaseTime,
controller: ipv6LeaseTimeController,
onChanged: (value) {
if (int.tryParse(value).runtimeType == int) {
setState(() => ipv6LeaseTimeError = null);
}
else {
setState(() => ipv6LeaseTimeError = AppLocalizations.of(context)!.leaseTimeNotValid);
}
},
error: ipv6LeaseTimeError
)
],
const SizedBox(height: 20),
SectionLabel(
label: AppLocalizations.of(context)!.dhcpLeases,
padding: const EdgeInsets.all(16),
),
if (width <= 900) Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.leases,
staticLeases: false,
)
)
);
},
child: Container(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocalizations.of(context)!.dhcpLeases,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
),
Icon(
Icons.arrow_forward_rounded,
color: Theme.of(context).colorScheme.onSurface,
)
],
),
),
),
),
if (width <= 900) Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.staticLeases,
staticLeases: true,
)
)
);
},
child: Container(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocalizations.of(context)!.dhcpStatic,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
),
Icon(
Icons.arrow_forward_rounded,
color: Theme.of(context).colorScheme.onSurface,
)
],
),
),
),
),
if (width > 900) Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
if (!(Platform.isAndroid || Platform.isIOS)) {
SplitView.of(context).push(
DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.leases,
staticLeases: false,
)
);
}
else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.leases,
staticLeases: false,
)
)
);
}
},
child: Row(
children: [
Text(AppLocalizations.of(context)!.dhcpLeases),
const SizedBox(width: 8),
const Icon(Icons.arrow_forward_rounded)
],
)
),
ElevatedButton(
onPressed: () {
if (!(Platform.isAndroid || Platform.isIOS)) {
SplitView.of(context).push(
DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.staticLeases,
staticLeases: true,
)
);
}
else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.staticLeases,
staticLeases: true,
)
)
);
}
},
child: Row(
children: [
Text(AppLocalizations.of(context)!.dhcpStatic),
const SizedBox(width: 8),
const Icon(Icons.arrow_forward_rounded)
],
)
),
],
),
const SizedBox(height: 10)
)
],
),
);
}
else {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
AppLocalizations.of(context)!.neededSelectInterface,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5)
case LoadStatus.loaded:
if (selectedInterface != null) {
return SingleChildScrollView(
child: Wrap(
children: [
DhcpMainButton(
selectedInterface: selectedInterface,
enabled: enabled,
setEnabled: (v) => setState(() => enabled = v)
),
if (selectedInterface!.ipv4Addresses.isNotEmpty) ...[
SectionLabel(
label: AppLocalizations.of(context)!.ipv4settings,
padding: const EdgeInsets.only(
top: 24, left: 16, right: 16, bottom: 8
)
),
_DhcpField(
icon: Icons.skip_previous_rounded,
label: AppLocalizations.of(context)!.startOfRange,
controller: ipv4StartRangeController,
onChanged: (value) => validateIpV4(value, 'ipv4StartRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv4StartRangeError
),
_DhcpField(
icon: Icons.skip_next_rounded,
label: AppLocalizations.of(context)!.endOfRange,
controller: ipv4EndRangeController,
onChanged: (value) => validateIpV4(value, 'ipv4EndRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv4EndRangeError
),
_DhcpField(
icon: Icons.hub_rounded,
label: AppLocalizations.of(context)!.subnetMask,
controller: ipv4SubnetMaskController,
onChanged: (value) => validateIpV4(value, 'ipv4SubnetMaskError', AppLocalizations.of(context)!.subnetMaskNotValid),
error: ipv4SubnetMaskError
),
_DhcpField(
icon: Icons.router_rounded,
label: AppLocalizations.of(context)!.gateway,
controller: ipv4GatewayController,
onChanged: (value) => validateIpV4(value, 'ipv4GatewayError', AppLocalizations.of(context)!.gatewayNotValid),
error: ipv4GatewayError
),
_DhcpField(
icon: Icons.timer,
label: AppLocalizations.of(context)!.leaseTime,
controller: ipv4LeaseTimeController,
onChanged: (value) {
if (int.tryParse(value).runtimeType == int) {
setState(() => ipv4LeaseTimeError = null);
}
else {
setState(() => ipv4LeaseTimeError = AppLocalizations.of(context)!.leaseTimeNotValid);
}
},
error: ipv4LeaseTimeError
),
],
if (selectedInterface!.ipv6Addresses.isNotEmpty) ...[
SectionLabel(
label: AppLocalizations.of(context)!.ipv6settings,
padding: const EdgeInsets.all(16)
),
_DhcpField(
icon: Icons.skip_next_rounded,
label: AppLocalizations.of(context)!.startOfRange,
controller: ipv6StartRangeController,
onChanged: (value) => validateIpV6(value, 'ipv6StartRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv6StartRangeError
),
_DhcpField(
icon: Icons.skip_previous_rounded,
label: AppLocalizations.of(context)!.endOfRange,
controller: ipv6EndRangeController,
onChanged: (value) => validateIpV6(value, 'ipv6EndRangeError', AppLocalizations.of(context)!.ipNotValid),
error: ipv6EndRangeError
),
_DhcpField(
icon: Icons.timer,
label: AppLocalizations.of(context)!.leaseTime,
controller: ipv6LeaseTimeController,
onChanged: (value) {
if (int.tryParse(value).runtimeType == int) {
setState(() => ipv6LeaseTimeError = null);
}
else {
setState(() => ipv6LeaseTimeError = AppLocalizations.of(context)!.leaseTimeNotValid);
}
},
error: ipv6LeaseTimeError
)
],
const SizedBox(height: 20),
SectionLabel(
label: AppLocalizations.of(context)!.dhcpLeases,
padding: const EdgeInsets.all(16),
),
if (width <= 900) Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.leases,
staticLeases: false,
)
)
);
},
child: Container(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocalizations.of(context)!.dhcpLeases,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
),
Icon(
Icons.arrow_forward_rounded,
color: Theme.of(context).colorScheme.onSurface,
)
],
),
),
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: selectInterface,
child: Text(AppLocalizations.of(context)!.selectInterface)
),
if (width <= 900) Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.staticLeases,
staticLeases: true,
)
)
);
},
child: Container(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocalizations.of(context)!.dhcpStatic,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
),
Icon(
Icons.arrow_forward_rounded,
color: Theme.of(context).colorScheme.onSurface,
)
],
),
),
),
],
),
),
if (width > 900) Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
if (!(Platform.isAndroid || Platform.isIOS)) {
SplitView.of(context).push(
DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.leases,
staticLeases: false,
)
);
}
else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.leases,
staticLeases: false,
)
)
);
}
},
child: Row(
children: [
Text(AppLocalizations.of(context)!.dhcpLeases),
const SizedBox(width: 8),
const Icon(Icons.arrow_forward_rounded)
],
)
),
ElevatedButton(
onPressed: () {
if (!(Platform.isAndroid || Platform.isIOS)) {
SplitView.of(context).push(
DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.staticLeases,
staticLeases: true,
)
);
}
else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DhcpLeases(
items: dhcpProvider.dhcp!.dhcpStatus!.staticLeases,
staticLeases: true,
)
)
);
}
},
child: Row(
children: [
Text(AppLocalizations.of(context)!.dhcpStatic),
const SizedBox(width: 8),
const Icon(Icons.arrow_forward_rounded)
],
)
),
],
),
const SizedBox(height: 10)
],
),
],
);
}
else {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
AppLocalizations.of(context)!.neededSelectInterface,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5)
),
),
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: selectInterface,
child: Text(AppLocalizations.of(context)!.selectInterface)
),
],
),
),
],
);
}
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.dhcpSettingsNotLoaded,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
}
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.dhcpSettingsNotLoaded,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -22,10 +22,10 @@ class DhcpLeases extends StatelessWidget {
final bool staticLeases;
const DhcpLeases({
Key? key,
super.key,
required this.items,
required this.staticLeases,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@ -130,32 +130,34 @@ class DhcpLeases extends StatelessWidget {
),
),
body: items.isNotEmpty
? ListView.builder(
padding: const EdgeInsets.only(top: 0),
itemCount: items.length,
itemBuilder: (context, index) => ListTile(
isThreeLine: true,
title: Text(items[index].ip),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(items[index].mac),
Text(items[index].hostname),
],
? SafeArea(
child: ListView.builder(
padding: const EdgeInsets.only(top: 0),
itemCount: items.length,
itemBuilder: (context, index) => ListTile(
isThreeLine: true,
title: Text(items[index].ip),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(items[index].mac),
Text(items[index].hostname),
],
),
trailing: staticLeases == true
? IconButton(
onPressed: () {
showModal(
context: context,
builder: (context) => DeleteStaticLeaseModal(
onConfirm: () => deleteLease(items[index])
)
);
},
icon: const Icon(Icons.delete)
)
: null,
),
trailing: staticLeases == true
? IconButton(
onPressed: () {
showModal(
context: context,
builder: (context) => DeleteStaticLeaseModal(
onConfirm: () => deleteLease(items[index])
)
);
},
icon: const Icon(Icons.delete)
)
: null,
),
)
: Center(

View file

@ -137,16 +137,17 @@ class SelectInterfaceModal extends StatelessWidget {
),
),
Expanded(
child: ListView.builder(
controller: controller,
itemCount: interfaces.length,
itemBuilder: (context, index) => DhcpInterfaceItem(
networkInterface: interfaces[index],
onSelect: onSelect
)
child: SafeArea(
child: ListView.builder(
controller: controller,
itemCount: interfaces.length,
itemBuilder: (context, index) => DhcpInterfaceItem(
networkInterface: interfaces[index],
onSelect: onSelect
)
),
)
),
const SizedBox(height: 16)
],
),
);

View file

@ -117,105 +117,107 @@ class _BootstrapDnsScreenState extends State<BootstrapDnsScreen> {
const SizedBox(width: 10)
],
),
body: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
Card(
margin: const EdgeInsets.only(
left: 16, right: 16, bottom: 20
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Icon(
Icons.info_rounded,
color: Theme.of(context).listTileTheme.iconColor,
),
const SizedBox(width: 20),
Flexible(
child: Text(
AppLocalizations.of(context)!.bootstrapDnsServersInfo,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
body: SafeArea(
child: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
Card(
margin: const EdgeInsets.only(
left: 16, right: 16, bottom: 20
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Icon(
Icons.info_rounded,
color: Theme.of(context).listTileTheme.iconColor,
),
const SizedBox(width: 20),
Flexible(
child: Text(
AppLocalizations.of(context)!.bootstrapDnsServersInfo,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
)
)
)
],
],
),
),
),
),
const SizedBox(height: 10),
if (bootstrapControllers.isEmpty) Column(
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Center(
child: Text(
AppLocalizations.of(context)!.noBootstrapDns,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16
const SizedBox(height: 10),
if (bootstrapControllers.isEmpty) Column(
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Center(
child: Text(
AppLocalizations.of(context)!.noBootstrapDns,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16
),
),
),
),
),
const SizedBox(height: 20),
],
),
...bootstrapControllers.map((c) => Padding(
padding: const EdgeInsets.only(
left: 16, right: 6, bottom: 20
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFormField(
controller: c['controller'],
onChanged: (value) => validateIp(c, value),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.dns_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: c['error'],
labelText: AppLocalizations.of(context)!.dnsServer,
)
),
),
const SizedBox(width: 8),
IconButton(
onPressed: () {
setState(() => bootstrapControllers = bootstrapControllers.where((con) => con != c).toList());
checkValidValues();
},
icon: const Icon(Icons.remove_circle_outline)
)
const SizedBox(height: 20),
],
),
)).toList(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() => bootstrapControllers.add({
'controller': TextEditingController(),
'error': null
}));
checkValidValues();
},
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.addItem)
...bootstrapControllers.map((c) => Padding(
padding: const EdgeInsets.only(
left: 16, right: 6, bottom: 20
),
],
),
const SizedBox(height: 20)
],
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFormField(
controller: c['controller'],
onChanged: (value) => validateIp(c, value),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.dns_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: c['error'],
labelText: AppLocalizations.of(context)!.dnsServer,
)
),
),
const SizedBox(width: 8),
IconButton(
onPressed: () {
setState(() => bootstrapControllers = bootstrapControllers.where((con) => con != c).toList());
checkValidValues();
},
icon: const Icon(Icons.remove_circle_outline)
)
],
),
)).toList(),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() => bootstrapControllers.add({
'controller': TextEditingController(),
'error': null
}));
checkValidValues();
},
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.addItem)
),
],
),
const SizedBox(height: 20)
],
),
),
);
}

View file

@ -169,81 +169,83 @@ class _CacheConfigDnsScreenState extends State<CacheConfigDnsScreen> {
const SizedBox(width: 10)
],
),
body: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
numericField(
controller: cacheSizeController,
label: AppLocalizations.of(context)!.cacheSize,
helper: AppLocalizations.of(context)!.inBytes,
error: cacheSizeError,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => cacheSizeError = null);
body: SafeArea(
child: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
numericField(
controller: cacheSizeController,
label: AppLocalizations.of(context)!.cacheSize,
helper: AppLocalizations.of(context)!.inBytes,
error: cacheSizeError,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => cacheSizeError = null);
}
else {
setState(() => cacheSizeError = AppLocalizations.of(context)!.valueNotNumber);
}
checkValidData();
}
else {
setState(() => cacheSizeError = AppLocalizations.of(context)!.valueNotNumber);
),
const SizedBox(height: 30),
numericField(
controller: overrideMinTtlController,
label: AppLocalizations.of(context)!.overrideMinimumTtl,
helper: AppLocalizations.of(context)!.overrideMinimumTtlDescription,
error: overrideMinTtlError,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => overrideMinTtlError = null);
}
else {
setState(() => overrideMinTtlError = AppLocalizations.of(context)!.valueNotNumber);
}
checkValidData();
}
checkValidData();
}
),
const SizedBox(height: 30),
numericField(
controller: overrideMinTtlController,
label: AppLocalizations.of(context)!.overrideMinimumTtl,
helper: AppLocalizations.of(context)!.overrideMinimumTtlDescription,
error: overrideMinTtlError,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => overrideMinTtlError = null);
),
const SizedBox(height: 30),
numericField(
controller: overrideMaxTtlController,
label: AppLocalizations.of(context)!.overrideMaximumTtl,
helper: AppLocalizations.of(context)!.overrideMaximumTtlDescription,
error: overrideMaxTtlError,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => overrideMaxTtlError = null);
}
else {
setState(() => overrideMaxTtlError = AppLocalizations.of(context)!.valueNotNumber);
}
checkValidData();
}
else {
setState(() => overrideMinTtlError = AppLocalizations.of(context)!.valueNotNumber);
}
checkValidData();
}
),
const SizedBox(height: 30),
numericField(
controller: overrideMaxTtlController,
label: AppLocalizations.of(context)!.overrideMaximumTtl,
helper: AppLocalizations.of(context)!.overrideMaximumTtlDescription,
error: overrideMaxTtlError,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => overrideMaxTtlError = null);
}
else {
setState(() => overrideMaxTtlError = AppLocalizations.of(context)!.valueNotNumber);
}
checkValidData();
}
),
const SizedBox(height: 10),
CustomSwitchListTile(
value: optimisticCache,
onChanged: (value) => setState(() => optimisticCache = value),
title: AppLocalizations.of(context)!.optimisticCaching,
subtitle: AppLocalizations.of(context)!.optimisticCachingDescription,
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon(
onPressed: () => showDialog(
context: context,
builder: (context) => ClearDnsCacheDialog(
onConfirm: clearCache
)
),
const SizedBox(height: 10),
CustomSwitchListTile(
value: optimisticCache,
onChanged: (value) => setState(() => optimisticCache = value),
title: AppLocalizations.of(context)!.optimisticCaching,
subtitle: AppLocalizations.of(context)!.optimisticCachingDescription,
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon(
onPressed: () => showDialog(
context: context,
builder: (context) => ClearDnsCacheDialog(
onConfirm: clearCache
)
),
icon: const Icon(Icons.delete_rounded),
label: Text(AppLocalizations.of(context)!.clearDnsCache),
),
icon: const Icon(Icons.delete_rounded),
label: Text(AppLocalizations.of(context)!.clearDnsCache),
),
],
),
const SizedBox(height: 16)
],
],
),
const SizedBox(height: 16)
],
),
),
);
}

View file

@ -1,141 +1,30 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class CommentModal extends StatefulWidget {
class CommentModal extends StatelessWidget {
final String? comment;
final void Function(String) onConfirm;
final bool dialog;
const CommentModal({
Key? key,
super.key,
this.comment,
required this.onConfirm,
required this.dialog
}) : super(key: key);
@override
State<CommentModal> createState() => _CommentModalState();
}
class _CommentModalState extends State<CommentModal> {
final TextEditingController commentController = TextEditingController();
bool validData = false;
@override
void initState() {
if (widget.comment != null) {
commentController.text = widget.comment!.replaceFirst(RegExp(r'#(\s)?'), "");
}
super.initState();
}
});
@override
Widget build(BuildContext context) {
Widget content() {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.comment_rounded,
size: 24,
color: Theme.of(context).colorScheme.secondary,
),
),
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.comment,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 16),
],
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: commentController,
onChanged: (value) {
if (value != '') {
setState(() => validData = true);
}
else {
setState(() => validData = false);
}
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.comment_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.comment,
helperText: AppLocalizations.of(context)!.commentsDescription,
helperMaxLines: 3
)
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel)
),
const SizedBox(width: 20),
TextButton(
onPressed: validData == true
? () {
Navigator.pop(context);
widget.onConfirm("# ${commentController.text}");
}
: null,
child: Text(
AppLocalizations.of(context)!.confirm,
style: TextStyle(
color: validData == true
? Theme.of(context).colorScheme.primary
: Colors.grey
),
)
),
],
),
)
],
);
}
if (widget.dialog == true) {
if (dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: content()
child: _Content(
comment: comment,
onConfirm: onConfirm,
)
),
);
}
@ -150,9 +39,139 @@ class _CommentModalState extends State<CommentModal> {
),
color: Theme.of(context).dialogBackgroundColor
),
child: content()
child: SafeArea(
child: _Content(
comment: comment,
onConfirm: onConfirm,
),
)
),
);
}
}
}
class _Content extends StatefulWidget {
final String? comment;
final void Function(String) onConfirm;
const _Content({
required this.comment,
required this.onConfirm
});
@override
State<_Content> createState() => __ContentState();
}
class __ContentState extends State<_Content> {
final TextEditingController commentController = TextEditingController();
bool validData = false;
@override
void initState() {
if (widget.comment != null) {
commentController.text = widget.comment!.replaceFirst(RegExp(r'#(\s)?'), "");
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 24),
child: Icon(
Icons.comment_rounded,
size: 24,
color: Theme.of(context).colorScheme.secondary,
),
),
const SizedBox(height: 16),
Text(
AppLocalizations.of(context)!.comment,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
color: Theme.of(context).colorScheme.onSurface
),
),
const SizedBox(height: 16),
],
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: commentController,
onChanged: (value) {
if (value != '') {
setState(() => validData = true);
}
else {
setState(() => validData = false);
}
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.comment_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.comment,
helperText: AppLocalizations.of(context)!.commentsDescription,
helperMaxLines: 3
)
),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.cancel)
),
const SizedBox(width: 20),
TextButton(
onPressed: validData == true
? () {
Navigator.pop(context);
widget.onConfirm("# ${commentController.text}");
}
: null,
child: Text(
AppLocalizations.of(context)!.confirm,
style: TextStyle(
color: validData == true
? Theme.of(context).colorScheme.primary
: Colors.grey
),
)
),
],
),
)
],
);
}
}

View file

@ -25,9 +25,9 @@ class DnsSettings extends StatefulWidget {
final bool splitView;
const DnsSettings({
Key? key,
super.key,
required this.splitView,
}) : super(key: key);
});
@override
State<DnsSettings> createState() => _DnsSettingsState();
@ -118,95 +118,97 @@ class _DnsSettingsState extends State<DnsSettings> {
const SizedBox(width: 10)
],
),
body: Builder(
builder: (context) {
switch (dnsProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingDnsConfig,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
)
);
body: SafeArea(
child: Builder(
builder: (context) {
switch (dnsProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingDnsConfig,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
)
);
case LoadStatus.loaded:
return ListView(
children: [
CustomListTile(
title: AppLocalizations.of(context)!.upstreamDns,
subtitle: AppLocalizations.of(context)!.upstreamDnsDescription,
onTap: () => navigate(const UpstreamDnsScreen()),
icon: Icons.upload_rounded,
),
CustomListTile(
title: AppLocalizations.of(context)!.bootstrapDns,
subtitle: AppLocalizations.of(context)!.bootstrapDnsDescription,
onTap: () => navigate(const BootstrapDnsScreen()),
icon: Icons.dns_rounded,
),
CustomListTile(
title: AppLocalizations.of(context)!.privateReverseDnsServers,
subtitle: AppLocalizations.of(context)!.privateReverseDnsDescription,
onTap: () => navigate(const PrivateReverseDnsServersScreen()),
icon: Icons.person_rounded,
),
CustomListTile(
title: AppLocalizations.of(context)!.dnsServerSettings,
subtitle: AppLocalizations.of(context)!.dnsServerSettingsDescription,
onTap: () => navigate(const DnsServerSettingsScreen()),
icon: Icons.settings,
),
CustomListTile(
title: AppLocalizations.of(context)!.dnsCacheConfig,
subtitle: AppLocalizations.of(context)!.dnsCacheConfigDescription,
onTap: () => navigate(const CacheConfigDnsScreen()),
icon: Icons.storage_rounded,
),
],
);
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
case LoadStatus.loaded:
return ListView(
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
CustomListTile(
title: AppLocalizations.of(context)!.upstreamDns,
subtitle: AppLocalizations.of(context)!.upstreamDnsDescription,
onTap: () => navigate(const UpstreamDnsScreen()),
icon: Icons.upload_rounded,
),
CustomListTile(
title: AppLocalizations.of(context)!.bootstrapDns,
subtitle: AppLocalizations.of(context)!.bootstrapDnsDescription,
onTap: () => navigate(const BootstrapDnsScreen()),
icon: Icons.dns_rounded,
),
CustomListTile(
title: AppLocalizations.of(context)!.privateReverseDnsServers,
subtitle: AppLocalizations.of(context)!.privateReverseDnsDescription,
onTap: () => navigate(const PrivateReverseDnsServersScreen()),
icon: Icons.person_rounded,
),
CustomListTile(
title: AppLocalizations.of(context)!.dnsServerSettings,
subtitle: AppLocalizations.of(context)!.dnsServerSettingsDescription,
onTap: () => navigate(const DnsServerSettingsScreen()),
icon: Icons.settings,
),
CustomListTile(
title: AppLocalizations.of(context)!.dnsCacheConfig,
subtitle: AppLocalizations.of(context)!.dnsCacheConfigDescription,
onTap: () => navigate(const CacheConfigDnsScreen()),
icon: Icons.storage_rounded,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.dnsConfigNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
);
default:
return const SizedBox();
}
},
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.dnsConfigNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -167,141 +167,143 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
const SizedBox(width: 10)
],
),
body: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextFormField(
controller: limitRequestsController,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => limitRequestsError = null);
}
else {
setState(() => limitRequestsError = AppLocalizations.of(context)!.valueNotNumber);
}
validateData();
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.looks_one_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.limitRequestsSecond,
errorText: limitRequestsError
),
keyboardType: TextInputType.number,
),
),
const SizedBox(height: 10),
CustomSwitchListTile(
value: enableEdns,
onChanged: (value) => setState(() => enableEdns = value),
title: AppLocalizations.of(context)!.enableEdns,
subtitle: AppLocalizations.of(context)!.enableEdnsDescription,
),
CustomSwitchListTile(
value: enableDnssec,
onChanged: (value) => setState(() => enableDnssec = value),
title: AppLocalizations.of(context)!.enableDnssec,
subtitle: AppLocalizations.of(context)!.enableDnssecDescription,
),
CustomSwitchListTile(
value: disableIpv6Resolving,
onChanged: (value) => setState(() => disableIpv6Resolving = value),
title: AppLocalizations.of(context)!.disableResolvingIpv6,
subtitle: AppLocalizations.of(context)!.disableResolvingIpv6Description,
),
SectionLabel(label: AppLocalizations.of(context)!.blockingMode),
CustomRadioListTile(
groupValue: blockingMode,
value: "default",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.defaultMode,
subtitle: AppLocalizations.of(context)!.defaultDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "refused",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: "REFUSED",
subtitle: AppLocalizations.of(context)!.refusedDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "nxdomain",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: "NXDOMAIN",
subtitle: AppLocalizations.of(context)!.nxdomainDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "null_ip",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.nullIp,
subtitle: AppLocalizations.of(context)!.nullIpDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "custom_ip",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.customIp,
subtitle: AppLocalizations.of(context)!.customIpDescription,
onChanged: updateBlockingMode,
),
const SizedBox(height: 10),
if (blockingMode == 'custom_ip') ...[
body: SafeArea(
child: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextFormField(
controller: ipv4controller,
onChanged: validateIpv4,
controller: limitRequestsController,
onChanged: (value) {
if (int.tryParse(value) != null) {
setState(() => limitRequestsError = null);
}
else {
setState(() => limitRequestsError = AppLocalizations.of(context)!.valueNotNumber);
}
validateData();
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
prefixIcon: const Icon(Icons.looks_one_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: ipv4error,
helperText: AppLocalizations.of(context)!.blockingIpv4Description,
helperMaxLines: 10,
labelText: AppLocalizations.of(context)!.blockingIpv4,
labelText: AppLocalizations.of(context)!.limitRequestsSecond,
errorText: limitRequestsError
),
keyboardType: TextInputType.number,
),
),
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: ipv6controller,
onChanged: validateIpv6,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
const SizedBox(height: 10),
CustomSwitchListTile(
value: enableEdns,
onChanged: (value) => setState(() => enableEdns = value),
title: AppLocalizations.of(context)!.enableEdns,
subtitle: AppLocalizations.of(context)!.enableEdnsDescription,
),
CustomSwitchListTile(
value: enableDnssec,
onChanged: (value) => setState(() => enableDnssec = value),
title: AppLocalizations.of(context)!.enableDnssec,
subtitle: AppLocalizations.of(context)!.enableDnssecDescription,
),
CustomSwitchListTile(
value: disableIpv6Resolving,
onChanged: (value) => setState(() => disableIpv6Resolving = value),
title: AppLocalizations.of(context)!.disableResolvingIpv6,
subtitle: AppLocalizations.of(context)!.disableResolvingIpv6Description,
),
SectionLabel(label: AppLocalizations.of(context)!.blockingMode),
CustomRadioListTile(
groupValue: blockingMode,
value: "default",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.defaultMode,
subtitle: AppLocalizations.of(context)!.defaultDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "refused",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: "REFUSED",
subtitle: AppLocalizations.of(context)!.refusedDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "nxdomain",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: "NXDOMAIN",
subtitle: AppLocalizations.of(context)!.nxdomainDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "null_ip",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.nullIp,
subtitle: AppLocalizations.of(context)!.nullIpDescription,
onChanged: updateBlockingMode,
),
CustomRadioListTile(
groupValue: blockingMode,
value: "custom_ip",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.customIp,
subtitle: AppLocalizations.of(context)!.customIpDescription,
onChanged: updateBlockingMode,
),
const SizedBox(height: 10),
if (blockingMode == 'custom_ip') ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: ipv4controller,
onChanged: validateIpv4,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: ipv4error,
helperText: AppLocalizations.of(context)!.blockingIpv4Description,
helperMaxLines: 10,
labelText: AppLocalizations.of(context)!.blockingIpv4,
),
errorText: ipv6error,
helperText: AppLocalizations.of(context)!.blockingIpv6Description,
helperMaxLines: 10,
labelText: AppLocalizations.of(context)!.blockingIpv6,
keyboardType: TextInputType.number,
),
keyboardType: TextInputType.number,
),
),
const SizedBox(height: 30)
]
],
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextFormField(
controller: ipv6controller,
onChanged: validateIpv6,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.link_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: ipv6error,
helperText: AppLocalizations.of(context)!.blockingIpv6Description,
helperMaxLines: 10,
labelText: AppLocalizations.of(context)!.blockingIpv6,
),
keyboardType: TextInputType.number,
),
),
const SizedBox(height: 30)
]
],
),
),
);
}

View file

@ -13,7 +13,7 @@ import 'package:adguard_home_manager/functions/snackbar.dart';
import 'package:adguard_home_manager/providers/app_config_provider.dart';
class PrivateReverseDnsServersScreen extends StatefulWidget {
const PrivateReverseDnsServersScreen({Key? key}) : super(key: key);
const PrivateReverseDnsServersScreen({super.key});
@override
State<PrivateReverseDnsServersScreen> createState() => _PrivateReverseDnsServersScreenState();
@ -149,107 +149,40 @@ class _PrivateReverseDnsServersScreenState extends State<PrivateReverseDnsServer
const SizedBox(width: 10)
],
),
body: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
Card(
margin: const EdgeInsets.only(
left: 16, right: 16, bottom: 10
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Icon(
Icons.info_rounded,
color: Theme.of(context).listTileTheme.iconColor,
),
const SizedBox(width: 16),
Flexible(
child: Text(
AppLocalizations.of(context)!.privateReverseDnsServersDescription,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
)
)
],
body: SafeArea(
child: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
Card(
margin: const EdgeInsets.only(
left: 16, right: 16, bottom: 10
),
),
),
if (editReverseResolvers == false) ...[
Padding(
padding: const EdgeInsets.all(20),
child: Text(
"${AppLocalizations.of(context)!.reverseDnsDefault}:\n\n${defaultReverseResolvers.map((item) => item).join(', ').toString().replaceAll(RegExp(r'\(|\)'), '')}",
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Icon(
Icons.info_rounded,
color: Theme.of(context).listTileTheme.iconColor,
),
const SizedBox(width: 16),
Flexible(
child: Text(
AppLocalizations.of(context)!.privateReverseDnsServersDescription,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
)
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10, bottom: 20),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() => editReverseResolvers = true);
checkDataValid();
},
icon: const Icon(Icons.edit),
label: Text(AppLocalizations.of(context)!.edit)
),
],
),
)
],
if (editReverseResolvers == true) ...[
const SizedBox(height: 20),
...reverseResolversControllers.map((c) => Padding(
padding: const EdgeInsets.only(
left: 16, right: 6, bottom: 20
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFormField(
controller: c['controller'],
onChanged: (value) => validateAddress(c, value),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.dns_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: c['error'],
labelText: AppLocalizations.of(context)!.serverAddress,
)
),
),
const SizedBox(width: 8),
IconButton(
onPressed: () {
setState(() => reverseResolversControllers = reverseResolversControllers.where((con) => con != c).toList());
checkDataValid();
},
icon: const Icon(Icons.remove_circle_outline)
)
],
),
)),
if (reverseResolversControllers.isEmpty) Padding(
padding: const EdgeInsets.only(
left: 20, right: 20, bottom: 20
),
child: Center(
if (editReverseResolvers == false) ...[
Padding(
padding: const EdgeInsets.all(20),
child: Text(
AppLocalizations.of(context)!.noServerAddressesAdded,
"${AppLocalizations.of(context)!.reverseDnsDefault}:\n\n${defaultReverseResolvers.map((item) => item).join(', ').toString().replaceAll(RegExp(r'\(|\)'), '')}",
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
@ -257,41 +190,110 @@ class _PrivateReverseDnsServersScreenState extends State<PrivateReverseDnsServer
),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() => reverseResolversControllers.add({
'controller': TextEditingController(),
'error': null
}));
checkDataValid();
},
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.addItem)
Padding(
padding: const EdgeInsets.only(top: 10, bottom: 20),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() => editReverseResolvers = true);
checkDataValid();
},
icon: const Icon(Icons.edit),
label: Text(AppLocalizations.of(context)!.edit)
),
],
),
)
],
if (editReverseResolvers == true) ...[
const SizedBox(height: 20),
...reverseResolversControllers.map((c) => Padding(
padding: const EdgeInsets.only(
left: 16, right: 6, bottom: 20
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextFormField(
controller: c['controller'],
onChanged: (value) => validateAddress(c, value),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.dns_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
errorText: c['error'],
labelText: AppLocalizations.of(context)!.serverAddress,
)
),
),
const SizedBox(width: 8),
IconButton(
onPressed: () {
setState(() => reverseResolversControllers = reverseResolversControllers.where((con) => con != c).toList());
checkDataValid();
},
icon: const Icon(Icons.remove_circle_outline)
)
],
),
)),
if (reverseResolversControllers.isEmpty) Padding(
padding: const EdgeInsets.only(
left: 20, right: 20, bottom: 20
),
child: Center(
child: Text(
AppLocalizations.of(context)!.noServerAddressesAdded,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton.icon(
onPressed: () {
setState(() => reverseResolversControllers.add({
'controller': TextEditingController(),
'error': null
}));
checkDataValid();
},
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.addItem)
),
],
),
),
],
CustomSwitchListTile(
value: usePrivateReverseDnsResolvers,
onChanged: (value) => setState(() => usePrivateReverseDnsResolvers = value),
title: AppLocalizations.of(context)!.usePrivateReverseDnsResolvers,
subtitle: AppLocalizations.of(context)!.usePrivateReverseDnsResolversDescription
),
CustomSwitchListTile(
value: enableReverseResolve,
onChanged: (value) => setState(() => enableReverseResolve = value),
title: AppLocalizations.of(context)!.enableReverseResolving,
subtitle: AppLocalizations.of(context)!.enableReverseResolvingDescription
),
],
CustomSwitchListTile(
value: usePrivateReverseDnsResolvers,
onChanged: (value) => setState(() => usePrivateReverseDnsResolvers = value),
title: AppLocalizations.of(context)!.usePrivateReverseDnsResolvers,
subtitle: AppLocalizations.of(context)!.usePrivateReverseDnsResolversDescription
),
CustomSwitchListTile(
value: enableReverseResolve,
onChanged: (value) => setState(() => enableReverseResolve = value),
title: AppLocalizations.of(context)!.enableReverseResolving,
subtitle: AppLocalizations.of(context)!.enableReverseResolvingDescription
),
],
),
),
);
}

View file

@ -189,129 +189,131 @@ class _UpstreamDnsScreenState extends State<UpstreamDnsScreen> {
const SizedBox(width: 10)
],
),
body: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
if (dnsServers.isEmpty) Column(
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Center(
child: Text(
AppLocalizations.of(context)!.noUpstreamDns,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16
body: SafeArea(
child: ListView(
padding: const EdgeInsets.only(top: 10),
children: [
if (dnsServers.isEmpty) Column(
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Center(
child: Text(
AppLocalizations.of(context)!.noUpstreamDns,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 16
),
),
),
),
),
const SizedBox(height: 20),
],
),
...dnsServers.map((item) => Padding(
padding: const EdgeInsets.only(
left: 16, right: 6, bottom: 24
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (item['controller'] != null) Expanded(
child: TextFormField(
controller: item['controller'],
onChanged: (_) => checkValidValues(),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.dns_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.dnsServer,
)
),
),
const SizedBox(width: 8),
if (item['comment'] != null) Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item['comment'],
style: TextStyle(
fontSize: 16,
color: Theme.of(context).listTileTheme.iconColor
),
),
IconButton(
onPressed: () => openEditCommentModal(item, dnsServers.indexOf(item)),
icon: const Icon(Icons.edit),
tooltip: AppLocalizations.of(context)!.edit,
)
],
),
),
IconButton(
onPressed: () {
setState(() => dnsServers = dnsServers.where((i) => i != item).toList());
checkValidValues();
},
icon: const Icon(Icons.remove_circle_outline),
tooltip: AppLocalizations.of(context)!.remove,
),
const SizedBox(width: 4),
const SizedBox(height: 20),
],
),
)).toList(),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton.icon(
onPressed: openAddCommentModal,
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.comment)
...dnsServers.map((item) => Padding(
padding: const EdgeInsets.only(
left: 16, right: 6, bottom: 24
),
ElevatedButton.icon(
onPressed: () {
setState(() => dnsServers.add({
'controller': TextEditingController()
}));
checkValidValues();
},
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.address)
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (item['controller'] != null) Expanded(
child: TextFormField(
controller: item['controller'],
onChanged: (_) => checkValidValues(),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.dns_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10)
)
),
labelText: AppLocalizations.of(context)!.dnsServer,
)
),
),
const SizedBox(width: 8),
if (item['comment'] != null) Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item['comment'],
style: TextStyle(
fontSize: 16,
color: Theme.of(context).listTileTheme.iconColor
),
),
IconButton(
onPressed: () => openEditCommentModal(item, dnsServers.indexOf(item)),
icon: const Icon(Icons.edit),
tooltip: AppLocalizations.of(context)!.edit,
)
],
),
),
IconButton(
onPressed: () {
setState(() => dnsServers = dnsServers.where((i) => i != item).toList());
checkValidValues();
},
icon: const Icon(Icons.remove_circle_outline),
tooltip: AppLocalizations.of(context)!.remove,
),
const SizedBox(width: 4),
],
),
],
),
const SizedBox(height: 16),
SectionLabel(label: AppLocalizations.of(context)!.dnsMode),
CustomRadioListTile(
groupValue: upstreamMode,
value: "",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.loadBalancing,
subtitle: AppLocalizations.of(context)!.loadBalancingDescription,
onChanged: (value) => setState(() => upstreamMode = value),
),
CustomRadioListTile(
groupValue: upstreamMode,
value: "parallel",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.parallelRequests,
subtitle: AppLocalizations.of(context)!.parallelRequestsDescription,
onChanged: (value) => setState(() => upstreamMode = value),
),
CustomRadioListTile(
groupValue: upstreamMode,
value: "fastest_addr",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.fastestIpAddress,
subtitle: AppLocalizations.of(context)!.fastestIpAddressDescription,
onChanged: (value) => setState(() => upstreamMode = value),
),
],
)).toList(),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton.icon(
onPressed: openAddCommentModal,
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.comment)
),
ElevatedButton.icon(
onPressed: () {
setState(() => dnsServers.add({
'controller': TextEditingController()
}));
checkValidValues();
},
icon: const Icon(Icons.add),
label: Text(AppLocalizations.of(context)!.address)
),
],
),
const SizedBox(height: 16),
SectionLabel(label: AppLocalizations.of(context)!.dnsMode),
CustomRadioListTile(
groupValue: upstreamMode,
value: "",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.loadBalancing,
subtitle: AppLocalizations.of(context)!.loadBalancingDescription,
onChanged: (value) => setState(() => upstreamMode = value),
),
CustomRadioListTile(
groupValue: upstreamMode,
value: "parallel",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.parallelRequests,
subtitle: AppLocalizations.of(context)!.parallelRequestsDescription,
onChanged: (value) => setState(() => upstreamMode = value),
),
CustomRadioListTile(
groupValue: upstreamMode,
value: "fastest_addr",
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
title: AppLocalizations.of(context)!.fastestIpAddress,
subtitle: AppLocalizations.of(context)!.fastestIpAddressDescription,
onChanged: (value) => setState(() => upstreamMode = value),
),
],
),
),
);
}

View file

@ -46,10 +46,12 @@ class DnsRewriteModal extends StatelessWidget {
),
color: Theme.of(context).dialogBackgroundColor,
),
child: _Content(
onConfirm: onConfirm,
onDelete: onDelete,
rule: rule,
child: SafeArea(
child: _Content(
onConfirm: onConfirm,
onDelete: onDelete,
rule: rule,
),
)
),
);

View file

@ -136,239 +136,241 @@ class _DnsRewritesScreenState extends State<DnsRewritesScreen> {
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
centerTitle: false,
),
body: Stack(
children: [
Builder(
builder: (context) {
switch (rewriteRulesProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingRewriteRules,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
body: SafeArea(
child: Stack(
children: [
Builder(
builder: (context) {
switch (rewriteRulesProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingRewriteRules,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
if (rewriteRulesProvider.rewriteRules!.isNotEmpty) {
return RefreshIndicator(
onRefresh: () async {
final result = await rewriteRulesProvider.fetchRules();
if (result == false) {
showSnacbkar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.rewriteRulesNotLoaded,
color: Colors.red
);
}
},
child: ListView.builder(
controller: scrollController,
padding: const EdgeInsets.only(top: 0),
itemCount: rewriteRulesProvider.rewriteRules!.length,
itemBuilder: (context, index) => Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: InkWell(
onTap: () => {
if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) {
showDialog(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: true,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
)
}
else {
showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: false,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
backgroundColor: Colors.transparent,
isScrollControlled: true,
)
}
},
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.only(
left: 16, top: 16, bottom: 16, right: 8
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"${AppLocalizations.of(context)!.domain}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].domain,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
case LoadStatus.loaded:
if (rewriteRulesProvider.rewriteRules!.isNotEmpty) {
return RefreshIndicator(
onRefresh: () async {
final result = await rewriteRulesProvider.fetchRules();
if (result == false) {
showSnacbkar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.rewriteRulesNotLoaded,
color: Colors.red
);
}
},
child: ListView.builder(
controller: scrollController,
padding: const EdgeInsets.only(top: 0),
itemCount: rewriteRulesProvider.rewriteRules!.length,
itemBuilder: (context, index) => Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: InkWell(
onTap: () => {
if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) {
showDialog(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: true,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
const SizedBox(height: 3),
Row(
children: [
Text(
"${AppLocalizations.of(context)!.answer}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].answer,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
],
),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
}
else {
showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: false,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
backgroundColor: Colors.transparent,
isScrollControlled: true,
)
}
},
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.only(
left: 16, top: 16, bottom: 16, right: 8
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"${AppLocalizations.of(context)!.domain}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].domain,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
const SizedBox(height: 3),
Row(
children: [
Text(
"${AppLocalizations.of(context)!.answer}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].answer,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
],
),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Theme.of(context).colorScheme.onSurfaceVariant,
)
],
),
),
),
),
)
),
);
}
else {
return Center(
child: Text(
AppLocalizations.of(context)!.noRewriteRules,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
)
),
),
);
}
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.rewriteRulesNotLoaded,
textAlign: TextAlign.center,
);
}
else {
return Center(
child: Text(
AppLocalizations.of(context)!.noRewriteRules,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
),
);
}
default:
return const SizedBox();
}
},
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: isVisible ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: FloatingActionButton(
onPressed: () => {
if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) {
showDialog(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: addDnsRewrite,
dialog: true,
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.rewriteRulesNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
),
],
),
)
}
else {
showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => DnsRewriteModal(
onConfirm: addDnsRewrite,
dialog: false,
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
);
default:
return const SizedBox();
}
},
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: isVisible ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: FloatingActionButton(
onPressed: () => {
if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) {
showDialog(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: addDnsRewrite,
dialog: true,
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
),
backgroundColor: Colors.transparent,
isScrollControlled: true
)
}
},
child: const Icon(Icons.add),
),
)
],
)
}
else {
showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => DnsRewriteModal(
onConfirm: addDnsRewrite,
dialog: false,
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
backgroundColor: Colors.transparent,
isScrollControlled: true
)
}
},
child: const Icon(Icons.add),
),
)
],
),
),
);
}

View file

@ -4,6 +4,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class ServerVersionNeeded extends StatelessWidget {
final String version;
// ignore: use_super_parameters
const ServerVersionNeeded({
Key? key,
required this.version

View file

@ -283,376 +283,378 @@ class _EncryptionSettingsState extends State<EncryptionSettings> {
const SizedBox(width: 10),
],
),
body: Builder(
builder: (context) {
switch (loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingEncryptionSettings,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
)
);
case LoadStatus.loaded:
return ListView(
children: [
EncryptionMasterSwitch(
value: enabled,
onChange: (value) {
setState(() => enabled = value);
onEditValidate();
}
),
SectionLabel(
label: AppLocalizations.of(context)!.serverConfiguration,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
),
EncryptionTextField(
enabled: enabled,
controller: domainNameController,
icon: Icons.link_rounded,
onChanged: (value) {
setState(() => domainError = validateDomain(context, value));
onEditValidate();
},
errorText: domainError,
label: AppLocalizations.of(context)!.domainName,
helperText: AppLocalizations.of(context)!.domainNameDescription,
),
const SizedBox(height: 10),
CustomSwitchListTile(
value: redirectHttps,
onChanged: (value) {
setState(() => redirectHttps = value);
onEditValidate();
},
title: AppLocalizations.of(context)!.redirectHttps,
disabled: !enabled,
),
const SizedBox(height: 10),
Wrap(
body: SafeArea(
child: Builder(
builder: (context) {
switch (loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FractionallySizedBox(
widthFactor: width > 900 ? 0.33 : 1,
child: EncryptionTextField(
enabled: enabled,
controller: httpsPortController,
icon: Icons.numbers_rounded,
onChanged: (value) {
setState(() => httpsPortError = validatePort(context, value));
onEditValidate();
},
errorText: httpsPortError,
label: AppLocalizations.of(context)!.httpsPort,
keyboardType: TextInputType.number,
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingEncryptionSettings,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
Padding(
padding: width <= 900
? const EdgeInsets.symmetric(vertical: 24)
: const EdgeInsets.all(0),
child: FractionallySizedBox(
)
],
)
);
case LoadStatus.loaded:
return ListView(
children: [
EncryptionMasterSwitch(
value: enabled,
onChange: (value) {
setState(() => enabled = value);
onEditValidate();
}
),
SectionLabel(
label: AppLocalizations.of(context)!.serverConfiguration,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
),
EncryptionTextField(
enabled: enabled,
controller: domainNameController,
icon: Icons.link_rounded,
onChanged: (value) {
setState(() => domainError = validateDomain(context, value));
onEditValidate();
},
errorText: domainError,
label: AppLocalizations.of(context)!.domainName,
helperText: AppLocalizations.of(context)!.domainNameDescription,
),
const SizedBox(height: 10),
CustomSwitchListTile(
value: redirectHttps,
onChanged: (value) {
setState(() => redirectHttps = value);
onEditValidate();
},
title: AppLocalizations.of(context)!.redirectHttps,
disabled: !enabled,
),
const SizedBox(height: 10),
Wrap(
children: [
FractionallySizedBox(
widthFactor: width > 900 ? 0.33 : 1,
child: EncryptionTextField(
enabled: enabled,
controller: tlsPortController,
controller: httpsPortController,
icon: Icons.numbers_rounded,
onChanged: (value) {
setState(() => tlsPortError = validatePort(context, value));
setState(() => httpsPortError = validatePort(context, value));
onEditValidate();
},
errorText: tlsPortError,
label: AppLocalizations.of(context)!.tlsPort,
errorText: httpsPortError,
label: AppLocalizations.of(context)!.httpsPort,
keyboardType: TextInputType.number,
),
),
),
FractionallySizedBox(
widthFactor: width > 900 ? 0.33 : 1,
child: EncryptionTextField(
enabled: enabled,
controller: dnsOverQuicPortController,
icon: Icons.numbers_rounded,
onChanged: (value) {
setState(() => dnsOverQuicPortError = validatePort(context, value));
onEditValidate();
},
errorText: dnsOverQuicPortError,
label: AppLocalizations.of(context)!.dnsOverQuicPort,
keyboardType: TextInputType.number,
Padding(
padding: width <= 900
? const EdgeInsets.symmetric(vertical: 24)
: const EdgeInsets.all(0),
child: FractionallySizedBox(
widthFactor: width > 900 ? 0.33 : 1,
child: EncryptionTextField(
enabled: enabled,
controller: tlsPortController,
icon: Icons.numbers_rounded,
onChanged: (value) {
setState(() => tlsPortError = validatePort(context, value));
onEditValidate();
},
errorText: tlsPortError,
label: AppLocalizations.of(context)!.tlsPort,
keyboardType: TextInputType.number,
),
),
),
FractionallySizedBox(
widthFactor: width > 900 ? 0.33 : 1,
child: EncryptionTextField(
enabled: enabled,
controller: dnsOverQuicPortController,
icon: Icons.numbers_rounded,
onChanged: (value) {
setState(() => dnsOverQuicPortError = validatePort(context, value));
onEditValidate();
},
errorText: dnsOverQuicPortError,
label: AppLocalizations.of(context)!.dnsOverQuicPort,
keyboardType: TextInputType.number,
),
),
],
),
SectionLabel(
label: AppLocalizations.of(context)!.certificates,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
),
Card(
margin: const EdgeInsets.symmetric(horizontal: 16),
child: Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Icon(
Icons.info_rounded,
color: Theme.of(context).listTileTheme.iconColor,
),
const SizedBox(width: 20),
Flexible(
child: Text(
AppLocalizations.of(context)!.certificatesDescription,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
)
)
],
),
),
],
),
SectionLabel(
label: AppLocalizations.of(context)!.certificates,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
),
Card(
margin: const EdgeInsets.symmetric(horizontal: 16),
child: Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Icon(
Icons.info_rounded,
color: Theme.of(context).listTileTheme.iconColor,
),
const SizedBox(width: 20),
Flexible(
child: Text(
AppLocalizations.of(context)!.certificatesDescription,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
)
)
],
),
),
),
const SizedBox(height: 20),
RadioListTile(
value: 0,
groupValue: certificateOption,
onChanged: enabled == true
? (value) {
setState(() => certificateOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.certificateFilePath,
style: const TextStyle(
fontWeight: FontWeight.normal
),
),
),
RadioListTile(
value: 1,
groupValue: certificateOption,
onChanged: enabled == true
? (value) {
setState(() => certificateOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.pasteCertificateContent,
style: const TextStyle(
fontWeight: FontWeight.normal
),
),
),
const SizedBox(height: 10),
if (certificateOption == 0) EncryptionTextField(
enabled: enabled,
controller: certificatePathController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => certificatePathError = validatePath(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.certificatePath,
errorText: certificatePathError,
),
if (certificateOption == 1) EncryptionTextField(
enabled: enabled,
controller: certificateContentController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => certificateContentError = validateCertificate(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.certificateContent,
errorText: certificateContentError,
multiline: true,
keyboardType: TextInputType.multiline,
),
if (certKeyValid != null && (certificateContentController.text != '' || certificatePathController.text != '')) ...[
const SizedBox(height: 20),
if (certKeyValid!.validChain != null) ...[
Status(
valid: certKeyValid!.validChain ?? false,
label: certKeyValid!.validChain == true
? AppLocalizations.of(context)!.validCertificateChain
: AppLocalizations.of(context)!.invalidCertificateChain,
RadioListTile(
value: 0,
groupValue: certificateOption,
onChanged: enabled == true
? (value) {
setState(() => certificateOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.certificateFilePath,
style: const TextStyle(
fontWeight: FontWeight.normal
),
),
const SizedBox(height: 10),
],
if (certKeyValid!.subject != null) ...[
Status(
),
RadioListTile(
value: 1,
groupValue: certificateOption,
onChanged: enabled == true
? (value) {
setState(() => certificateOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.pasteCertificateContent,
style: const TextStyle(
fontWeight: FontWeight.normal
),
),
),
const SizedBox(height: 10),
if (certificateOption == 0) EncryptionTextField(
enabled: enabled,
controller: certificatePathController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => certificatePathError = validatePath(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.certificatePath,
errorText: certificatePathError,
),
if (certificateOption == 1) EncryptionTextField(
enabled: enabled,
controller: certificateContentController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => certificateContentError = validateCertificate(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.certificateContent,
errorText: certificateContentError,
multiline: true,
keyboardType: TextInputType.multiline,
),
if (certKeyValid != null && (certificateContentController.text != '' || certificatePathController.text != '')) ...[
const SizedBox(height: 20),
if (certKeyValid!.validChain != null) ...[
Status(
valid: certKeyValid!.validChain ?? false,
label: certKeyValid!.validChain == true
? AppLocalizations.of(context)!.validCertificateChain
: AppLocalizations.of(context)!.invalidCertificateChain,
),
const SizedBox(height: 10),
],
if (certKeyValid!.subject != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.subject}: ${certKeyValid?.subject}"
),
const SizedBox(height: 10),
],
if (certKeyValid!.issuer != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.subject}: ${certKeyValid?.subject}"
label: "${AppLocalizations.of(context)!.issuer}: ${certKeyValid?.issuer}"
),
const SizedBox(height: 10),
const SizedBox(height: 10),
],
if (certKeyValid!.notAfter != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.expirationDate}: ${certKeyValid?.notAfter}"
),
const SizedBox(height: 10),
],
if (certKeyValid!.dnsNames != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.hostNames}: ${certKeyValid?.dnsNames?.join(', ')}"
),
const SizedBox(height: 10),
],
],
if (certKeyValid!.issuer != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.issuer}: ${certKeyValid?.issuer}"
SectionLabel(
label: AppLocalizations.of(context)!.privateKey,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
),
const SizedBox(height: 10),
],
if (certKeyValid!.notAfter != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.expirationDate}: ${certKeyValid?.notAfter}"
),
const SizedBox(height: 10),
],
if (certKeyValid!.dnsNames != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.hostNames}: ${certKeyValid?.dnsNames?.join(', ')}"
),
const SizedBox(height: 10),
],
],
SectionLabel(
label: AppLocalizations.of(context)!.privateKey,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
),
RadioListTile(
value: 0,
groupValue: privateKeyOption,
onChanged: enabled == true
? (value) {
setState(() => privateKeyOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.privateKeyFile,
style: const TextStyle(
fontWeight: FontWeight.normal
RadioListTile(
value: 0,
groupValue: privateKeyOption,
onChanged: enabled == true
? (value) {
setState(() => privateKeyOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.privateKeyFile,
style: const TextStyle(
fontWeight: FontWeight.normal
),
),
),
),
RadioListTile(
value: 1,
groupValue: privateKeyOption,
onChanged: enabled == true
? (value) {
setState(() => privateKeyOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.pastePrivateKey,
style: const TextStyle(
fontWeight: FontWeight.normal
RadioListTile(
value: 1,
groupValue: privateKeyOption,
onChanged: enabled == true
? (value) {
setState(() => privateKeyOption = int.parse(value.toString()));
onEditValidate();
}
: null,
title: Text(
AppLocalizations.of(context)!.pastePrivateKey,
style: const TextStyle(
fontWeight: FontWeight.normal
),
),
),
),
if (privateKeyOption == 0) const SizedBox(height: 10),
if (privateKeyOption == 1) ...[
CustomSwitchListTile(
value: usePreviouslySavedKey,
onChanged: (value) => setState(() => usePreviouslySavedKey = value),
title: AppLocalizations.of(context)!.usePreviousKey,
),
const SizedBox(height: 10)
],
if (privateKeyOption == 0) EncryptionTextField(
enabled: enabled,
controller: privateKeyPathController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => privateKeyPathError = validatePath(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.privateKeyPath,
errorText: privateKeyPathError,
),
if (privateKeyOption == 1) EncryptionTextField(
enabled: enabled == true
? !usePreviouslySavedKey
: false,
controller: pastePrivateKeyController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => pastePrivateKeyError = validatePrivateKey(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.pastePrivateKey,
errorText: pastePrivateKeyError,
keyboardType: TextInputType.multiline,
multiline: true,
),
const SizedBox(height: 20),
if (certKeyValid != null && (privateKeyPathController.text != '' || pastePrivateKeyController.text != '' || usePreviouslySavedKey == true)) ...[
if (certKeyValid!.validKey != null) ...[
Status(
valid: certKeyValid!.validKey ?? false,
label: certKeyValid!.validKey == true
? AppLocalizations.of(context)!.validPrivateKey
: AppLocalizations.of(context)!.invalidPrivateKey,
if (privateKeyOption == 0) const SizedBox(height: 10),
if (privateKeyOption == 1) ...[
CustomSwitchListTile(
value: usePreviouslySavedKey,
onChanged: (value) => setState(() => usePreviouslySavedKey = value),
title: AppLocalizations.of(context)!.usePreviousKey,
),
const SizedBox(height: 10)
],
if (certKeyValid!.validPair != null && certKeyValid!.validPair == false) ...[
Status(
valid: false,
label: AppLocalizations.of(context)!.keysNotMatch,
),
const SizedBox(height: 10)
],
if (certKeyValid!.keyType != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.keyType}: ${certKeyValid!.keyType}"
),
const SizedBox(height: 10),
],
const SizedBox(height: 10)
]
],
);
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
if (privateKeyOption == 0) EncryptionTextField(
enabled: enabled,
controller: privateKeyPathController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => privateKeyPathError = validatePath(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.privateKeyPath,
errorText: privateKeyPathError,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.encryptionSettingsNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
if (privateKeyOption == 1) EncryptionTextField(
enabled: enabled == true
? !usePreviouslySavedKey
: false,
controller: pastePrivateKeyController,
icon: Icons.description_rounded,
onChanged: (value) {
setState(() => pastePrivateKeyError = validatePrivateKey(context, value));
onEditValidate();
},
label: AppLocalizations.of(context)!.pastePrivateKey,
errorText: pastePrivateKeyError,
keyboardType: TextInputType.multiline,
multiline: true,
),
const SizedBox(height: 20),
if (certKeyValid != null && (privateKeyPathController.text != '' || pastePrivateKeyController.text != '' || usePreviouslySavedKey == true)) ...[
if (certKeyValid!.validKey != null) ...[
Status(
valid: certKeyValid!.validKey ?? false,
label: certKeyValid!.validKey == true
? AppLocalizations.of(context)!.validPrivateKey
: AppLocalizations.of(context)!.invalidPrivateKey,
),
const SizedBox(height: 10)
],
if (certKeyValid!.validPair != null && certKeyValid!.validPair == false) ...[
Status(
valid: false,
label: AppLocalizations.of(context)!.keysNotMatch,
),
const SizedBox(height: 10)
],
if (certKeyValid!.keyType != null) ...[
Status(
valid: true,
label: "${AppLocalizations.of(context)!.keyType}: ${certKeyValid!.keyType}"
),
const SizedBox(height: 10),
],
const SizedBox(height: 10)
]
],
),
);
);
default:
return const SizedBox();
}
},
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.encryptionSettingsNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -124,173 +124,175 @@ class _GeneralSettingsState extends State<GeneralSettings> {
title: Text(AppLocalizations.of(context)!.generalSettings),
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
),
body: ListView(
children: [
SectionLabel(label: AppLocalizations.of(context)!.home),
CustomListTile(
icon: Icons.exposure_zero_rounded,
title: AppLocalizations.of(context)!.hideZeroValues,
subtitle: AppLocalizations.of(context)!.hideZeroValuesDescription,
trailing: Switch(
value: appConfigProvider.hideZeroValues,
onChanged: (value) => updateSettings(
newStatus: value,
body: SafeArea(
child: ListView(
children: [
SectionLabel(label: AppLocalizations.of(context)!.home),
CustomListTile(
icon: Icons.exposure_zero_rounded,
title: AppLocalizations.of(context)!.hideZeroValues,
subtitle: AppLocalizations.of(context)!.hideZeroValuesDescription,
trailing: Switch(
value: appConfigProvider.hideZeroValues,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setHideZeroValues
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.hideZeroValues,
function: appConfigProvider.setHideZeroValues
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.hideZeroValues,
function: appConfigProvider.setHideZeroValues
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
CustomListTile(
icon: Icons.show_chart_rounded,
title: AppLocalizations.of(context)!.combinedChart,
subtitle: AppLocalizations.of(context)!.combinedChartDescription,
trailing: Switch(
value: appConfigProvider.combinedChartHome,
onChanged: (value) => updateSettings(
newStatus: value,
CustomListTile(
icon: Icons.show_chart_rounded,
title: AppLocalizations.of(context)!.combinedChart,
subtitle: AppLocalizations.of(context)!.combinedChartDescription,
trailing: Switch(
value: appConfigProvider.combinedChartHome,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setCombinedChartHome
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.combinedChartHome,
function: appConfigProvider.setCombinedChartHome
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.combinedChartHome,
function: appConfigProvider.setCombinedChartHome
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
CustomListTile(
icon: Icons.remove_red_eye_rounded,
title: AppLocalizations.of(context)!.hideServerAddress,
subtitle: AppLocalizations.of(context)!.hideServerAddressDescription,
trailing: Switch(
value: appConfigProvider.hideServerAddress,
onChanged: (value) => updateSettings(
newStatus: value,
CustomListTile(
icon: Icons.remove_red_eye_rounded,
title: AppLocalizations.of(context)!.hideServerAddress,
subtitle: AppLocalizations.of(context)!.hideServerAddressDescription,
trailing: Switch(
value: appConfigProvider.hideServerAddress,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setHideServerAddress
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.hideServerAddress,
function: appConfigProvider.setHideServerAddress
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.hideServerAddress,
function: appConfigProvider.setHideServerAddress
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
CustomListTile(
icon: Icons.reorder_rounded,
title: AppLocalizations.of(context)!.topItemsOrder,
subtitle: AppLocalizations.of(context)!.topItemsOrderDescription,
onTap: () => widget.splitView == true
? SplitView.of(context).push(const ReorderableTopItemsHome())
: Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const ReorderableTopItemsHome()
CustomListTile(
icon: Icons.reorder_rounded,
title: AppLocalizations.of(context)!.topItemsOrder,
subtitle: AppLocalizations.of(context)!.topItemsOrderDescription,
onTap: () => widget.splitView == true
? SplitView.of(context).push(const ReorderableTopItemsHome())
: Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const ReorderableTopItemsHome()
)
)
)
),
CustomListTile(
icon: Icons.donut_large_rounded,
title: AppLocalizations.of(context)!.showTopItemsChart,
subtitle: AppLocalizations.of(context)!.showTopItemsChartDescription,
trailing: Switch(
value: appConfigProvider.showTopItemsChart,
onChanged: (value) => updateSettings(
newStatus: value,
),
CustomListTile(
icon: Icons.donut_large_rounded,
title: AppLocalizations.of(context)!.showTopItemsChart,
subtitle: AppLocalizations.of(context)!.showTopItemsChartDescription,
trailing: Switch(
value: appConfigProvider.showTopItemsChart,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setShowTopItemsChart
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.showTopItemsChart,
function: appConfigProvider.setShowTopItemsChart
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.showTopItemsChart,
function: appConfigProvider.setShowTopItemsChart
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
SectionLabel(label: AppLocalizations.of(context)!.logs),
CustomListTile(
icon: Icons.timer_rounded,
title: AppLocalizations.of(context)!.timeLogs,
subtitle: AppLocalizations.of(context)!.timeLogsDescription,
trailing: Switch(
value: appConfigProvider.showTimeLogs,
onChanged: (value) => updateSettings(
newStatus: value,
SectionLabel(label: AppLocalizations.of(context)!.logs),
CustomListTile(
icon: Icons.timer_rounded,
title: AppLocalizations.of(context)!.timeLogs,
subtitle: AppLocalizations.of(context)!.timeLogsDescription,
trailing: Switch(
value: appConfigProvider.showTimeLogs,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setshowTimeLogs
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.showTimeLogs,
function: appConfigProvider.setshowTimeLogs
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.showTimeLogs,
function: appConfigProvider.setshowTimeLogs
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
CustomListTile(
icon: Icons.more,
title: AppLocalizations.of(context)!.ipLogs,
subtitle: AppLocalizations.of(context)!.ipLogsDescription,
trailing: Switch(
value: appConfigProvider.showIpLogs,
onChanged: (value) => updateSettings(
newStatus: value,
CustomListTile(
icon: Icons.more,
title: AppLocalizations.of(context)!.ipLogs,
subtitle: AppLocalizations.of(context)!.ipLogsDescription,
trailing: Switch(
value: appConfigProvider.showIpLogs,
onChanged: (value) => updateSettings(
newStatus: value,
function: appConfigProvider.setShowIpLogs
),
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.showIpLogs,
function: appConfigProvider.setShowIpLogs
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
onTap: () => updateSettings(
newStatus: !appConfigProvider.showIpLogs,
function: appConfigProvider.setShowIpLogs
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
left: 16,
right: 10
)
),
if (
!(Platform.isAndroid || Platform.isIOS) ||
(Platform.isAndroid && (
appConfigProvider.installationSource == Source.IS_INSTALLED_FROM_LOCAL_SOURCE ||
appConfigProvider.installationSource == Source.IS_INSTALLED_FROM_PLAY_PACKAGE_INSTALLER ||
appConfigProvider.installationSource == Source.UNKNOWN
))
) ...[
SectionLabel(label: AppLocalizations.of(context)!.application),
CustomListTile(
icon: Icons.system_update_rounded,
title: AppLocalizations.of(context)!.appUpdates,
subtitle: appConfigProvider.appUpdatesAvailable != null
? AppLocalizations.of(context)!.updateAvailable
: AppLocalizations.of(context)!.usingLatestVersion,
trailing: generateAppUpdateStatus()
)
]
],
if (
!(Platform.isAndroid || Platform.isIOS) ||
(Platform.isAndroid && (
appConfigProvider.installationSource == Source.IS_INSTALLED_FROM_LOCAL_SOURCE ||
appConfigProvider.installationSource == Source.IS_INSTALLED_FROM_PLAY_PACKAGE_INSTALLER ||
appConfigProvider.installationSource == Source.UNKNOWN
))
) ...[
SectionLabel(label: AppLocalizations.of(context)!.application),
CustomListTile(
icon: Icons.system_update_rounded,
title: AppLocalizations.of(context)!.appUpdates,
subtitle: appConfigProvider.appUpdatesAvailable != null
? AppLocalizations.of(context)!.updateAvailable
: AppLocalizations.of(context)!.usingLatestVersion,
trailing: generateAppUpdateStatus()
)
]
],
),
)
);
}

View file

@ -14,7 +14,7 @@ import 'package:adguard_home_manager/functions/snackbar.dart';
import 'package:adguard_home_manager/providers/app_config_provider.dart';
class SafeSearchSettingsScreen extends StatefulWidget {
const SafeSearchSettingsScreen({Key? key}) : super(key: key);
const SafeSearchSettingsScreen({super.key});
@override
State<SafeSearchSettingsScreen> createState() => _SafeSearchSettingsScreenState();
@ -123,166 +123,168 @@ class _SafeSearchSettingsScreenState extends State<SafeSearchSettingsScreen> {
const SizedBox(width: 8)
],
),
body: Builder(
builder: (context) {
switch (statusProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingSafeSearchSettings,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
body: SafeArea(
child: Builder(
builder: (context) {
switch (statusProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingSafeSearchSettings,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
return RefreshIndicator(
onRefresh: requestSafeSearchSettings,
child: ListView(
children: [
Padding(
padding: const EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8
),
child: Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(28),
child: InkWell(
case LoadStatus.loaded:
return RefreshIndicator(
onRefresh: requestSafeSearchSettings,
child: ListView(
children: [
Padding(
padding: const EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8
),
child: Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(28),
onTap: () => setState(() => generalEnabled = !generalEnabled),
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12
),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
borderRadius: BorderRadius.circular(28)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Text(
AppLocalizations.of(context)!.enableSafeSearch,
style: const TextStyle(
fontSize: 18
child: InkWell(
borderRadius: BorderRadius.circular(28),
onTap: () => setState(() => generalEnabled = !generalEnabled),
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12
),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
borderRadius: BorderRadius.circular(28)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Text(
AppLocalizations.of(context)!.enableSafeSearch,
style: const TextStyle(
fontSize: 18
),
),
),
),
Switch(
value: generalEnabled,
onChanged: (value) => setState(() => generalEnabled = value)
)
],
Switch(
value: generalEnabled,
onChanged: (value) => setState(() => generalEnabled = value)
)
],
),
),
),
),
),
),
CustomCheckboxListTile(
value: bingEnabled,
onChanged: (value) => setState(() => bingEnabled = value),
title: "Bing",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
CustomCheckboxListTile(
value: bingEnabled,
onChanged: (value) => setState(() => bingEnabled = value),
title: "Bing",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
),
disabled: !generalEnabled,
),
disabled: !generalEnabled,
),
CustomCheckboxListTile(
value: duckduckgoEnabled,
onChanged: (value) => setState(() => duckduckgoEnabled = value),
title: "DuckDuckGo",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
CustomCheckboxListTile(
value: duckduckgoEnabled,
onChanged: (value) => setState(() => duckduckgoEnabled = value),
title: "DuckDuckGo",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
),
disabled: !generalEnabled,
),
disabled: !generalEnabled,
),
CustomCheckboxListTile(
value: googleEnabled,
onChanged: (value) => setState(() => googleEnabled = value),
title: "Google",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
CustomCheckboxListTile(
value: googleEnabled,
onChanged: (value) => setState(() => googleEnabled = value),
title: "Google",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
),
disabled: !generalEnabled,
),
disabled: !generalEnabled,
),
CustomCheckboxListTile(
value: pixabayEnabled,
onChanged: (value) => setState(() => pixabayEnabled = value),
title: "Pixabay",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
CustomCheckboxListTile(
value: pixabayEnabled,
onChanged: (value) => setState(() => pixabayEnabled = value),
title: "Pixabay",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
),
disabled: !generalEnabled,
),
disabled: !generalEnabled,
),
CustomCheckboxListTile(
value: yandexEnabled,
onChanged: (value) => setState(() => yandexEnabled = value),
title: "Yandex",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
CustomCheckboxListTile(
value: yandexEnabled,
onChanged: (value) => setState(() => yandexEnabled = value),
title: "Yandex",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
),
disabled: !generalEnabled,
),
disabled: !generalEnabled,
),
CustomCheckboxListTile(
value: youtubeEnabled,
onChanged: (value) => setState(() => youtubeEnabled = value),
title: "YouTube",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
CustomCheckboxListTile(
value: youtubeEnabled,
onChanged: (value) => setState(() => youtubeEnabled = value),
title: "YouTube",
padding: const EdgeInsets.only(
top: 8, left: 40, right: 40, bottom: 8
),
disabled: !generalEnabled,
),
disabled: !generalEnabled,
),
],
),
);
],
),
);
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.safeSearchSettingsNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
)
],
),
);
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.safeSearchSettingsNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -51,114 +51,116 @@ class _ServerInformationState extends State<ServerInformation> {
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
centerTitle: false,
),
body: Builder(
builder: (context) {
switch (serverInfo.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
body: SafeArea(
child: Builder(
builder: (context) {
switch (serverInfo.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
AppLocalizations.of(context)!.loadingServerInfo,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
)
],
),
);
case LoadStatus.loaded:
return ListView(
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
AppLocalizations.of(context)!.loadingServerInfo,
CustomListTile(
title: AppLocalizations.of(context)!.dnsAddresses,
subtitle: AppLocalizations.of(context)!.seeDnsAddresses,
onTap: () {
showModal(
context: context,
builder: (context) => DnsAddressesModal(
dnsAddresses: serverInfo.data!.dnsAddresses
)
);
},
),
CustomListTile(
title: AppLocalizations.of(context)!.dnsPort,
subtitle: serverInfo.data!.dnsPort.toString(),
),
CustomListTile(
title: AppLocalizations.of(context)!.httpPort,
subtitle: serverInfo.data!.httpPort.toString(),
),
CustomListTile(
title: AppLocalizations.of(context)!.protectionEnabled,
subtitle: serverInfo.data!.protectionEnabled == true
? AppLocalizations.of(context)!.yes
: AppLocalizations.of(context)!.no,
),
CustomListTile(
title: AppLocalizations.of(context)!.dhcpAvailable,
subtitle: serverInfo.data!.dhcpAvailable == true
? AppLocalizations.of(context)!.yes
: AppLocalizations.of(context)!.no,
),
CustomListTile(
title: AppLocalizations.of(context)!.serverRunning,
subtitle: serverInfo.data!.running == true
? AppLocalizations.of(context)!.yes
: AppLocalizations.of(context)!.no,
),
CustomListTile(
title: AppLocalizations.of(context)!.serverVersion,
subtitle: serverInfo.data!.version,
),
CustomListTile(
title: AppLocalizations.of(context)!.serverLanguage,
subtitle: serverInfo.data!.language,
),
]
);
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.serverInfoNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
)
],
),
);
)
],
),
);
case LoadStatus.loaded:
return ListView(
children: [
CustomListTile(
title: AppLocalizations.of(context)!.dnsAddresses,
subtitle: AppLocalizations.of(context)!.seeDnsAddresses,
onTap: () {
showModal(
context: context,
builder: (context) => DnsAddressesModal(
dnsAddresses: serverInfo.data!.dnsAddresses
)
);
},
),
CustomListTile(
title: AppLocalizations.of(context)!.dnsPort,
subtitle: serverInfo.data!.dnsPort.toString(),
),
CustomListTile(
title: AppLocalizations.of(context)!.httpPort,
subtitle: serverInfo.data!.httpPort.toString(),
),
CustomListTile(
title: AppLocalizations.of(context)!.protectionEnabled,
subtitle: serverInfo.data!.protectionEnabled == true
? AppLocalizations.of(context)!.yes
: AppLocalizations.of(context)!.no,
),
CustomListTile(
title: AppLocalizations.of(context)!.dhcpAvailable,
subtitle: serverInfo.data!.dhcpAvailable == true
? AppLocalizations.of(context)!.yes
: AppLocalizations.of(context)!.no,
),
CustomListTile(
title: AppLocalizations.of(context)!.serverRunning,
subtitle: serverInfo.data!.running == true
? AppLocalizations.of(context)!.yes
: AppLocalizations.of(context)!.no,
),
CustomListTile(
title: AppLocalizations.of(context)!.serverVersion,
subtitle: serverInfo.data!.version,
),
CustomListTile(
title: AppLocalizations.of(context)!.serverLanguage,
subtitle: serverInfo.data!.language,
),
]
);
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.serverInfoNotLoaded,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
default:
return const SizedBox();
}
},
),
)
);
}

View file

@ -14,10 +14,10 @@ class ThemeModal extends StatefulWidget {
final int selectedTheme;
const ThemeModal({
Key? key,
super.key,
required this.statusBarHeight,
required this.selectedTheme,
}) : super(key: key);
});
@override
State<ThemeModal> createState() => _ThemeModalState();

View file

@ -17,7 +17,7 @@ import 'package:adguard_home_manager/constants/enums.dart';
import 'package:adguard_home_manager/providers/servers_provider.dart';
class UpdateScreen extends StatelessWidget {
const UpdateScreen({Key? key}) : super(key: key);
const UpdateScreen({super.key});
@override
Widget build(BuildContext context) {
@ -166,33 +166,38 @@ class UpdateScreen extends StatelessWidget {
);
}
final changelog = serversProvider.updateAvailable.loadStatus == LoadStatus.loaded && serversProvider.updateAvailable.data!.changelog != null
? ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Changelog ${serversProvider.updateAvailable.data!.canAutoupdate == true
? serversProvider.updateAvailable.data!.newVersion
: serversProvider.updateAvailable.data!.currentVersion}",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurfaceVariant
final SafeArea? changelog;
if (serversProvider.updateAvailable.loadStatus == LoadStatus.loaded && serversProvider.updateAvailable.data!.changelog != null) {
changelog = SafeArea(
child: ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Changelog ${serversProvider.updateAvailable.data!.canAutoupdate == true
? serversProvider.updateAvailable.data!.newVersion
: serversProvider.updateAvailable.data!.currentVersion}",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurfaceVariant
),
),
),
),
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Html(
data: html.parse(md.markdownToHtml(serversProvider.updateAvailable.data!.changelog!)).outerHtml,
onLinkTap: (url, context, attributes) => url != null ? openUrl(url) : null,
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Html(
data: html.parse(md.markdownToHtml(serversProvider.updateAvailable.data!.changelog!)).outerHtml,
onLinkTap: (url, context, attributes) => url != null ? openUrl(url) : null,
)
)
)
],
)
: null;
],
),
);
} else {
changelog = null;
}
return Scaffold(
body: Column(

View file

@ -550,8 +550,10 @@ class _AddServerModalState extends State<AddServerModal> {
const SizedBox(width: 8)
],
),
body: ListView(
children: form()
body: SafeArea(
child: ListView(
children: form()
),
),
),
);

View file

@ -5,12 +5,14 @@ class OverlayStyle extends StatelessWidget {
final Widget child;
const OverlayStyle({
Key? key,
super.key,
required this.child
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
final systemGestureInsets = MediaQuery.of(context).systemGestureInsets;
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
@ -20,7 +22,13 @@ class OverlayStyle extends StatelessWidget {
statusBarIconBrightness: Theme.of(context).brightness == Brightness.light
? Brightness.dark
: Brightness.light,
systemNavigationBarColor: Theme.of(context).colorScheme.background,
systemNavigationBarColor: systemGestureInsets.left > 0 // If true gestures navigation
? Colors.transparent
: ElevationOverlay.applySurfaceTint(
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surfaceTint,
3
),
systemNavigationBarIconBrightness: Theme.of(context).brightness == Brightness.light
? Brightness.dark
: Brightness.light,

View file

@ -19,7 +19,7 @@ class CustomTabContentList extends StatelessWidget {
final EdgeInsets? listPadding;
const CustomTabContentList({
Key? key,
super.key,
required this.loadingGenerator,
required this.itemsCount,
required this.contentWidget,
@ -32,7 +32,7 @@ class CustomTabContentList extends StatelessWidget {
this.fabVisible,
this.noSliver,
this.listPadding
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@ -49,7 +49,6 @@ class CustomTabContentList extends StatelessWidget {
else {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) => CustomScrollView(
slivers: [
@ -72,41 +71,45 @@ class CustomTabContentList extends StatelessWidget {
case LoadStatus.loaded:
if (noSliver == true) {
if (itemsCount > 0) {
return Stack(
children: [
ListView.builder(
padding: listPadding,
itemCount: itemsCount,
itemBuilder: (context, index) => contentWidget(index),
),
if (fab != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible != null && fabVisible == true ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: fab!
),
],
return SafeArea(
child: Stack(
children: [
ListView.builder(
padding: listPadding,
itemCount: itemsCount,
itemBuilder: (context, index) => contentWidget(index),
),
if (fab != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible != null && fabVisible == true ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: fab!
),
],
),
);
}
else {
return Stack(
children: [
noData,
if (fab != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible != null && fabVisible == true ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: fab!
),
],
return SafeArea(
child: Stack(
children: [
noData,
if (fab != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible != null && fabVisible == true ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: fab!
),
],
),
);
}
}
@ -146,10 +149,10 @@ class CustomTabContentList extends StatelessWidget {
curve: Curves.easeInOut,
bottom: fabVisible != null && fabVisible == true ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
? 90 : 20
: -90,
right: 20,
child: fab!
child: SafeArea(child: fab!)
),
],
);
@ -169,7 +172,6 @@ class CustomTabContentList extends StatelessWidget {
else {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) => CustomScrollView(
slivers: [