mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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<AccountEditorOverlay> {
|
||||
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<AccountEditorOverlay> {
|
||||
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<AccountEditorOverlay> {
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: Text(
|
||||
dash.isAddingAccount ? 'Создать счёт' : s.apply,
|
||||
dash.isAddingAccount ? s.add : s.apply,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700, fontSize: 14)),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user