Skip to content

Commit

Permalink
Fix pin not shown automatically after error
Browse files Browse the repository at this point in the history
  • Loading branch information
DDavidPrime committed Oct 2, 2024
1 parent 815c666 commit 7d4609e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
1 change: 1 addition & 0 deletions packages/widget_toolkit_pin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [0.2.1]
* Fixed a visual bug where held buttons would remain stuck in the pressed state
* Fixed a visual bug where pin indicators wouldn't be displayed after an error is presented
* Throw an error if biometrics aren't supported during biometrics authentication

## [0.2.0]
Expand Down
2 changes: 1 addition & 1 deletion packages/widget_toolkit_pin/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.0"
version: "0.2.1"
xdg_directories:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class PinCodeBloc extends $PinCodeBloc {
return Stream.value(_pinCode.value.length);
},
).asResultStream(),
errorState
.delay(const Duration(milliseconds: 300))
.mapTo(0)
.asResultStream(),
]).whereSuccess().startWith(0).share();

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ class PinCodeComponent extends StatefulWidget {
/// to make it clickable.
final PinCodeCustomKey? bottomRightKeyboardButton;

/// The duration of the input label animation presenting the error or input dots
final Duration inputLabelAnimationDuration =
const Duration(milliseconds: 300);

@override
State<PinCodeComponent> createState() => _PinCodeComponentState();
}
Expand Down Expand Up @@ -197,20 +193,13 @@ class _PinCodeComponentState extends State<PinCodeComponent>
child: RxBlocBuilder<PinCodeBlocType, int>(
state: (bloc) => bloc.states.digitsCount,
builder: (context, pinLength, bloc) => _buildPageContent(
pinLength: _pinLengthData(pinLength),
pinLength: pinLength.data ?? 0,
context: context,
),
),
),
);

int _pinLengthData(AsyncSnapshot<int> pinLength) {
if (pinLength.hasData && pinLength.data != null) {
return pinLength.data!;
}
return 0;
}

Widget _buildPageContent({
required int pinLength,
required BuildContext context,
Expand Down Expand Up @@ -244,7 +233,7 @@ class _PinCodeComponentState extends State<PinCodeComponent>
child: child,
),
child: AnimatedSwitcher(
duration: widget.inputLabelAnimationDuration,
duration: const Duration(milliseconds: 300),
switchInCurve: Curves.easeOut,
switchOutCurve: Curves.easeOut,
transitionBuilder: (child, animation) {
Expand All @@ -266,11 +255,7 @@ class _PinCodeComponentState extends State<PinCodeComponent>
},
child: hasErrorText && widget.error != null
? _buildErrorText(context, widget.error!)
: RxBlocBuilder<PinCodeBlocType, int>(
state: (bloc) => bloc.states.digitsCount,
builder: (context, pinLength, bloc) =>
_buildMaskedKeysRow(context, pinLength.data ?? 0),
),
: _buildMaskedKeysRow(context, pinLength),
),
);

Expand Down

0 comments on commit 7d4609e

Please sign in to comment.