Skip to content

Commit 6344390

Browse files
committed
refactor: states and views of restore options
1 parent 5c18e78 commit 6344390

File tree

2 files changed

+92
-74
lines changed

2 files changed

+92
-74
lines changed

lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class _NameYourWalletViewState extends ConsumerState<NameYourWalletView> {
322322
)
323323
: Semantics(
324324
label:
325-
"Clear Block Height Field Button. Clears the block height field.",
325+
"Clear Wallet Name Field Button. Clears the wallet name field.",
326326
excludeSemantics: true,
327327
child: XIcon(
328328
width: isDesktop ? 21 : 18,

lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart

Lines changed: 91 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import 'package:dropdown_button2/dropdown_button2.dart';
1212
import 'package:flutter/material.dart';
13+
import 'package:flutter/services.dart';
1314
import 'package:flutter_riverpod/flutter_riverpod.dart';
1415
import 'package:flutter_svg/svg.dart';
1516
import 'package:logger/logger.dart';
@@ -476,44 +477,52 @@ class _SeedRestoreOptionState extends ConsumerState<SeedRestoreOption> {
476477
onTap: widget.dateChooserFunction,
477478
controller: widget.dateController,
478479
) :
479-
TextField(
480-
focusNode: widget.blockHeightFocusNode,
481-
controller: widget.blockHeightController,
482-
keyboardType: TextInputType.number,
483-
textInputAction: TextInputAction.done,
484-
style: Util.isDesktop
485-
? STextStyles.desktopTextMedium(context).copyWith(
486-
height: 2,
487-
)
488-
: STextStyles.field(context),
489-
onChanged: (value) {
490-
setState(() {
491-
_blockFieldEmpty = value.isEmpty;
492-
});
493-
},
494-
decoration: standardInputDecoration(
495-
"Start scanning from...",
496-
widget.blockHeightFocusNode,
497-
context,
498-
).copyWith(
499-
suffixIcon: UnconstrainedBox(
500-
child: TextFieldIconButton(child:
501-
Semantics(
480+
ClipRRect(
481+
borderRadius: BorderRadius.circular(
482+
Constants.size.circularBorderRadius,
483+
),
484+
child: TextField(
485+
focusNode: widget.blockHeightFocusNode,
486+
controller: widget.blockHeightController,
487+
keyboardType: TextInputType.number,
488+
inputFormatters: [
489+
FilteringTextInputFormatter.digitsOnly,
490+
],
491+
textInputAction: TextInputAction.done,
492+
style: Util.isDesktop
493+
? STextStyles.desktopTextMedium(context).copyWith(
494+
height: 2,
495+
)
496+
: STextStyles.field(context),
497+
onChanged: (value) {
498+
setState(() {
499+
_blockFieldEmpty = value.isEmpty;
500+
});
501+
},
502+
decoration: standardInputDecoration(
503+
"Start scanning from...",
504+
widget.blockHeightFocusNode,
505+
context,
506+
).copyWith(
507+
suffixIcon: UnconstrainedBox(
508+
child: TextFieldIconButton(child:
509+
Semantics(
502510
label: "Clear Block Height Field Button. Clears the block height field",
503511
excludeSemantics: true,
504512
child: !_blockFieldEmpty
505513
? XIcon(
506-
width: Util.isDesktop ? 24 : 16,
507-
height: Util.isDesktop ? 24 : 16,
508-
)
514+
width: Util.isDesktop ? 24 : 16,
515+
height: Util.isDesktop ? 24 : 16,
516+
)
509517
: const SizedBox.shrink(),
510518
),
511-
onTap: () {
512-
widget.blockHeightController.text = "";
513-
setState(() {
514-
_blockFieldEmpty = true;
515-
});
516-
},
519+
onTap: () {
520+
widget.blockHeightController.text = "";
521+
setState(() {
522+
_blockFieldEmpty = true;
523+
});
524+
},
525+
),
517526
),
518527
),
519528
),
@@ -778,9 +787,7 @@ class _SeedRestoreOptionState extends ConsumerState<SeedRestoreOption> {
778787
void initState() {
779788
super.initState();
780789

781-
setState(() {
782-
_blockFieldEmpty = widget.blockHeightController.text.isEmpty;
783-
});
790+
_blockFieldEmpty = widget.blockHeightController.text.isEmpty;
784791
}
785792
}
786793

@@ -854,44 +861,57 @@ class _ViewOnlyRestoreOptionState extends State<ViewOnlyRestoreOption> {
854861
onTap: widget.dateChooserFunction,
855862
controller: widget.dateController,
856863
)
857-
: TextField(
858-
focusNode: widget.blockHeightFocusNode,
859-
controller: widget.blockHeightController,
860-
keyboardType: TextInputType.number,
861-
textInputAction: TextInputAction.done,
862-
style: Util.isDesktop
863-
? STextStyles.desktopTextMedium(context).copyWith(
864-
height: 2,
865-
)
866-
: STextStyles.field(context),
867-
decoration: standardInputDecoration(
868-
"Start scanning from...",
869-
widget.blockHeightFocusNode,
870-
context,
871-
).copyWith(
872-
suffixIcon: UnconstrainedBox(
873-
child: TextFieldIconButton(
874-
child: Semantics(
875-
label:
876-
"Clear Block Height Field Button. Clears the block height field",
877-
excludeSemantics: true,
878-
child: !_blockFieldEmpty
879-
? XIcon(
880-
width: Util.isDesktop ? 24 : 16,
881-
height: Util.isDesktop ? 24 : 16,
882-
)
883-
: const SizedBox.shrink(),
884-
),
885-
onTap: () {
886-
widget.blockHeightController.text = "";
887-
setState(() {
888-
_blockFieldEmpty = true;
889-
});
890-
},
891-
),
864+
: ClipRRect(
865+
borderRadius: BorderRadius.circular(
866+
Constants.size.circularBorderRadius,
867+
),
868+
child: TextField(
869+
focusNode: widget.blockHeightFocusNode,
870+
controller: widget.blockHeightController,
871+
keyboardType: TextInputType.number,
872+
inputFormatters: [
873+
FilteringTextInputFormatter.digitsOnly,
874+
],
875+
textInputAction: TextInputAction.done,
876+
style: Util.isDesktop
877+
? STextStyles.desktopTextMedium(context).copyWith(
878+
height: 2,
879+
)
880+
: STextStyles.field(context),
881+
onChanged: (value) {
882+
setState(() {
883+
_blockFieldEmpty = value.isEmpty;
884+
});
885+
},
886+
decoration: standardInputDecoration(
887+
"Start scanning from...",
888+
widget.blockHeightFocusNode,
889+
context,
890+
).copyWith(
891+
suffixIcon: UnconstrainedBox(
892+
child: TextFieldIconButton(
893+
child: Semantics(
894+
label:
895+
"Clear Block Height Field Button. Clears the block height field",
896+
excludeSemantics: true,
897+
child: !_blockFieldEmpty
898+
? XIcon(
899+
width: Util.isDesktop ? 24 : 16,
900+
height: Util.isDesktop ? 24 : 16,
901+
)
902+
: const SizedBox.shrink(),
892903
),
904+
onTap: () {
905+
widget.blockHeightController.text = "";
906+
setState(() {
907+
_blockFieldEmpty = true;
908+
});
909+
},
893910
),
894911
),
912+
),
913+
),
914+
),
895915
if (showDateOption)
896916
const SizedBox(
897917
height: 8,
@@ -927,8 +947,6 @@ class _ViewOnlyRestoreOptionState extends State<ViewOnlyRestoreOption> {
927947
void initState() {
928948
super.initState();
929949

930-
setState(() {
931-
_blockFieldEmpty = widget.blockHeightController.text.isEmpty;
932-
});
950+
_blockFieldEmpty = widget.blockHeightController.text.isEmpty;
933951
}
934952
}

0 commit comments

Comments
 (0)