Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
JGeek00 committed Jan 30, 2024
2 parents 1a7925f + 3eaf714 commit f8f3914
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 161 deletions.
2 changes: 1 addition & 1 deletion lib/models/applied_filters.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AppliedFiters {
String selectedResultStatus = 'all';
String? searchText;
List<String>? clients;
List<String> clients;

AppliedFiters({
required this.selectedResultStatus,
Expand Down
16 changes: 8 additions & 8 deletions lib/providers/logs_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LogsProvider with ChangeNotifier {
AppliedFiters _appliedFilters = AppliedFiters(
selectedResultStatus: 'all',
searchText: null,
clients: null
clients: []
);

LoadStatus get loadStatus {
Expand Down Expand Up @@ -177,18 +177,18 @@ class LogsProvider with ChangeNotifier {
if (loadingMore != null && loadingMore == true && logsData != null) {
LogsData newLogsData = result.content;
newLogsData.data = [...logsData!.data, ...(result.content as LogsData).data];
if (appliedFilters.clients != null) {
if (appliedFilters.clients.isNotEmpty) {
newLogsData.data = newLogsData.data.where(
(item) => appliedFilters.clients!.contains(item.client)
(item) => appliedFilters.clients.contains(item.client)
).toList();
}
_logsData = newLogsData;
}
else {
LogsData newLogsData = result.content;
if (appliedFilters.clients != null) {
if (appliedFilters.clients.isNotEmpty) {
newLogsData.data = newLogsData.data.where(
(item) => appliedFilters.clients!.contains(item.client)
(item) => appliedFilters.clients.contains(item.client)
).toList();
}
_logsData = newLogsData;
Expand Down Expand Up @@ -217,7 +217,7 @@ class LogsProvider with ChangeNotifier {
_appliedFilters = AppliedFiters(
selectedResultStatus: 'all',
searchText: null,
clients: null
clients: []
);

if (result.successful == true) {
Expand Down Expand Up @@ -254,9 +254,9 @@ class LogsProvider with ChangeNotifier {

if (result.successful == true) {
LogsData newLogsData = result.content as LogsData;
if (appliedFilters.clients != null) {
if (appliedFilters.clients.isNotEmpty) {
newLogsData.data = newLogsData.data.where(
(item) => appliedFilters.clients!.contains(item.client)
(item) => appliedFilters.clients.contains(item.client)
).toList();
}
_logsData = newLogsData;
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/home/top_items/top_items_lists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TopItemsLists extends StatelessWidget {
AppliedFiters(
selectedResultStatus: 'all',
searchText: value,
clients: null
clients: []
)
);
appConfigProvider.setSelectedScreen(2);
Expand Down
244 changes: 109 additions & 135 deletions lib/screens/logs/filters/filter_status_modal.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:io';


import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

import 'package:adguard_home_manager/widgets/list_bottom_sheet.dart';

import 'package:adguard_home_manager/providers/logs_provider.dart';

class FilterStatusModal extends StatefulWidget {
Expand Down Expand Up @@ -33,169 +35,141 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
Widget build(BuildContext context) {
final logsProvider = Provider.of<LogsProvider>(context);

void apply() async {
logsProvider.setSelectedResultStatus(value: selectedResultStatus);

Navigator.pop(context);
}

if (widget.dialog == true) {
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 400
),
child: _Content(
onApply: apply,
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
selectedResultStatus: selectedResultStatus,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: SingleChildScrollView(
child: Wrap(
children: [
Padding(
padding: const EdgeInsets.only(top: 16, left: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
CloseButton(
onPressed: () => Navigator.pop(context),
),
const SizedBox(width: 12),
Text(
AppLocalizations.of(context)!.responseStatus,
style: const TextStyle(
fontSize: 22
),
)
],
),
),
Container(height: 16),
_ItemsList(
selectedResultStatus: logsProvider.selectedResultStatus,
updateSelectedResultStatus: (v) => logsProvider.setSelectedResultStatus(value: v),
),
Container(height: 16)
],
),
),
),
],
)
),
);
}
else {
return Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(28),
topRight: Radius.circular(28)
),
color: Theme.of(context).dialogBackgroundColor
return SizedBox(
height: 700,
child: ListBottomSheet(
icon: Icons.shield_rounded,
title: AppLocalizations.of(context)!.responseStatus,
initialChildSize: 1,
minChildSize: 0.5,
children: [
_ItemsList(
selectedResultStatus: logsProvider.selectedResultStatus,
updateSelectedResultStatus: (v) => logsProvider.setSelectedResultStatus(value: v),
)
]
),
child: SafeArea(
child: _Content(
onApply: apply,
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
selectedResultStatus: selectedResultStatus,
),
)
);
}
}
}

class _Content extends StatelessWidget {
class _ItemsList extends StatelessWidget {
final String selectedResultStatus;
final void Function(String) updateSelectedResultStatus;
final void Function() onApply;

const _Content({
const _ItemsList({
required this.selectedResultStatus,
required this.updateSelectedResultStatus,
required this.onApply,
required this.updateSelectedResultStatus
});

@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,
bottom: 16,
),
child: Icon(
Icons.shield_rounded,
size: 24,
color: Theme.of(context).listTileTheme.iconColor
),
),
Text(
AppLocalizations.of(context)!.responseStatus,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w400,
color: Theme.of(context).colorScheme.onSurface
),
),
],
)
],
),
Container(height: 16),
_Item(
selectedResultStatus: selectedResultStatus,
id: "all",
icon: Icons.shield_rounded,
label: AppLocalizations.of(context)!.all,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "filtered",
icon: Icons.shield_rounded,
label: AppLocalizations.of(context)!.filtered,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "processed",
icon: Icons.verified_user_rounded,
label: AppLocalizations.of(context)!.processedRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "whitelisted",
icon: Icons.verified_user_rounded,
label: AppLocalizations.of(context)!.processedWhitelistRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "blocked",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blocked,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "blocked_safebrowsing",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedSafeBrowsingRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "blocked_parental",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedParentalRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "safe_search",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedSafeSearchRow,
onChanged: updateSelectedResultStatus
),
],
),
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "all",
icon: Icons.shield_rounded,
label: AppLocalizations.of(context)!.all,
onChanged: updateSelectedResultStatus
),
Padding(
padding: const EdgeInsets.all(24),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: onApply,
child: Text(AppLocalizations.of(context)!.apply)
)
],
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "filtered",
icon: Icons.shield_rounded,
label: AppLocalizations.of(context)!.filtered,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "processed",
icon: Icons.verified_user_rounded,
label: AppLocalizations.of(context)!.processedRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "whitelisted",
icon: Icons.verified_user_rounded,
label: AppLocalizations.of(context)!.processedWhitelistRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "blocked",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blocked,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "blocked_safebrowsing",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedSafeBrowsingRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "blocked_parental",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedParentalRow,
onChanged: updateSelectedResultStatus
),
_Item(
selectedResultStatus: selectedResultStatus,
id: "safe_search",
icon: Icons.gpp_bad_rounded,
label: AppLocalizations.of(context)!.blockedSafeSearchRow,
onChanged: updateSelectedResultStatus
),
if (Platform.isIOS) const SizedBox(height: 16)
],
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/screens/logs/filters/logs_filters_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ class _FiltersList extends StatelessWidget {
final void Function() onClearSearch;

const _FiltersList({
Key? key,
required this.searchController,
required this.onClearSearch,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -125,7 +124,8 @@ class _FiltersList extends StatelessWidget {
dialog: false,
),
isScrollControlled: true,
backgroundColor: Colors.transparent
backgroundColor: Colors.transparent,
useSafeArea: true
);
}
}
Expand Down
Loading

0 comments on commit f8f3914

Please sign in to comment.