mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-25 11:45:59 +00:00
Merge pull request #834 from cypherstack/ui
Validate remainder seed word input(s)
This commit is contained in:
commit
d4b760c3e9
1 changed files with 426 additions and 448 deletions
|
@ -56,7 +56,6 @@ import 'package:stackwallet/wallets/wallet/impl/monero_wallet.dart';
|
|||
import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart';
|
||||
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
|
@ -833,8 +832,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
children: [
|
||||
TextFormField(
|
||||
autocorrect: !isDesktop,
|
||||
enableSuggestions:
|
||||
!isDesktop,
|
||||
enableSuggestions: !isDesktop,
|
||||
textCapitalization:
|
||||
TextCapitalization.none,
|
||||
key: Key(
|
||||
|
@ -861,15 +859,13 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
|
||||
if (value.isEmpty) {
|
||||
formInputStatus =
|
||||
FormInputStatus
|
||||
.empty;
|
||||
FormInputStatus.empty;
|
||||
} else if (_isValidMnemonicWord(
|
||||
value
|
||||
.trim()
|
||||
.toLowerCase())) {
|
||||
formInputStatus =
|
||||
FormInputStatus
|
||||
.valid;
|
||||
FormInputStatus.valid;
|
||||
} else {
|
||||
formInputStatus =
|
||||
FormInputStatus
|
||||
|
@ -889,15 +885,15 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
// }
|
||||
// }
|
||||
setState(() {
|
||||
_inputStatuses[
|
||||
i * 4 + j - 1] =
|
||||
formInputStatus;
|
||||
_inputStatuses[i * 4 +
|
||||
j -
|
||||
1] = formInputStatus;
|
||||
});
|
||||
},
|
||||
controller: _controllers[
|
||||
i * 4 + j - 1],
|
||||
style: STextStyles.field(
|
||||
context)
|
||||
style:
|
||||
STextStyles.field(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<
|
||||
|
@ -915,8 +911,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.only(
|
||||
const EdgeInsets.only(
|
||||
left: 12.0,
|
||||
bottom: 4.0,
|
||||
),
|
||||
|
@ -948,6 +943,16 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
spacing: 16,
|
||||
cells: [
|
||||
for (int i = rows * cols;
|
||||
i < _seedWordCount - remainder;
|
||||
i++) ...[
|
||||
TableViewCell(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
// ... (existing code for input field)
|
||||
),
|
||||
),
|
||||
],
|
||||
for (int i = _seedWordCount - remainder;
|
||||
i < _seedWordCount;
|
||||
i++) ...[
|
||||
TableViewCell(
|
||||
|
@ -956,8 +961,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
children: [
|
||||
TextFormField(
|
||||
autocorrect: !isDesktop,
|
||||
enableSuggestions:
|
||||
!isDesktop,
|
||||
enableSuggestions: !isDesktop,
|
||||
textCapitalization:
|
||||
TextCapitalization.none,
|
||||
key: Key(
|
||||
|
@ -972,53 +976,33 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
selectionControls: i == 1
|
||||
? textSelectionControls
|
||||
: null,
|
||||
// focusNode: _focusNodes[i],
|
||||
onChanged: (value) {
|
||||
final FormInputStatus
|
||||
formInputStatus;
|
||||
|
||||
if (value.isEmpty) {
|
||||
formInputStatus =
|
||||
FormInputStatus
|
||||
.empty;
|
||||
FormInputStatus.empty;
|
||||
} else if (_isValidMnemonicWord(
|
||||
value
|
||||
.trim()
|
||||
.toLowerCase())) {
|
||||
formInputStatus =
|
||||
FormInputStatus
|
||||
.valid;
|
||||
FormInputStatus.valid;
|
||||
} else {
|
||||
formInputStatus =
|
||||
FormInputStatus
|
||||
.invalid;
|
||||
}
|
||||
|
||||
// if (formInputStatus ==
|
||||
// FormInputStatus
|
||||
// .valid &&
|
||||
// (i - 1) <
|
||||
// _focusNodes.length) {
|
||||
// Focus.of(context)
|
||||
// .requestFocus(
|
||||
// _focusNodes[i]);
|
||||
// }
|
||||
|
||||
// if (formInputStatus ==
|
||||
// FormInputStatus.valid) {
|
||||
// if (i + 1 <
|
||||
// _focusNodes.length) {
|
||||
// _focusNodes[i + 1]
|
||||
// .requestFocus();
|
||||
// } else if (i + 1 ==
|
||||
// _focusNodes.length) {
|
||||
// _focusNodes[i].unfocus();
|
||||
// }
|
||||
// }
|
||||
setState(() {
|
||||
_inputStatuses[i] =
|
||||
formInputStatus;
|
||||
});
|
||||
},
|
||||
controller: _controllers[i],
|
||||
style: STextStyles.field(
|
||||
context)
|
||||
style:
|
||||
STextStyles.field(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<
|
||||
|
@ -1035,8 +1019,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.only(
|
||||
const EdgeInsets.only(
|
||||
left: 12.0,
|
||||
bottom: 4.0,
|
||||
),
|
||||
|
@ -1061,8 +1044,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
),
|
||||
),
|
||||
],
|
||||
for (int i = remainder;
|
||||
i < cols;
|
||||
for (int i = 0;
|
||||
i < cols - remainder;
|
||||
i++) ...[
|
||||
TableViewCell(
|
||||
flex: 1,
|
||||
|
@ -1109,8 +1092,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
child: TextFormField(
|
||||
autocorrect: !isDesktop,
|
||||
enableSuggestions: !isDesktop,
|
||||
textCapitalization:
|
||||
TextCapitalization.none,
|
||||
textCapitalization: TextCapitalization.none,
|
||||
key: Key("restoreMnemonicFormField_$i"),
|
||||
decoration: _getInputDecorationFor(
|
||||
_inputStatuses[i - 1], "$i"),
|
||||
|
@ -1123,12 +1105,10 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
final FormInputStatus formInputStatus;
|
||||
|
||||
if (value.isEmpty) {
|
||||
formInputStatus =
|
||||
FormInputStatus.empty;
|
||||
formInputStatus = FormInputStatus.empty;
|
||||
} else if (_isValidMnemonicWord(
|
||||
value.trim().toLowerCase())) {
|
||||
formInputStatus =
|
||||
FormInputStatus.valid;
|
||||
formInputStatus = FormInputStatus.valid;
|
||||
} else {
|
||||
formInputStatus =
|
||||
FormInputStatus.invalid;
|
||||
|
@ -1143,13 +1123,11 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
// }
|
||||
// }
|
||||
setState(() {
|
||||
_inputStatuses[i - 1] =
|
||||
formInputStatus;
|
||||
_inputStatuses[i - 1] = formInputStatus;
|
||||
});
|
||||
},
|
||||
controller: _controllers[i - 1],
|
||||
style:
|
||||
STextStyles.field(context).copyWith(
|
||||
style: STextStyles.field(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textRestore,
|
||||
|
@ -1169,8 +1147,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
child: Text(
|
||||
"Please check spelling",
|
||||
textAlign: TextAlign.left,
|
||||
style: STextStyles.label(context)
|
||||
.copyWith(
|
||||
style:
|
||||
STextStyles.label(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textError,
|
||||
|
|
Loading…
Reference in a new issue