Skip to content

Commit d799710

Browse files
Merge branch 'main' into header-enhancement
2 parents 0fd7f75 + e28873a commit d799710

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

modules/ensemble/lib/framework/widget/widget.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ abstract class EWidgetState<W extends HasController>
100100
rtn = AnimatedOpacity(
101101
// If visible, apply opacity if specified, else default to 1
102102
opacity: widgetController.visible != false
103-
? (Utils.getValidOpacity(widgetController.opacity ?? 1) ?? 1)
103+
? (Utils.optionalDouble(widgetController.opacity ?? 1, min: 0, max: 1.0) ?? 1)
104104
: 0,
105105
duration: widgetController.visibilityTransitionDuration!,
106106
child: rtn);
@@ -116,7 +116,7 @@ abstract class EWidgetState<W extends HasController>
116116
if (widgetController.visibilityTransitionDuration == null &&
117117
widgetController.opacity != null) {
118118
rtn = Opacity(
119-
opacity: Utils.getValidOpacity(widgetController.opacity!) ?? 1,
119+
opacity: Utils.optionalDouble(widgetController.opacity!, min: 0, max: 1.0) ?? 1.0,
120120
child: rtn,
121121
);
122122
}

modules/ensemble/lib/layout/form.dart

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class EnsembleForm extends StatefulWidget
6868
_controller.labelStyle = Utils.getTextStyle(value),
6969
'enabled': (value) => _controller.enabled = Utils.optionalBool(value),
7070
'readOnly': (value) => _controller.readOnly = Utils.optionalBool(value),
71+
'dismissibleKeyboard': (value) => _controller.dismissibleKeyboard = Utils.getBool(value, fallback: _controller.dismissibleKeyboard),
7172
'width': (value) => _controller.width = Utils.optionalInt(value),
7273
'height': (value) => _controller.height = Utils.optionalInt(value),
7374
'gap': (value) => _controller.gap =
@@ -110,6 +111,7 @@ class FormController extends WidgetController {
110111
String? labelOverflow;
111112
bool? enabled;
112113
bool? readOnly;
114+
bool dismissibleKeyboard = true;
113115

114116
// labelMaxWidth applicable only to labelPosition=start
115117
int? labelMaxWidth;

modules/ensemble/lib/util/utils.dart

-7
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,6 @@ class Utils {
694694
return textAlign;
695695
}
696696

697-
static double? getValidOpacity(double opacity) {
698-
if (opacity < 0 || opacity > 1) {
699-
return 1;
700-
} else {
701-
return opacity;
702-
}
703-
}
704697

705698
static Curve? getCurve(String? curveType) {
706699
Curve? curve;

modules/ensemble/lib/widget/button.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ class ButtonState extends EWidgetState<Button> {
280280
// if focus in on a formfield (e.g. TextField), clicking on button will
281281
// not remove focus, so its value is never updated. Unfocus here before
282282
// executing button click ensure we get all the latest value of the form fields
283-
FocusManager.instance.primaryFocus?.unfocus();
283+
if (widget._controller.submitForm == false) {
284+
FocusManager.instance.primaryFocus?.unfocus();
285+
}
284286

285287
// submit the form if specified
286288
if (widget._controller.submitForm == true) {

modules/ensemble/lib/widget/helpers/controllers.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ abstract class WidgetController extends Controller with HasStyles {
261261
'flex': (value) => flex = Utils.optionalInt(value, min: 1),
262262
'expanded': (value) => expanded = Utils.getBool(value, fallback: false),
263263
'visible': (value) => visible = Utils.getBool(value, fallback: true),
264-
'opacity': (value) => opacity = Utils.getValidOpacity(value),
264+
'opacity': (value) => opacity = Utils.optionalDouble(value, min: 0, max: 1),
265265
'visibilityTransitionDuration': (value) =>
266266
visibilityTransitionDuration = Utils.getDuration(value),
267267
'elevation': (value) =>
@@ -487,7 +487,7 @@ abstract class EnsembleWidgetController extends EnsembleController
487487
'flexMode': (value) => flexMode = FlexMode.values.from(value),
488488
'flex': (value) => flex = Utils.optionalInt(value, min: 1),
489489
'visible': (value) => visible = Utils.getBool(value, fallback: true),
490-
'opacity': (value) => opacity = Utils.getValidOpacity(value),
490+
'opacity': (value) => opacity = Utils.optionalDouble(value, min: 0, max: 1),
491491
'visibilityTransitionDuration': (value) =>
492492
visibilityTransitionDuration = Utils.getDuration(value),
493493
'textDirection': (value) => textDirection = Utils.getTextDirection(value),

modules/ensemble/lib/widget/helpers/form_helper.dart

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ class FormHelper {
118118
event: EnsembleEvent(formState.widget));
119119
}
120120
}
121+
// only dismiss keyboard if dismissKeyboardOnSubmit is true (By default it is true)
122+
if(formState?.widget.controller.dismissibleKeyboard == true) {
123+
FocusManager.instance.primaryFocus?.unfocus();
124+
}
121125
}
122126
}
123127

modules/ensemble/lib/widget/input/form_textfield.dart

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ abstract class BaseTextInput extends StatefulWidget
145145
'validator': (value) => _controller.validator = Utils.getValidator(value),
146146
'enableClearText': (value) =>
147147
_controller.enableClearText = Utils.optionalBool(value),
148+
'dismissibleKeyboard': (value) =>
149+
_controller.dismissibleKeyboard = Utils.getBool(value, fallback: _controller.dismissibleKeyboard),
148150
'obscureToggle': (value) =>
149151
_controller.obscureToggle = Utils.optionalBool(value),
150152
'obscured': (widget) => _controller.obscureText == true,
@@ -224,6 +226,7 @@ class TextInputController extends FormFieldController with HasTextPlaceholder {
224226
EnsembleAction? onFocusReceived;
225227
EnsembleAction? onFocusLost;
226228
bool? enableClearText;
229+
bool dismissibleKeyboard = true;
227230

228231
// applicable only for TextInput
229232
bool? obscureText;
@@ -305,7 +308,10 @@ class TextInputState extends FormFieldWidgetState<BaseTextInput>
305308
overlayEntry!.remove();
306309
overlayEntry = null;
307310
}
311+
// only dismiss if dismissibleKeyboard is true (By Default dismissibleKeyboard is true)
312+
if(widget._controller.dismissibleKeyboard == true){
308313
FocusManager.instance.primaryFocus?.unfocus();
314+
}
309315
}
310316

311317
@override

0 commit comments

Comments
 (0)