Adapt ui to support text scale

This commit is contained in:
Juan Gilsanz Polo 2023-11-29 11:56:28 +01:00
parent bddfac7e72
commit c9c960d1ee
23 changed files with 624 additions and 495 deletions

View file

@ -10,12 +10,12 @@ class BlockedServicesSection extends StatelessWidget {
final void Function(bool) onUpdateServicesGlobalSettings; final void Function(bool) onUpdateServicesGlobalSettings;
const BlockedServicesSection({ const BlockedServicesSection({
Key? key, super.key,
required this.useGlobalSettingsServices, required this.useGlobalSettingsServices,
required this.blockedServices, required this.blockedServices,
required this.onUpdatedBlockedServices, required this.onUpdatedBlockedServices,
required this.onUpdateServicesGlobalSettings required this.onUpdateServicesGlobalSettings
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -37,13 +37,15 @@ class BlockedServicesSection extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Flexible(
child: Text(
AppLocalizations.of(context)!.useGlobalSettings, AppLocalizations.of(context)!.useGlobalSettings,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: Theme.of(context).colorScheme.onSurface color: Theme.of(context).colorScheme.onSurface
), ),
), ),
),
Switch( Switch(
value: useGlobalSettingsServices, value: useGlobalSettingsServices,
onChanged: (value) => onUpdateServicesGlobalSettings(value), onChanged: (value) => onUpdateServicesGlobalSettings(value),
@ -78,7 +80,8 @@ class BlockedServicesSection extends StatelessWidget {
: Theme.of(context).colorScheme.onSurface.withOpacity(0.38), : Theme.of(context).colorScheme.onSurface.withOpacity(0.38),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
Column( Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
@ -102,6 +105,7 @@ class BlockedServicesSection extends StatelessWidget {
) )
] ]
], ],
),
) )
], ],
), ),

View file

