Skip to content

Commit

Permalink
Fixed date in CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkko committed Jun 6, 2024
1 parent 7a41192 commit bb62783
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 5.0.0 · 9/04/2024
#### 5.0.0 · 6/06/2024
- Implemented Pinput.builder to build custom Pinput fields
- Migrated deprecated imperative apply of Flutter's Gradle plugins example app
- Removed smart_auth dependency which was responsible for SMS autofill (Not everyone might need it and it was causing some issues)
Expand Down
55 changes: 36 additions & 19 deletions lib/src/pinput_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class _PinputState extends State<Pinput>
late bool forcePressEnabled;

@override
final GlobalKey<EditableTextState> editableTextKey = GlobalKey<EditableTextState>();
final GlobalKey<EditableTextState> editableTextKey =
GlobalKey<EditableTextState>();

@override
bool get selectionEnabled => widget.toolbarEnabled;
Expand All @@ -37,8 +38,8 @@ class _PinputState extends State<Pinput>
String? get _errorText => widget.errorText ?? _validatorErrorText;

bool get _canRequestFocus {
final NavigationMode mode =
MediaQuery.maybeOf(context)?.navigationMode ?? NavigationMode.traditional;
final NavigationMode mode = MediaQuery.maybeOf(context)?.navigationMode ??
NavigationMode.traditional;
switch (mode) {
case NavigationMode.traditional:
return isEnabled && widget.useNativeKeyboard;
Expand All @@ -47,10 +48,12 @@ class _PinputState extends State<Pinput>
}
}

TextEditingController get _effectiveController => widget.controller ?? _controller!.value;
TextEditingController get _effectiveController =>
widget.controller ?? _controller!.value;

@protected
FocusNode get effectiveFocusNode => widget.focusNode ?? (_focusNode ??= FocusNode());
FocusNode get effectiveFocusNode =>
widget.focusNode ?? (_focusNode ??= FocusNode());

@protected
bool get hasError => widget.forceErrorState || _validatorErrorText != null;
Expand All @@ -71,7 +74,8 @@ class _PinputState extends State<Pinput>
@override
void initState() {
super.initState();
_gestureDetectorBuilder = _PinputSelectionGestureDetectorBuilder(state: this);
_gestureDetectorBuilder =
_PinputSelectionGestureDetectorBuilder(state: this);
if (widget.controller == null) {
_createLocalController();
_recentControllerValue = TextEditingValue.empty;
Expand Down Expand Up @@ -106,7 +110,8 @@ class _PinputState extends State<Pinput>
}

void _handleTextEditingControllerChanges() {
final textChanged = _recentControllerValue.text != _effectiveController.value.text;
final textChanged =
_recentControllerValue.text != _effectiveController.value.text;
_recentControllerValue = _effectiveController.value;
if (textChanged) {
_onChanged(pin);
Expand Down Expand Up @@ -204,7 +209,8 @@ class _PinputState extends State<Pinput>
TextSelection selection,
SelectionChangedCause? cause,
) {
_effectiveController.selection = TextSelection.collapsed(offset: pin.length);
_effectiveController.selection =
TextSelection.collapsed(offset: pin.length);

switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
Expand All @@ -213,7 +219,8 @@ class _PinputState extends State<Pinput>
case TargetPlatform.windows:
case TargetPlatform.fuchsia:
case TargetPlatform.android:
if (cause == SelectionChangedCause.longPress || cause == SelectionChangedCause.drag) {
if (cause == SelectionChangedCause.longPress ||
cause == SelectionChangedCause.drag) {
_editableText?.bringIntoView(selection.extent);
}
break;
Expand Down Expand Up @@ -293,7 +300,8 @@ class _PinputState extends State<Pinput>
forcePressEnabled = false;
textSelectionControls ??= cupertinoDesktopTextSelectionHandleControls;
handleDidGainAccessibilityFocus = () {
if (!effectiveFocusNode.hasFocus && effectiveFocusNode.canRequestFocus) {
if (!effectiveFocusNode.hasFocus &&
effectiveFocusNode.canRequestFocus) {
effectiveFocusNode.requestFocus();
}
};
Expand All @@ -311,7 +319,8 @@ class _PinputState extends State<Pinput>
forcePressEnabled = false;
textSelectionControls ??= desktopTextSelectionHandleControls;
handleDidGainAccessibilityFocus = () {
if (!effectiveFocusNode.hasFocus && effectiveFocusNode.canRequestFocus) {
if (!effectiveFocusNode.hasFocus &&
effectiveFocusNode.canRequestFocus) {
effectiveFocusNode.requestFocus();
}
};
Expand Down Expand Up @@ -419,14 +428,17 @@ class _PinputState extends State<Pinput>
onSelectionChanged: _handleSelectionChanged,
onSelectionHandleTapped: _handleSelectionHandleTapped,
readOnly: widget.readOnly || !isEnabled || !widget.useNativeKeyboard,
selectionControls: widget.toolbarEnabled ? textSelectionControls : null,
keyboardAppearance: widget.keyboardAppearance ?? Theme.of(context).brightness,
selectionControls:
widget.toolbarEnabled ? textSelectionControls : null,
keyboardAppearance:
widget.keyboardAppearance ?? Theme.of(context).brightness,
),
),
);
}

MouseCursor get _effectiveMouseCursor => MaterialStateProperty.resolveAs<MouseCursor>(
MouseCursor get _effectiveMouseCursor =>
MaterialStateProperty.resolveAs<MouseCursor>(
widget.mouseCursor ?? MaterialStateMouseCursor.textable,
<MaterialState>{
if (!isEnabled) MaterialState.disabled,
Expand Down Expand Up @@ -492,7 +504,8 @@ class _PinputState extends State<Pinput>
<Listenable>[effectiveFocusNode, _effectiveController],
),
builder: (BuildContext context, Widget? child) {
final shouldHideErrorContent = widget.validator == null && widget.errorText == null;
final shouldHideErrorContent =
widget.validator == null && widget.errorText == null;

if (shouldHideErrorContent) return onlyFields();

Expand All @@ -515,7 +528,8 @@ class _PinputState extends State<Pinput>
@protected
bool get hasFocus {
final isLastPin = selectedIndex == widget.length;
return effectiveFocusNode.hasFocus || (!widget.useNativeKeyboard && !isLastPin);
return effectiveFocusNode.hasFocus ||
(!widget.useNativeKeyboard && !isLastPin);
}

@protected
Expand All @@ -534,7 +548,8 @@ class _PinputState extends State<Pinput>
child: Text(
_errorText!,
style: widget.errorTextStyle ??
theme.textTheme.titleMedium?.copyWith(color: theme.colorScheme.error),
theme.textTheme.titleMedium
?.copyWith(color: theme.colorScheme.error),
),
);
}
Expand All @@ -545,11 +560,13 @@ class _PinputState extends State<Pinput>

// AutofillClient implementation start.
@override
void autofill(TextEditingValue newEditingValue) => _editableText!.autofill(newEditingValue);
void autofill(TextEditingValue newEditingValue) =>
_editableText!.autofill(newEditingValue);

@override
TextInputConfiguration get textInputConfiguration {
final List<String>? autofillHints = widget.autofillHints?.toList(growable: false);
final List<String>? autofillHints =
widget.autofillHints?.toList(growable: false);
final AutofillConfiguration autofillConfiguration = autofillHints != null
? AutofillConfiguration(
uniqueIdentifier: autofillId,
Expand Down

0 comments on commit bb62783

Please sign in to comment.