|
@@ -68,89 +68,88 @@ class FISTextField extends StatelessWidget {
|
|
|
Widget build(BuildContext context) {
|
|
|
FocusNode focusNode = FocusNode();
|
|
|
return TextField(
|
|
|
- key: uniqueKey,
|
|
|
- scrollPadding: EdgeInsets.all(20.0.s),
|
|
|
- cursorWidth: 2.s,
|
|
|
- cursorHeight: 25.s,
|
|
|
- enableInteractiveSelection: false,
|
|
|
- controller: controller,
|
|
|
- inputFormatters: inputFormatters,
|
|
|
- style: textStyle ??
|
|
|
- Storage.currentTheme.normalTextStyle.copyWith(
|
|
|
- color: Colors.black,
|
|
|
- fontSize: Storage.currentTheme.normalTextStyle.fontSize!.s),
|
|
|
- readOnly: readOnly,
|
|
|
- onChanged: onChanged,
|
|
|
- obscureText: obscureText,
|
|
|
- autofocus: autofocus,
|
|
|
- focusNode: focusNode,
|
|
|
- maxLines: maxLines,
|
|
|
- minLines: minLines,
|
|
|
- expands: expands,
|
|
|
- textAlignVertical: textAlignVertical,
|
|
|
- keyboardType: keyboardType,
|
|
|
- onSubmitted: onSubmitted,
|
|
|
- enabled: enabled,
|
|
|
- decoration: DefaultInputDecoration(
|
|
|
- placeHolder: placeHolder,
|
|
|
- errorText: errorText,
|
|
|
- suffixIcon: suffixIcon,
|
|
|
- contentPadding:
|
|
|
- contentPadding ?? EdgeInsets.fromLTRB(12.s, 0, 12.s, 0),
|
|
|
- fillColor: fillColor,
|
|
|
- borderColor: borderColor,
|
|
|
- enabledBorderColor: enabledBorderColor),
|
|
|
- onTap: onTap ??
|
|
|
- () async {
|
|
|
- if (route != Get.currentRoute ||
|
|
|
- Storage.platform == Platform.Android) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Offset position = const Offset(0, 0);
|
|
|
- Size screenSize = const Size(0, 0);
|
|
|
- double controlHeight = 0;
|
|
|
- if (uniqueKey is GlobalKey) {
|
|
|
- final RenderBox renderBox = (uniqueKey as GlobalKey)
|
|
|
- .currentContext!
|
|
|
- .findRenderObject() as RenderBox;
|
|
|
- position = renderBox.localToGlobal(Offset.zero);
|
|
|
- screenSize =
|
|
|
- MediaQuery.of((uniqueKey as GlobalKey).currentContext!)
|
|
|
- .size;
|
|
|
- controlHeight = renderBox.size.height;
|
|
|
- }
|
|
|
- var positionY = position.dy + controlHeight > screenSize.height
|
|
|
- ? screenSize.height
|
|
|
- : position.dy + controlHeight;
|
|
|
- if (positionY < 0) {
|
|
|
- positionY = 0;
|
|
|
- }
|
|
|
- var fiscontrolPositionInfo = FISControlPositionInfo(
|
|
|
- isShowSoftwareKeyBoard: true,
|
|
|
- screenHeight: screenSize.height,
|
|
|
- screenWidth: screenSize.width,
|
|
|
- positionX: position.dx,
|
|
|
- positionY: positionY);
|
|
|
- await operateSoftKeyBoard(fiscontrolPositionInfo);
|
|
|
- },
|
|
|
- onTapOutside: onTapOutside ??
|
|
|
- (e) async {
|
|
|
- if (route != Get.currentRoute) {
|
|
|
- return;
|
|
|
- }
|
|
|
- focusNode.unfocus();
|
|
|
- if (Storage.platform == Platform.Android) {
|
|
|
- return;
|
|
|
- }
|
|
|
- var fiscontrolPositionInfo = FISControlPositionInfo(
|
|
|
- isShowSoftwareKeyBoard: false,
|
|
|
- screenHeight: 0,
|
|
|
- screenWidth: 0,
|
|
|
- positionX: 0,
|
|
|
- positionY: 0);
|
|
|
- await operateSoftKeyBoard(fiscontrolPositionInfo);
|
|
|
- },
|
|
|
- obscuringCharacter: "*");
|
|
|
+ key: uniqueKey,
|
|
|
+ scrollPadding: EdgeInsets.all(20.0.s),
|
|
|
+ cursorWidth: 2.s,
|
|
|
+ cursorHeight: 25.s,
|
|
|
+ enableInteractiveSelection: false,
|
|
|
+ controller: controller,
|
|
|
+ inputFormatters: inputFormatters,
|
|
|
+ style: textStyle ??
|
|
|
+ Storage.currentTheme.normalTextStyle.copyWith(
|
|
|
+ color: Colors.black,
|
|
|
+ fontSize: Storage.currentTheme.normalTextStyle.fontSize!.s),
|
|
|
+ readOnly: readOnly,
|
|
|
+ onChanged: onChanged,
|
|
|
+ obscureText: obscureText,
|
|
|
+ autofocus: autofocus,
|
|
|
+ focusNode: focusNode,
|
|
|
+ maxLines: maxLines,
|
|
|
+ minLines: minLines,
|
|
|
+ expands: expands,
|
|
|
+ textAlignVertical: textAlignVertical,
|
|
|
+ keyboardType: keyboardType,
|
|
|
+ onSubmitted: onSubmitted,
|
|
|
+ enabled: enabled,
|
|
|
+ decoration: DefaultInputDecoration(
|
|
|
+ placeHolder: placeHolder,
|
|
|
+ errorText: errorText,
|
|
|
+ suffixIcon: suffixIcon,
|
|
|
+ contentPadding:
|
|
|
+ contentPadding ?? EdgeInsets.fromLTRB(12.s, 0, 12.s, 0),
|
|
|
+ fillColor: fillColor,
|
|
|
+ borderColor: borderColor,
|
|
|
+ enabledBorderColor: enabledBorderColor),
|
|
|
+ onTap: onTap ??
|
|
|
+ () async {
|
|
|
+ if (route != Get.currentRoute ||
|
|
|
+ Storage.platform == Platform.Android) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Offset position = const Offset(0, 0);
|
|
|
+ Size screenSize = const Size(0, 0);
|
|
|
+ double controlHeight = 0;
|
|
|
+ if (uniqueKey is GlobalKey) {
|
|
|
+ final RenderBox renderBox = (uniqueKey as GlobalKey)
|
|
|
+ .currentContext!
|
|
|
+ .findRenderObject() as RenderBox;
|
|
|
+ position = renderBox.localToGlobal(Offset.zero);
|
|
|
+ screenSize =
|
|
|
+ MediaQuery.of((uniqueKey as GlobalKey).currentContext!).size;
|
|
|
+ controlHeight = renderBox.size.height;
|
|
|
+ }
|
|
|
+ var positionY = position.dy + controlHeight > screenSize.height
|
|
|
+ ? screenSize.height
|
|
|
+ : position.dy + controlHeight;
|
|
|
+ if (positionY < 0) {
|
|
|
+ positionY = 0;
|
|
|
+ }
|
|
|
+ var fiscontrolPositionInfo = FISControlPositionInfo(
|
|
|
+ isShowSoftwareKeyBoard: true,
|
|
|
+ screenHeight: screenSize.height,
|
|
|
+ screenWidth: screenSize.width,
|
|
|
+ positionX: position.dx,
|
|
|
+ positionY: positionY);
|
|
|
+ await operateSoftKeyBoard(fiscontrolPositionInfo);
|
|
|
+ },
|
|
|
+ onTapOutside: onTapOutside ??
|
|
|
+ (e) async {
|
|
|
+ if (route != Get.currentRoute) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ focusNode.unfocus();
|
|
|
+ if (Storage.platform == Platform.Android) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var fiscontrolPositionInfo = FISControlPositionInfo(
|
|
|
+ isShowSoftwareKeyBoard: false,
|
|
|
+ screenHeight: 0,
|
|
|
+ screenWidth: 0,
|
|
|
+ positionX: 0,
|
|
|
+ positionY: 0);
|
|
|
+ await operateSoftKeyBoard(fiscontrolPositionInfo);
|
|
|
+ },
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|