@@ -149,8 +149,6 @@ abstract class BaseTextInput extends StatefulWidget
149
149
_controller.dismissibleKeyboard = Utils .getBool (value, fallback: _controller.dismissibleKeyboard),
150
150
'obscureToggle' : (value) =>
151
151
_controller.obscureToggle = Utils .optionalBool (value),
152
- 'allowMention' : (value) =>
153
- _controller.allowMention = Utils .optionalBool (value),
154
152
'obscured' : (widget) => _controller.obscureText == true ,
155
153
'obscureTextWidget' : (widget) => _controller.obscureTextWidget = widget,
156
154
'readOnly' : (value) => _controller.readOnly = Utils .optionalBool (value),
@@ -236,7 +234,6 @@ class TextInputController extends FormFieldController with HasTextPlaceholder {
236
234
// applicable only for Password or obscure TextInput, to toggle between plain and secure text
237
235
bool ? obscured;
238
236
bool ? obscureToggle;
239
- bool ? allowMention;
240
237
dynamic obscureTextWidget;
241
238
bool ? readOnly;
242
239
bool selectable = true ;
@@ -477,121 +474,124 @@ class TextInputState extends FormFieldWidgetState<BaseTextInput>
477
474
}
478
475
479
476
return InputWrapper (
480
- type: TextInput .type,
481
- controller: widget._controller,
482
- widget: TextFormField (
483
- key: validatorKey,
484
- autofillHints: widget._controller.autofillHints,
485
- autovalidateMode: widget._controller.validateOnUserInteraction
486
- ? AutovalidateMode .onUserInteraction
487
- : AutovalidateMode .disabled,
488
- validator: (value) {
489
- if (value == null || value.isEmpty) {
490
- return widget._controller.required
491
- ? Utils .translateWithFallback (
492
- 'ensemble.input.required' ,
493
- widget._controller.requiredMessage ??
494
- 'This field is required' )
495
- : null ;
496
- }
497
-
498
- if (widget._controller.validator != null ) {
499
- ValidationBuilder ? builder;
500
- if (widget._controller.validator? .minLength != null ) {
501
- builder = ValidationBuilder ().minLength (
502
- widget._controller.validator! .minLength! ,
503
- Utils .translateOrNull (
504
- 'ensemble.input.validation.minimumLength' ));
505
- }
506
- if (widget._controller.validator? .maxLength != null ) {
507
- builder = (builder ?? ValidationBuilder ()).maxLength (
508
- widget._controller.validator! .maxLength! ,
509
- Utils .translateOrNull (
510
- 'ensemble.input.validation.maximumLength' ));
511
- }
512
- if (widget._controller.validator? .regex != null ) {
513
- builder = (builder ?? ValidationBuilder ()).regExp (
514
- RegExp (widget._controller.validator! .regex! ),
515
- widget._controller.validator! .regexError ??
516
- Utils .translateWithFallback (
517
- 'ensemble.input.validation.invalidInput' ,
518
- 'This field has invalid value' ));
519
- }
520
- if (builder != null ) {
521
- return builder.build ().call (value);
522
- }
523
- }
524
-
525
- if (! widget.isPassword ()) {
526
- if (widget._controller.inputType == InputType .email.name) {
527
- if (! EmailValidator .validate (value)) {
528
- return Utils .translateWithFallback (
529
- 'ensemble.input.validation.invalidEmailType' ,
530
- 'Please enter a valid email address' );
477
+ type: TextInput .type,
478
+ controller: widget._controller,
479
+ widget: TextFormField (
480
+ key: validatorKey,
481
+ autofillHints: widget._controller.autofillHints,
482
+ autovalidateMode: widget._controller.validateOnUserInteraction
483
+ ? AutovalidateMode .onUserInteraction
484
+ : AutovalidateMode .disabled,
485
+ validator: (value) {
486
+ if (value == null || value.isEmpty) {
487
+ return widget._controller.required
488
+ ? Utils .translateWithFallback (
489
+ 'ensemble.input.required' ,
490
+ widget._controller.requiredMessage ??
491
+ 'This field is required' )
492
+ : null ;
493
+ }
494
+
495
+ // First we're using the validator to validate the TextInput Field
496
+ if (widget._controller.validator != null ) {
497
+ ValidationBuilder ? builder;
498
+ if (widget._controller.validator? .minLength != null ) {
499
+ builder = ValidationBuilder ().minLength (
500
+ widget._controller.validator! .minLength! ,
501
+ Utils .translateOrNull (
502
+ 'ensemble.input.validation.minimumLength' ));
503
+ }
504
+ if (widget._controller.validator? .maxLength != null ) {
505
+ builder = (builder ?? ValidationBuilder ()).maxLength (
506
+ widget._controller.validator! .maxLength! ,
507
+ Utils .translateOrNull (
508
+ 'ensemble.input.validation.maximumLength' ));
509
+ }
510
+ if (widget._controller.validator? .regex != null ) {
511
+ builder = (builder ?? ValidationBuilder ()).regExp (
512
+ RegExp (widget._controller.validator! .regex! ),
513
+ widget._controller.validator! .regexError ??
514
+ Utils .translateWithFallback (
515
+ 'ensemble.input.validation.invalidInput' ,
516
+ 'This field has invalid value' ));
517
+ }
518
+ if (builder != null ) {
519
+ return builder.build ().call (value);
520
+ }
521
+ }
522
+
523
+ // If validator is null, we can use our own validation based on the InputType
524
+ //only applicable for TextInput
525
+ if (! widget.isPassword ()) {
526
+ if (widget._controller.inputType == InputType .email.name) {
527
+ if (! EmailValidator .validate (value)) {
528
+ return Utils .translateWithFallback (
529
+ 'ensemble.input.validation.invalidEmailType' ,
530
+ 'Please enter a valid email address' );
531
531
}
532
- } else if (widget._controller.inputType ==
533
- InputType .ipAddress.name) {
534
- if (! InputValidator .ipAddress (value)) {
535
- return Utils .translateWithFallback (
536
- 'ensemble.input.validation.invalidIPAddressType' ,
537
- 'Please enter a valid IP Address' );
532
+ } else if (widget._controller.inputType ==
533
+ InputType .ipAddress.name) {
534
+ if (! InputValidator .ipAddress (value)) {
535
+ return Utils .translateWithFallback (
536
+ 'ensemble.input.validation.invalidIPAddressType' ,
537
+ 'Please enter a valid IP Address' );
538
538
}
539
- } else if (widget._controller.inputType ==
540
- InputType .phone.name) {
541
- if (! InputValidator .phone (value)) {
542
- return Utils .translateWithFallback (
543
- 'ensemble.input.validation.invalidPhoneType' ,
544
- "Please enter a valid Phone Number" );
539
+ } else if (widget._controller.inputType == InputType .phone.name) {
540
+ if (! InputValidator .phone (value)) {
541
+ return Utils .translateWithFallback (
542
+ 'ensemble.input.validation.invalidPhoneType' ,
543
+ "Please enter a valid Phone Number" );
545
544
}
546
- }
547
- }
548
- return null ;
549
- },
550
- textInputAction: widget._controller.keyboardAction,
551
- keyboardType: widget.keyboardType,
552
- inputFormatters: _inputFormatter,
553
- minLines: isMultiline () ? widget._controller.minLines : null ,
554
- maxLines: isMultiline () ? widget._controller.maxLines : 1 ,
555
- maxLength: widget._controller.maxLength,
556
- maxLengthEnforcement: widget._controller.maxLengthEnforcement ??
557
- MaxLengthEnforcement .enforced,
558
- obscureText: isObscureOrPlainText (),
559
- enableSuggestions: ! widget.isPassword (),
560
- autocorrect: ! widget.isPassword (),
561
- controller: widget.textController,
562
- focusNode: focusNode,
563
- enabled: isEnabled (),
564
- readOnly: widget._controller.readOnly == true ,
565
- enableInteractiveSelection: widget._controller.selectable,
566
- // onTap: () => showOverlay(context),
567
- // onTapOutside: (_) => removeOverlayAndUnfocus(),
568
- onFieldSubmitted: (value) =>
569
- widget.controller.submitForm (context),
570
- onChanged: (String txt) {
571
- if (txt != previousText) {
572
- didItChange = true ;
573
- previousText = txt;
574
-
575
- if (widget._controller.onKeyPress != null ) {
576
- ScreenController ().executeAction (
577
- context, widget._controller.onKeyPress! ,
578
- event: EnsembleEvent (widget));
579
- }
580
-
581
- if (widget._controller.onDelayedKeyPress != null ) {
582
- executeDelayedAction (widget._controller.onDelayedKeyPress! );
583
- }
584
- }
585
- setState (() {});
586
- },
587
- style: isEnabled ()
588
- ? widget._controller.textStyle
589
- : widget._controller.textStyle? .copyWith (
590
- color: Theme .of (context).disabledColor,
591
- ),
592
- decoration: decoration,
593
- ),
594
- );
545
+ }
546
+ }
547
+ return null ;
548
+ },
549
+ textInputAction: widget._controller.keyboardAction,
550
+ keyboardType: widget.keyboardType,
551
+ inputFormatters: _inputFormatter,
552
+ minLines: isMultiline () ? widget._controller.minLines : null ,
553
+ maxLines: isMultiline () ? widget._controller.maxLines : 1 ,
554
+ maxLength: widget._controller.maxLength,
555
+ maxLengthEnforcement: widget._controller.maxLengthEnforcement ??
556
+ MaxLengthEnforcement .enforced,
557
+ obscureText: isObscureOrPlainText (),
558
+ enableSuggestions: ! widget.isPassword (),
559
+ autocorrect: ! widget.isPassword (),
560
+ controller: widget.textController,
561
+ focusNode: focusNode,
562
+ enabled: isEnabled (),
563
+ readOnly: widget._controller.readOnly == true ,
564
+ enableInteractiveSelection: widget._controller.selectable,
565
+ onTap: () => showOverlay (context),
566
+ onTapOutside: (_) => removeOverlayAndUnfocus (),
567
+ onFieldSubmitted: (value) => widget.controller.submitForm (context),
568
+ onChanged: (String txt) {
569
+ if (txt != previousText) {
570
+ // for performance reason, we dispatch onChange (as well as binding to value)
571
+ // upon EditingComplete (select Done on virtual keyboard) or Focus Out
572
+ didItChange = true ;
573
+ previousText = txt;
574
+
575
+ // we dispatch onKeyPress here
576
+ if (widget._controller.onKeyPress != null ) {
577
+ ScreenController ().executeAction (
578
+ context, widget._controller.onKeyPress! ,
579
+ event: EnsembleEvent (widget));
580
+ }
581
+
582
+ if (widget._controller.onDelayedKeyPress != null ) {
583
+ executeDelayedAction (widget._controller.onDelayedKeyPress! );
584
+ }
585
+ }
586
+ setState (() {});
587
+ },
588
+ style: isEnabled ()
589
+ ? widget._controller.textStyle
590
+ : widget._controller.textStyle? .copyWith (
591
+ color: Theme .of (context).disabledColor,
592
+ ),
593
+ decoration: decoration,
594
+ ));
595
595
}
596
596
597
597
/// multi-line if specified or if maxLine is more than 1
0 commit comments