Skip to content

Commit

Permalink
修复了多个自定义键盘无法切换的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin authored and Kevin committed Aug 4, 2019
1 parent bbc3d00 commit b28fad3
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 121 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.2.1]
* TODO: 修复了多个自定义键盘无法切换的问题

## [0.2.0]
* TODO: 优化了WeuiToast的效果,添加了WeuiToastConfig,可以全局配置默认设置
* TODO: 添加了Keyboard对android 返回按钮的监听
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Usage Add this to your package's pubspec.yaml file:
Flutter >=1.7
``` yaml
dependencies:
cool_ui: "^0.2.0"
cool_ui: "^0.2.1"
```
Flutter < 1.7
Expand Down
90 changes: 90 additions & 0 deletions example/lib/keyboards/test_keyboard.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

import 'package:cool_ui/cool_ui.dart';
import 'package:flutter/material.dart';

class TestKeyboard extends StatelessWidget{
static const CKTextInputType inputType = const CKTextInputType(name:'CKTestKeyboard');
static double getHeight(BuildContext ctx){
MediaQueryData mediaQuery = MediaQuery.of(ctx);
return mediaQuery.size.width / 3 / 2 * 4;
}
final KeyboardController controller ;
const TestKeyboard({this.controller});

static register(){
CoolKeyboard.addKeyboard(TestKeyboard.inputType,KeyboardConfig(builder: (context,controller){
return TestKeyboard(controller: controller);
},getHeight: TestKeyboard.getHeight));
}


@override
Widget build(BuildContext context) {
MediaQueryData mediaQuery = MediaQuery.of(context);
return Material(
child: DefaultTextStyle(style: TextStyle(fontWeight: FontWeight.w500,color: Colors.black,fontSize: 23.0), child: Container(
height:getHeight(context),
width: mediaQuery.size.width,
decoration: BoxDecoration(
color: Color(0xffafafaf),
),
child: GridView.count(
childAspectRatio: 2/1,
mainAxisSpacing:0.5,
crossAxisSpacing:0.5,
padding: EdgeInsets.all(0.0),
crossAxisCount: 3,
children: <Widget>[
buildButton('A'),
buildButton('B'),
buildButton('C'),
buildButton('D'),
buildButton('E'),
buildButton('F'),
buildButton('G'),
buildButton('H'),
buildButton('J'),
Container(
color: Color(0xFFd3d6dd),
child: GestureDetector(
behavior: HitTestBehavior.translucent,
child: Center(child: Icon(Icons.expand_more),),
onTap: (){
controller.doneAction();
},
),
),
buildButton('0'),
Container(
color: Color(0xFFd3d6dd),
child: GestureDetector(
behavior: HitTestBehavior.translucent,
child: Center(child: Text('X'),),
onTap: (){
controller.deleteOne();
},
),
),
]),
)),
);
}

Widget buildButton(String title,{String value}){
if(value == null){
value = title;
}
return Container(
color: Colors.white,
child: GestureDetector(
behavior: HitTestBehavior.translucent,
child: Center(child: Text(title),),
onTap: (){
controller.addText(value);
},
),
);
}
}


3 changes: 3 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import 'package:cool_ui_example/pages/weui_toast_demo.dart';
import 'package:cool_ui/cool_ui.dart';
import 'package:flutter/material.dart';

import 'keyboards/test_keyboard.dart';

void main(){
NumberKeyboard.register();
TestKeyboard.register();
runApp(MyApp());
}

Expand Down
7 changes: 6 additions & 1 deletion example/lib/pages/custom_keyboard.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cool_ui_example/keyboards/test_keyboard.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cool_ui/cool_ui.dart';
Expand Down Expand Up @@ -28,14 +29,18 @@ class CustomKeyboardDemoState extends State<CustomKeyboardDemo>{
body: ListView(
children: <Widget>[
TextField(
keyboardType: NumberKeyboard.inputType,
keyboardType: TextInputType.text,
),
Container(
height: 300.0,
),
TextField(
decoration: InputDecoration(labelText: '演示键盘弹出后滚动'),
keyboardType: NumberKeyboard.inputType,
),
TextField(
decoration: InputDecoration(labelText: '多个键盘演示'),
keyboardType: TestKeyboard.inputType,
)
],
)
Expand Down
Loading

0 comments on commit b28fad3

Please sign in to comment.