mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-19 13:29:12 +00:00
Changed response status bottom sheet
This commit is contained in:
parent
16f1d4664c
commit
ae3e172033
3 changed files with 122 additions and 142 deletions
|
@ -1,9 +1,11 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.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';
|
import 'package:adguard_home_manager/providers/logs_provider.dart';
|
||||||
|
|
||||||
class FilterStatusModal extends StatefulWidget {
|
class FilterStatusModal extends StatefulWidget {
|
||||||
|
@ -33,169 +35,141 @@ class _FilterStatusModalState extends State<FilterStatusModal> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final logsProvider = Provider.of<LogsProvider>(context);
|
final logsProvider = Provider.of<LogsProvider>(context);
|
||||||
|
|
||||||
void apply() async {
|
|
||||||
logsProvider.setSelectedResultStatus(value: selectedResultStatus);
|
|
||||||
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget.dialog == true) {
|
if (widget.dialog == true) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
maxWidth: 400
|
maxWidth: 400
|
||||||
),
|
),
|
||||||
child: _Content(
|
child: Column(
|
||||||
onApply: apply,
|
mainAxisSize: MainAxisSize.min,
|
||||||
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
|
children: [
|
||||||
selectedResultStatus: selectedResultStatus,
|
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 {
|
else {
|
||||||
return Container(
|
return SizedBox(
|
||||||
decoration: BoxDecoration(
|
height: 700,
|
||||||
borderRadius: const BorderRadius.only(
|
child: ListBottomSheet(
|
||||||
topLeft: Radius.circular(28),
|
icon: Icons.shield_rounded,
|
||||||
topRight: Radius.circular(28)
|
title: AppLocalizations.of(context)!.responseStatus,
|
||||||
),
|
initialChildSize: 1,
|
||||||
color: Theme.of(context).dialogBackgroundColor
|
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 String selectedResultStatus;
|
||||||
final void Function(String) updateSelectedResultStatus;
|
final void Function(String) updateSelectedResultStatus;
|
||||||
final void Function() onApply;
|
|
||||||
|
|
||||||
const _Content({
|
const _ItemsList({
|
||||||
required this.selectedResultStatus,
|
required this.selectedResultStatus,
|
||||||
required this.updateSelectedResultStatus,
|
required this.updateSelectedResultStatus
|
||||||
required this.onApply,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
_Item(
|
||||||
child: SingleChildScrollView(
|
selectedResultStatus: selectedResultStatus,
|
||||||
child: Wrap(
|
id: "all",
|
||||||
children: [
|
icon: Icons.shield_rounded,
|
||||||
Row(
|
label: AppLocalizations.of(context)!.all,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
onChanged: updateSelectedResultStatus
|
||||||
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
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Padding(
|
_Item(
|
||||||
padding: const EdgeInsets.all(24),
|
selectedResultStatus: selectedResultStatus,
|
||||||
child: Row(
|
id: "filtered",
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
icon: Icons.shield_rounded,
|
||||||
children: [
|
label: AppLocalizations.of(context)!.filtered,
|
||||||
TextButton(
|
onChanged: updateSelectedResultStatus
|
||||||
onPressed: onApply,
|
),
|
||||||
child: Text(AppLocalizations.of(context)!.apply)
|
_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)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,9 @@ class _FiltersList extends StatelessWidget {
|
||||||
final void Function() onClearSearch;
|
final void Function() onClearSearch;
|
||||||
|
|
||||||
const _FiltersList({
|
const _FiltersList({
|
||||||
Key? key,
|
|
||||||
required this.searchController,
|
required this.searchController,
|
||||||
required this.onClearSearch,
|
required this.onClearSearch,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -125,7 +124,8 @@ class _FiltersList extends StatelessWidget {
|
||||||
dialog: false,
|
dialog: false,
|
||||||
),
|
),
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent
|
backgroundColor: Colors.transparent,
|
||||||
|
useSafeArea: true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,18 @@ class ListBottomSheet extends StatelessWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String title;
|
final String title;
|
||||||
final List<Widget> children;
|
final List<Widget> children;
|
||||||
|
final double? initialChildSize;
|
||||||
|
final double? minChildSize;
|
||||||
|
final double? maxChildSize;
|
||||||
|
|
||||||
const ListBottomSheet({
|
const ListBottomSheet({
|
||||||
super.key,
|
super.key,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.children
|
required this.children,
|
||||||
|
this.initialChildSize,
|
||||||
|
this.maxChildSize,
|
||||||
|
this.minChildSize,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -17,9 +23,9 @@ class ListBottomSheet extends StatelessWidget {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => Navigator.of(context).pop(),
|
onTap: () => Navigator.of(context).pop(),
|
||||||
child: DraggableScrollableSheet(
|
child: DraggableScrollableSheet(
|
||||||
initialChildSize: 0.6,
|
initialChildSize: initialChildSize ?? 0.6,
|
||||||
minChildSize: 0.3,
|
minChildSize: minChildSize ?? 0.3,
|
||||||
maxChildSize: 1,
|
maxChildSize: maxChildSize ?? 1,
|
||||||
builder: (context, controller) {
|
builder: (context, controller) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
Loading…
Add table
Reference in a new issue