mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
WIP working horizontal centering
need to test on mobile and re-enable commented flex items
This commit is contained in:
parent
ce2bc33744
commit
cd9ac3c2e5
1 changed files with 541 additions and 501 deletions
|
@ -132,16 +132,23 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
Constants.defaultSeedPhraseLengthFor(coin: coin);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: IntrinsicHeight(
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints:
|
||||
BoxConstraints(maxWidth: isDesktop ? 480 : double.infinity),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (isDesktop)
|
||||
const Spacer(
|
||||
// TODO vertical centering/alignment.
|
||||
/*const Spacer(
|
||||
flex: 10,
|
||||
),
|
||||
),*/
|
||||
if (!isDesktop)
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
|
@ -183,7 +190,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
"able to restore your recover phrase. Only you have "
|
||||
"access to your wallet.",
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextMediumRegular(context)
|
||||
? STextStyles.desktopTextMediumRegular(
|
||||
context)
|
||||
: STextStyles.subtitle(context).copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
|
@ -192,7 +200,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
children: [
|
||||
Text(
|
||||
"Important",
|
||||
style: STextStyles.desktopH3(context).copyWith(
|
||||
style:
|
||||
STextStyles.desktopH3(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorBlue,
|
||||
|
@ -208,9 +217,10 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
.copyWith(fontSize: 18),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "On the next screen you will be given ",
|
||||
style:
|
||||
STextStyles.desktopH3(context).copyWith(
|
||||
text:
|
||||
"On the next screen you will be given ",
|
||||
style: STextStyles.desktopH3(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
|
@ -220,8 +230,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
),
|
||||
TextSpan(
|
||||
text: "$seedCount words",
|
||||
style:
|
||||
STextStyles.desktopH3(context).copyWith(
|
||||
style: STextStyles.desktopH3(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorBlue,
|
||||
|
@ -231,8 +241,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
),
|
||||
TextSpan(
|
||||
text: ". They are your ",
|
||||
style:
|
||||
STextStyles.desktopH3(context).copyWith(
|
||||
style: STextStyles.desktopH3(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
|
@ -242,8 +252,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
),
|
||||
TextSpan(
|
||||
text: "recovery phrase",
|
||||
style:
|
||||
STextStyles.desktopH3(context).copyWith(
|
||||
style: STextStyles.desktopH3(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorBlue,
|
||||
|
@ -253,8 +263,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
),
|
||||
TextSpan(
|
||||
text: ".",
|
||||
style:
|
||||
STextStyles.desktopH3(context).copyWith(
|
||||
style: STextStyles.desktopH3(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
|
@ -294,7 +304,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
),
|
||||
Text(
|
||||
"Write them down.",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
style:
|
||||
STextStyles.navBarTitle(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -325,7 +336,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
),
|
||||
Text(
|
||||
"Keep them safe.",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
style:
|
||||
STextStyles.navBarTitle(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -357,7 +369,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
Expanded(
|
||||
child: Text(
|
||||
"Do not show them to anyone.",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
style: STextStyles.navBarTitle(
|
||||
context),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -388,15 +401,17 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
final value =
|
||||
ref.read(checkBoxStateProvider.state).state;
|
||||
final value = ref
|
||||
.read(checkBoxStateProvider.state)
|
||||
.state;
|
||||
ref.read(checkBoxStateProvider.state).state =
|
||||
!value;
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 24,
|
||||
|
@ -405,11 +420,13 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
value: ref
|
||||
.watch(checkBoxStateProvider.state)
|
||||
.watch(
|
||||
checkBoxStateProvider.state)
|
||||
.state,
|
||||
onChanged: (newValue) {
|
||||
ref
|
||||
.read(checkBoxStateProvider.state)
|
||||
.read(
|
||||
checkBoxStateProvider.state)
|
||||
.state = newValue!;
|
||||
},
|
||||
),
|
||||
|
@ -421,8 +438,10 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
child: Text(
|
||||
"I understand that Stack Wallet does not keep and cannot restore my recovery phrase, and If I lose my recovery phrase, I will not be able to access my funds.",
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextMedium(context)
|
||||
: STextStyles.baseXS(context).copyWith(
|
||||
? STextStyles.desktopTextMedium(
|
||||
context)
|
||||
: STextStyles.baseXS(context)
|
||||
.copyWith(
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
|
@ -460,9 +479,10 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
String? otherDataJsonString;
|
||||
if (widget.coin == Coin.tezos) {
|
||||
otherDataJsonString = jsonEncode({
|
||||
WalletInfoKeys.tezosDerivationPath:
|
||||
Tezos
|
||||
.standardDerivationPath.value,
|
||||
WalletInfoKeys
|
||||
.tezosDerivationPath:
|
||||
Tezos.standardDerivationPath
|
||||
.value,
|
||||
});
|
||||
// }//todo: probably not needed (broken anyways)
|
||||
// else if (widget.coin == Coin.epicCash) {
|
||||
|
@ -495,7 +515,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
// ),
|
||||
// },
|
||||
// );
|
||||
} else if (widget.coin == Coin.firo) {
|
||||
} else if (widget.coin ==
|
||||
Coin.firo) {
|
||||
otherDataJsonString = jsonEncode(
|
||||
{
|
||||
WalletInfoKeys
|
||||
|
@ -518,7 +539,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
.getPrimaryNodeFor(coin: coin);
|
||||
|
||||
if (node == null) {
|
||||
node = DefaultNodes.getNodeFor(coin);
|
||||
node =
|
||||
DefaultNodes.getNodeFor(coin);
|
||||
await ref
|
||||
.read(
|
||||
nodeServiceChangeNotifierProvider)
|
||||
|
@ -538,8 +560,8 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
String? mnemonic;
|
||||
String? privateKey;
|
||||
|
||||
wordCount =
|
||||
Constants.defaultSeedPhraseLengthFor(
|
||||
wordCount = Constants
|
||||
.defaultSeedPhraseLengthFor(
|
||||
coin: info.coin,
|
||||
);
|
||||
|
||||
|
@ -550,19 +572,22 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
// own mnemonic generation
|
||||
} else if (wordCount > 0) {
|
||||
if (ref
|
||||
.read(pNewWalletOptions.state)
|
||||
.read(pNewWalletOptions
|
||||
.state)
|
||||
.state !=
|
||||
null) {
|
||||
if (coin
|
||||
.hasMnemonicPassphraseSupport) {
|
||||
mnemonicPassphrase = ref
|
||||
.read(pNewWalletOptions.state)
|
||||
.read(pNewWalletOptions
|
||||
.state)
|
||||
.state!
|
||||
.mnemonicPassphrase;
|
||||
} else {}
|
||||
|
||||
wordCount = ref
|
||||
.read(pNewWalletOptions.state)
|
||||
.read(
|
||||
pNewWalletOptions.state)
|
||||
.state!
|
||||
.mnemonicWordsCount;
|
||||
} else {
|
||||
|
@ -572,10 +597,12 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
if (wordCount < 12 ||
|
||||
24 < wordCount ||
|
||||
wordCount % 3 != 0) {
|
||||
throw Exception("Invalid word count");
|
||||
throw Exception(
|
||||
"Invalid word count");
|
||||
}
|
||||
|
||||
final strength = (wordCount ~/ 3) * 32;
|
||||
final strength =
|
||||
(wordCount ~/ 3) * 32;
|
||||
|
||||
mnemonic = bip39.generateMnemonic(
|
||||
strength: strength,
|
||||
|
@ -589,9 +616,10 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
ref.read(secureStoreProvider),
|
||||
nodeService: ref.read(
|
||||
nodeServiceChangeNotifierProvider),
|
||||
prefs: ref
|
||||
.read(prefsChangeNotifierProvider),
|
||||
mnemonicPassphrase: mnemonicPassphrase,
|
||||
prefs: ref.read(
|
||||
prefsChangeNotifierProvider),
|
||||
mnemonicPassphrase:
|
||||
mnemonicPassphrase,
|
||||
mnemonic: mnemonic,
|
||||
privateKey: privateKey,
|
||||
);
|
||||
|
@ -604,40 +632,49 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
}
|
||||
// set checkbox back to unchecked to annoy users to agree again :P
|
||||
ref
|
||||
.read(checkBoxStateProvider.state)
|
||||
.read(
|
||||
checkBoxStateProvider.state)
|
||||
.state = false;
|
||||
|
||||
if (mounted) {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
NewWalletRecoveryPhraseView.routeName,
|
||||
unawaited(Navigator.of(context)
|
||||
.pushNamed(
|
||||
NewWalletRecoveryPhraseView
|
||||
.routeName,
|
||||
arguments: Tuple2(
|
||||
wallet,
|
||||
await (wallet as MnemonicInterface)
|
||||
await (wallet
|
||||
as MnemonicInterface)
|
||||
.getMnemonicAsWords(),
|
||||
),
|
||||
));
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance
|
||||
.log("$e\n$s", level: LogLevel.Fatal);
|
||||
Logging.instance.log("$e\n$s",
|
||||
level: LogLevel.Fatal);
|
||||
// TODO: handle gracefully
|
||||
// any network/socket exception here will break new wallet creation
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
: null,
|
||||
style: ref.read(checkBoxStateProvider.state).state
|
||||
style: ref
|
||||
.read(checkBoxStateProvider.state)
|
||||
.state
|
||||
? Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getPrimaryEnabledButtonStyle(context)
|
||||
: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getPrimaryDisabledButtonStyle(context),
|
||||
.getPrimaryDisabledButtonStyle(
|
||||
context),
|
||||
child: Text(
|
||||
"View recovery phrase",
|
||||
style: isDesktop
|
||||
? ref.read(checkBoxStateProvider.state).state
|
||||
? ref
|
||||
.read(
|
||||
checkBoxStateProvider.state)
|
||||
.state
|
||||
? STextStyles.desktopButtonEnabled(
|
||||
context)
|
||||
: STextStyles.desktopButtonDisabled(
|
||||
|
@ -651,14 +688,17 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
},
|
||||
),
|
||||
),
|
||||
if (isDesktop)
|
||||
/*if (isDesktop)
|
||||
const Spacer(
|
||||
flex: 15,
|
||||
),*/
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue