@@ -11,7 +11,7 @@ import 'package:infusion_timer/tea.dart';
1111import 'package:infusion_timer/widgets/preferences_page.dart' ;
1212import 'package:infusion_timer/widgets/tea_actions_bottom_sheet.dart' ;
1313import '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' ;
1515import 'package:infusion_timer/widgets/timer_page.dart' ;
1616import 'package:package_info_plus/package_info_plus.dart' ;
1717import '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 },
0 commit comments