@ -47,7 +47,7 @@ class ClientForm extends StatelessWidget {
final void Function(bool) updateUseGlobalSettingsServices; final void Function(bool) updateUseGlobalSettingsServices;
const ClientForm({ const ClientForm({
Key? key, super.key,
required this.isFullScreen, required this.isFullScreen,
required this.client, required this.client,
required this.nameController, required this.nameController,
@ -75,7 +75,7 @@ class ClientForm extends StatelessWidget {
required this.updateEnableSafeSearch, required this.updateEnableSafeSearch,
required this.updateSafeSearch, required this.updateSafeSearch,
required this.updateUseGlobalSettingsServices, required this.updateUseGlobalSettingsServices,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -154,13 +154,15 @@ class ClientForm extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Flexible(
child: Text(
AppLocalizations.of(context)!.useGlobalSettings, AppLocalizations.of(context)!.useGlobalSettings,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: Theme.of(context).colorScheme.onSurface color: Theme.of(context).colorScheme.onSurface
), ),
), ),
),
Switch( Switch(
value: useGlobalSettingsFiltering, value: useGlobalSettingsFiltering,
onChanged: (value) => enableDisableGlobalSettingsFiltering() onChanged: (value) => enableDisableGlobalSettingsFiltering()

View file

@ -27,12 +27,12 @@ class ClientScreen extends StatefulWidget {
final bool fullScreen; final bool fullScreen;
const ClientScreen({ const ClientScreen({
Key? key, super.key,
this.client, this.client,
required this.onConfirm, required this.onConfirm,
this.onDelete, this.onDelete,
required this.fullScreen required this.fullScreen
}) : super(key: key); });
@override @override
State<ClientScreen> createState() => _ClientScreenState(); State<ClientScreen> createState() => _ClientScreenState();

View file

@ -7,11 +7,11 @@ class TagsModal extends StatefulWidget {
final void Function(List<String>) onConfirm; final void Function(List<String>) onConfirm;
const TagsModal({ const TagsModal({
Key? key, super.key,
required this.selectedTags, required this.selectedTags,
required this.tags, required this.tags,
required this.onConfirm, required this.onConfirm,
}) : super(key: key); });
@override @override
State<TagsModal> createState() => _TagsModalState(); State<TagsModal> createState() => _TagsModalState();
@ -82,7 +82,8 @@ class _TagsModalState extends State<TagsModal> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Flexible(
child: Text(
widget.tags[index], widget.tags[index],
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
@ -90,6 +91,7 @@ class _TagsModalState extends State<TagsModal> {
color: Theme.of(context).colorScheme.onSurface, color: Theme.of(context).colorScheme.onSurface,
), ),
), ),
),
Checkbox( Checkbox(
value: selectedTags.contains(widget.tags[index]), value: selectedTags.contains(widget.tags[index]),
onChanged: (value) => checkUncheckTag(value!, widget.tags[index]), onChanged: (value) => checkUncheckTag(value!, widget.tags[index]),

View file

@ -12,11 +12,11 @@ class UpdateIntervalListsModal extends StatefulWidget {
final bool dialog; final bool dialog;
const UpdateIntervalListsModal({ const UpdateIntervalListsModal({
Key? key, super.key,
required this.interval, required this.interval,
required this.onChange, required this.onChange,
required this.dialog required this.dialog
}) : super(key: key); });
@override @override
State<UpdateIntervalListsModal> createState() => _UpdateIntervalListsModalState(); State<UpdateIntervalListsModal> createState() => _UpdateIntervalListsModalState();
@ -25,7 +25,7 @@ class UpdateIntervalListsModal extends StatefulWidget {
class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> { class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
int? selectedOption; int? selectedOption;
void _updateRadioValue(value) { void _updateRadioValue(int value) {
setState(() { setState(() {
selectedOption = value; selectedOption = value;
}); });
@ -41,7 +41,55 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final MediaQueryData mediaQueryData = MediaQuery.of(context); final MediaQueryData mediaQueryData = MediaQuery.of(context);
Widget content() { if (widget.dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 500
),
child: _Content(
selectedOption: selectedOption,
onUpdateValue: _updateRadioValue,
onConfirm: () => widget.onChange(selectedOption!),
)
),
);
}
else {
return Padding(
padding: mediaQueryData.viewInsets,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).dialogBackgroundColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
),
child: _Content(
selectedOption: selectedOption,
onUpdateValue: _updateRadioValue,
onConfirm: () => widget.onChange(selectedOption!),
)
),
);
}
}
}
class _Content extends StatelessWidget {
final int? selectedOption;
final void Function(int) onUpdateValue;
final void Function() onConfirm;
const _Content({
required this.selectedOption,
required this.onUpdateValue,
required this.onConfirm,
});
@override
Widget build(BuildContext context) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -52,7 +100,8 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Column( Flexible(
child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(top: 24), padding: const EdgeInsets.only(top: 24),
@ -62,7 +111,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
color: Theme.of(context).listTileTheme.iconColor color: Theme.of(context).listTileTheme.iconColor
), ),
), ),
Container( Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 24, horizontal: 24,
vertical: 16 vertical: 16
@ -78,6 +127,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
), ),
), ),
], ],
),
) )
], ],
), ),
@ -93,7 +143,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
child: OptionBox( child: OptionBox(
optionsValue: selectedOption, optionsValue: selectedOption,
itemValue: 0, itemValue: 0,
onTap: _updateRadioValue, onTap: (v) => onUpdateValue(v as int),
label: AppLocalizations.of(context)!.never, label: AppLocalizations.of(context)!.never,
), ),
), ),
@ -105,7 +155,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
child: OptionBox( child: OptionBox(
optionsValue: selectedOption, optionsValue: selectedOption,
itemValue: 1, itemValue: 1,
onTap: _updateRadioValue, onTap: (v) => onUpdateValue(v as int),
label: AppLocalizations.of(context)!.hour1, label: AppLocalizations.of(context)!.hour1,
), ),
), ),
@ -117,7 +167,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
child: OptionBox( child: OptionBox(
optionsValue: selectedOption, optionsValue: selectedOption,
itemValue: 12, itemValue: 12,
onTap: _updateRadioValue, onTap: (v) => onUpdateValue(v as int),
label: AppLocalizations.of(context)!.hours12, label: AppLocalizations.of(context)!.hours12,
), ),
), ),
@ -129,9 +179,8 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
child: OptionBox( child: OptionBox(
optionsValue: selectedOption, optionsValue: selectedOption,
itemValue: 24, itemValue: 24,
onTap: _updateRadioValue, onTap: (v) => onUpdateValue(v as int),
label: AppLocalizations.of(context)!.hours24, label: AppLocalizations.of(context)!.hours24,
), ),
), ),
), ),
@ -142,9 +191,8 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
child: OptionBox( child: OptionBox(
optionsValue: selectedOption, optionsValue: selectedOption,
itemValue: 72, itemValue: 72,
onTap: _updateRadioValue, onTap: (v) => onUpdateValue(v as int),
label: AppLocalizations.of(context)!.days3, label: AppLocalizations.of(context)!.days3,
), ),
), ),
), ),
@ -155,7 +203,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
child: OptionBox( child: OptionBox(
optionsValue: selectedOption, optionsValue: selectedOption,
itemValue: 168, itemValue: 168,
onTap: _updateRadioValue, onTap: (v) => onUpdateValue(v as int),
label: AppLocalizations.of(context)!.days7, label: AppLocalizations.of(context)!.days7,
), ),
), ),
@ -181,7 +229,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
onPressed: selectedOption != null onPressed: selectedOption != null
? () { ? () {
Navigator.pop(context); Navigator.pop(context);
widget.onChange(selectedOption!); onConfirm();
} }
: null, : null,
style: ButtonStyle( style: ButtonStyle(
@ -203,32 +251,4 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
], ],
); );
} }
if (widget.dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 500
),
child: content()
),
);
}
else {
return Padding(
padding: mediaQueryData.viewInsets,
child: Container(
height: Platform.isIOS ? 406 : 390,
decoration: BoxDecoration(
color: Theme.of(context).dialogBackgroundColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
),
child: content()
),
);
}
}
} }

