mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 02:15:29 +03:00
update
This commit is contained in:
@@ -77,10 +77,16 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
_noteController.text = widget.initial!.note ?? '';
|
||||
} else {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final activeAccount = ref.read(activeAccountProvider);
|
||||
final curr = ref.read(currencyProvider);
|
||||
|
||||
// Use active account's currency if available, otherwise use global currency
|
||||
final currencyCode = activeAccount?.currency ?? curr.code;
|
||||
final currencySymbol = currencyMap[currencyCode]?.symbol ?? curr.symbol;
|
||||
|
||||
ref
|
||||
.read(addTransactionProvider(null).notifier)
|
||||
.setCurrency(curr.symbol, curr.code);
|
||||
.setCurrency(currencySymbol, currencyCode);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -155,18 +161,24 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
|
||||
try {
|
||||
print('--- SUBMIT CLICKED ---');
|
||||
print('Amount: $amount, Category: ${state.category}, Type: ${state.type.name}');
|
||||
print(
|
||||
'Amount: $amount, Category: ${state.category}, Type: ${state.type.name}',
|
||||
);
|
||||
|
||||
final activeAccount = ref.read(activeAccountProvider);
|
||||
int accountId;
|
||||
|
||||
if (activeAccount != null) {
|
||||
print('Using active account ID: ${activeAccount.id}, Name: ${activeAccount.name}');
|
||||
print(
|
||||
'Using active account ID: ${activeAccount.id}, Name: ${activeAccount.name}',
|
||||
);
|
||||
accountId = activeAccount.id;
|
||||
} else {
|
||||
print('No active account. Fetching main account...');
|
||||
final mainAccount = await ref.read(accountRepositoryProvider).getMain();
|
||||
print('Main account fetched: ID=${mainAccount.id}, Name: ${mainAccount.name}');
|
||||
print(
|
||||
'Main account fetched: ID=${mainAccount.id}, Name: ${mainAccount.name}',
|
||||
);
|
||||
accountId = mainAccount.id;
|
||||
}
|
||||
|
||||
@@ -190,7 +202,9 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
print('Update completed');
|
||||
} else {
|
||||
final res = await ref.read(transactionsProvider.notifier).add(tx);
|
||||
print('Add completed. Result: ${res.isSuccess ? "SUCCESS" : "FAILURE"}');
|
||||
print(
|
||||
'Add completed. Result: ${res.isSuccess ? "SUCCESS" : "FAILURE"}',
|
||||
);
|
||||
|
||||
if (res.isFailure) {
|
||||
print('!!! Provider returned failure: ${res.errorOrNull}');
|
||||
@@ -343,8 +357,12 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
Expanded(
|
||||
child: accountsAsync.when(
|
||||
data: (accounts) {
|
||||
final displayAccount = activeAccount ??
|
||||
accounts.firstWhere((a) => a.isMain, orElse: () => accounts.first);
|
||||
final displayAccount =
|
||||
activeAccount ??
|
||||
accounts.firstWhere(
|
||||
(a) => a.isMain,
|
||||
orElse: () => accounts.first,
|
||||
);
|
||||
|
||||
return Container(
|
||||
height: 56,
|
||||
@@ -369,11 +387,12 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
Flexible(
|
||||
child: Text(
|
||||
displayAccount.name,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: const Color(0xFF7C6DED),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
style: Theme.of(context).textTheme.bodyMedium
|
||||
?.copyWith(
|
||||
color: const Color(0xFF7C6DED),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -408,14 +427,21 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: isDark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||
: Border.all(
|
||||
color: const Color(0xFFDDDDEE),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => ref
|
||||
.read(addTransactionProvider(widget.initial).notifier)
|
||||
.read(
|
||||
addTransactionProvider(
|
||||
widget.initial,
|
||||
).notifier,
|
||||
)
|
||||
.setType(TransactionType.income),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
@@ -430,7 +456,10 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
Icons.arrow_downward_rounded,
|
||||
color: state.type == TransactionType.income
|
||||
? AppColors.income
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.4),
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withOpacity(0.4),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
@@ -440,7 +469,11 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => ref
|
||||
.read(addTransactionProvider(widget.initial).notifier)
|
||||
.read(
|
||||
addTransactionProvider(
|
||||
widget.initial,
|
||||
).notifier,
|
||||
)
|
||||
.setType(TransactionType.expense),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
@@ -455,7 +488,10 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
Icons.arrow_upward_rounded,
|
||||
color: state.type == TransactionType.expense
|
||||
? AppColors.expense
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.4),
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withOpacity(0.4),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user