Skip to content

Commit 795aa7a

Browse files
committed
feat: move entries filter into modal sheet
1 parent d0dbca9 commit 795aa7a

File tree

3 files changed

+101
-16
lines changed

3 files changed

+101
-16
lines changed

lib/widgets/app_bar/journal_sliver_appbar.dart

+92-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'package:lotti/blocs/journal/journal_page_state.dart';
66
import 'package:lotti/widgets/search/entry_type_filter.dart';
77
import 'package:lotti/widgets/search/search_widget.dart';
88
import 'package:lotti/widgets/search/task_status_filter.dart';
9+
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
10+
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart';
911

1012
class JournalSliverAppBar extends StatelessWidget {
1113
const JournalSliverAppBar({
@@ -20,9 +22,8 @@ class JournalSliverAppBar extends StatelessWidget {
2022
final showTasks = snapshot.showTasks;
2123

2224
return SliverAppBar(
23-
expandedHeight: showTasks ? null : 230,
2425
pinned: true,
25-
toolbarHeight: showTasks ? 100 : 200,
26+
toolbarHeight: 100,
2627
title: Column(
2728
children: [
2829
const SizedBox(height: 10),
@@ -39,11 +40,9 @@ class JournalSliverAppBar extends StatelessWidget {
3940
),
4041
),
4142
if (showTasks) const TaskFilterIcon(),
43+
if (!showTasks) const JournalFilterIcon(),
4244
],
4345
),
44-
if (!showTasks) const JournalFilter(),
45-
const SizedBox(height: 10),
46-
if (!showTasks) const EntryTypeFilter(),
4746
],
4847
),
4948
);
@@ -117,3 +116,91 @@ class JournalFilter extends StatelessWidget {
117116
);
118117
}
119118
}
119+
120+
const double _pagePadding = 16;
121+
const double _pageBreakpoint = 768;
122+
123+
class JournalFilterIcon extends StatelessWidget {
124+
const JournalFilterIcon({super.key});
125+
126+
@override
127+
Widget build(BuildContext context) {
128+
final pageIndexNotifier = ValueNotifier(0);
129+
130+
SliverWoltModalSheetPage page1(
131+
BuildContext modalSheetContext,
132+
TextTheme textTheme,
133+
) {
134+
return WoltModalSheetPage(
135+
hasSabGradient: false,
136+
topBarTitle: Text('Entries Filter', style: textTheme.titleSmall),
137+
isTopBarLayerAlwaysVisible: true,
138+
trailingNavBarWidget: IconButton(
139+
padding: const EdgeInsets.all(_pagePadding),
140+
icon: const Icon(Icons.close),
141+
onPressed: Navigator.of(modalSheetContext).pop,
142+
),
143+
child: const Padding(
144+
padding: EdgeInsets.only(
145+
bottom: 30,
146+
left: 10,
147+
top: 10,
148+
right: 10,
149+
),
150+
child: Column(
151+
children: [
152+
JournalFilter(),
153+
SizedBox(height: 10),
154+
EntryTypeFilter(),
155+
],
156+
),
157+
),
158+
);
159+
}
160+
161+
return Padding(
162+
padding: const EdgeInsets.only(right: 30),
163+
child: IconButton(
164+
onPressed: () {
165+
WoltModalSheet.show<void>(
166+
pageIndexNotifier: pageIndexNotifier,
167+
context: context,
168+
pageListBuilder: (modalSheetContext) {
169+
final textTheme = Theme.of(context).textTheme;
170+
return [
171+
page1(modalSheetContext, textTheme),
172+
];
173+
},
174+
decorator: (child) {
175+
return MultiBlocProvider(
176+
providers: [
177+
BlocProvider.value(
178+
value: context.read<JournalPageCubit>(),
179+
),
180+
],
181+
child: child,
182+
);
183+
},
184+
modalTypeBuilder: (context) {
185+
final size = MediaQuery.of(context).size.width;
186+
if (size < _pageBreakpoint) {
187+
return WoltModalType.bottomSheet;
188+
} else {
189+
return WoltModalType.dialog;
190+
}
191+
},
192+
onModalDismissedWithBarrierTap: () {
193+
debugPrint('Closed modal sheet with barrier tap');
194+
Navigator.of(context).pop();
195+
},
196+
maxDialogWidth: 560,
197+
minDialogWidth: 400,
198+
minPageHeight: 0,
199+
maxPageHeight: 0.9,
200+
);
201+
},
202+
icon: Icon(MdiIcons.filterVariant),
203+
),
204+
);
205+
}
206+
}

lib/widgets/search/entry_type_filter.dart

+8-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ class EntryTypeFilter extends StatelessWidget {
1313
Widget build(BuildContext context) {
1414
return BlocBuilder<JournalPageCubit, JournalPageState>(
1515
builder: (context, snapshot) {
16-
return SingleChildScrollView(
17-
scrollDirection: Axis.horizontal,
18-
child: Row(
19-
children: [
20-
const SizedBox(width: 5),
21-
...entryTypes.map(EntryTypeChip.new),
22-
const EntryTypeAllChip(),
23-
const SizedBox(width: 5),
24-
],
25-
),
16+
return Wrap(
17+
runSpacing: 10,
18+
spacing: 5,
19+
children: [
20+
...entryTypes.map(EntryTypeChip.new),
21+
const EntryTypeAllChip(),
22+
const SizedBox(width: 5),
23+
],
2624
);
2725
},
2826
);

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: lotti
22
description: Achieve your goals and keep your data private with Lotti.
33
publish_to: 'none'
4-
version: 0.9.441+2413
4+
version: 0.9.441+2414
55

66
msix_config:
77
display_name: LottiApp

0 commit comments

Comments
 (0)