View file

@ -197,7 +197,7 @@ class _SelectionScreenState extends State<SelectionScreen> with TickerProviderSt
), ),
_Tab( _Tab(
icon: Icons.gpp_bad_rounded, icon: Icons.gpp_bad_rounded,
text: AppLocalizations.of(context)!.blacklist, text: AppLocalizations.of(context)!.blacklists,
quantity: _selectedBlacklists.length quantity: _selectedBlacklists.length
), ),
] ]
@ -263,7 +263,7 @@ class _SelectionScreenState extends State<SelectionScreen> with TickerProviderSt
), ),
_Tab( _Tab(
icon: Icons.gpp_bad_rounded, icon: Icons.gpp_bad_rounded,
text: AppLocalizations.of(context)!.blacklist, text: AppLocalizations.of(context)!.blacklists,
quantity: _selectedBlacklists.length quantity: _selectedBlacklists.length
), ),
] ]
@ -336,7 +336,12 @@ class _Tab extends StatelessWidget {
children: [ children: [
Icon(icon), Icon(icon),
const SizedBox(width: 8), const SizedBox(width: 8),
Text(text), Flexible(
child: Text(
text,
overflow: TextOverflow.ellipsis,
)
),
const SizedBox(width: 8), const SizedBox(width: 8),
Container( Container(
height: 22, height: 22,

View file

@ -14,14 +14,14 @@ class HomeChart extends StatelessWidget {
final int hoursInterval; final int hoursInterval;
const HomeChart({ const HomeChart({
Key? key, super.key,
required this.data, required this.data,
required this.label, required this.label,
required this.primaryValue, required this.primaryValue,
required this.secondaryValue, required this.secondaryValue,
required this.color, required this.color,
required this.hoursInterval required this.hoursInterval
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -15,12 +15,12 @@ class MainSwitch extends StatelessWidget {
final Animation<double> animation; final Animation<double> animation;
const MainSwitch({ const MainSwitch({
Key? key, super.key,
required this.expandableController, required this.expandableController,
required this.updateBlocking, required this.updateBlocking,
required this.disableWithCountdown, required this.disableWithCountdown,
required this.animation, required this.animation,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -88,12 +88,11 @@ class _TopRow extends StatelessWidget {
final Animation<double> animation; final Animation<double> animation;
const _TopRow({ const _TopRow({
Key? key,
required this.legacyMode, required this.legacyMode,
required this.expandableController, required this.expandableController,
required this.updateBlocking, required this.updateBlocking,
required this.animation, required this.animation,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -102,9 +101,9 @@ class _TopRow extends StatelessWidget {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( Expanded(
child: Row(
children: [ children: [
if (legacyMode == false) ...[
RotationTransition( RotationTransition(
turns: animation, turns: animation,
child: Icon( child: Icon(
@ -116,12 +115,13 @@ class _TopRow extends StatelessWidget {
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
], Flexible(
Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
AppLocalizations.of(context)!.allProtections, AppLocalizations.of(context)!.allProtections,
overflow: TextOverflow.ellipsis,
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
), ),
@ -134,8 +134,11 @@ class _TopRow extends StatelessWidget {
] ]
], ],
), ),
),
], ],
), ),
),
const SizedBox(width: 8),
Switch( Switch(
value: statusProvider.serverStatus!.generalEnabled, value: statusProvider.serverStatus!.generalEnabled,
onChanged: statusProvider.protectionsManagementProcess.contains('general') == false onChanged: statusProvider.protectionsManagementProcess.contains('general') == false
@ -145,7 +148,7 @@ class _TopRow extends StatelessWidget {
} }
updateBlocking( updateBlocking(
value: value, value: value,
filter: legacyMode == true ? 'general_legacy' : 'general' filter: 'general'
); );
} : null, } : null,
) )
@ -158,9 +161,8 @@ class _BottomRow extends StatefulWidget {
final void Function(int) disableWithCountdown; final void Function(int) disableWithCountdown;
const _BottomRow({ const _BottomRow({
Key? key,
required this.disableWithCountdown, required this.disableWithCountdown,
}) : super(key: key); });
@override @override
State<_BottomRow> createState() => _BottomRowState(); State<_BottomRow> createState() => _BottomRowState();
@ -173,8 +175,12 @@ class _BottomRowState extends State<_BottomRow> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final statusProvider = Provider.of<StatusProvider>(context); final statusProvider = Provider.of<StatusProvider>(context);
final textScale = MediaQuery.of(context).textScaleFactor;
return Container( return Container(
height: Platform.isMacOS || Platform.isLinux || Platform.isWindows ? 50 : 40, height: Platform.isMacOS || Platform.isLinux || Platform.isWindows
? 50 * textScale
: 40 * textScale,
margin: const EdgeInsets.only(top: 8), margin: const EdgeInsets.only(top: 8),
child: Scrollbar( child: Scrollbar(
controller: _chipsScrollController, controller: _chipsScrollController,

View file

@ -181,12 +181,11 @@ class _Modal extends StatelessWidget {
final Animation<double> animation; final Animation<double> animation;
const _Modal({ const _Modal({
Key? key,
required this.expandableController, required this.expandableController,
required this.updateBlocking, required this.updateBlocking,
required this.disableWithCountdown, required this.disableWithCountdown,
required this.animation, required this.animation,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -9,17 +9,43 @@ class ServerStatusWidget extends StatelessWidget {
final ServerStatus serverStatus; final ServerStatus serverStatus;
const ServerStatusWidget({ const ServerStatusWidget({
Key? key, super.key,
required this.serverStatus, required this.serverStatus,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width; final width = MediaQuery.of(context).size.width;
final textScaleFactor = MediaQuery.of(context).textScaleFactor;
return Container( double boxSize() {
if (textScaleFactor < 1 || (textScaleFactor >= 1 && textScaleFactor < 1.15)) {
return 65;
}
else if (textScaleFactor >= 1.15 && textScaleFactor < 1.3) {
return 75;
}
else if (textScaleFactor >= 1.3 && textScaleFactor < 1.45) {
return 80;
}
else if (textScaleFactor >= 1.45 && textScaleFactor < 1.6) {
return 85;
}
else if (textScaleFactor >= 1.6 && textScaleFactor < 1.85) {
return 100;
}
else if (textScaleFactor >= 1.85) {
return 110;
}
else {
return 65;
}
}
return Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
AppLocalizations.of(context)!.serverStatus, AppLocalizations.of(context)!.serverStatus,
@ -30,16 +56,16 @@ class ServerStatusWidget extends StatelessWidget {
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
SizedBox( GridView(
height: width > 700 ? 66 : 146, primary: false,
child: GridView( shrinkWrap: true,
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: width > 700 ? 4 : 2, crossAxisCount: width > 700 ? 4 : 2,
crossAxisSpacing: 10, crossAxisSpacing: 10,
mainAxisSpacing: 10, mainAxisSpacing: 10,
mainAxisExtent: 65 mainAxisExtent: boxSize()
), ),
children: [ children: [
StatusBox( StatusBox(
@ -63,7 +89,6 @@ class ServerStatusWidget extends StatelessWidget {
isEnabled: serverStatus.safeSearchEnabled isEnabled: serverStatus.safeSearchEnabled
), ),
], ],
),
) )
], ],
), ),

View file

@ -9,11 +9,11 @@ class StatusBox extends StatelessWidget {
final bool isEnabled; final bool isEnabled;
const StatusBox({ const StatusBox({
Key? key, super.key,
required this.icon, required this.icon,
required this.label, required this.label,
required this.isEnabled required this.isEnabled
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -17,7 +17,7 @@ class LogsConfigOptions extends StatelessWidget {
final void Function() onConfirm; final void Function() onConfirm;
const LogsConfigOptions({ const LogsConfigOptions({
Key? key, super.key,
required this.generalSwitch, required this.generalSwitch,
required this.updateGeneralSwitch, required this.updateGeneralSwitch,
required this.anonymizeClientIp, required this.anonymizeClientIp,
@ -27,10 +27,12 @@ class LogsConfigOptions extends StatelessWidget {
required this.updateRetentionTime, required this.updateRetentionTime,
required this.onClear, required this.onClear,
required this.onConfirm required this.onConfirm
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width;
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -111,12 +113,14 @@ class LogsConfigOptions extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Flexible(
child: Text(
AppLocalizations.of(context)!.anonymizeClientIp, AppLocalizations.of(context)!.anonymizeClientIp,
style: const TextStyle( style: const TextStyle(
fontSize: 16 fontSize: 16
), ),
), ),
),
Switch( Switch(
value: anonymizeClientIp, value: anonymizeClientIp,
onChanged: updateAnonymizeClientIp, onChanged: updateAnonymizeClientIp,
@ -159,13 +163,21 @@ class LogsConfigOptions extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
TextButton( if (width > 500) TextButton(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
onClear(); onClear();
}, },
child: Text(AppLocalizations.of(context)!.clearLogs) child: Text(AppLocalizations.of(context)!.clearLogs)
), ),
if (width <= 500) IconButton(
onPressed: () {
Navigator.pop(context);
onClear();
},
icon: const Icon(Icons.delete_rounded),
tooltip: AppLocalizations.of(context)!.clearLogs,
),
Row( Row(
children: [ children: [
TextButton( TextButton(
@ -174,7 +186,7 @@ class LogsConfigOptions extends StatelessWidget {
), ),
const SizedBox(width: 20), const SizedBox(width: 20),
TextButton( TextButton(
onPressed: retentionTime != '' onPressed: retentionTime != null
? () { ? () {
Navigator.pop(context); Navigator.pop(context);
onConfirm(); onConfirm();
@ -183,7 +195,7 @@ class LogsConfigOptions extends StatelessWidget {
child: Text( child: Text(
AppLocalizations.of(context)!.confirm, AppLocalizations.of(context)!.confirm,
style: TextStyle( style: TextStyle(
color: retentionTime != '' color: retentionTime != null
? Theme.of(context).colorScheme.primary ? Theme.of(context).colorScheme.primary
: Colors.grey : Colors.grey
), ),
@ -201,7 +213,7 @@ class LogsConfigOptions extends StatelessWidget {
} }
class ConfigLogsLoading extends StatelessWidget { class ConfigLogsLoading extends StatelessWidget {
const ConfigLogsLoading({Key? key}) : super(key: key); const ConfigLogsLoading({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -232,7 +244,7 @@ class ConfigLogsLoading extends StatelessWidget {
} }
class ConfigLogsError extends StatelessWidget { class ConfigLogsError extends StatelessWidget {
const ConfigLogsError({Key? key}) : super(key: key); const ConfigLogsError({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -143,7 +143,6 @@ class _LogsConfigModalState extends State<LogsConfigModal> {
} }
else { else {
return Container( return Container(
height: Platform.isIOS ? 436 : 420,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28), topLeft: Radius.circular(28),

View file

@ -12,10 +12,10 @@ class ClientsModal extends StatefulWidget {
final bool dialog; final bool dialog;
const ClientsModal({ const ClientsModal({
Key? key, super.key,
required this.value, required this.value,
required this.dialog required this.dialog
}) : super(key: key); });
@override @override
State<ClientsModal> createState() => _ClientsModalState(); State<ClientsModal> createState() => _ClientsModalState();
@ -75,10 +75,9 @@ class _ModalContent extends StatelessWidget {
final void Function(List<String>) onClientsSelected; final void Function(List<String>) onClientsSelected;
const _ModalContent({ const _ModalContent({
Key? key,
required this.selectedClients, required this.selectedClients,
required this.onClientsSelected, required this.onClientsSelected,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -188,11 +187,10 @@ class _ListItem extends StatelessWidget {
final void Function(bool) onChanged; final void Function(bool) onChanged;
const _ListItem({ const _ListItem({
Key? key,
required this.label, required this.label,
required this.checkboxActive, required this.checkboxActive,
required this.onChanged, required this.onChanged,
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -11,10 +11,10 @@ class FilterStatusModal extends StatefulWidget {
final bool dialog; final bool dialog;
const FilterStatusModal({ const FilterStatusModal({
Key? key, super.key,
required this.value, required this.value,
required this.dialog required this.dialog
}) : super(key: key); });
@override @override
State<FilterStatusModal> createState() => _FilterStatusModalState(); State<FilterStatusModal> createState() => _FilterStatusModalState();
@ -39,51 +39,52 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
Navigator.pop(context); Navigator.pop(context);
} }
Widget filterStatusListItem({ if (widget.dialog == true) {
required String id, return Dialog(
required IconData icon, child: ConstrainedBox(
required String label, constraints: const BoxConstraints(
required void Function(String?) onChanged maxWidth: 400
}) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () => onChanged(id),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(
icon,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
const SizedBox(width: 16),
Text(
label,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface
), ),
child: _Content(
onApply: apply,
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
selectedResultStatus: selectedResultStatus,
) )
],
),
Radio(
value: id,
groupValue: selectedResultStatus,
onChanged: onChanged
)
],
),
),
), ),
); );
} }
else {
return Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
color: Theme.of(context).dialogBackgroundColor
),
child: _Content(
onApply: apply,
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
selectedResultStatus: selectedResultStatus,
)
);
}
}
}
Widget content() { class _Content extends StatelessWidget {
final String selectedResultStatus;
final void Function(String) updateSelectedResultStatus;
final void Function() onApply;
const _Content({
required this.selectedResultStatus,
required this.updateSelectedResultStatus,
required this.onApply,
});
@override
Widget build(BuildContext context) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -120,55 +121,62 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
], ],
), ),
Container(height: 16), Container(height: 16),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "all", id: "all",
icon: Icons.shield_rounded, icon: Icons.shield_rounded,
label: AppLocalizations.of(context)!.all, label: AppLocalizations.of(context)!.all,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "filtered", id: "filtered",
icon: Icons.shield_rounded, icon: Icons.shield_rounded,
label: AppLocalizations.of(context)!.filtered, label: AppLocalizations.of(context)!.filtered,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "processed", id: "processed",
icon: Icons.verified_user_rounded, icon: Icons.verified_user_rounded,
label: AppLocalizations.of(context)!.processedRow, label: AppLocalizations.of(context)!.processedRow,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "whitelisted", id: "whitelisted",
icon: Icons.verified_user_rounded, icon: Icons.verified_user_rounded,
label: AppLocalizations.of(context)!.processedWhitelistRow, label: AppLocalizations.of(context)!.processedWhitelistRow,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "blocked", id: "blocked",
icon: Icons.gpp_bad_rounded, icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blocked, label: AppLocalizations.of(context)!.blocked,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "blocked_safebrowsing", id: "blocked_safebrowsing",
icon: Icons.gpp_bad_rounded, icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedSafeBrowsingRow, label: AppLocalizations.of(context)!.blockedSafeBrowsingRow,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "blocked_parental", id: "blocked_parental",
icon: Icons.gpp_bad_rounded, icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedParentalRow, label: AppLocalizations.of(context)!.blockedParentalRow,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
filterStatusListItem( _Item(
selectedResultStatus: selectedResultStatus,
id: "safe_search", id: "safe_search",
icon: Icons.gpp_bad_rounded, icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedSafeSearchRow, label: AppLocalizations.of(context)!.blockedSafeSearchRow,
onChanged: (value) => setState(() => selectedResultStatus = value!) onChanged: updateSelectedResultStatus
), ),
], ],
), ),
), ),
@ -179,7 +187,7 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
TextButton( TextButton(
onPressed: apply, onPressed: onApply,
child: Text(AppLocalizations.of(context)!.apply) child: Text(AppLocalizations.of(context)!.apply)
) )
], ],
@ -189,28 +197,64 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
], ],
); );
} }
}
if (widget.dialog == true) { class _Item extends StatelessWidget {
return Dialog( final String selectedResultStatus;
child: ConstrainedBox( final String id;
constraints: const BoxConstraints( final IconData icon;
maxWidth: 400 final String label;
final void Function(String) onChanged;
const _Item({
required this.selectedResultStatus,
required this.id,
required this.icon,
required this.label,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () => onChanged(id),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Row(
children: [
Icon(
icon,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
const SizedBox(width: 16),
Flexible(
child: Text(
label,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface
),
),
)
],
),
),
Radio(
value: id,
groupValue: selectedResultStatus,
onChanged: (v) => onChanged(v!)
)
],
),
), ),
child: content()
), ),
); );
} }
else {
return Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
color: Theme.of(context).dialogBackgroundColor
),
child: content()
);
}
}
} }

View file

@ -8,10 +8,10 @@ class AddStaticLeaseModal extends StatefulWidget {
final bool dialog; final bool dialog;
const AddStaticLeaseModal({ const AddStaticLeaseModal({
Key? key, super.key,
required this.onConfirm, required this.onConfirm,
required this.dialog required this.dialog
}) : super(key: key); });
@override @override
State<AddStaticLeaseModal> createState() => _AddStaticLeaseModalState(); State<AddStaticLeaseModal> createState() => _AddStaticLeaseModalState();
@ -80,7 +80,8 @@ class _AddStaticLeaseModalState extends State<AddStaticLeaseModal> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Column( Flexible(
child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(top: 24), padding: const EdgeInsets.only(top: 24),
@ -101,6 +102,7 @@ class _AddStaticLeaseModalState extends State<AddStaticLeaseModal> {
), ),
], ],
), ),
),
], ],
), ),
), ),

View file

@ -414,6 +414,7 @@ class _DhcpScreenState extends State<DhcpScreen> {
const SizedBox(height: 30), const SizedBox(height: 30),
Text( Text(
AppLocalizations.of(context)!.loadingDhcp, AppLocalizations.of(context)!.loadingDhcp,
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,

View file

@ -8,10 +8,10 @@ class DhcpInterfaceItem extends StatelessWidget {
final void Function(NetworkInterface) onSelect; final void Function(NetworkInterface) onSelect;
const DhcpInterfaceItem({ const DhcpInterfaceItem({
Key? key, super.key,
required this.networkInterface, required this.networkInterface,
required this.onSelect required this.onSelect
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -56,6 +56,7 @@ class DhcpInterfaceItem extends StatelessWidget {
const SizedBox(height: 5), const SizedBox(height: 5),
if (networkInterface.flags.isNotEmpty) ...[ if (networkInterface.flags.isNotEmpty) ...[
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Flags: ", "Flags: ",
@ -64,13 +65,15 @@ class DhcpInterfaceItem extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurfaceVariant color: Theme.of(context).colorScheme.onSurfaceVariant
), ),
), ),
Text( Flexible(
child: Text(
networkInterface.flags.join(', '), networkInterface.flags.join(', '),
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Theme.of(context).colorScheme.onSurfaceVariant color: Theme.of(context).colorScheme.onSurfaceVariant
), ),
), ),
),
], ],
), ),
const SizedBox(height: 5), const SizedBox(height: 5),

View file

@ -13,11 +13,11 @@ class SelectInterfaceModal extends StatelessWidget {
final bool dialog; final bool dialog;
const SelectInterfaceModal({ const SelectInterfaceModal({
Key? key, super.key,
required this.interfaces, required this.interfaces,
required this.onSelect, required this.onSelect,
required this.dialog required this.dialog
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -5,9 +5,9 @@ class ClearDnsCacheDialog extends StatelessWidget {
final void Function() onConfirm; final void Function() onConfirm;
const ClearDnsCacheDialog({ const ClearDnsCacheDialog({
Key? key, super.key,
required this.onConfirm required this.onConfirm
}) : super(key: key); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -22,6 +22,7 @@ class ClearDnsCacheDialog extends StatelessWidget {
const SizedBox(height: 16), const SizedBox(height: 16),
Text( Text(
AppLocalizations.of(context)!.clearDnsCache, AppLocalizations.of(context)!.clearDnsCache,
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 24, fontSize: 24,
color: Theme.of(context).colorScheme.onSurface color: Theme.of(context).colorScheme.onSurface

View file

@ -19,7 +19,7 @@ import 'package:adguard_home_manager/models/rewrite_rules.dart';
import 'package:adguard_home_manager/classes/process_modal.dart'; import 'package:adguard_home_manager/classes/process_modal.dart';
class DnsRewritesScreen extends StatefulWidget { class DnsRewritesScreen extends StatefulWidget {
const DnsRewritesScreen({Key? key}) : super(key: key); const DnsRewritesScreen({super.key});
@override @override
State<DnsRewritesScreen> createState() => _DnsRewritesScreenState(); State<DnsRewritesScreen> createState() => _DnsRewritesScreenState();
@ -152,6 +152,7 @@ class _DnsRewritesScreenState extends State<DnsRewritesScreen> {
const SizedBox(height: 30), const SizedBox(height: 30),
Text( Text(
AppLocalizations.of(context)!.loadingRewriteRules, AppLocalizations.of(context)!.loadingRewriteRules,
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,
@ -305,6 +306,7 @@ class _DnsRewritesScreenState extends State<DnsRewritesScreen> {
const SizedBox(height: 30), const SizedBox(height: 30),
Text( Text(
AppLocalizations.of(context)!.rewriteRulesNotLoaded, AppLocalizations.of(context)!.rewriteRulesNotLoaded,
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,

View file

@ -177,12 +177,14 @@ class _SafeSearchSettingsScreenState extends State<SafeSearchSettingsScreen> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Flexible(
child: Text(
AppLocalizations.of(context)!.enableSafeSearch, AppLocalizations.of(context)!.enableSafeSearch,
style: const TextStyle( style: const TextStyle(
fontSize: 18 fontSize: 18
), ),
), ),
),
Switch( Switch(
value: generalEnabled, value: generalEnabled,
onChanged: (value) => setState(() => generalEnabled = value) onChanged: (value) => setState(() => generalEnabled = value)

View file

@ -29,13 +29,15 @@ class CustomListTileDialog extends StatelessWidget {
), ),
const SizedBox(width: 24), const SizedBox(width: 24),
], ],
Text( Flexible(
child: Text(
title, title,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: Theme.of(context).colorScheme.onSurface, color: Theme.of(context).colorScheme.onSurface,
), ),
),
) )
], ],
), ),