This commit is contained in:
2026-03-20 17:03:34 +03:00
parent 582e21a7e2
commit b2a0ed62fb
3 changed files with 116 additions and 93 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ class AddTransactionState {
const AddTransactionState({ const AddTransactionState({
this.amount, this.amount,
this.category = 'Food', this.category = 'Salary',
this.type = TransactionType.expense, this.type = TransactionType.income,
required this.date, required this.date,
this.note = '', this.note = '',
this.isSubmitting = false, this.isSubmitting = false,
+48 -18
View File
@@ -282,18 +282,48 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen> {
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
ElevatedButton( AnimatedContainer(
onPressed: state.isSubmitting ? null : _submit, duration: const Duration(milliseconds: 250),
child: state.isSubmitting curve: Curves.easeInOut,
? const SizedBox( child: Builder(
height: 20, builder: (context) {
width: 20, final selectedType = state.type;
child: CircularProgressIndicator( final typeColor = selectedType == TransactionType.income
strokeWidth: 2, ? const Color(0xFF4CAF8C)
color: Colors.white, : const Color(0xFFE05C6B);
return SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: state.isSubmitting ? null : _submit,
style: OutlinedButton.styleFrom(
backgroundColor: typeColor.withOpacity(0.1),
side: BorderSide(color: typeColor, width: 2),
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
foregroundColor: typeColor,
), ),
) child: state.isSubmitting
: Text(state.isEditing ? 'Update Transaction' : 'Save Transaction'), ? SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: typeColor,
),
)
: Text(
state.isEditing ? 'Save Changes' : 'Add Transaction',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: typeColor,
),
),
),
);
},
),
), ),
], ],
), ),
@@ -336,13 +366,6 @@ class _TypeToggle extends StatelessWidget {
), ),
child: Row( child: Row(
children: [ children: [
_TypeOption(
label: 'Expense',
icon: Icons.arrow_upward_rounded,
color: AppColors.expense,
isSelected: selected == TransactionType.expense,
onTap: () => onChanged(TransactionType.expense),
),
_TypeOption( _TypeOption(
label: 'Income', label: 'Income',
icon: Icons.arrow_downward_rounded, icon: Icons.arrow_downward_rounded,
@@ -350,6 +373,13 @@ class _TypeToggle extends StatelessWidget {
isSelected: selected == TransactionType.income, isSelected: selected == TransactionType.income,
onTap: () => onChanged(TransactionType.income), onTap: () => onChanged(TransactionType.income),
), ),
_TypeOption(
label: 'Expense',
icon: Icons.arrow_upward_rounded,
color: AppColors.expense,
isSelected: selected == TransactionType.expense,
onTap: () => onChanged(TransactionType.expense),
),
], ],
), ),
); );
+66 -73
View File
@@ -362,7 +362,7 @@ class _BalanceCard extends ConsumerWidget {
return Container( return Container(
width: double.infinity, width: double.infinity,
height: 180, height: 180,
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
@@ -381,88 +381,81 @@ class _BalanceCard extends ConsumerWidget {
), ),
], ],
), ),
child: LayoutBuilder( child: Row(
builder: (context, constraints) { mainAxisAlignment: MainAxisAlignment.center,
return Row( crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, children: [
children: [ // LEFT: main balance — takes available space, centered
// LEFT: main balance — takes as much space as needed, right side shrinks first Expanded(
Flexible( flex: 5,
flex: 3, child: Column(
child: Column( mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Text(
Text( 'TOTAL BALANCE',
'TOTAL BALANCE', style: TextStyle(
style: TextStyle( fontSize: 11,
fontSize: 11, letterSpacing: 1.5,
letterSpacing: 1.2, color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.6),
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.6), ),
), ),
const SizedBox(height: 6),
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.center,
child: Text(
_smartBalance(balance, fmt, currencyInfo.symbol),
style: TextStyle(
fontSize: 48,
fontWeight: FontWeight.w700,
color: Theme.of(context).colorScheme.onPrimary,
), ),
const SizedBox(height: 4), maxLines: 1,
// FittedBox shrinks text to fit available width textAlign: TextAlign.center,
FittedBox( ),
),
],
),
),
// Only show conversion column if there's a meaningful balance
if (balance != 0) ...[
const SizedBox(width: 16),
Container(
width: 1,
height: 70,
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.15),
),
const SizedBox(width: 16),
// RIGHT: conversions — fixed width, doesn't expand
SizedBox(
width: 110,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: others.map((c) {
final converted = rates.convert(balance, currencyInfo.code, c.$1);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3),
child: FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
_smartBalance(balance, fmt, currencyInfo.symbol), _smartBalance(converted, fmt, c.$2),
style: TextStyle( style: TextStyle(
fontSize: 36, // max font size fontSize: 14,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onPrimary, color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.65),
), ),
maxLines: 1, maxLines: 1,
), ),
), ),
], );
), }).toList(),
), ),
// RIGHT side: use Flexible (not Expanded) so it can shrink ),
// When balance is long, this column gets squeezed first ],
Flexible( ],
flex: 2,
child: Row(
children: [
const SizedBox(width: 12),
Container(
width: 1,
height: 60,
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.15),
),
const SizedBox(width: 12),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: others.map((c) {
final converted = rates.convert(balance, currencyInfo.code, c.$1);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 2),
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_smartBalance(converted, fmt, c.$2),
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.7),
),
maxLines: 1,
),
),
);
}).toList(),
),
),
],
),
),
],
);
},
), ),
); );
} }