From 494ff12cb0dff7ab6068f0e15f64ccb337cc1198 Mon Sep 17 00:00:00 2001 From: kolo Date: Tue, 24 Mar 2026 16:06:34 +0300 Subject: [PATCH] update --- lib/core/l10n/app_strings.dart | 2 +- .../widgets/account_editor_overlay.dart | 41 +++++++++++-------- .../widgets/balance_card_carousel.dart | 8 ++-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/core/l10n/app_strings.dart b/lib/core/l10n/app_strings.dart index 15b4af9..59cb8da 100644 --- a/lib/core/l10n/app_strings.dart +++ b/lib/core/l10n/app_strings.dart @@ -10,7 +10,7 @@ class AppStrings { String get appTitle => _ru ? 'Мои финансы' : 'My Finances'; String get totalBalance => _ru ? 'ОБЩИЙ БАЛАНС' : 'TOTAL BALANCE'; String get tapAndHoldToEdit => _ru ? 'удерживайте для редактирования' : 'tap and hold to edit'; - String get add => _ru ? 'Добавить' : 'Add'; + String get add => _ru ? 'Добавить счёт' : 'Add account'; String get transactions => _ru ? 'Транзакции' : 'Transactions'; String get searchHint => _ru ? 'Поиск транзакций...' : 'Search transactions...'; String get filterAll => _ru ? 'Все' : 'All'; diff --git a/lib/features/dashboard/widgets/account_editor_overlay.dart b/lib/features/dashboard/widgets/account_editor_overlay.dart index 1be546c..07093ad 100644 --- a/lib/features/dashboard/widgets/account_editor_overlay.dart +++ b/lib/features/dashboard/widgets/account_editor_overlay.dart @@ -5,6 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../../core/l10n/app_strings.dart'; import '../../../core/l10n/locale_provider.dart'; import '../../../core/services/card_color_service.dart'; +import '../../../core/services/haptic_service.dart'; import '../../../shared/models/transaction.dart'; import '../../settings/provider.dart'; import '../provider.dart'; @@ -89,22 +90,24 @@ class _AccountEditorOverlayState extends State { builder: (context, ref, _) { final exchangeService = ref.watch(exchangeRateServiceProvider); - // Calculate preview balance fresh from raw transactions + // Fix: If adding a new account, the balance is strictly 0.0 double previewBalance = 0.0; - if (dash.editingAccount != null) { - final txs = ref.watch(accountFilteredTransactionsProvider); - final accountTxs = txs.where((t) => t.accountId == dash.editingAccount!.id); - previewBalance = accountTxs.fold(0.0, (sum, t) { - final converted = exchangeService.convert( - t.amount, - t.currencyCode, - dash.tempAccountCurrency, // convert directly from tx currency to selected dropdown currency - ); - return t.type == TransactionType.income ? sum + converted : sum - converted; - }); - } else { - // Fallback just in case, though editingAccount should never be null here - previewBalance = ref.read(totalBalanceProvider); + if (!dash.isAddingAccount) { + if (dash.editingAccount != null) { + final txs = ref.watch(accountFilteredTransactionsProvider); + final accountTxs = txs.where((t) => t.accountId == dash.editingAccount!.id); + previewBalance = accountTxs.fold(0.0, (sum, t) { + final converted = exchangeService.convert( + t.amount, + t.currencyCode, + dash.tempAccountCurrency, // convert directly from tx currency to selected dropdown currency + ); + return t.type == TransactionType.income ? sum + converted : sum - converted; + }); + } else { + // Fallback for edge cases + previewBalance = ref.read(totalBalanceProvider); + } } return Material( @@ -863,7 +866,11 @@ class _AccountEditorOverlayState extends State { child: ElevatedButton( onPressed: _nameController.text.trim().isEmpty ? null - : () => dash.closeAccountOverlay(apply: true), + : () { + // Add haptic feedback here + HapticService.light(); + dash.closeAccountOverlay(apply: true); + }, style: ElevatedButton.styleFrom( backgroundColor: const Color(0xFF7C6DED), foregroundColor: Colors.white, @@ -880,7 +887,7 @@ class _AccountEditorOverlayState extends State { borderRadius: BorderRadius.circular(12)), ), child: Text( - dash.isAddingAccount ? 'Создать счёт' : s.apply, + dash.isAddingAccount ? s.add : s.apply, style: const TextStyle( fontWeight: FontWeight.w700, fontSize: 14)), ), diff --git a/lib/features/dashboard/widgets/balance_card_carousel.dart b/lib/features/dashboard/widgets/balance_card_carousel.dart index 310725a..0c8ebff 100644 --- a/lib/features/dashboard/widgets/balance_card_carousel.dart +++ b/lib/features/dashboard/widgets/balance_card_carousel.dart @@ -180,12 +180,12 @@ class AddAccountCard extends StatelessWidget { return GestureDetector( onTap: onTap, child: Container( - margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 15), // makes it smaller + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), // Reduced margins for larger size child: CustomPaint( painter: _DashedBorderPainter(), child: Container( width: double.infinity, - height: 190, // reduced from 220 + height: 205, // Increased height decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface.withOpacity(0.4), borderRadius: BorderRadius.circular(20), @@ -195,14 +195,14 @@ class AddAccountCard extends StatelessWidget { children: [ Icon( Icons.add_rounded, - size: 32, + size: 36, // Slightly bigger icon color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5), ), const SizedBox(height: 8), Text( 'Add account', style: TextStyle( - fontSize: 14, + fontSize: 15, color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5), fontWeight: FontWeight.w500, ),