From c44d4553c3c0a410cdd8ae9a3990a47f186f5046 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 1 Feb 2025 16:50:37 -0700 Subject: [PATCH] Attempting to move the input form to a popup. --- lib/main.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 2495631..dba2c7b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -50,9 +50,11 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { Widget page; + Widget? dialog; switch (pageSelected) { case 0: page = ExpensePage(); + dialog = ExpenseInputForm(); case 1: page = IncomePage(); case 2: @@ -65,6 +67,19 @@ class _HomePageState extends State { throw UnimplementedError('No widget for page $pageSelected yet!'); } + Widget newExpense() { + return AlertDialog(title: Text("Add New Value"), content: dialog); + } + + Widget? floatingButton; + if (dialog != null) { + floatingButton = IconButton( + onPressed: newExpense, + icon: Icon(Icons.add), + color: Theme.of(context).colorScheme.onSurface, + ); + } + return LayoutBuilder(builder: (context, constraints) { return Scaffold( body: Row( @@ -110,7 +125,7 @@ class _HomePageState extends State { ), ], ), - //floatingActionButton: IconButton(onPressed: appState.newExpense(), icon: Icon(Icons.add)), + floatingActionButton: floatingButton, ); }); }