Skip to content

Commit 61e0102

Browse files
committed
ui(spl): mobile sol token wallet nav
fix(spl): fix navigation to token sub-wallet
1 parent 4030002 commit 61e0102

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

lib/pages/wallets_view/sub_widgets/wallet_list_item.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import '../../../utilities/show_loading.dart';
2424
import '../../../utilities/show_node_tor_settings_mismatch.dart';
2525
import '../../../utilities/text_styles.dart';
2626
import '../../../utilities/util.dart';
27+
import '../../../wallets/crypto_currency/coins/solana.dart';
2728
import '../../../wallets/crypto_currency/crypto_currency.dart';
29+
import '../../../wallets/isar/providers/wallet_info_provider.dart';
2830
import '../../../wallets/wallet/intermediate/external_wallet.dart';
2931
import '../../../widgets/dialogs/tor_warning_dialog.dart';
3032
import '../../../widgets/rounded_white_container.dart';
@@ -80,7 +82,23 @@ class WalletListItem extends ConsumerWidget {
8082
}
8183
}
8284

83-
if (walletCount == 1 && coin is! Ethereum) {
85+
// Check if we should show the wallets overview or open wallet directly.
86+
bool shouldShowWalletsOverview = walletCount > 1 || coin is Ethereum;
87+
88+
// For Solana and other token-supporting coins, check if any wallet has tokens.
89+
if (!shouldShowWalletsOverview && coin.hasTokenSupport) {
90+
final wallet = ref
91+
.read(pWallets)
92+
.wallets
93+
.firstWhere((e) => e.info.coin == coin);
94+
95+
final tokenAddresses = ref.read(pWalletTokenAddresses(wallet.walletId));
96+
if (tokenAddresses.isNotEmpty) {
97+
shouldShowWalletsOverview = true;
98+
}
99+
}
100+
101+
if (walletCount == 1 && !shouldShowWalletsOverview) {
84102
final wallet = ref
85103
.read(pWallets)
86104
.wallets

lib/widgets/wallet_card.dart

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
1515

1616
import '../models/isar/models/ethereum/eth_contract.dart';
1717
import '../models/isar/models/solana/spl_token.dart';
18+
import '../pages/token_view/sol_token_view.dart';
1819
import '../pages/token_view/token_view.dart';
1920
import '../pages/wallet_view/wallet_view.dart';
21+
import '../pages_desktop_specific/my_stack_view/wallet_view/desktop_sol_token_view.dart';
2022
import '../pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart';
2123
import '../pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
2224
import '../providers/db/main_db_provider.dart';
@@ -170,20 +172,22 @@ class SimpleWalletCard extends ConsumerWidget {
170172
);
171173
if (popPrevious) nav.pop();
172174

173-
if (desktopNavigatorState != null) {
174-
unawaited(
175-
desktopNavigatorState!.pushNamed(
176-
DesktopWalletView.routeName,
177-
arguments: walletId,
178-
),
179-
);
180-
} else {
181-
unawaited(
182-
nav.pushNamed(
183-
WalletView.routeName,
184-
arguments: walletId,
185-
),
186-
);
175+
if (contractAddress == null) {
176+
if (desktopNavigatorState != null) {
177+
unawaited(
178+
desktopNavigatorState!.pushNamed(
179+
DesktopWalletView.routeName,
180+
arguments: walletId,
181+
),
182+
);
183+
} else {
184+
unawaited(
185+
nav.pushNamed(
186+
WalletView.routeName,
187+
arguments: walletId,
188+
),
189+
);
190+
}
187191
}
188192

189193
if (contractAddress != null) {
@@ -220,13 +224,13 @@ class SimpleWalletCard extends ConsumerWidget {
220224

221225
if (desktopNavigatorState != null) {
222226
await desktopNavigatorState!.pushNamed(
223-
DesktopTokenView.routeName,
224-
arguments: walletId,
227+
DesktopSolTokenView.routeName,
228+
arguments: (walletId: walletId, tokenMint: contractAddress!),
225229
);
226230
} else {
227231
await nav.pushNamed(
228-
TokenView.routeName,
229-
arguments: (walletId: walletId, popPrevious: !Util.isDesktop),
232+
SolTokenView.routeName,
233+
arguments: (walletId: walletId, tokenMint: contractAddress!),
230234
);
231235
}
232236
} else {

0 commit comments

Comments
 (0)