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,
+41 -11
View File
@@ -282,18 +282,48 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen> {
), ),
const SizedBox(height: 32), const SizedBox(height: 32),
ElevatedButton( AnimatedContainer(
duration: const Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: Builder(
builder: (context) {
final selectedType = state.type;
final typeColor = selectedType == TransactionType.income
? const Color(0xFF4CAF8C)
: const Color(0xFFE05C6B);
return SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: state.isSubmitting ? null : _submit, 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 child: state.isSubmitting
? const SizedBox( ? SizedBox(
height: 20, height: 20,
width: 20, width: 20,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 2, strokeWidth: 2,
color: Colors.white, color: typeColor,
), ),
) )
: Text(state.isEditing ? 'Update Transaction' : 'Save Transaction'), : 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),
),
], ],
), ),
); );
+23 -30
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,74 +381,71 @@ 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 as much space as needed, right side shrinks first // LEFT: main balance — takes available space, centered
Flexible( Expanded(
flex: 3, flex: 5,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text( Text(
'TOTAL BALANCE', 'TOTAL BALANCE',
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 11,
letterSpacing: 1.2, letterSpacing: 1.5,
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.6), color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.6),
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 6),
// FittedBox shrinks text to fit available width
FittedBox( FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft, alignment: Alignment.center,
child: Text( child: Text(
_smartBalance(balance, fmt, currencyInfo.symbol), _smartBalance(balance, fmt, currencyInfo.symbol),
style: TextStyle( style: TextStyle(
fontSize: 36, // max font size fontSize: 48,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: Theme.of(context).colorScheme.onPrimary, color: Theme.of(context).colorScheme.onPrimary,
), ),
maxLines: 1, maxLines: 1,
textAlign: TextAlign.center,
), ),
), ),
], ],
), ),
), ),
// RIGHT side: use Flexible (not Expanded) so it can shrink // Only show conversion column if there's a meaningful balance
// When balance is long, this column gets squeezed first if (balance != 0) ...[
Flexible( const SizedBox(width: 16),
flex: 2,
child: Row(
children: [
const SizedBox(width: 12),
Container( Container(
width: 1, width: 1,
height: 60, height: 70,
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.15), color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.15),
), ),
const SizedBox(width: 12), const SizedBox(width: 16),
Expanded( // RIGHT: conversions — fixed width, doesn't expand
SizedBox(
width: 110,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: others.map((c) { children: others.map((c) {
final converted = rates.convert(balance, currencyInfo.code, c.$1); final converted = rates.convert(balance, currencyInfo.code, c.$1);
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 2), padding: const EdgeInsets.symmetric(vertical: 3),
child: FittedBox( child: FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
_smartBalance(converted, fmt, c.$2), _smartBalance(converted, fmt, c.$2),
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.7), color: Theme.of(context).colorScheme.onPrimary.withOpacity(0.65),
), ),
maxLines: 1, maxLines: 1,
), ),
@@ -458,11 +455,7 @@ class _BalanceCard extends ConsumerWidget {
), ),
), ),
], ],
),
),
], ],
);
},
), ),
); );
} }