mobile show selected startup wallet

This commit is contained in:
julian 2023-03-20 11:04:00 -06:00
parent 6cd649a195
commit d9d6a8c156

View file

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
@ -21,6 +23,31 @@ class StartupPreferencesView extends ConsumerStatefulWidget {
class _StartupPreferencesViewState
extends ConsumerState<StartupPreferencesView> {
bool safe = true;
@override
void initState() {
final possibleWalletId =
ref.read(prefsChangeNotifierProvider).startupWalletId;
// check if wallet exists (hasn't been deleted or otherwise missing)
if (possibleWalletId != null) {
try {
ref.read(walletsChangeNotifierProvider).getManager(possibleWalletId);
} catch (_) {
safe = false;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
ref.read(prefsChangeNotifierProvider).startupWalletId = null;
setState(() {
safe = true;
});
});
}
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Background(
@ -195,13 +222,73 @@ class _StartupPreferencesViewState
context),
textAlign: TextAlign.left,
),
Text(
"Select a specific wallet to load into on startup",
style:
STextStyles.itemSubtitle(
context),
textAlign: TextAlign.left,
),
(safe &&
ref.watch(
prefsChangeNotifierProvider
.select((value) =>
value
.startupWalletId),
) !=
null)
? Padding(
padding:
const EdgeInsets
.only(top: 12),
child: Row(
children: [
SvgPicture.asset(
Assets.svg
.iconFor(
coin: ref
.watch(
walletsChangeNotifierProvider
.select(
(value) =>
value.getManager(
ref.watch(
prefsChangeNotifierProvider.select((value) =>
value.startupWalletId!),
),
),
),
)
.coin,
),
),
const SizedBox(
width: 10,
),
Text(
ref
.watch(
walletsChangeNotifierProvider
.select(
(value) =>
value
.getManager(
ref.watch(
prefsChangeNotifierProvider.select((value) =>
value.startupWalletId!),
),
),
),
)
.walletName,
style: STextStyles
.itemSubtitle(
context),
),
],
),
)
: Text(
"Select a specific wallet to load into on startup",
style: STextStyles
.itemSubtitle(
context),
textAlign:
TextAlign.left,
),
],
),
),