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
+4 -22
View File
@@ -432,35 +432,18 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
children: [ children: [
ListView( ListView(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
children: [
Stack(
children: [ children: [
IgnorePointer( IgnorePointer(
ignoring: isEditing, ignoring: isEditing,
child: TypeToggle( child: TypeToggle(
selected: state.type, selected: state.type,
onChanged: (type) => ref onChanged: (type) => ref
.read( .read(addTransactionProvider(widget.initial).notifier)
addTransactionProvider(widget.initial).notifier,
)
.setType(type), .setType(type),
isDark: isDark, isDark: isDark,
isEditing: isEditing,
), ),
), ),
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),
if (isTransfer) if (isTransfer)
@@ -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,13 +787,12 @@ 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),
@@ -900,6 +881,7 @@ class _ToAccountDropdownOverlay extends ConsumerWidget {
), ),
), ),
), ),
),
); );
} }
} }
@@ -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,13 +144,12 @@ 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),
@@ -257,6 +255,7 @@ class AccountDropdownOverlay extends ConsumerWidget {
), ),
), ),
), ),
),
); );
} }
} }
@@ -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,7 +106,9 @@ class _TypeOption extends StatelessWidget {
return GestureDetector( return GestureDetector(
onTap: disabled ? null : onTap, onTap: disabled ? null : onTap,
child: AnimatedContainer( child: Stack(
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected && !disabled color: isSelected && !disabled
@@ -118,9 +127,9 @@ class _TypeOption extends StatelessWidget {
icon, icon,
color: isSelected && !disabled color: isSelected && !disabled
? effectiveColor ? effectiveColor
: Theme.of( : Theme.of(context).colorScheme.onSurface.withOpacity(
context, disabled ? 0.2 : 0.4,
).colorScheme.onSurface.withOpacity(disabled ? 0.2 : 0.4), ),
size: 20, size: 20,
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
@@ -128,7 +137,9 @@ class _TypeOption extends StatelessWidget {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 11,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400, fontWeight: isSelected
? FontWeight.w600
: FontWeight.w400,
color: isSelected && !disabled color: isSelected && !disabled
? effectiveColor ? effectiveColor
: Theme.of(context).colorScheme.onSurface.withOpacity( : Theme.of(context).colorScheme.onSurface.withOpacity(
@@ -140,6 +151,18 @@ class _TypeOption extends StatelessWidget {
), ),
), ),
), ),
if (showLock)
Positioned(
top: 4,
right: 4,
child: Icon(
Icons.lock_outline,
size: 10,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
),
),
],
),
); );
} }
} }