From d7a8233f6b1dfb3257e0c6ed14e53e4d587cdec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Sat, 10 Feb 2024 15:52:36 +0100 Subject: [PATCH] fix: edit on tap now --- CHANGELOG.md | 2 ++ lib/views/home.dart | 66 +++++++++++++++-------------------- lib/views/recurring_view.dart | 56 +++++++++++++---------------- 3 files changed, 56 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f02ea1b..07cf67f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ - Change graph container style when using light mode - Make pie chart values more visible by adding the category's corresponding color as background - Welcome text on Setup view is now centered +- Editing entries is now done by tapping the entry, instead of a dedicated button + # 1.0.0-alpha+5 - Add tests - Add searching through entries to homepage diff --git a/lib/views/home.dart b/lib/views/home.dart index aafcd5f..b92e3fe 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -414,45 +414,9 @@ class _HomeViewState extends State { : groupSortOldest(a, b, locale), itemBuilder: (context, element) => Slidable( endActionPane: ActionPane( + extentRatio: 0.3, motion: const ScrollMotion(), children: [ - SlidableAction( - onPressed: (c) { - Navigator.of(context) - .push( - MaterialPageRoute( - builder: (c) => - CreateSingleEntryView( - locale: locale, - w: selectedWallet!, - editEntry: element, - ), - ), - ) - .then( - (editedEntry) { - if (editedEntry == null) { - return; - } - selectedWallet!.entries - .remove(element); - selectedWallet!.entries - .add(editedEntry); - WalletManager.saveWallet( - selectedWallet!, - ); - setState(() {}); - }, - ); - }, - backgroundColor: Theme.of(context) - .colorScheme - .secondary, - foregroundColor: Theme.of(context) - .colorScheme - .onSecondary, - icon: Icons.edit, - ), SlidableAction( backgroundColor: Theme.of(context) .colorScheme @@ -512,6 +476,34 @@ class _HomeViewState extends State { ], ), child: ListTile( + onTap: () { + Navigator.of(context) + .push( + MaterialPageRoute( + builder: (c) => + CreateSingleEntryView( + locale: locale, + w: selectedWallet!, + editEntry: element, + ), + ), + ) + .then( + (editedEntry) { + if (editedEntry == null) { + return; + } + selectedWallet!.entries + .remove(element); + selectedWallet!.entries + .add(editedEntry); + WalletManager.saveWallet( + selectedWallet!, + ); + setState(() {}); + }, + ); + }, leading: Container( decoration: BoxDecoration( borderRadius: diff --git a/lib/views/recurring_view.dart b/lib/views/recurring_view.dart index 64f1203..cc2f4c1 100644 --- a/lib/views/recurring_view.dart +++ b/lib/views/recurring_view.dart @@ -167,38 +167,8 @@ class _RecurringEntriesViewState extends State { itemBuilder: (c, i) => Slidable( endActionPane: ActionPane( motion: const ScrollMotion(), + extentRatio: 0.3, children: [ - SlidableAction( - onPressed: (c) { - Navigator.of(context) - .push( - MaterialPageRoute( - builder: (c) => CreateRecurringEntryView( - w: selectedWallet!, - locale: locale, - editEntry: - selectedWallet!.recurringEntries[i], - ), - ), - ) - .then( - (editedEntry) { - if (editedEntry == null) return; - selectedWallet!.entries.remove( - selectedWallet!.recurringEntries[i], - ); - selectedWallet!.entries.add(editedEntry); - WalletManager.saveWallet(selectedWallet!); - setState(() {}); - }, - ); - }, - backgroundColor: - Theme.of(context).colorScheme.secondary, - foregroundColor: - Theme.of(context).colorScheme.onSecondary, - icon: Icons.edit, - ), SlidableAction( backgroundColor: Theme.of(context).colorScheme.error, @@ -244,6 +214,30 @@ class _RecurringEntriesViewState extends State { ], ), child: ListTile( + onTap: () { + Navigator.of(context) + .push( + MaterialPageRoute( + builder: (c) => CreateRecurringEntryView( + w: selectedWallet!, + locale: locale, + editEntry: + selectedWallet!.recurringEntries[i], + ), + ), + ) + .then( + (editedEntry) { + if (editedEntry == null) return; + selectedWallet!.entries.remove( + selectedWallet!.recurringEntries[i], + ); + selectedWallet!.entries.add(editedEntry); + WalletManager.saveWallet(selectedWallet!); + setState(() {}); + }, + ); + }, leading: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(16),