mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-03 03:44:49 +00:00
Bug fixes
This commit is contained in:
parent
0e6cde57f0
commit
e5a971f3a3
6 changed files with 273 additions and 274 deletions
|
@ -214,7 +214,7 @@ class _MainState extends State<Main> with WidgetsBindingObserver {
|
||||||
isBeta: appConfigProvider.getAppInfo!.version.contains('beta'),
|
isBeta: appConfigProvider.getAppInfo!.version.contains('beta'),
|
||||||
);
|
);
|
||||||
if (result != null && appConfigProvider.doNotRememberVersion != result.tagName && mounted) {
|
if (result != null && appConfigProvider.doNotRememberVersion != result.tagName && mounted) {
|
||||||
await showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => UpdateModal(
|
builder: (context) => UpdateModal(
|
||||||
gitHubRelease: result,
|
gitHubRelease: result,
|
||||||
|
|
|
@ -188,7 +188,6 @@ class _AddedListState extends State<AddedList> {
|
||||||
: null,
|
: null,
|
||||||
onDelete: openDeleteModal,
|
onDelete: openDeleteModal,
|
||||||
splitView: widget.splitView,
|
splitView: widget.splitView,
|
||||||
serverVersion: statusProvider.serverStatus!.serverVersion,
|
|
||||||
),
|
),
|
||||||
noData: SizedBox(
|
noData: SizedBox(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
||||||
|
|
||||||
|
import 'package:adguard_home_manager/providers/status_provider.dart';
|
||||||
import 'package:adguard_home_manager/functions/compare_versions.dart';
|
import 'package:adguard_home_manager/functions/compare_versions.dart';
|
||||||
import 'package:adguard_home_manager/functions/copy_clipboard.dart';
|
import 'package:adguard_home_manager/functions/copy_clipboard.dart';
|
||||||
import 'package:adguard_home_manager/models/clients.dart';
|
import 'package:adguard_home_manager/models/clients.dart';
|
||||||
|
@ -18,7 +19,6 @@ class AddedClientTile extends StatelessWidget {
|
||||||
final void Function(Client) onDelete;
|
final void Function(Client) onDelete;
|
||||||
final Client? selectedClient;
|
final Client? selectedClient;
|
||||||
final bool? splitView;
|
final bool? splitView;
|
||||||
final String serverVersion;
|
|
||||||
|
|
||||||
const AddedClientTile({
|
const AddedClientTile({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -29,11 +29,11 @@ class AddedClientTile extends StatelessWidget {
|
||||||
required this.onDelete,
|
required this.onDelete,
|
||||||
this.selectedClient,
|
this.selectedClient,
|
||||||
required this.splitView,
|
required this.splitView,
|
||||||
required this.serverVersion
|
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final statusProvider = Provider.of<StatusProvider>(context);
|
||||||
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
||||||
|
|
||||||
if (splitView == true) {
|
if (splitView == true) {
|
||||||
|
@ -147,7 +147,7 @@ class AddedClientTile extends StatelessWidget {
|
||||||
Icons.search_rounded,
|
Icons.search_rounded,
|
||||||
size: 19,
|
size: 19,
|
||||||
color: serverVersionIsAhead(
|
color: serverVersionIsAhead(
|
||||||
currentVersion: serverVersion,
|
currentVersion: statusProvider.serverStatus!.serverVersion,
|
||||||
referenceVersion: 'v0.107.28',
|
referenceVersion: 'v0.107.28',
|
||||||
referenceVersionBeta: 'v0.108.0-b.33'
|
referenceVersionBeta: 'v0.108.0-b.33'
|
||||||
) == true
|
) == true
|
||||||
|
@ -261,7 +261,7 @@ class AddedClientTile extends StatelessWidget {
|
||||||
Icons.search_rounded,
|
Icons.search_rounded,
|
||||||
size: 19,
|
size: 19,
|
||||||
color: serverVersionIsAhead(
|
color: serverVersionIsAhead(
|
||||||
currentVersion: serverVersion,
|
currentVersion: statusProvider.serverStatus!.serverVersion,
|
||||||
referenceVersion: 'v0.107.28',
|
referenceVersion: 'v0.107.28',
|
||||||
referenceVersionBeta: 'v0.108.0-b.33'
|
referenceVersionBeta: 'v0.108.0-b.33'
|
||||||
) == true
|
) == true
|
||||||
|
|
|
@ -73,258 +73,7 @@ class FiltersTripleColumn extends StatelessWidget {
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget content() {
|
|
||||||
switch (filteringProvider.loadStatus) {
|
|
||||||
case LoadStatus.loading:
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const CircularProgressIndicator(),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.loadingFilters,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
case LoadStatus.loaded:
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.whitelists,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w500
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AddFiltersButton(
|
|
||||||
type: 'whitelist',
|
|
||||||
widget: (fn) => IconButton(
|
|
||||||
onPressed: fn,
|
|
||||||
icon: const Icon(Icons.add_rounded),
|
|
||||||
tooltip: AppLocalizations.of(context)!.addWhitelist,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: filteringProvider.filtering!.whitelistFilters.length,
|
|
||||||
itemBuilder: (context, index) => ListOptionsMenu(
|
|
||||||
list: filteringProvider.filtering!.whitelistFilters[index],
|
|
||||||
listType: 'whitelist',
|
|
||||||
child: CustomListTile(
|
|
||||||
title: filteringProvider.filtering!.whitelistFilters[index].name,
|
|
||||||
subtitle: "${intFormat(filteringProvider.filtering!.whitelistFilters[index].rulesCount, Platform.localeName)} ${AppLocalizations.of(context)!.enabledRules}",
|
|
||||||
trailing: Icon(
|
|
||||||
filteringProvider.filtering!.whitelistFilters[index].enabled == true
|
|
||||||
? Icons.check_circle_rounded
|
|
||||||
: Icons.cancel,
|
|
||||||
color: filteringProvider.filtering!.whitelistFilters[index].enabled == true
|
|
||||||
? appConfigProvider.useThemeColorForStatus == true
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Colors.green
|
|
||||||
: appConfigProvider.useThemeColorForStatus == true
|
|
||||||
? Colors.grey
|
|
||||||
: Colors.red
|
|
||||||
),
|
|
||||||
onTap: () => onOpenDetailsModal(filteringProvider.filtering!.whitelistFilters[index], 'whitelist'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.blacklists,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w500
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AddFiltersButton(
|
|
||||||
type: 'blacklist',
|
|
||||||
widget: (fn) => IconButton(
|
|
||||||
onPressed: fn,
|
|
||||||
icon: const Icon(Icons.add_rounded),
|
|
||||||
tooltip: AppLocalizations.of(context)!.addBlacklist,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: filteringProvider.filtering!.filters.length,
|
|
||||||
itemBuilder: (context, index) => ListOptionsMenu(
|
|
||||||
list: filteringProvider.filtering!.filters[index],
|
|
||||||
listType: 'blacklist',
|
|
||||||
child: CustomListTile(
|
|
||||||
title: filteringProvider.filtering!.filters[index].name,
|
|
||||||
subtitle: "${intFormat(filteringProvider.filtering!.filters[index].rulesCount, Platform.localeName)} ${AppLocalizations.of(context)!.enabledRules}",
|
|
||||||
trailing: Icon(
|
|
||||||
filteringProvider.filtering!.filters[index].enabled == true
|
|
||||||
? Icons.check_circle_rounded
|
|
||||||
: Icons.cancel,
|
|
||||||
color: filteringProvider.filtering!.filters[index].enabled == true
|
|
||||||
? appConfigProvider.useThemeColorForStatus == true
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Colors.green
|
|
||||||
: appConfigProvider.useThemeColorForStatus == true
|
|
||||||
? Colors.grey
|
|
||||||
: Colors.red
|
|
||||||
),
|
|
||||||
onTap: () => onOpenDetailsModal(filteringProvider.filtering!.filters[index], 'blacklist'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.customRules,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w500
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AddFiltersButton(
|
|
||||||
type: '',
|
|
||||||
widget: (fn) => IconButton(
|
|
||||||
onPressed: fn,
|
|
||||||
icon: const Icon(Icons.add_rounded),
|
|
||||||
tooltip: AppLocalizations.of(context)!.addCustomRule,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: filteringProvider.filtering!.userRules.length,
|
|
||||||
itemBuilder: (context, index) => ContextMenuArea(
|
|
||||||
builder: (context) => [
|
|
||||||
CustomListTile(
|
|
||||||
title: AppLocalizations.of(context)!.copyClipboard,
|
|
||||||
icon: Icons.copy_rounded,
|
|
||||||
onTap: () {
|
|
||||||
copyToClipboard(
|
|
||||||
value: filteringProvider.filtering!.userRules[index],
|
|
||||||
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
|
||||||
);
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: CustomListTile(
|
|
||||||
onLongPress: () => showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => OptionsModal(
|
|
||||||
options: [
|
|
||||||
MenuOption(
|
|
||||||
title: AppLocalizations.of(context)!.copyClipboard,
|
|
||||||
icon: Icons.copy_rounded,
|
|
||||||
action: () => copyToClipboard(
|
|
||||||
value: filteringProvider.filtering!.userRules[index],
|
|
||||||
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
title: filteringProvider.filtering!.userRules[index],
|
|
||||||
subtitleWidget: generateSubtitle(filteringProvider.filtering!.userRules[index]),
|
|
||||||
trailing: IconButton(
|
|
||||||
onPressed: () => onRemoveCustomRule(filteringProvider.filtering!.userRules[index]),
|
|
||||||
icon: const Icon(Icons.delete),
|
|
||||||
tooltip: AppLocalizations.of(context)!.delete,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
case LoadStatus.error:
|
|
||||||
return SizedBox.expand(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
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)!.filtersNotLoaded,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -334,7 +83,7 @@ class FiltersTripleColumn extends StatelessWidget {
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final result = await filteringProvider.fetchFilters();
|
final result = await filteringProvider.fetchFilters();
|
||||||
if (result == false) {
|
if (result == false && context.mounted) {
|
||||||
showSnacbkar(
|
showSnacbkar(
|
||||||
appConfigProvider: appConfigProvider,
|
appConfigProvider: appConfigProvider,
|
||||||
label: AppLocalizations.of(context)!.errorLoadFilters,
|
label: AppLocalizations.of(context)!.errorLoadFilters,
|
||||||
|
@ -348,7 +97,258 @@ class FiltersTripleColumn extends StatelessWidget {
|
||||||
...actions
|
...actions
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: content(),
|
body: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
switch (filteringProvider.loadStatus) {
|
||||||
|
case LoadStatus.loading:
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const CircularProgressIndicator(),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.loadingFilters,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
case LoadStatus.loaded:
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.whitelists,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AddFiltersButton(
|
||||||
|
type: 'whitelist',
|
||||||
|
widget: (fn) => IconButton(
|
||||||
|
onPressed: fn,
|
||||||
|
icon: const Icon(Icons.add_rounded),
|
||||||
|
tooltip: AppLocalizations.of(context)!.addWhitelist,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: filteringProvider.filtering!.whitelistFilters.length,
|
||||||
|
itemBuilder: (context, index) => ListOptionsMenu(
|
||||||
|
list: filteringProvider.filtering!.whitelistFilters[index],
|
||||||
|
listType: 'whitelist',
|
||||||
|
child: CustomListTile(
|
||||||
|
title: filteringProvider.filtering!.whitelistFilters[index].name,
|
||||||
|
subtitle: "${intFormat(filteringProvider.filtering!.whitelistFilters[index].rulesCount, Platform.localeName)} ${AppLocalizations.of(context)!.enabledRules}",
|
||||||
|
trailing: Icon(
|
||||||
|
filteringProvider.filtering!.whitelistFilters[index].enabled == true
|
||||||
|
? Icons.check_circle_rounded
|
||||||
|
: Icons.cancel,
|
||||||
|
color: filteringProvider.filtering!.whitelistFilters[index].enabled == true
|
||||||
|
? appConfigProvider.useThemeColorForStatus == true
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Colors.green
|
||||||
|
: appConfigProvider.useThemeColorForStatus == true
|
||||||
|
? Colors.grey
|
||||||
|
: Colors.red
|
||||||
|
),
|
||||||
|
onTap: () => onOpenDetailsModal(filteringProvider.filtering!.whitelistFilters[index], 'whitelist'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.blacklists,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AddFiltersButton(
|
||||||
|
type: 'blacklist',
|
||||||
|
widget: (fn) => IconButton(
|
||||||
|
onPressed: fn,
|
||||||
|
icon: const Icon(Icons.add_rounded),
|
||||||
|
tooltip: AppLocalizations.of(context)!.addBlacklist,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: filteringProvider.filtering!.filters.length,
|
||||||
|
itemBuilder: (context, index) => ListOptionsMenu(
|
||||||
|
list: filteringProvider.filtering!.filters[index],
|
||||||
|
listType: 'blacklist',
|
||||||
|
child: CustomListTile(
|
||||||
|
title: filteringProvider.filtering!.filters[index].name,
|
||||||
|
subtitle: "${intFormat(filteringProvider.filtering!.filters[index].rulesCount, Platform.localeName)} ${AppLocalizations.of(context)!.enabledRules}",
|
||||||
|
trailing: Icon(
|
||||||
|
filteringProvider.filtering!.filters[index].enabled == true
|
||||||
|
? Icons.check_circle_rounded
|
||||||
|
: Icons.cancel,
|
||||||
|
color: filteringProvider.filtering!.filters[index].enabled == true
|
||||||
|
? appConfigProvider.useThemeColorForStatus == true
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Colors.green
|
||||||
|
: appConfigProvider.useThemeColorForStatus == true
|
||||||
|
? Colors.grey
|
||||||
|
: Colors.red
|
||||||
|
),
|
||||||
|
onTap: () => onOpenDetailsModal(filteringProvider.filtering!.filters[index], 'blacklist'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.customRules,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AddFiltersButton(
|
||||||
|
type: '',
|
||||||
|
widget: (fn) => IconButton(
|
||||||
|
onPressed: fn,
|
||||||
|
icon: const Icon(Icons.add_rounded),
|
||||||
|
tooltip: AppLocalizations.of(context)!.addCustomRule,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: filteringProvider.filtering!.userRules.length,
|
||||||
|
itemBuilder: (context, index) => ContextMenuArea(
|
||||||
|
builder: (context) => [
|
||||||
|
CustomListTile(
|
||||||
|
title: AppLocalizations.of(context)!.copyClipboard,
|
||||||
|
icon: Icons.copy_rounded,
|
||||||
|
onTap: () {
|
||||||
|
copyToClipboard(
|
||||||
|
value: filteringProvider.filtering!.userRules[index],
|
||||||
|
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
||||||
|
);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: CustomListTile(
|
||||||
|
onLongPress: () => showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => OptionsModal(
|
||||||
|
options: [
|
||||||
|
MenuOption(
|
||||||
|
title: AppLocalizations.of(context)!.copyClipboard,
|
||||||
|
icon: Icons.copy_rounded,
|
||||||
|
action: () => copyToClipboard(
|
||||||
|
value: filteringProvider.filtering!.userRules[index],
|
||||||
|
successMessage: AppLocalizations.of(context)!.copiedClipboard,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
title: filteringProvider.filtering!.userRules[index],
|
||||||
|
subtitleWidget: generateSubtitle(filteringProvider.filtering!.userRules[index]),
|
||||||
|
trailing: IconButton(
|
||||||
|
onPressed: () => onRemoveCustomRule(filteringProvider.filtering!.userRules[index]),
|
||||||
|
icon: const Icon(Icons.delete),
|
||||||
|
tooltip: AppLocalizations.of(context)!.delete,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
case LoadStatus.error:
|
||||||
|
return SizedBox.expand(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
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)!.filtersNotLoaded,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,8 +11,8 @@ class LogsConfigOptions extends StatelessWidget {
|
||||||
final bool anonymizeClientIp;
|
final bool anonymizeClientIp;
|
||||||
final void Function(bool) updateAnonymizeClientIp;
|
final void Function(bool) updateAnonymizeClientIp;
|
||||||
final List<RetentionItem> retentionItems;
|
final List<RetentionItem> retentionItems;
|
||||||
final String? retentionTime;
|
final double? retentionTime;
|
||||||
final void Function(String?) updateRetentionTime;
|
final void Function(double?) updateRetentionTime;
|
||||||
final void Function() onClear;
|
final void Function() onClear;
|
||||||
final void Function() onConfirm;
|
final void Function() onConfirm;
|
||||||
|
|
||||||
|
@ -130,14 +130,12 @@ class LogsConfigOptions extends StatelessWidget {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
child: DropdownButtonFormField(
|
child: DropdownButtonFormField(
|
||||||
items: retentionItems.map<DropdownMenuItem<String>>((item) {
|
items: retentionItems.map((item) => DropdownMenuItem(
|
||||||
return DropdownMenuItem<String>(
|
value: item.value,
|
||||||
value: item.value.toString(),
|
child: Text(item.label),
|
||||||
child: Text(item.label),
|
)).toList(),
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
value: retentionTime,
|
value: retentionTime,
|
||||||
onChanged: (value) => updateRetentionTime(value),
|
onChanged: (value) => updateRetentionTime(value as double),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
|
|
|
@ -79,7 +79,7 @@ class LogsConfigModalWidget extends StatefulWidget {
|
||||||
class _LogsConfigModalWidgetState extends State<LogsConfigModalWidget> {
|
class _LogsConfigModalWidgetState extends State<LogsConfigModalWidget> {
|
||||||
bool generalSwitch = false;
|
bool generalSwitch = false;
|
||||||
bool anonymizeClientIp = false;
|
bool anonymizeClientIp = false;
|
||||||
String? retentionTime = "";
|
double? retentionTime;
|
||||||
|
|
||||||
List<RetentionItem> retentionItems = [];
|
List<RetentionItem> retentionItems = [];
|
||||||
|
|
||||||
|
@ -101,8 +101,10 @@ class _LogsConfigModalWidgetState extends State<LogsConfigModalWidget> {
|
||||||
setState(() {
|
setState(() {
|
||||||
generalSwitch = result['data']['enabled'];
|
generalSwitch = result['data']['enabled'];
|
||||||
anonymizeClientIp = result['data']['anonymize_client_ip'];
|
anonymizeClientIp = result['data']['anonymize_client_ip'];
|
||||||
retentionTime = result['data']['interval'].toString();
|
retentionTime = result['data']['interval'] != null
|
||||||
loadStatus = LoadStatus.loading;
|
? double.parse(result['data']['interval'].toString())
|
||||||
|
: null;
|
||||||
|
loadStatus = LoadStatus.loaded;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -191,7 +193,7 @@ class _LogsConfigModalWidgetState extends State<LogsConfigModalWidget> {
|
||||||
onClear: () => widget.onClear(),
|
onClear: () => widget.onClear(),
|
||||||
onConfirm: () => widget.onConfirm({
|
onConfirm: () => widget.onConfirm({
|
||||||
"enabled": generalSwitch,
|
"enabled": generalSwitch,
|
||||||
"interval": double.parse(retentionTime!),
|
"interval": retentionTime,
|
||||||
"anonymize_client_ip": anonymizeClientIp
|
"anonymize_client_ip": anonymizeClientIp
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -235,7 +237,7 @@ class _LogsConfigModalWidgetState extends State<LogsConfigModalWidget> {
|
||||||
onClear: () => widget.onClear(),
|
onClear: () => widget.onClear(),
|
||||||
onConfirm: () => widget.onConfirm({
|
onConfirm: () => widget.onConfirm({
|
||||||
"enabled": generalSwitch,
|
"enabled": generalSwitch,
|
||||||
"interval": double.parse(retentionTime!),
|
"interval": retentionTime,
|
||||||
"anonymize_client_ip": anonymizeClientIp
|
"anonymize_client_ip": anonymizeClientIp
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue