Browse Source

[fix]键盘引导页,未选择为默认键盘时,禁止输入框与用户交互

hezihao 7 tháng trước cách đây
mục cha
commit
ea00f0f805
1 tập tin đã thay đổi với 49 bổ sung44 xóa
  1. 49 44
      lib/module/keyboard_guide/keyboard_guide_page.dart

+ 49 - 44
lib/module/keyboard_guide/keyboard_guide_page.dart

@@ -191,53 +191,58 @@ class KeyboardGuidePage extends BasePage<KeyboardGuidePageController> {
                       color: ColorName.white,
                       borderRadius: BorderRadius.circular(10.0),
                     ),
-                    child: TextField(
-                      autofocus: false,
-                      style: TextStyle(
-                        color: ColorName.black80,
-                        fontSize: 14.0,
-                        fontWeight: FontWeight.w500,
-                      ),
-                      // 设置光标颜色
-                      cursorColor: ColorName.inputCursor,
-                      // 光标宽度
-                      cursorWidth: 2.0,
-                      // 光标圆角
-                      cursorRadius: Radius.circular(2),
-                      // 设置按钮显示为发送
-                      textInputAction: TextInputAction.send,
-                      // 用户点击软键盘的发送按钮时,触发回调
-                      onSubmitted: (value) {
-                        var msg = controller.editingController.text;
-                        controller.sendMsg(msg);
-                        // 保持输入框焦点获取,不降下键盘
-                        controller.requestInputFocus();
-                      },
-                      // 输入框焦点
-                      focusNode: controller.inputFocusNode,
-                      // 点击外部区域,关闭软键盘
-                      // onTapUpOutside: (event) {
-                      //   controller.clearInputFocus();
-                      // },
-                      // 输入框控制器
-                      controller: controller.editingController,
-                      decoration: InputDecoration(
-                        // 提示文字
-                        hintText: StringName.keyboardGuideInputHint,
-                        hintStyle: TextStyle(
+                    child: Obx(() {
+                      return TextField(
+                        // 是否可用,选择了默认键盘时,才可用
+                        enabled: controller.isDefaultKeyboard.value,
+                        // 是否自动获取焦点
+                        autofocus: false,
+                        style: TextStyle(
+                          color: ColorName.black80,
                           fontSize: 14.0,
-                          fontWeight: FontWeight.w400,
-                          color: ColorName.black40,
+                          fontWeight: FontWeight.w500,
                         ),
-                        // 去掉默认的边框
-                        border: InputBorder.none,
-                        // 设置输入框的内边距
-                        contentPadding: EdgeInsets.symmetric(
-                          horizontal: 9.0,
-                          vertical: 13.0,
+                        // 设置光标颜色
+                        cursorColor: ColorName.inputCursor,
+                        // 光标宽度
+                        cursorWidth: 2.0,
+                        // 光标圆角
+                        cursorRadius: Radius.circular(2),
+                        // 设置按钮显示为发送
+                        textInputAction: TextInputAction.send,
+                        // 用户点击软键盘的发送按钮时,触发回调
+                        onSubmitted: (value) {
+                          var msg = controller.editingController.text;
+                          controller.sendMsg(msg);
+                          // 保持输入框焦点获取,不降下键盘
+                          controller.requestInputFocus();
+                        },
+                        // 输入框焦点
+                        focusNode: controller.inputFocusNode,
+                        // 点击外部区域,关闭软键盘
+                        // onTapUpOutside: (event) {
+                        //   controller.clearInputFocus();
+                        // },
+                        // 输入框控制器
+                        controller: controller.editingController,
+                        decoration: InputDecoration(
+                          // 提示文字
+                          hintText: StringName.keyboardGuideInputHint,
+                          hintStyle: TextStyle(
+                            fontSize: 14.0,
+                            fontWeight: FontWeight.w400,
+                            color: ColorName.black40,
+                          ),
+                          // 去掉默认的边框
+                          border: InputBorder.none,
+                          // 设置输入框的内边距
+                          contentPadding: EdgeInsets.symmetric(
+                            horizontal: 9.0,
+                            vertical: 13.0,
+                          ),
                         ),
-                      ),
-                    ),
+                      );
+                    }),
                   ),
                 ),
               ],