This commit is contained in:
2026-03-27 14:49:30 +03:00
parent ce324a0a5e
commit 2fc1d3e200
4 changed files with 252 additions and 255 deletions
+92 -110
View File
@@ -433,33 +433,16 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
ListView( ListView(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
children: [ children: [
Stack( IgnorePointer(
children: [ ignoring: isEditing,
IgnorePointer( child: TypeToggle(
ignoring: isEditing, selected: state.type,
child: TypeToggle( onChanged: (type) => ref
selected: state.type, .read(addTransactionProvider(widget.initial).notifier)
onChanged: (type) => ref .setType(type),
.read( isDark: isDark,
addTransactionProvider(widget.initial).notifier, isEditing: isEditing,
) ),
.setType(type),
isDark: isDark,
),
),
if (isEditing)
Positioned(
top: 8,
right: 8,
child: Icon(
Icons.lock_outline,
size: 16,
color: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.4),
),
),
],
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
@@ -796,7 +779,6 @@ class _ToAccountDropdownOverlay extends ConsumerWidget {
// Calculate position from trigger key // Calculate position from trigger key
double top = 340; double top = 340;
double left = 20; double left = 20;
double? width;
if (triggerKey?.currentContext != null) { if (triggerKey?.currentContext != null) {
final renderBox = final renderBox =
@@ -805,98 +787,98 @@ class _ToAccountDropdownOverlay extends ConsumerWidget {
final size = renderBox.size; final size = renderBox.size;
top = offset.dy + size.height + 4; top = offset.dy + size.height + 4;
left = offset.dx; left = offset.dx;
width = size.width;
} }
return Positioned( return Positioned(
top: top, top: top,
left: left, left: left,
width: width, child: IntrinsicWidth(
child: Material( child: Material(
elevation: 8, elevation: 8,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
color: Colors.transparent, color: Colors.transparent,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: const Color(0xFF7C6DED).withOpacity(0.3), color: const Color(0xFF7C6DED).withOpacity(0.3),
width: 1.5, width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 16,
offset: const Offset(0, 4),
), ),
], boxShadow: [
), BoxShadow(
child: accountsAsync.when( color: Colors.black.withOpacity(0.2),
data: (accounts) { blurRadius: 16,
final filteredAccounts = accounts offset: const Offset(0, 4),
.where((a) => a.id != selectedAccountId) ),
.toList(); ],
),
child: accountsAsync.when(
data: (accounts) {
final filteredAccounts = accounts
.where((a) => a.id != selectedAccountId)
.toList();
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: filteredAccounts.map((account) { children: filteredAccounts.map((account) {
final isSelected = account.id == toAccountId; final isSelected = account.id == toAccountId;
return InkWell( return InkWell(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
onTap: () { onTap: () {
ref ref
.read(addTransactionProvider(initial).notifier) .read(addTransactionProvider(initial).notifier)
.setToAccountId(account.id); .setToAccountId(account.id);
onClose(); onClose();
HapticService.light(); HapticService.light();
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 14, horizontal: 14,
vertical: 12, vertical: 12,
), ),
child: Row( child: Row(
children: [ children: [
Icon( Icon(
Icons.account_balance_wallet_rounded, Icons.account_balance_wallet_rounded,
size: 16, size: 16,
color: isSelected color: isSelected
? const Color(0xFF7C6DED) ? const Color(0xFF7C6DED)
: Theme.of( : Theme.of(
context, context,
).colorScheme.onSurface.withOpacity(0.5), ).colorScheme.onSurface.withOpacity(0.5),
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
Expanded( Expanded(
child: Text( child: Text(
account.name, account.name,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: isSelected fontWeight: isSelected
? FontWeight.w600 ? FontWeight.w600
: FontWeight.w400, : FontWeight.w400,
color: isSelected color: isSelected
? const Color(0xFF7C6DED) ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface, : Theme.of(context).colorScheme.onSurface,
),
), ),
), ),
), if (isSelected)
if (isSelected) const Icon(
const Icon( Icons.check_rounded,
Icons.check_rounded, size: 16,
size: 16, color: Color(0xFF7C6DED),
color: Color(0xFF7C6DED), ),
), ],
], ),
), ),
), );
); }).toList(),
}).toList(), );
); },
}, loading: () => const SizedBox.shrink(),
loading: () => const SizedBox.shrink(), error: (_, __) => const SizedBox.shrink(),
error: (_, __) => const SizedBox.shrink(), ),
), ),
), ),
), ),
@@ -418,13 +418,6 @@ class _AccountHalf extends StatelessWidget {
), ),
), ),
), ),
if (error != null) ...[
const SizedBox(height: 4),
Text(
error!,
style: const TextStyle(fontSize: 11, color: Color(0xFFE05C6B)),
),
],
], ],
); );
} }
@@ -136,7 +136,6 @@ class AccountDropdownOverlay extends ConsumerWidget {
// Calculate position from trigger key // Calculate position from trigger key
double top = 76; double top = 76;
double left = 20; double left = 20;
double? width;
if (triggerKey?.currentContext != null) { if (triggerKey?.currentContext != null) {
final renderBox = final renderBox =
@@ -145,115 +144,115 @@ class AccountDropdownOverlay extends ConsumerWidget {
final size = renderBox.size; final size = renderBox.size;
top = offset.dy + size.height + 4; top = offset.dy + size.height + 4;
left = offset.dx; left = offset.dx;
width = size.width;
} }
return Positioned( return Positioned(
top: top, top: top,
left: left, left: left,
width: width, child: IntrinsicWidth(
child: Material( child: Material(
elevation: 8, elevation: 8,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
color: Colors.transparent, color: Colors.transparent,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: const Color(0xFF7C6DED).withOpacity(0.3), color: const Color(0xFF7C6DED).withOpacity(0.3),
width: 1.5, width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 16,
offset: const Offset(0, 4),
), ),
], boxShadow: [
), BoxShadow(
child: accountsAsync.when( color: Colors.black.withOpacity(0.2),
data: (accounts) { blurRadius: 16,
final txAccountId = ref offset: const Offset(0, 4),
.read(addTransactionProvider(initial)) ),
.selectedAccountId; ],
final Account displayAccount; ),
if (txAccountId != null) { child: accountsAsync.when(
displayAccount = accounts.firstWhere( data: (accounts) {
(a) => a.id == txAccountId, final txAccountId = ref
orElse: () => accounts.firstWhere( .read(addTransactionProvider(initial))
(a) => a.isMain, .selectedAccountId;
orElse: () => accounts.first, final Account displayAccount;
), if (txAccountId != null) {
); displayAccount = accounts.firstWhere(
} else { (a) => a.id == txAccountId,
displayAccount = orElse: () => accounts.firstWhere(
activeAccount ??
accounts.firstWhere(
(a) => a.isMain, (a) => a.isMain,
orElse: () => accounts.first, orElse: () => accounts.first,
);
}
return Column(
mainAxisSize: MainAxisSize.min,
children: accounts.map((account) {
final isSelected = account.id == displayAccount.id;
return InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () {
ref
.read(addTransactionProvider(initial).notifier)
.setAccountId(account.id);
onClose();
HapticService.light();
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 12,
),
child: Row(
children: [
Icon(
Icons.account_balance_wallet_rounded,
size: 16,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.5),
),
const SizedBox(width: 10),
Expanded(
child: Text(
account.name,
style: TextStyle(
fontSize: 14,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.w400,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface,
),
),
),
if (isSelected)
const Icon(
Icons.check_rounded,
size: 16,
color: Color(0xFF7C6DED),
),
],
),
), ),
); );
}).toList(), } else {
); displayAccount =
}, activeAccount ??
loading: () => const SizedBox.shrink(), accounts.firstWhere(
error: (_, __) => const SizedBox.shrink(), (a) => a.isMain,
orElse: () => accounts.first,
);
}
return Column(
mainAxisSize: MainAxisSize.min,
children: accounts.map((account) {
final isSelected = account.id == displayAccount.id;
return InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () {
ref
.read(addTransactionProvider(initial).notifier)
.setAccountId(account.id);
onClose();
HapticService.light();
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 12,
),
child: Row(
children: [
Icon(
Icons.account_balance_wallet_rounded,
size: 16,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(
context,
).colorScheme.onSurface.withOpacity(0.5),
),
const SizedBox(width: 10),
Expanded(
child: Text(
account.name,
style: TextStyle(
fontSize: 14,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.w400,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface,
),
),
),
if (isSelected)
const Icon(
Icons.check_rounded,
size: 16,
color: Color(0xFF7C6DED),
),
],
),
),
);
}).toList(),
);
},
loading: () => const SizedBox.shrink(),
error: (_, __) => const SizedBox.shrink(),
),
), ),
), ),
), ),
@@ -8,12 +8,14 @@ class TypeToggle extends ConsumerWidget {
final TransactionType selected; final TransactionType selected;
final ValueChanged<TransactionType> onChanged; final ValueChanged<TransactionType> onChanged;
final bool isDark; final bool isDark;
final bool isEditing;
const TypeToggle({ const TypeToggle({
super.key, super.key,
required this.selected, required this.selected,
required this.onChanged, required this.onChanged,
required this.isDark, required this.isDark,
this.isEditing = false,
}); });
@override @override
@@ -41,6 +43,7 @@ class TypeToggle extends ConsumerWidget {
isSelected: selected == TransactionType.income, isSelected: selected == TransactionType.income,
onTap: () => onChanged(TransactionType.income), onTap: () => onChanged(TransactionType.income),
isDark: isDark, isDark: isDark,
showLock: isEditing && selected == TransactionType.income,
), ),
), ),
Expanded( Expanded(
@@ -51,6 +54,7 @@ class TypeToggle extends ConsumerWidget {
isSelected: selected == TransactionType.expense, isSelected: selected == TransactionType.expense,
onTap: () => onChanged(TransactionType.expense), onTap: () => onChanged(TransactionType.expense),
isDark: isDark, isDark: isDark,
showLock: isEditing && selected == TransactionType.expense,
), ),
), ),
Expanded( Expanded(
@@ -64,6 +68,7 @@ class TypeToggle extends ConsumerWidget {
: () => onChanged(TransactionType.transfer), : () => onChanged(TransactionType.transfer),
isDark: isDark, isDark: isDark,
disabled: transferDisabled, disabled: transferDisabled,
showLock: isEditing && selected == TransactionType.transfer,
), ),
), ),
], ],
@@ -80,6 +85,7 @@ class _TypeOption extends StatelessWidget {
final VoidCallback? onTap; final VoidCallback? onTap;
final bool isDark; final bool isDark;
final bool disabled; final bool disabled;
final bool showLock;
const _TypeOption({ const _TypeOption({
required this.icon, required this.icon,
@@ -89,6 +95,7 @@ class _TypeOption extends StatelessWidget {
required this.onTap, required this.onTap,
required this.isDark, required this.isDark,
this.disabled = false, this.disabled = false,
this.showLock = false,
}); });
@override @override
@@ -99,46 +106,62 @@ class _TypeOption extends StatelessWidget {
return GestureDetector( return GestureDetector(
onTap: disabled ? null : onTap, onTap: disabled ? null : onTap,
child: AnimatedContainer( child: Stack(
duration: const Duration(milliseconds: 200), children: [
decoration: BoxDecoration( AnimatedContainer(
color: isSelected && !disabled duration: const Duration(milliseconds: 200),
? effectiveColor.withOpacity(0.15) decoration: BoxDecoration(
: Colors.transparent, color: isSelected && !disabled
borderRadius: BorderRadius.circular(11), ? effectiveColor.withOpacity(0.15)
border: isSelected && !disabled : Colors.transparent,
? Border.all(color: effectiveColor, width: 1.5) borderRadius: BorderRadius.circular(11),
: null, border: isSelected && !disabled
), ? Border.all(color: effectiveColor, width: 1.5)
child: Center( : null,
child: Column( ),
mainAxisAlignment: MainAxisAlignment.center, child: Center(
children: [ child: Column(
Icon( mainAxisAlignment: MainAxisAlignment.center,
icon, children: [
color: isSelected && !disabled Icon(
? effectiveColor icon,
: Theme.of( color: isSelected && !disabled
context, ? effectiveColor
).colorScheme.onSurface.withOpacity(disabled ? 0.2 : 0.4), : Theme.of(context).colorScheme.onSurface.withOpacity(
size: 20, disabled ? 0.2 : 0.4,
),
size: 20,
),
const SizedBox(height: 4),
Text(
label,
style: TextStyle(
fontSize: 11,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.w400,
color: isSelected && !disabled
? effectiveColor
: Theme.of(context).colorScheme.onSurface.withOpacity(
disabled ? 0.2 : 0.5,
),
),
),
],
), ),
const SizedBox(height: 4), ),
Text(
label,
style: TextStyle(
fontSize: 11,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
color: isSelected && !disabled
? effectiveColor
: Theme.of(context).colorScheme.onSurface.withOpacity(
disabled ? 0.2 : 0.5,
),
),
),
],
), ),
), if (showLock)
Positioned(
top: 4,
right: 4,
child: Icon(
Icons.lock_outline,
size: 10,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
),
),
],
), ),
); );
} }