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: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 {
|
||||
|
@ -33,96 +35,85 @@ 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,
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(28),
|
||||
topRight: Radius.circular(28)
|
||||
),
|
||||
color: Theme.of(context).dialogBackgroundColor
|
||||
),
|
||||
child: SafeArea(
|
||||
child: _Content(
|
||||
onApply: apply,
|
||||
updateSelectedResultStatus: (v) => setState(() => selectedResultStatus = v),
|
||||
selectedResultStatus: selectedResultStatus,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _Content extends StatelessWidget {
|
||||
final String selectedResultStatus;
|
||||
final void Function(String) updateSelectedResultStatus;
|
||||
final void Function() onApply;
|
||||
|
||||
const _Content({
|
||||
required this.selectedResultStatus,
|
||||
required this.updateSelectedResultStatus,
|
||||
required this.onApply,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
child: 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
|
||||
),
|
||||
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: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Theme.of(context).colorScheme.onSurface
|
||||
style: const TextStyle(
|
||||
fontSize: 22
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(height: 16),
|
||||
_ItemsList(
|
||||
selectedResultStatus: logsProvider.selectedResultStatus,
|
||||
updateSelectedResultStatus: (v) => logsProvider.setSelectedResultStatus(value: v),
|
||||
),
|
||||
Container(height: 16)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
Container(height: 16),
|
||||
);
|
||||
}
|
||||
else {
|
||||
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),
|
||||
)
|
||||
]
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _ItemsList extends StatelessWidget {
|
||||
final String selectedResultStatus;
|
||||
final void Function(String) updateSelectedResultStatus;
|
||||
|
||||
const _ItemsList({
|
||||
required this.selectedResultStatus,
|
||||
required this.updateSelectedResultStatus
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
_Item(
|
||||
selectedResultStatus: selectedResultStatus,
|
||||
id: "all",
|
||||
|
@ -180,23 +171,6 @@ class _Content extends StatelessWidget {
|
|||
onChanged: updateSelectedResultStatus
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: onApply,
|
||||
child: Text(AppLocalizations.of(context)!.apply)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (Platform.isIOS) const SizedBox(height: 16)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
@ -125,7 +124,8 @@ class _FiltersList extends StatelessWidget {
|
|||
dialog: false,
|
||||
),
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent
|
||||
backgroundColor: Colors.transparent,
|
||||
useSafeArea: true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,18 @@ 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
|
||||
|
@ -17,9 +23,9 @@ class ListBottomSheet extends StatelessWidget {
|
|||
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(
|
||||
|
|
Loading…
Add table
Reference in a new issue