From 85148378a68b440770d1901f9a984e8484650245 Mon Sep 17 00:00:00 2001 From: Arlind <56867496+Lindi31@users.noreply.github.com> Date: Sun, 18 Jun 2023 03:00:17 +0200 Subject: [PATCH] minor changes --- lib/account/account_detail.dart | 76 ++++++++++++++++++++----- lib/account/account_dialog.dart | 5 +- lib/assets/translations/de-DE.json | 6 +- lib/assets/translations/en-US.json | 6 +- lib/main.dart | 13 ++++- lib/transaction/transaction_dialog.dart | 5 +- pubspec.lock | 8 +++ pubspec.yaml | 4 +- 8 files changed, 96 insertions(+), 27 deletions(-) diff --git a/lib/account/account_detail.dart b/lib/account/account_detail.dart index 8a3aba5..6c90e0f 100644 --- a/lib/account/account_detail.dart +++ b/lib/account/account_detail.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:circular_seek_bar/circular_seek_bar.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; @@ -469,29 +470,78 @@ class AccountDetailPageState extends State } Widget _buildTransactionsList(List transactionsList) { - return ListView.builder( + + return ListView.separated( physics: const BouncingScrollPhysics(), itemCount: transactionsList.length, itemBuilder: (context, index) { - return ListTile( - title: Text(transactionsList[index].title), - subtitle: Text(transactionsList[index].title), - trailing: Text( - transactionsList[index].isExpense - ? '-$_selectedCurrency${transactionsList[index].amount.toStringAsFixed(2)}' - : '+$_selectedCurrency${transactionsList[index].amount.toStringAsFixed(2)}', - style: TextStyle( - color: - transactionsList[index].isExpense ? Colors.red : Colors.green, - fontWeight: FontWeight.bold, + final transaction = transactionsList[index]; + final formattedDate = DateFormat.yMMMMd().add_Hm().format(transaction.date); + return GestureDetector( + onLongPress: () => + _showDeleteConfirmationDialog(transactionsList[index]), + child: ListTile( + + title: Text( + transactionsList[index].title, + style: TextStyle( + color: Theme.of(context).brightness == Brightness.dark + ? Colors.white54 + : Colors.black87), + ), + subtitle:Text( + formattedDate, + style: TextStyle( + fontSize: 12, + color: Theme.of(context).brightness == Brightness.dark ? Colors.grey[600] : Colors.grey[400], + ), + ), + trailing: Text( + transactionsList[index].isExpense + ? '-$_selectedCurrency${transactionsList[index].amount.toStringAsFixed(2)}' + : '+$_selectedCurrency${transactionsList[index].amount.toStringAsFixed(2)}', + style: TextStyle( + color: transactionsList[index].isExpense + ? Colors.red + : Colors.green, + fontWeight: FontWeight.bold, + ), ), ), - onLongPress: () => deleteTransaction(transactionsList[index]), ); }, + separatorBuilder: (context, index) => Divider( + indent: MediaQuery.of(context).size.width * 0.03, + endIndent: MediaQuery.of(context).size.width * 0.03, + color: Colors.grey, + height: 0.05, + ), ); } + Future _showDeleteConfirmationDialog(Transaction transaction) { + return AwesomeDialog( + dialogBackgroundColor: Theme.of(context).brightness == Brightness.dark + ? Colors.grey[800] + : Colors.grey[200], + btnOkText: "Delete".tr(), + btnOkColor: Colors.red, + btnCancelColor: Theme.of(context).brightness == Brightness.dark + ? Colors.grey[500] + : Colors.grey[500], + context: context, + animType: AnimType.bottomSlide, + dialogType: DialogType.info, + title: 'deletetransaction'.tr(), + headerAnimationLoop: false, + desc: 'suretransaction'.tr(), + btnCancelOnPress: () {}, + btnOkOnPress: () { + deleteTransaction(transaction); + }, + ).show(); + } + double calculateMonthlyExpensesTotal() { double total = 0; for (var transaction in expenseTransactions) { diff --git a/lib/account/account_dialog.dart b/lib/account/account_dialog.dart index def5066..12fb6a7 100644 --- a/lib/account/account_dialog.dart +++ b/lib/account/account_dialog.dart @@ -46,9 +46,11 @@ class AddAccountDialogState extends State { ), title: Text( 'addaccount'.tr(), + textAlign: TextAlign.center, ), - titleTextStyle: const TextStyle( + titleTextStyle: TextStyle( fontSize: 20, + color: Theme.of(context).brightness==Brightness.dark?Colors.white70:Colors.black87, ), content: Form( key: _formKey, @@ -131,7 +133,6 @@ class AddAccountDialogState extends State { ), actions: [ NeumorphicButton( - margin: const EdgeInsets.fromLTRB(0, 0, 4, 4), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/assets/translations/de-DE.json b/lib/assets/translations/de-DE.json index 523fbaf..ec4d9a5 100644 --- a/lib/assets/translations/de-DE.json +++ b/lib/assets/translations/de-DE.json @@ -1,7 +1,7 @@ { "title": "My Finance Planner", "delete": "Löschen", - "deleteaccount": "Account löschen", + "deleteaccount": "Account löschen?", "sure": "Sind Sie sicher, dass Sie dieses Konto löschen möchten?", "balance": "Bilanz", "addaccount": "Konto hinzufügen", @@ -42,5 +42,7 @@ "tip15": "Nutze kostenlose Online-Ressourcen für Weiterbildung und Hobbys.", "hint": "Spartipps gefällig? \nDrücke auf den Info-Button", "budgetmax": "Budget verbraucht!", - "enterbudget": "Budget eingeben" + "enterbudget": "Budget eingeben", + "deletetransaction":"Transaktion löschen?", + "suretransaction": "Sind Sie sicher, dass Sie die Transaktion löschen möchten?" } \ No newline at end of file diff --git a/lib/assets/translations/en-US.json b/lib/assets/translations/en-US.json index 699369f..634d73c 100644 --- a/lib/assets/translations/en-US.json +++ b/lib/assets/translations/en-US.json @@ -1,7 +1,7 @@ { "title": "My Finance Planner", "delete": "Delete", - "deleteaccount": "Delete account", + "deleteaccount": "Delete account?", "sure": "Are you sure you want to delete this account?", "balance": "Balance", "addaccount": "Add account", @@ -42,5 +42,7 @@ "tip15":"Use free online resources for continuing education and hobbies.", "hint": "Need saving tips? \nPress the info button", "budgetmax": "Budget spent!", - "enterbudget": "Enter budget" + "enterbudget": "Enter budget", + "deletetransaction":"Delete transaction?", + "suretransaction": "Are you sure you want to delete this transaction?" } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index bb04eca..61aebd7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -149,7 +149,7 @@ class HomePageState extends State { backgroundColor: Colors.transparent, elevation: 0, leading: Padding( - padding: EdgeInsets.only(left: 5), + padding: const EdgeInsets.only(left: 5), child: Image.asset( 'lib/assets/mfa_logo.png', width: 32, @@ -207,9 +207,16 @@ class HomePageState extends State { return GestureDetector( onLongPress: () { AwesomeDialog( + dialogBackgroundColor: + Theme.of(context).brightness == Brightness.dark + ? Colors.grey[800] + : Colors.grey[200], btnOkText: "Delete".tr(), - btnOkColor: Colors.lightGreen, - btnCancelColor: Theme.of(context).shadowColor, + btnOkColor: Colors.red, + btnCancelColor: + Theme.of(context).brightness == Brightness.dark + ? Colors.grey[500] + : Colors.grey[500], context: context, animType: AnimType.bottomSlide, dialogType: DialogType.info, diff --git a/lib/transaction/transaction_dialog.dart b/lib/transaction/transaction_dialog.dart index f8b13e4..81cd276 100644 --- a/lib/transaction/transaction_dialog.dart +++ b/lib/transaction/transaction_dialog.dart @@ -147,7 +147,7 @@ class AddTransactionDialogState extends State { ? grey200 : grey800, selectedDepth: -10, - unselectedDepth: 8), + unselectedDepth: 6), value: _isExpense, onChanged: (value) { setState(() { @@ -155,7 +155,7 @@ class AddTransactionDialogState extends State { }); }, ), - const SizedBox(width: 8), + const SizedBox(width: 9), Text( 'expense'.tr(), ), @@ -195,7 +195,6 @@ class AddTransactionDialogState extends State { ), ), NeumorphicButton( - margin: const EdgeInsets.fromLTRB(0, 0, 4, 4), onPressed: _submitForm, style: NeumorphicStyle( shape: NeumorphicShape.concave, diff --git a/pubspec.lock b/pubspec.lock index 67329b9..bed8e49 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -211,6 +211,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.0" + flutter_slidable: + dependency: "direct main" + description: + name: flutter_slidable + sha256: "6c68e1fad129b4b807b2218ef4cf7f7f6f61c5ec8861c990dc2278d9d03cb09f" + url: "https://pub.dev" + source: hosted + version: "2.0.0" flutter_svg: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 82560de..a2c7ce3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: circular_seek_bar: ^1.1.0 tab_indicator_styler: ^2.0.0 provider: ^6.0.5 + flutter_slidable: ^2.0.0 dev_dependencies: flutter_test: @@ -79,5 +80,4 @@ flutter: weight: 600 - asset: lib/fonts/Montserrat-Thin.ttf weight: 100 - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages +