WIP working horizontal centering

need to test on mobile and re-enable commented flex items
This commit is contained in:
sneurlax 2024-01-24 13:05:22 -06:00
parent ce2bc33744
commit cd9ac3c2e5

View file

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