Some improvements

This commit is contained in:
Juan Gilsanz Polo 2022-10-02 04:25:11 +02:00
parent f6b747f729
commit a5ba156e95
5 changed files with 124 additions and 78 deletions

View file

@ -3,6 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:adguard_home_manager/screens/logs/log_list_tile.dart';
import 'package:adguard_home_manager/functions/get_filtered_status.dart';
import 'package:adguard_home_manager/functions/format_time.dart';
import 'package:adguard_home_manager/models/logs.dart';
@ -18,54 +19,15 @@ class LogDetailsModal extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool isLogBlocked() {
switch (log.reason) {
case 'NotFilteredNotFound':
return false;
case 'NotFilteredWhiteList':
return true;
case 'FilteredBlackList':
return true;
default:
return true;
}
}
Widget getResult() {
switch (log.reason) {
case 'NotFilteredNotFound':
return Text(
AppLocalizations.of(context)!.processed,
style: const TextStyle(
color: Colors.green,
fontWeight: FontWeight.w500
),
);
case 'NotFilteredWhiteList':
return Text(
AppLocalizations.of(context)!.processedWhitelist,
style: const TextStyle(
color: Colors.green,
fontWeight: FontWeight.w500
),
);
case 'FilteredBlackList':
return Text(
AppLocalizations.of(context)!.blockedBlacklist,
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.w500
),
);
default:
return const Text("");
}
final filter = getFilteredStatus(context, log.reason);
return Text(
filter['label'],
style: TextStyle(
color: filter['color'],
fontWeight: FontWeight.w500
),
);
}
return DraggableScrollableSheet(
@ -228,11 +190,11 @@ class LogDetailsModal extends StatelessWidget {
children: [
TextButton(
onPressed: () {
blockUnblock(log, isLogBlocked() == true ? 'unblock' : 'block');
blockUnblock(log, getFilteredStatus(context, log.reason)['filtered'] == true ? 'unblock' : 'block');
Navigator.pop(context);
},
child: Text(
isLogBlocked() == true
getFilteredStatus(context, log.reason)['filtered'] == true
? AppLocalizations.of(context)!.unblockDomain
: AppLocalizations.of(context)!.blockDomain
)

View file

@ -6,6 +6,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:adguard_home_manager/screens/logs/log_details_modal.dart';
import 'package:adguard_home_manager/functions/get_filtered_status.dart';
import 'package:adguard_home_manager/models/filtering_status.dart';
import 'package:adguard_home_manager/classes/process_modal.dart';
import 'package:adguard_home_manager/providers/servers_provider.dart';
@ -57,35 +58,12 @@ class LogTile extends StatelessWidget {
}
Widget generateLogStatus() {
switch (log.reason) {
case "NotFilteredNotFound":
return logStatusWidget(
icon: Icons.verified_user_rounded,
color: Colors.green,
text: AppLocalizations.of(context)!.processed,
);
case "FilteredBlackList":
return logStatusWidget(
icon: Icons.verified_user_rounded,
color: Colors.red,
text: AppLocalizations.of(context)!.blockedBlacklist,
);
case "NotFilteredWhiteList":
return logStatusWidget(
icon: Icons.verified_user_rounded,
color: Colors.green,
text: AppLocalizations.of(context)!.processedWhitelist,
);
default:
return logStatusWidget(
icon: Icons.shield_rounded,
color: Colors.grey,
text: "Unknwon"
);
}
final filter = getFilteredStatus(context, log.reason);
return logStatusWidget(
icon: filter['icon'],
color: filter['color'],
text: filter['label'],
);
}
void blockUnblock(Log log, String newStatus) async {