Skip to content

Commit f0aaa0b

Browse files
committed
replace tea input dialog with full page
1 parent c519b51 commit f0aaa0b

File tree

4 files changed

+336
-260
lines changed

4 files changed

+336
-260
lines changed

lib/widgets/collection_page.dart

Lines changed: 48 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:infusion_timer/tea.dart';
1111
import 'package:infusion_timer/widgets/preferences_page.dart';
1212
import 'package:infusion_timer/widgets/tea_actions_bottom_sheet.dart';
1313
import 'package:infusion_timer/widgets/tea_card.dart';
14-
import 'package:infusion_timer/widgets/tea_input_dialog.dart';
14+
import 'package:infusion_timer/widgets/tea_input_page.dart';
1515
import 'package:infusion_timer/widgets/timer_page.dart';
1616
import 'package:package_info_plus/package_info_plus.dart';
1717
import 'package:share_plus/share_plus.dart';
@@ -243,6 +243,7 @@ class CollectionPageState extends State<CollectionPage> {
243243
context: context,
244244
builder: (BuildContext context) => TeaActionsBottomSheet(
245245
tea,
246+
// shareCallback
246247
(tea) async {
247248
await SharePlus.instance.share(
248249
ShareParams(
@@ -252,50 +253,45 @@ class CollectionPageState extends State<CollectionPage> {
252253
),
253254
);
254255
},
255-
(tea) => {
256-
showDialog(
257-
context: context,
258-
barrierDismissible: false,
259-
builder: (BuildContext context) => TeaInputDialog(
260-
tea,
261-
(tea) {
262-
PersistenceService.updateTea(tea).then((value) {
263-
setState(() {});
264-
if (context.mounted) {
265-
Navigator.of(context).pop();
266-
Navigator.of(context).pop();
267-
}
268-
});
269-
},
270-
(tea) {
271-
Navigator.of(context).pop();
272-
Navigator.of(context).pop();
273-
},
256+
// editCallback
257+
(tea) async {
258+
// hide bottom sheet first
259+
Navigator.of(context).pop();
260+
Navigator.push(
261+
context,
262+
MaterialPageRoute(
263+
builder: (context) => TeaInputPage(
264+
tea: tea,
265+
saveCallback: (tea) {
266+
PersistenceService.updateTea(tea).then((
267+
value,
268+
) {
269+
setState(() {});
270+
});
271+
},
272+
),
274273
),
275-
),
274+
);
276275
},
277-
(tea) => {
278-
showDialog(
279-
context: context,
280-
barrierDismissible: false,
281-
builder: (BuildContext context) => TeaInputDialog(
282-
Tea.copyWithGeneratedId(tea),
283-
(tea) {
284-
PersistenceService.addTea(tea).then((value) {
285-
setState(() {});
286-
if (context.mounted) {
287-
Navigator.of(context).pop();
288-
Navigator.of(context).pop();
289-
}
290-
});
291-
},
292-
(tea) {
293-
Navigator.of(context).pop();
294-
Navigator.of(context).pop();
295-
},
276+
// copyCallback
277+
(tea) async {
278+
// hide bottom sheet first
279+
Navigator.of(context).pop();
280+
Navigator.push(
281+
context,
282+
MaterialPageRoute(
283+
builder: (context) => TeaInputPage(
284+
tea: Tea.copyWithGeneratedId(tea),
285+
saveCallback: (tea) {
286+
PersistenceService.addTea(tea).then((value) {
287+
setState(() {});
288+
});
289+
},
290+
),
296291
),
297-
),
292+
);
298293
},
294+
// deleteCallback
299295
(tea) async {
300296
await PersistenceService.deleteTea(tea);
301297
setState(() {});
@@ -335,20 +331,17 @@ class CollectionPageState extends State<CollectionPage> {
335331
FloatingActionButton(
336332
heroTag: "FloatingActionButtonAddTea",
337333
onPressed: () {
338-
showDialog(
339-
context: context,
340-
barrierDismissible: false,
341-
builder: (BuildContext context) => TeaInputDialog(
342-
Tea.withGeneratedId(null, null, null, [], null, 0),
343-
(tea) {
344-
setState(() {
345-
PersistenceService.addTea(tea);
346-
});
347-
Navigator.of(context).pop();
348-
},
349-
(tea) {
350-
Navigator.of(context).pop();
351-
},
334+
Navigator.push(
335+
context,
336+
MaterialPageRoute(
337+
builder: (context) => TeaInputPage(
338+
tea: Tea.withGeneratedId(null, null, null, [], null, 0),
339+
saveCallback: (tea) {
340+
PersistenceService.addTea(tea).then((value) {
341+
setState(() {});
342+
});
343+
},
344+
),
352345
),
353346
);
354347
},

lib/widgets/star_rating_form_field.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class StarRatingFormField extends FormField<int> {
1313
autovalidateMode: autovalidate,
1414
builder: (FormFieldState<int> state) {
1515
return Row(
16+
mainAxisAlignment: MainAxisAlignment.center,
1617
children: [
1718
for (int i = 1; i <= 5; i++)
1819
InkWell(

lib/widgets/tea_input_dialog.dart

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)