This commit is contained in:
2026-03-26 00:42:54 +03:00
parent d1ef8a64a1
commit 71de991587
18 changed files with 564 additions and 187 deletions
@@ -20,7 +20,9 @@ class AmountFormatSection extends ConsumerWidget {
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1),
border: isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -44,9 +46,9 @@ class AmountFormatSection extends ConsumerWidget {
child: Text(
s.amountFormat,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
],
@@ -57,9 +59,13 @@ class AmountFormatSection extends ConsumerWidget {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: GestureDetector(
onTap: () => ref.read(amountFormatProvider.notifier).set(format),
onTap: () =>
ref.read(amountFormatProvider.notifier).set(format),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
decoration: BoxDecoration(
color: isSelected
? AppColors.accent.withOpacity(0.2)
@@ -67,7 +73,12 @@ class AmountFormatSection extends ConsumerWidget {
borderRadius: BorderRadius.circular(12),
border: isSelected
? Border.all(color: AppColors.accent, width: 1.5)
: (isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1)),
: (isDark
? null
: Border.all(
color: const Color(0xFFDDDDEE),
width: 1,
)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -75,14 +86,25 @@ class AmountFormatSection extends ConsumerWidget {
Text(
format.label,
style: TextStyle(
color: isSelected ? AppColors.accent : Theme.of(context).colorScheme.onSurface,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
color: isSelected
? AppColors.accent
: Theme.of(context).colorScheme.onSurface,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.w500,
),
),
Text(
format.example.replaceFirst('SYM', currencyInfo.symbol),
format.example.replaceFirst(
'SYM',
currencyInfo.symbol.isEmpty
? 'Br'
: currencyInfo.symbol,
),
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
color: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.6),
fontSize: 12,
),
),
@@ -5,6 +5,7 @@ import '../../../core/constants.dart';
import '../../../core/l10n/locale_provider.dart';
import '../../../shared/providers/amount_format_provider.dart';
import '../../../shared/utils/currency_utils.dart';
import '../../../shared/widgets/byn_sign.dart';
import '../provider.dart';
class BudgetSection extends ConsumerStatefulWidget {
@@ -59,7 +60,9 @@ class _BudgetSectionState extends ConsumerState<BudgetSection> {
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1),
border: isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -83,15 +86,17 @@ class _BudgetSectionState extends ConsumerState<BudgetSection> {
child: Text(
s.monthlyBudgetSetting,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
if (!_isEditing)
IconButton(
icon: const Icon(Icons.edit_rounded, size: 20),
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
color: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.6),
onPressed: () => setState(() => _isEditing = true),
),
],
@@ -103,14 +108,32 @@ class _BudgetSectionState extends ConsumerState<BudgetSection> {
children: [
TextFormField(
controller: _budgetController,
keyboardType: const TextInputType.numberWithOptions(decimal: true),
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,2}')),
FilteringTextInputFormatter.allow(
RegExp(r'^\d+\.?\d{0,2}'),
),
],
decoration: InputDecoration(
prefixText: currencyInfo.symbol == 'Br' || currencyInfo.symbol == ''
? '${currencyInfo.symbol} '
: currencyInfo.symbol,
prefix: currencyInfo.code == 'BYN'
? Row(
mainAxisSize: MainAxisSize.min,
children: [
BynSign(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
const SizedBox(width: 4),
],
)
: null,
prefixText: currencyInfo.code != 'BYN'
? (currencyInfo.symbol == ''
? '${currencyInfo.symbol} '
: currencyInfo.symbol)
: null,
hintText: '0.00',
helperText: s.leaveEmptyToRemove,
),
@@ -123,7 +146,8 @@ class _BudgetSectionState extends ConsumerState<BudgetSection> {
TextButton(
onPressed: () {
final budget = ref.read(budgetProvider);
_budgetController.text = budget?.toStringAsFixed(2) ?? '';
_budgetController.text =
budget?.toStringAsFixed(2) ?? '';
setState(() => _isEditing = false);
},
child: Text(s.cancel),
@@ -144,23 +168,47 @@ class _BudgetSectionState extends ConsumerState<BudgetSection> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
budget != null
? formatAmount(currencyInfo.symbol, budget, fmt)
: s.budgetNone,
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
color: budget != null ? AppColors.accent : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
fontWeight: FontWeight.w700,
budget != null && currencyInfo.code == 'BYN'
? Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BynSign(fontSize: 24, color: AppColors.accent),
const SizedBox(width: 2),
Text(
formatAmount('', budget, fmt),
style: Theme.of(context).textTheme.headlineSmall
?.copyWith(
color: AppColors.accent,
fontWeight: FontWeight.w700,
),
),
],
)
: Text(
budget != null
? formatAmount(currencyInfo.symbol, budget, fmt)
: s.budgetNone,
style: Theme.of(context).textTheme.headlineSmall
?.copyWith(
color: budget != null
? AppColors.accent
: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.6),
fontWeight: FontWeight.w700,
),
),
),
const SizedBox(height: 8),
Text(
budget != null
? s.yourMonthlySpendingLimit
: s.setMonthlySpendingLimit,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
),
color: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.6),
),
),
],
),
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart';
import '../../../core/l10n/locale_provider.dart';
import '../../../shared/widgets/byn_sign.dart';
import '../provider.dart';
class CurrencySection extends ConsumerWidget {
@@ -18,7 +19,9 @@ class CurrencySection extends ConsumerWidget {
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1),
border: isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -42,9 +45,9 @@ class CurrencySection extends ConsumerWidget {
child: Text(
s.currency,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
],
@@ -61,7 +64,9 @@ class CurrencySection extends ConsumerWidget {
onTap: () {
final oldCode = ref.read(currencyProvider).code;
final rates = ref.read(exchangeRateServiceProvider);
ref.read(budgetProvider.notifier).onCurrencyChanged(oldCode, code, rates);
ref
.read(budgetProvider.notifier)
.onCurrencyChanged(oldCode, code, rates);
ref.read(currencyProvider.notifier).setCurrency(code);
},
child: Container(
@@ -71,25 +76,52 @@ class CurrencySection extends ConsumerWidget {
? AppColors.accent.withOpacity(0.2)
: Theme.of(context).scaffoldBackgroundColor,
borderRadius: BorderRadius.circular(12),
border: isSelected
border: isSelected
? Border.all(color: AppColors.accent, width: 1.5)
: (isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1)),
: (isDark
? null
: Border.all(
color: const Color(0xFFDDDDEE),
width: 1,
)),
),
child: Column(
children: [
Text(
info.symbol,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: isSelected ? AppColors.accent : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
fontWeight: isSelected ? FontWeight.w700 : FontWeight.normal,
code == 'BYN'
? BynSign(
fontSize: 28,
color: isSelected
? AppColors.accent
: Theme.of(context).colorScheme.onSurface
.withOpacity(0.6),
)
: Text(
info.symbol,
style: Theme.of(context).textTheme.titleLarge
?.copyWith(
color: isSelected
? AppColors.accent
: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.6),
fontWeight: isSelected
? FontWeight.w700
: FontWeight.normal,
),
),
),
const SizedBox(height: 2),
Text(
code,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: isSelected ? AppColors.accent : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
style: Theme.of(context).textTheme.bodySmall
?.copyWith(
color: isSelected
? AppColors.accent
: Theme.of(context).colorScheme.onSurface
.withOpacity(0.6),
fontWeight: isSelected
? FontWeight.w600
: FontWeight.normal,
),
),
],