Skip to content

Commit

Permalink
Changed response status bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
JGeek00 committed Jan 30, 2024
1 parent 16f1d46 commit ae3e172
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 142 deletions.
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
14 changes: 10 additions & 4 deletions lib/widgets/list_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ class ListBottomSheet extends StatelessWidget {
final IconData icon;
final String title;
final List<Widget> children;
final double? initialChildSize;
final double? minChildSize;
final double? maxChildSize;

const ListBottomSheet({
super.key,
required this.icon,
required this.title,
required this.children
required this.children,
this.initialChildSize,
this.maxChildSize,
this.minChildSize,
});

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Navigator.of(context).pop(),
child: DraggableScrollableSheet(
initialChildSize: 0.6,
minChildSize: 0.3,
maxChildSize: 1,
initialChildSize: initialChildSize ?? 0.6,
minChildSize: minChildSize ?? 0.3,
maxChildSize: maxChildSize ?? 1,
builder: (context, controller) {
return Container(
decoration: BoxDecoration(
Expand Down

0 comments on commit ae3e172

Please sign in to comment.