From cfd4d6200e83f47d61d7e7571effcedc276232d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Wed, 31 Jan 2024 07:54:29 +0100 Subject: [PATCH] chore: cosmetic changes Change some comment text, also change current balance to a getter --- lib/api/category.dart | 4 ++-- lib/api/entry_data.dart | 4 ++-- lib/api/recurring_entry.dart | 4 ++-- lib/api/wallet.dart | 6 +++--- lib/api/wallet_entry.dart | 4 ++-- lib/views/home.dart | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/api/category.dart b/lib/api/category.dart index 7088b9a..65cf0cc 100644 --- a/lib/api/category.dart +++ b/lib/api/category.dart @@ -14,7 +14,7 @@ class WalletCategory { required this.color, }); - /// Connects generated fromJson method + /// Connects the generated fromJson method factory WalletCategory.fromJson(Map json) => _$WalletCategoryFromJson(json); @@ -32,7 +32,7 @@ class WalletCategory { @JsonKey(fromJson: _colorFromJson, toJson: _colorToJson) Color color; - /// Connects generated toJson method + /// Connects the generated toJson method Map toJson() => _$WalletCategoryToJson(this); @override diff --git a/lib/api/entry_data.dart b/lib/api/entry_data.dart index 23281f2..1c63ced 100644 --- a/lib/api/entry_data.dart +++ b/lib/api/entry_data.dart @@ -7,7 +7,7 @@ class EntryData { /// Contains raw data EntryData({required this.name, required this.amount, this.description = ""}); - /// Connects generated fromJson method + /// Connects the generated fromJson method factory EntryData.fromJson(Map json) => _$EntryDataFromJson(json); @@ -20,6 +20,6 @@ class EntryData { /// Amount for entry double amount; - /// Connects generated toJson method + /// Connects the generated toJson method Map toJson() => _$EntryDataToJson(this); } diff --git a/lib/api/recurring_entry.dart b/lib/api/recurring_entry.dart index f45aac8..27662cb 100644 --- a/lib/api/recurring_entry.dart +++ b/lib/api/recurring_entry.dart @@ -20,11 +20,11 @@ class RecurringWalletEntry extends WalletSingleEntry { this.repeatAfter = 1, }); - /// Connects generated fromJson method + /// Connects the generated fromJson method factory RecurringWalletEntry.fromJson(Map json) => _$RecurringWalletEntryFromJson(json); - /// Connects generated toJson method + /// Connects the generated toJson method @override Map toJson() => _$RecurringWalletEntryToJson(this); diff --git a/lib/api/wallet.dart b/lib/api/wallet.dart index e2dcd1f..06bca51 100644 --- a/lib/api/wallet.dart +++ b/lib/api/wallet.dart @@ -30,7 +30,7 @@ class Wallet { this.starterBalance = 0, }); - /// Connects generated fromJson method + /// Connects the generated fromJson method factory Wallet.fromJson(Map json) => _$WalletFromJson(json); /// A list of all [RecurringWalletEntry]s @@ -54,7 +54,7 @@ class Wallet { @JsonKey(fromJson: _currencyFromJson) final Currency currency; - /// Connects generated toJson method + /// Connects the generated toJson method Map toJson() => _$WalletToJson(this); /// Getter for the next unused unique number ID in the wallet's **entry** list @@ -163,7 +163,7 @@ class Wallet { /// Returns the current balance /// /// Basically just takes *starterBalance* and adds all the entries to it - double calculateCurrentBalance() { + double get currentBalance { var toAdd = 0.0; for (final e in entries) { toAdd += (e.type == EntryType.income) ? e.data.amount : -e.data.amount; diff --git a/lib/api/wallet_entry.dart b/lib/api/wallet_entry.dart index e6f85da..fe34b37 100644 --- a/lib/api/wallet_entry.dart +++ b/lib/api/wallet_entry.dart @@ -17,7 +17,7 @@ class WalletSingleEntry { required this.id, }); - /// Connects generated fromJson method + /// Connects the generated fromJson method factory WalletSingleEntry.fromJson(Map json) => _$WalletSingleEntryFromJson(json); @@ -36,6 +36,6 @@ class WalletSingleEntry { /// Unique entry ID int id; - /// Connects generated toJson method + /// Connects the generated toJson method Map toJson() => _$WalletSingleEntryToJson(this); } diff --git a/lib/views/home.dart b/lib/views/home.dart index e7dbdf0..bbe60cd 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -298,7 +298,7 @@ class _HomeViewState extends State { locale: locale, symbol: selectedWallet!.currency.symbol, ).format( - selectedWallet!.calculateCurrentBalance(), + selectedWallet!.currentBalance, ), style: const TextStyle( fontWeight: FontWeight.bold,