mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -45,12 +45,10 @@ class TransactionsNotifier extends StateNotifier<List<Transaction>> {
|
||||
|
||||
void clearAll() {
|
||||
state = [];
|
||||
// also clear from SharedPreferences:
|
||||
SharedPreferences.getInstance().then((prefs) => prefs.remove('transactions'));
|
||||
}
|
||||
}
|
||||
|
||||
// Search and filter state
|
||||
final searchQueryProvider = StateProvider<String>((ref) => '');
|
||||
|
||||
enum TransactionFilter { all, income, expense }
|
||||
@@ -58,7 +56,6 @@ enum TransactionFilter { all, income, expense }
|
||||
final transactionFilterProvider =
|
||||
StateProvider<TransactionFilter>((ref) => TransactionFilter.all);
|
||||
|
||||
// Converted balance providers (convert all transactions to selected currency)
|
||||
final totalBalanceProvider = Provider<double>((ref) {
|
||||
final txs = ref.watch(transactionsProvider);
|
||||
final exchangeService = ref.watch(exchangeRateServiceProvider);
|
||||
@@ -111,14 +108,12 @@ final filteredTransactionsProvider = Provider<List<Transaction>>((ref) {
|
||||
|
||||
var filtered = txs;
|
||||
|
||||
// Apply type filter
|
||||
if (filter == TransactionFilter.income) {
|
||||
filtered = filtered.where((t) => t.type == TransactionType.income).toList();
|
||||
} else if (filter == TransactionFilter.expense) {
|
||||
filtered = filtered.where((t) => t.type == TransactionType.expense).toList();
|
||||
}
|
||||
|
||||
// Apply search query
|
||||
if (query.isNotEmpty) {
|
||||
filtered = filtered.where((t) {
|
||||
final matchesCategory = t.category.toLowerCase().contains(query);
|
||||
@@ -127,7 +122,6 @@ final filteredTransactionsProvider = Provider<List<Transaction>>((ref) {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// Sort by date descending
|
||||
filtered.sort((a, b) => b.date.compareTo(a.date));
|
||||
return filtered;
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@ import '../../shared/providers/amount_format_provider.dart';
|
||||
import '../settings/provider.dart';
|
||||
import 'provider.dart';
|
||||
|
||||
// Helper for balance card only - hides .00 decimals
|
||||
String _smartBalance(double amount, AmountFormat fmt, String symbol) {
|
||||
const spaceAfter = {'Br'};
|
||||
final sep = spaceAfter.contains(symbol) ? ' ' : '';
|
||||
@@ -20,7 +19,6 @@ String _smartBalance(double amount, AmountFormat fmt, String symbol) {
|
||||
|
||||
String formatted;
|
||||
if (isWhole) {
|
||||
// format the integer, then manually remove .00
|
||||
formatted = fmt.format(amount);
|
||||
if (formatted.endsWith('.00')) {
|
||||
formatted = formatted.substring(0, formatted.length - 3);
|
||||
|
||||
Reference in New Issue
Block a user