Im-Kevin / cool_ui

用flutter实现一些我认为好看的UI控件,有Popover,仿Weui的Toast,自定义键盘
Apache License 2.0
460 stars 74 forks source link

同一个页面怎么支持多个自定义键盘? #22

Closed ko1o closed 4 years ago

ko1o commented 5 years ago

比如聊天页面有多个自定义键盘,如何支持呢?目前我注册多个键盘 ,并自定义键盘就不生效,麻烦作者有时间看下哈~

Im-Kevin commented 5 years ago

能贴代码和例子看看吗

ko1o commented 5 years ago

1、Register

  @override
  void initState() {
    super.initState();

    EmojiKeyboard.register();
    MoreKeyboard.register();
}

2、Iint

   // 初始化自定义键盘
    CoolKeyboard.init(cxt);

3、Usage

CupertinoTextField(
    controller: _textEditingController,
    padding: EdgeInsets.only(
        left: 6, top: 2, bottom: 2, right: 6),
    focusNode: _textFieldFocunNode,
    placeholder: "输入新消息",
    maxLines: 10,
    textInputAction: TextInputAction.send,
    keyboardType:
        _keyboardType == ChatKeyboardType.emoji
            ? EmojiKeyboard.inputType
            : (_keyboardType ==
                    ChatKeyboardType.more
                ? MoreKeyboard.inputType
                : TextInputType.text),
    onSubmitted: (value) {
        _textEditingController.clear();
        _textFieldFocunNode.unfocus();
    },
    style: TextStyle(
        fontSize: 14,
        fontWeight: FontWeight.w400,
        color: Colors.black),
    )
),
Im-Kevin commented 5 years ago

是怎么不生效,是不会切换,还是说所有的都没有弹出

ko1o commented 5 years ago

是会被覆盖掉,后面注册的自定义键盘覆盖了前面自定义注册的键盘。

Im-Kevin commented 5 years ago

是不是只有最后注册的键盘可以用

ko1o commented 5 years ago

麻烦提供个邮箱 我写了个Demo 私发下 @Im-Kevin

Im-Kevin commented 5 years ago

468561207@qq.com 我的代码应该是没有这个Bug的,是不是你两个键盘的inputType填写的是一样的

Im-Kevin commented 5 years ago

问题已修复