This commit is contained in:
2026-03-29 14:59:51 +03:00
parent 0020c65d1e
commit 13fbbeda11
3 changed files with 362 additions and 251 deletions
+121 -47
View File
@@ -51,6 +51,8 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
bool _showToAccountDropdown = false; bool _showToAccountDropdown = false;
String? _toAccountError; String? _toAccountError;
String? _fromAccountError; String? _fromAccountError;
String? _transferExpenseRecordId;
String? _transferIncomeRecordId;
@override @override
void initState() { void initState() {
@@ -82,22 +84,59 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
if (widget.initial!.category == 'Transfer') { if (widget.initial!.category == 'Transfer') {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
final allTxs = ref.read(transactionsProvider).valueOrNull ?? []; final allTxs = ref.read(transactionsProvider).valueOrNull ?? [];
final counterpart = allTxs.firstWhereOrNull(
(t) => if (widget.initial!.type == TransactionType.expense) {
t.category == 'Transfer' && // widget.initial IS the expense side — find income counterpart for To
t.type == TransactionType.income && final counterpart = allTxs.firstWhereOrNull(
t.amount == widget.initial!.amount && (t) =>
t.date.year == widget.initial!.date.year && t.id != widget.initial!.id &&
t.date.month == widget.initial!.date.month && t.category == 'Transfer' &&
t.date.day == widget.initial!.date.day && t.type == TransactionType.income &&
t.date.hour == widget.initial!.date.hour && t.amount == widget.initial!.amount &&
t.date.minute == widget.initial!.date.minute && t.date.year == widget.initial!.date.year &&
t.note == widget.initial!.note, t.date.month == widget.initial!.date.month &&
); t.date.day == widget.initial!.date.day &&
if (counterpart != null) { t.date.hour == widget.initial!.date.hour &&
ref t.date.minute == widget.initial!.date.minute &&
.read(addTransactionProvider(widget.initial).notifier) t.note == widget.initial!.note,
.setToAccountId(counterpart.accountId); );
if (counterpart != null) {
ref
.read(addTransactionProvider(widget.initial).notifier)
.setToAccountId(counterpart.accountId);
}
setState(() {
_transferExpenseRecordId = widget.initial!.id;
_transferIncomeRecordId = counterpart?.id;
});
} else {
// widget.initial IS the income side — find expense counterpart
final expenseRecord = allTxs.firstWhereOrNull(
(t) =>
t.id != widget.initial!.id &&
t.category == 'Transfer' &&
t.type == TransactionType.expense &&
t.amount == widget.initial!.amount &&
t.date.year == widget.initial!.date.year &&
t.date.month == widget.initial!.date.month &&
t.date.day == widget.initial!.date.day &&
t.date.hour == widget.initial!.date.hour &&
t.date.minute == widget.initial!.date.minute &&
t.note == widget.initial!.note,
);
if (expenseRecord != null) {
// Swap: From = expense account, To = this income account
ref
.read(addTransactionProvider(widget.initial).notifier)
.setAccountId(expenseRecord.accountId);
ref
.read(addTransactionProvider(widget.initial).notifier)
.setToAccountId(widget.initial!.accountId);
}
setState(() {
_transferExpenseRecordId = expenseRecord?.id;
_transferIncomeRecordId = widget.initial!.id;
});
} }
}); });
} }
@@ -235,9 +274,9 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
if (state.isEditing) { if (state.isEditing) {
// Update both sides of the transfer pair // Update both sides of the transfer pair
// Update the expense side (widget.initial = expense record) // Update the expense side
final updatedExpense = Transaction( final updatedExpense = Transaction(
id: widget.initial!.id, id: _transferExpenseRecordId ?? widget.initial!.id,
amount: amount, amount: amount,
category: 'Transfer', category: 'Transfer',
type: TransactionType.expense, type: TransactionType.expense,
@@ -245,30 +284,14 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
note: note, note: note,
currency: currency, currency: currency,
currencyCode: currencyCode, currencyCode: currencyCode,
accountId: widget.initial!.accountId, // locked, unchanged accountId: state.selectedAccountId!, // from initState
); );
await ref.read(transactionsProvider.notifier).update(updatedExpense); await ref.read(transactionsProvider.notifier).update(updatedExpense);
// Find and update the income counterpart // Update the income side
final allTxs = ref.read(transactionsProvider).valueOrNull ?? []; if (_transferIncomeRecordId != null) {
final counterpart = allTxs.firstWhereOrNull(
(t) =>
t.category == 'Transfer' &&
t.type == TransactionType.income &&
t.accountId == state.toAccountId &&
t.amount ==
widget.initial!.amount && // match by original amount
t.date.year == widget.initial!.date.year &&
t.date.month == widget.initial!.date.month &&
t.date.day == widget.initial!.date.day &&
t.date.hour == widget.initial!.date.hour &&
t.date.minute == widget.initial!.date.minute &&
t.note == widget.initial!.note,
);
if (counterpart != null) {
final updatedIncome = Transaction( final updatedIncome = Transaction(
id: counterpart.id, id: _transferIncomeRecordId!,
amount: amount, // updated amount amount: amount, // updated amount
category: 'Transfer', category: 'Transfer',
type: TransactionType.income, type: TransactionType.income,
@@ -276,7 +299,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
note: note, note: note,
currency: currency, // updated currency currency: currency, // updated currency
currencyCode: currencyCode, currencyCode: currencyCode,
accountId: counterpart.accountId, // locked, unchanged accountId: state.toAccountId!, // from initState
); );
await ref.read(transactionsProvider.notifier).update(updatedIncome); await ref.read(transactionsProvider.notifier).update(updatedIncome);
} }
@@ -458,7 +481,8 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
final activeAccount = ref.watch(activeAccountProvider); final activeAccount = ref.watch(activeAccountProvider);
final isTransfer = state.type == TransactionType.transfer; final isTransfer = state.type == TransactionType.transfer;
final isEditingTransfer = isEditing && isTransfer; final isEditingTransfer = isEditing && isTransfer;
final isAccountLocked = activeAccount != null || isEditingTransfer; final isFromAccountLocked = activeAccount != null || isTransfer;
final isToAccountLocked = isEditingTransfer;
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
@@ -485,12 +509,60 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
child: Text(s.cancel), child: Text(s.cancel),
), ),
TextButton( TextButton(
onPressed: () { onPressed: () async {
ref Navigator.pop(ctx);
// Always delete the record we were given
await ref
.read(transactionsProvider.notifier) .read(transactionsProvider.notifier)
.delete(widget.initial!.id); .delete(widget.initial!.id);
Navigator.pop(ctx);
context.pop(); // If this is a Transfer, also delete the counterpart
if (widget.initial!.category == 'Transfer') {
// Use the pre-populated IDs from initState if available
final counterpartId =
widget.initial!.type == TransactionType.expense
? _transferIncomeRecordId
: _transferExpenseRecordId;
if (counterpartId != null) {
await ref
.read(transactionsProvider.notifier)
.delete(counterpartId);
} else {
// Fallback: search manually
final allTxs =
ref.read(transactionsProvider).valueOrNull ??
[];
final oppositeType =
widget.initial!.type ==
TransactionType.expense
? TransactionType.income
: TransactionType.expense;
final counterpart = allTxs.firstWhereOrNull(
(t) =>
t.id != widget.initial!.id &&
t.category == 'Transfer' &&
t.type == oppositeType &&
t.amount == widget.initial!.amount &&
t.date.year == widget.initial!.date.year &&
t.date.month ==
widget.initial!.date.month &&
t.date.day == widget.initial!.date.day &&
t.date.hour == widget.initial!.date.hour &&
t.date.minute ==
widget.initial!.date.minute &&
t.note == widget.initial!.note,
);
if (counterpart != null) {
await ref
.read(transactionsProvider.notifier)
.delete(counterpart.id);
}
}
}
if (mounted) context.pop();
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: const Color(0xFFE05C6B), foregroundColor: const Color(0xFFE05C6B),
@@ -544,7 +616,8 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
fromAccountError: _fromAccountError, fromAccountError: _fromAccountError,
toAccountError: _toAccountError, toAccountError: _toAccountError,
isDark: isDark, isDark: isDark,
isAccountLocked: isAccountLocked, isFromAccountLocked: isFromAccountLocked,
isToAccountLocked: isToAccountLocked,
), ),
if (isTransfer) const SizedBox(height: 24), if (isTransfer) const SizedBox(height: 24),
@@ -586,7 +659,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
}), }),
indicatorKey: _fromAccountIndicatorKey, indicatorKey: _fromAccountIndicatorKey,
isDark: isDark, isDark: isDark,
isLocked: isAccountLocked, isLocked: isFromAccountLocked,
), ),
], ],
], ],
@@ -767,8 +840,9 @@ class _InlineAccountSelector extends ConsumerWidget {
onTap: onToggleDropdown, onTap: onToggleDropdown,
child: Container( child: Container(
key: indicatorKey, key: indicatorKey,
constraints: const BoxConstraints(minWidth: 130),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 14, horizontal: 16,
vertical: 16, vertical: 16,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -16,7 +16,8 @@ class AccountRow extends ConsumerWidget {
final String? fromAccountError; final String? fromAccountError;
final String? toAccountError; final String? toAccountError;
final bool isDark; final bool isDark;
final bool isAccountLocked; final bool isFromAccountLocked;
final bool isToAccountLocked;
const AccountRow({ const AccountRow({
super.key, super.key,
@@ -30,7 +31,8 @@ class AccountRow extends ConsumerWidget {
this.fromAccountError, this.fromAccountError,
this.toAccountError, this.toAccountError,
required this.isDark, required this.isDark,
this.isAccountLocked = false, this.isFromAccountLocked = false,
this.isToAccountLocked = false,
}); });
@override @override
@@ -81,7 +83,8 @@ class AccountRow extends ConsumerWidget {
fromAccountError: fromAccountError, fromAccountError: fromAccountError,
toAccountError: toAccountError, toAccountError: toAccountError,
isDark: isDark, isDark: isDark,
isAccountLocked: isAccountLocked, isFromAccountLocked: isFromAccountLocked,
isToAccountLocked: isToAccountLocked,
) )
else else
_SingleAccountSelector( _SingleAccountSelector(
@@ -229,7 +232,8 @@ class _TransferAccountRow extends ConsumerWidget {
final String? fromAccountError; final String? fromAccountError;
final String? toAccountError; final String? toAccountError;
final bool isDark; final bool isDark;
final bool isAccountLocked; final bool isFromAccountLocked;
final bool isToAccountLocked;
const _TransferAccountRow({ const _TransferAccountRow({
required this.initial, required this.initial,
@@ -243,7 +247,8 @@ class _TransferAccountRow extends ConsumerWidget {
this.fromAccountError, this.fromAccountError,
this.toAccountError, this.toAccountError,
required this.isDark, required this.isDark,
this.isAccountLocked = false, this.isFromAccountLocked = false,
this.isToAccountLocked = false,
}); });
@override @override
@@ -290,11 +295,11 @@ class _TransferAccountRow extends ConsumerWidget {
account: fromAccount, account: fromAccount,
label: 'From', label: 'From',
showDropdown: showFromDropdown, showDropdown: showFromDropdown,
onToggle: isAccountLocked ? null : onToggleFromDropdown, onToggle: isFromAccountLocked ? null : onToggleFromDropdown,
indicatorKey: fromIndicatorKey, indicatorKey: fromIndicatorKey,
error: fromAccountError, error: fromAccountError,
isDark: isDark, isDark: isDark,
disabled: isAccountLocked, disabled: isFromAccountLocked,
), ),
), ),
Padding( Padding(
@@ -310,11 +315,13 @@ class _TransferAccountRow extends ConsumerWidget {
account: toAccount, account: toAccount,
label: 'To', label: 'To',
showDropdown: showToDropdown, showDropdown: showToDropdown,
onToggle: autoSelectEnabled ? null : onToggleToDropdown, onToggle: (autoSelectEnabled || isToAccountLocked)
? null
: onToggleToDropdown,
indicatorKey: toIndicatorKey, indicatorKey: toIndicatorKey,
error: toAccountError, error: toAccountError,
isDark: isDark, isDark: isDark,
disabled: autoSelectEnabled, disabled: autoSelectEnabled || isToAccountLocked,
), ),
), ),
], ],
@@ -66,22 +66,21 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
child: SizedBox( child: SizedBox(
height: cardHeight, height: cardHeight,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
child: Consumer( child: Consumer(
builder: (ctx, ref, _) => BalanceCard( builder: (ctx, ref, _) => BalanceCard(
balance: ref.read(totalBalanceProvider), balance: ref.read(totalBalanceProvider),
currencyInfo: ref.read(currencyProvider), currencyInfo: ref.read(currencyProvider),
onLongPress: null, onLongPress: null,
previewPrimary: dash.tempPrimary, previewPrimary: dash.tempPrimary,
previewSecondary: dash.tempSecondary, previewSecondary: dash.tempSecondary,
previewGradientType: Theme.of(widget.context) previewGradientType:
.brightness == Theme.of(widget.context).brightness == Brightness.dark
Brightness.dark ? dash.tempDarkGradientType
? dash.tempDarkGradientType : dash.tempLightGradientType,
: dash.tempLightGradientType,
),
), ),
), ),
),
), ),
), ),
), ),
@@ -97,30 +96,34 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
), ),
// Close Button - Top Right // Close Button - Top Right
Positioned( Positioned(
top: mq.padding.top + 8, top: mq.padding.top + (kToolbarHeight / 2) - 20,
right: 20, right: 20,
child: SafeArea( child: GestureDetector(
child: GestureDetector( onTap: () => dash.closeOverlay(apply: false),
onTap: () => dash.closeOverlay(apply: false), child: Container(
child: Container( width: 40,
width: 40, height: 40,
height: 40, decoration: BoxDecoration(
decoration: BoxDecoration( color: Theme.of(widget.context).colorScheme.surface,
color: Theme.of(widget.context).colorScheme.surface, shape: BoxShape.circle,
shape: BoxShape.circle, border: Border.all(
boxShadow: [ color: Theme.of(
BoxShadow( widget.context,
color: Colors.black.withOpacity(0.3), ).colorScheme.onSurface.withOpacity(0.15),
blurRadius: 8, width: 1.5,
offset: const Offset(0, 2),
),
],
),
child: Icon(
Icons.close_rounded,
size: 24,
color: Theme.of(widget.context).colorScheme.onSurface,
), ),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Icon(
Icons.close_rounded,
size: 24,
color: Theme.of(widget.context).colorScheme.onSurface,
), ),
), ),
), ),
@@ -137,7 +140,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
color: Theme.of(widget.context).colorScheme.surface, color: Theme.of(widget.context).colorScheme.surface,
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
border: Border.all( border: Border.all(
color: Theme.of(widget.context).colorScheme.onSurface.withOpacity(0.1), color: Theme.of(
widget.context,
).colorScheme.onSurface.withOpacity(0.1),
width: 1.5, width: 1.5,
), ),
boxShadow: [ boxShadow: [
@@ -170,8 +175,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
final activeGradientType = final activeGradientType =
Theme.of(widget.context).brightness == Brightness.dark Theme.of(widget.context).brightness == Brightness.dark
? dash.tempDarkGradientType ? dash.tempDarkGradientType
: dash.tempLightGradientType; : dash.tempLightGradientType;
final isSolid = activeGradientType == GradientType.solid; final isSolid = activeGradientType == GradientType.solid;
final currentHSV = (isSolid || dash.editingPrimary) final currentHSV = (isSolid || dash.editingPrimary)
? dash.tempPrimaryHSV ? dash.tempPrimaryHSV
@@ -191,10 +196,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
label: s.colorPrimary, label: s.colorPrimary,
isSelected: dash.editingPrimary && !isSolid, isSelected: dash.editingPrimary && !isSolid,
color: isSolid color: isSolid
? Theme.of(widget.context) ? Theme.of(
.colorScheme widget.context,
.onSurface ).colorScheme.onSurface.withOpacity(0.12)
.withOpacity(0.12)
: dash.tempPrimary, : dash.tempPrimary,
isDimmed: isSolid, isDimmed: isSolid,
onTap: () { onTap: () {
@@ -246,31 +250,36 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
child: Container( child: Container(
width: 1, width: 1,
color: Theme.of(widget.context) color: Theme.of(
.colorScheme widget.context,
.onSurface ).colorScheme.onSurface.withOpacity(0.15),
.withOpacity(0.15),
margin: const EdgeInsets.symmetric(vertical: 4), margin: const EdgeInsets.symmetric(vertical: 4),
), ),
), ),
GestureDetector( GestureDetector(
onTap: isSolid ? null : () { onTap: isSolid
dash.setState(() { ? null
if (Theme.of(widget.context).brightness == : () {
Brightness.dark) { dash.setState(() {
dash.tempDarkGradientType = GradientType.solid; if (Theme.of(widget.context).brightness ==
} else { Brightness.dark) {
dash.tempLightGradientType = GradientType.solid; dash.tempDarkGradientType =
} GradientType.solid;
dash.editingPrimary = true; } else {
}); dash.tempLightGradientType =
setPanelState(() {}); GradientType.solid;
dash.overlayEntry?.markNeedsBuild(); }
}, dash.editingPrimary = true;
});
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
child: Container( child: Container(
height: double.infinity, height: double.infinity,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 6), horizontal: 10,
vertical: 6,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSolid color: isSolid
? const Color(0xFF7C6DED).withOpacity(0.15) ? const Color(0xFF7C6DED).withOpacity(0.15)
@@ -279,10 +288,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
border: Border.all( border: Border.all(
color: isSolid color: isSolid
? const Color(0xFF7C6DED) ? const Color(0xFF7C6DED)
: Theme.of(widget.context) : Theme.of(
.colorScheme widget.context,
.onSurface ).colorScheme.onSurface.withOpacity(0.2),
.withOpacity(0.2),
width: 1.5, width: 1.5,
), ),
), ),
@@ -297,8 +305,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
color: dash.tempPrimary, color: dash.tempPrimary,
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all( border: Border.all(
color: Theme.of(widget.context) color:
.brightness == Theme.of(widget.context).brightness ==
Brightness.dark Brightness.dark
? Colors.white30 ? Colors.white30
: Colors.black12, : Colors.black12,
@@ -321,9 +329,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
color: isSolid color: isSolid
? const Color(0xFF7C6DED) ? const Color(0xFF7C6DED)
: Theme.of(widget.context) : Theme.of(widget.context)
.colorScheme .colorScheme
.onSurface .onSurface
.withOpacity(0.5), .withOpacity(0.5),
), ),
), ),
), ),
@@ -339,9 +347,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
child: LayoutBuilder( child: LayoutBuilder(
builder: (lbCtx, constraints) { builder: (lbCtx, constraints) {
const reservedBelow = 78.0; const reservedBelow = 78.0;
final spectrumH = final spectrumH = (constraints.maxHeight - reservedBelow)
(constraints.maxHeight - reservedBelow).clamp( .clamp(40.0, double.infinity);
40.0, double.infinity);
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -360,7 +367,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
SizedBox( SizedBox(
height: 36, // height: 36, //
child: ColorPickerSlider( child: ColorPickerSlider(
TrackType.hue, TrackType.hue,
currentHSV, currentHSV,
@@ -381,7 +388,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
dash.setState( dash.setState(
() => dash.editingPrimary = true); () => dash.editingPrimary = true,
);
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -398,10 +406,12 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
border: dash.editingPrimary border: dash.editingPrimary
? Border.all( ? Border.all(
color: Colors.white, color: Colors.white,
width: 2) width: 2,
)
: Border.all( : Border.all(
color: Colors.transparent, color: Colors.transparent,
width: 2), width: 2,
),
), ),
), ),
const SizedBox(width: 5), const SizedBox(width: 5),
@@ -417,9 +427,10 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
.colorScheme .colorScheme
.onSurface .onSurface
.withOpacity( .withOpacity(
dash.editingPrimary dash.editingPrimary
? 0.8 ? 0.8
: 0.4), : 0.4,
),
), ),
), ),
], ],
@@ -429,8 +440,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
if (!isSolid) if (!isSolid)
GestureDetector( GestureDetector(
onTap: () { onTap: () {
dash.setState(() => dash.setState(
dash.editingPrimary = false); () => dash.editingPrimary = false,
);
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -449,9 +461,10 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
.colorScheme .colorScheme
.onSurface .onSurface
.withOpacity( .withOpacity(
!dash.editingPrimary !dash.editingPrimary
? 0.8 ? 0.8
: 0.4), : 0.4,
),
), ),
), ),
const SizedBox(width: 5), const SizedBox(width: 5),
@@ -465,11 +478,13 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
border: !dash.editingPrimary border: !dash.editingPrimary
? Border.all( ? Border.all(
color: Colors.white, color: Colors.white,
width: 2) width: 2,
)
: Border.all( : Border.all(
color: color:
Colors.transparent, Colors.transparent,
width: 2), width: 2,
),
), ),
), ),
], ],
@@ -495,92 +510,99 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
children: GradientType.values children: GradientType.values
.where((t) => t != GradientType.solid) .where((t) => t != GradientType.solid)
.map((type) { .map((type) {
final isSelected = activeGradientType == type; final isSelected = activeGradientType == type;
final label = switch (type) { final label = switch (type) {
GradientType.linear => s.gradientLinear, GradientType.linear => s.gradientLinear,
GradientType.linearReverse => s.gradientReverse, GradientType.linearReverse => s.gradientReverse,
GradientType.radial => s.gradientRadial, GradientType.radial => s.gradientRadial,
GradientType.sweep => s.gradientSweep, GradientType.sweep => s.gradientSweep,
GradientType.solid => '', GradientType.solid => '',
}; };
final icon = switch (type) { final icon = switch (type) {
GradientType.linear => Icons.trending_flat_rounded, GradientType.linear =>
GradientType.linearReverse => Icons.trending_flat_rounded,
Icons.swap_horiz_rounded, GradientType.linearReverse =>
GradientType.radial => Icons.blur_circular_rounded, Icons.swap_horiz_rounded,
GradientType.sweep => Icons.rotate_right_rounded, GradientType.radial =>
GradientType.solid => Icons.square_rounded, Icons.blur_circular_rounded,
}; GradientType.sweep => Icons.rotate_right_rounded,
return Expanded( GradientType.solid => Icons.square_rounded,
child: Padding( };
padding: const EdgeInsets.only(right: 6), return Expanded(
child: GestureDetector( child: Padding(
onTap: () { padding: const EdgeInsets.only(right: 6),
dash.setState(() { child: GestureDetector(
if (Theme.of(widget.context).brightness == onTap: () {
Brightness.dark) { dash.setState(() {
dash.tempDarkGradientType = type; if (Theme.of(widget.context).brightness ==
} else { Brightness.dark) {
dash.tempLightGradientType = type; dash.tempDarkGradientType = type;
} } else {
}); dash.tempLightGradientType = type;
setPanelState(() {}); }
dash.overlayEntry?.markNeedsBuild(); });
}, setPanelState(() {});
child: AnimatedContainer( dash.overlayEntry?.markNeedsBuild();
duration: const Duration(milliseconds: 150), },
padding: child: AnimatedContainer(
const EdgeInsets.symmetric(vertical: 5), duration: const Duration(milliseconds: 150),
decoration: BoxDecoration( padding: const EdgeInsets.symmetric(
color: isSelected vertical: 5,
? const Color(0xFF7C6DED) ),
.withOpacity(0.15) decoration: BoxDecoration(
: Theme.of(widget.context) color: isSelected
.colorScheme ? const Color(
.onSurface 0xFF7C6DED,
.withOpacity(0.05), ).withOpacity(0.15)
borderRadius: BorderRadius.circular(8), : Theme.of(widget.context)
border: Border.all(
color: isSelected
? const Color(0xFF7C6DED)
: Colors.transparent,
width: 1.5,
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon,
size: 15,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(widget.context)
.colorScheme .colorScheme
.onSurface .onSurface
.withOpacity(0.45)), .withOpacity(0.05),
const SizedBox(height: 2), borderRadius: BorderRadius.circular(8),
Text( border: Border.all(
label,
style: TextStyle(
fontSize: 9,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.normal,
color: isSelected color: isSelected
? const Color(0xFF7C6DED) ? const Color(0xFF7C6DED)
: Theme.of(widget.context) : Colors.transparent,
.colorScheme width: 1.5,
.onSurface
.withOpacity(0.45),
), ),
), ),
], child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
icon,
size: 15,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(widget.context)
.colorScheme
.onSurface
.withOpacity(0.45),
),
const SizedBox(height: 2),
Text(
label,
style: TextStyle(
fontSize: 9,
fontWeight: isSelected
? FontWeight.w600
: FontWeight.normal,
color: isSelected
? const Color(0xFF7C6DED)
: Theme.of(widget.context)
.colorScheme
.onSurface
.withOpacity(0.45),
),
),
],
),
),
), ),
), ),
), );
), })
); .toList(),
}).toList(),
), ),
), ),
), ),
@@ -592,7 +614,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
onPressed: () { onPressed: () {
final isDarkTheme = final isDarkTheme =
Theme.of(widget.context).brightness == Theme.of(widget.context).brightness ==
Brightness.dark; Brightness.dark;
final defP = isDarkTheme final defP = isDarkTheme
? CardColorService.defaultPrimary ? CardColorService.defaultPrimary
: CardColorService.defaultPrimaryLight; : CardColorService.defaultPrimaryLight;
@@ -604,31 +626,32 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
dash.tempSecondary = defS; dash.tempSecondary = defS;
dash.tempPrimaryHSV = HSVColor.fromColor(defP); dash.tempPrimaryHSV = HSVColor.fromColor(defP);
dash.tempSecondaryHSV = HSVColor.fromColor(defS); dash.tempSecondaryHSV = HSVColor.fromColor(defS);
dash.tempLightGradientType = dash.tempLightGradientType =
CardColorService.defaultGradientLight; CardColorService.defaultGradientLight;
dash.tempDarkGradientType = dash.tempDarkGradientType =
CardColorService.defaultGradientDark; CardColorService.defaultGradientDark;
}); });
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
icon: const Icon(Icons.restart_alt_rounded, size: 15), icon: const Icon(Icons.restart_alt_rounded, size: 15),
label: Text(s.reset, label: Text(
style: const TextStyle(fontSize: 13)), s.reset,
style: const TextStyle(fontSize: 13),
),
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
foregroundColor: Theme.of(widget.context) foregroundColor: Theme.of(
.colorScheme widget.context,
.onSurface ).colorScheme.onSurface.withOpacity(0.7),
.withOpacity(0.7),
side: BorderSide( side: BorderSide(
color: Theme.of(widget.context) color: Theme.of(
.colorScheme widget.context,
.onSurface ).colorScheme.onSurface.withOpacity(0.2),
.withOpacity(0.2),
), ),
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)), borderRadius: BorderRadius.circular(12),
),
), ),
), ),
), ),
@@ -642,11 +665,16 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
foregroundColor: Colors.white, foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)), borderRadius: BorderRadius.circular(12),
),
),
child: Text(
s.apply,
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 14,
),
), ),
child: Text(s.apply,
style: const TextStyle(
fontWeight: FontWeight.w700, fontSize: 14)),
), ),
), ),
], ],
@@ -684,7 +712,9 @@ class PanelTab extends StatelessWidget {
: (isDark ? Colors.white24 : const Color(0xFFCCCCDD)); : (isDark ? Colors.white24 : const Color(0xFFCCCCDD));
final textColor = isSelected final textColor = isSelected
? const Color(0xFF7C6DED) ? const Color(0xFF7C6DED)
: (isDark ? Colors.white60 : Theme.of(context).colorScheme.onSurface.withOpacity(0.5)); : (isDark
? Colors.white60
: Theme.of(context).colorScheme.onSurface.withOpacity(0.5));
return GestureDetector( return GestureDetector(
onTap: onTap, onTap: onTap,
@@ -696,12 +726,11 @@ class PanelTab extends StatelessWidget {
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? const Color(0xFF7C6DED).withOpacity(0.15) : Colors.transparent, color: isSelected
? const Color(0xFF7C6DED).withOpacity(0.15)
: Colors.transparent,
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
border: Border.all( border: Border.all(color: borderColor, width: 1.5),
color: borderColor,
width: 1.5,
),
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -728,8 +757,9 @@ class PanelTab extends StatelessWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: fontWeight: isSelected
isSelected ? FontWeight.w600 : FontWeight.normal, ? FontWeight.w600
: FontWeight.normal,
color: textColor, color: textColor,
), ),
), ),