Skip to content

Commit 1c7471c

Browse files
committed
feat: bring back the autoswap active tick card on home, threshold gated
1 parent e1968e7 commit 1c7471c

3 files changed

Lines changed: 55 additions & 4 deletions

File tree

lib/core/widgets/cards/autoswap_warning_card.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,28 @@ class AutoSwapWarningCard extends StatelessWidget {
4444
const Gap(14),
4545
Expanded(
4646
child: isActiveMode
47-
? BBText(
48-
context.loc.autoswapActiveCardTitle,
49-
style: context.font.bodyMedium,
50-
color: context.appColors.onSurface,
47+
? Column(
48+
crossAxisAlignment: CrossAxisAlignment.start,
49+
children: [
50+
BBText(
51+
context.loc.autoswapActiveCardTitle,
52+
style: context.font.bodyMedium,
53+
color: context.appColors.onSurface,
54+
),
55+
const Gap(2),
56+
GestureDetector(
57+
onTap: () {
58+
onTap();
59+
},
60+
child: Text(
61+
context.loc.autoswapWarningCardSubtitle,
62+
style: context.font.bodySmall?.copyWith(
63+
decoration: TextDecoration.underline,
64+
color: context.appColors.onSurfaceVariant,
65+
),
66+
),
67+
),
68+
],
5169
)
5270
: Column(
5371
crossAxisAlignment: CrossAxisAlignment.start,

lib/features/wallet/presentation/bloc/wallet_state.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,23 @@ sealed class WalletState with _$WalletState {
7979
liquidWallet.balanceSat.toInt(),
8080
);
8181
}
82+
83+
/// "Autoswap is active" tick card (restored from the last release, which
84+
/// showed it whenever autoswap was enabled): once the warning has been
85+
/// acknowledged, it appears only while the Liquid balance has actually
86+
/// passed the trigger threshold — i.e. while a swap is imminent — so it
87+
/// never overlaps with [showAutoSwapDefaultEnabledWarning] (which owns
88+
/// the un-acknowledged state).
89+
bool showAutoSwapActiveStatus() {
90+
if (autoSwapSettings == null ||
91+
!autoSwapSettings!.enabled ||
92+
autoSwapSettings!.showWarning) {
93+
return false;
94+
}
95+
final liquidWallet = defaultLiquidWallet();
96+
if (liquidWallet == null) return false;
97+
return autoSwapSettings!.passedRequiredBalance(
98+
liquidWallet.balanceSat.toInt(),
99+
);
100+
}
82101
}

lib/features/wallet/ui/widgets/home_errors.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:bb_mobile/core/widgets/cards/autoswap_warning_card.dart';
33
import 'package:bb_mobile/core/widgets/cards/backup_card.dart';
44
import 'package:bb_mobile/core/widgets/cards/info_card.dart';
55
import 'package:bb_mobile/features/backup_settings/ui/backup_settings_router.dart';
6+
import 'package:bb_mobile/features/settings/public/settings_facade.dart';
67
import 'package:bb_mobile/features/wallet/presentation/bloc/wallet_bloc.dart';
78
import 'package:bb_mobile/features/wallet/ui/widgets/autoswap_warning_bottom_sheet.dart';
89
import 'package:flutter/material.dart';
@@ -21,16 +22,20 @@ class HomeWarnings extends StatelessWidget {
2122
previous.isOnLegacyStorage != current.isOnLegacyStorage ||
2223
previous.showAutoSwapDefaultEnabledWarning() !=
2324
current.showAutoSwapDefaultEnabledWarning() ||
25+
previous.showAutoSwapActiveStatus() !=
26+
current.showAutoSwapActiveStatus() ||
2427
previous.warnings != current.warnings,
2528
builder: (context, state) {
2629
final showBackupWarning =
2730
state.hasNoBackup() && !state.isOnLegacyStorage;
2831
final showAutoSwapDefaultEnabledWarning = state
2932
.showAutoSwapDefaultEnabledWarning();
33+
final showAutoSwapActiveStatus = state.showAutoSwapActiveStatus();
3034
final serverWarning = state.warnings;
3135

3236
if (!showBackupWarning &&
3337
!showAutoSwapDefaultEnabledWarning &&
38+
!showAutoSwapActiveStatus &&
3439
serverWarning.isEmpty) {
3540
return const SizedBox.shrink();
3641
}
@@ -54,6 +59,15 @@ class HomeWarnings extends StatelessWidget {
5459
),
5560
],
5661

62+
if (showAutoSwapActiveStatus) ...[
63+
if (showBackupWarning) const Gap(5),
64+
AutoSwapWarningCard(
65+
isActiveMode: true,
66+
onTap: () =>
67+
context.pushNamed(SettingsRoute.autoswapSettings.name),
68+
),
69+
],
70+
5771
for (final warning in serverWarning) ...[
5872
const Gap(5),
5973
InfoCard(

0 commit comments

Comments
 (0)