Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cool_ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
cool_ui
Commits
bbc3d000
提交
bbc3d000
authored
5 年前
作者:
Kevin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化了WeuiToast的效果,添加了WeuiToastConfig,可以全局配置默认设置
添加了Keyboard对android 返回按钮的监听
上级
1de6edba
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
132 行增加
和
41 行删除
+132
-41
CHANGELOG.md
CHANGELOG.md
+4
-0
README.md
README.md
+1
-1
weui_toast.md
documents/weui_toast.md
+81
-21
main.dart
example/lib/main.dart
+7
-3
custom_keyboard.dart
example/lib/pages/custom_keyboard.dart
+1
-1
weui_toast_demo.dart
example/lib/pages/weui_toast_demo.dart
+2
-2
cool_ui.dart
lib/cool_ui.dart
+1
-0
weui_toast.dart
lib/dialogs/weui_toast.dart
+0
-0
keyboard_manager.dart
lib/keyboards/keyboard_manager.dart
+9
-3
pubspec.lock
pubspec.lock
+24
-9
pubspec.yaml
pubspec.yaml
+2
-1
没有找到文件。
CHANGELOG.md
浏览文件 @
bbc3d000
## [0.2.0]
*
TODO: 优化了WeuiToast的效果,添加了WeuiToastConfig,可以全局配置默认设置
*
TODO: 添加了Keyboard对android 返回按钮的监听
## [0.1.16]
*
Updated SDK constraint to support new error message formats
*
Updated error message formats
...
...
This diff is collapsed.
Click to expand it.
README.md
浏览文件 @
bbc3d000
...
...
@@ -9,7 +9,7 @@ Usage Add this to your package's pubspec.yaml file:
Flutter >=1.7
```
yaml
dependencies
:
cool_ui
:
"
^0.
1.16
"
cool_ui
:
"
^0.
2.0
"
```
Flutter < 1.7
...
...
This diff is collapsed.
Click to expand it.
documents/weui_toast.md
浏览文件 @
bbc3d000
...
...
@@ -6,16 +6,18 @@ VoidCallback showWeuiToast({
@required
BuildContext
context
,
@required
Widget
message
,
@required
Widget
icon
,
Alignment
alignment
=
const
Alignment
(
0.0
,-
0.2
),
RouteTransitionsBuilder
transitionBuilder
})
bool
stopEvent
=
false
,
Alignment
alignment
,
bool
backButtonClose
})
```
| Param | Type | Default | Description |
| --- | --- | --- | --- |
|
[
context
]
|
<code>
BuildContext
<Widget></code>
| | 上下文 |
|
[
message
]
|
<code>
Widget
<Widget></code>
| | 提示消息 |
|
[
alignment
]
|
<code>
Alignment
<Widget></code>
| 默认是居中偏上 | Toast的位置 |
|
[
icon
]
|
<code>
Widget
<Widget></code>
| | 图标 |
|
[
transitionBuilder
]
|
<code>
RouteTransitionsBuilder
<Widget></code>
| | 自定义过度动画 |
|
[
context
]
|
<code>
BuildContext
</code>
| | 上下文 |
|
[
message
]
|
<code>
Widget
</code>
| | 提示消息 |
|
[
icon
]
|
<code>
Widget
</code>
| | 图标 |
|
[
stopEvent
]
|
<code>
bool
</code>
| false | 阻止父页面事件触发 |
|
[
alignment
]
|
<code>
Alignment
</code>
| 默认是居中偏上 | Toast的位置 |
|
[
backButtonClose
]
|
<code>
bool
</code>
| | 安卓返回按钮是否关闭Toast |
返回参数:VoidCallback,用于关闭Toast
...
...
@@ -27,19 +29,21 @@ VoidCallback showWeuiToast({
```
dart
Future
showWeuiSuccessToast
(
{
@required
BuildContext
context
,
@required
Widget
message
=
const
Text
(
"成功"
),
Alignment
alignment
=
const
Alignment
(
0.0
,-
0.2
),
RouteTransitionsBuilder
transitionBuilder
,
Duration
closeDuration
=
const
Duration
(
seconds:
3
)
Widget
message
,
bool
stopEvent
,
bool
backButtonClose
,
Alignment
alignment
,
Duration
closeDuration
})
```
| Param | Type | Default | Description |
| --- | --- | --- | --- |
|
[
context
]
|
<code>
BuildContext
<Widget></code>
| | 上下文 |
|
[
transitionBuilder
]
|
<code>
RouteTransitionsBuilder
<Widget></code>
| | 自定义过度动画 |
|
[
alignment
]
|
<code>
Alignment
<Widget></code>
| 默认是居中偏上 | Toast的位置 |
|
[
message
]
|
<code>
Widget
<Widget></code>
| 成功| 提示消息 |
|
[
closeDuration
]
|
<code>
Duration
<Widget></code>
| 3s | 关闭时间 |
|
[
context
]
|
<code>
BuildContext
</code>
| | 上下文 |
|
[
alignment
]
|
<code>
Alignment
</code>
| 默认是居中偏上 | Toast的位置 |
|
[
message
]
|
<code>
Widget
</code>
| 成功| 提示消息 |
|
[
stopEvent
]
|
<code>
bool
</code>
| false | 阻止父页面事件触发 |
|
[
closeDuration
]
|
<code>
Duration
</code>
| 3s | 关闭时间 |
|
[
backButtonClose
]
|
<code>
bool
</code>
| true | 安卓返回按钮是否关闭Toast |
返回参数:Future dart 异步操作,代表Toast已关闭
...
...
@@ -49,16 +53,72 @@ Future showWeuiSuccessToast({
```
dart
VoidCallback
showWeuiToast
(
{
@required
BuildContext
context
,
@required
Widget
message
,
Alignment
alignment
=
const
Alignment
(
0.0
,-
0.2
),
RouteTransitionsBuilder
transitionBuilder
Widget
message
,
stopEvent
=
true
,
bool
backButtonClose
,
Alignment
alignment
})
```
| Param | Type | Default | Description |
| --- | --- | --- | --- |
|
[
context
]
|
<code>
BuildContext
<Widget></code>
| | 上下文 |
|
[
message
]
|
<code>
Widget
<Widget></code>
| | 提示消息 |
|
[
alignment
]
|
<code>
Alignment
<Widget></code>
| 默认是居中偏上 | Toast的位置 |
|
[
transitionBuilder
]
|
<code>
RouteTransitionsBuilder
<Widget></code>
| | 自定义过度动画 |
|
[
stopEvent
]
|
<code>
bool
</code>
| true | 阻止父页面事件触发 |
|
[
backButtonClose
]
|
<code>
bool
</code>
| false | 安卓返回按钮是否关闭Toast |
|
[
alignment
]
|
<code>
Alignment
</code>
| 默认是居中偏上 | Toast的位置 |
返回参数:VoidCallback,用于关闭Toast
## WeuiToastConfigData
设置默认Toast效果
```
dart
const
WeuiToastConfigData
(
{
this
.
successText
=
'成功'
,
this
.
successDuration
=
const
Duration
(
seconds:
3
),
this
.
successBackButtonClose
=
true
,
this
.
loadingText
=
'加载中'
,
this
.
loadingBackButtonClose
=
false
,
this
.
toastAlignment
=
const
Alignment
(
0.0
,
-
0.2
)});
```
| Param | Type | Default | Description |
| --- | --- | --- | --- |
|
[
successText
]
|
<code>
String
</code>
| 成功 | 成功提示消息 |
|
[
successDuration
]
|
<code>
Duration
</code>
|3s | 成功Toast关闭事件 |
|
[
successBackButtonClose
]
|
<code>
bool
</code>
| true | 成功安卓返回按钮是否关闭Toast |
|
[
loadingText
]
|
<code>
String
</code>
| 加载中 | 加载中提示消息 |
|
[
loadingBackButtonClose
]
|
<code>
false
</code>
| true | 加载中安卓返回按钮是否关闭Toast |
|
[
alignment
]
|
<code>
Alignment
</code>
| 默认是居中偏上 | Toast的位置 |
## WeuiToastConfig
设置默认Toast效果 配合WeuiToastConfigData使用
```
dart
WeuiToastConfig
({
Widget
child
,
this
.
data
})
```
| Param | Type | Default | Description |
| --- | --- | --- | --- |
|
[
child
]
|
<code>
Widget
</code>
| | Widget |
|
[
data
]
|
<code>
WeuiToastConfigData
</code>
| | Toast配置数据 |
在Widget中添加了WeuiToastConfig,然后子Widget的context就可以应用到效果了
例如:
```
dart
main
.
dart
class
MyApp
extends
StatelessWidget
{
// This widget is the root of your application.
@override
Widget
build
(
BuildContext
context
)
{
return
WeuiToastConfig
(
// --关键代码
data:
WeuiToastConfigData
(
// --关键代码
successText:
'测试ConfigData'
// --关键代码
),
// --关键代码
child:
MaterialApp
(
title:
'Flutter Demo'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
),
home:
MyHomePage
(
title:
'Flutter Demo Home Page'
)
));
}
}
```
代表全局默认配置
This diff is collapsed.
Click to expand it.
example/lib/main.dart
浏览文件 @
bbc3d000
...
...
@@ -16,7 +16,11 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
WeuiToastConfig
(
data:
WeuiToastConfigData
(
successText:
'测试ConfigData'
),
child:
MaterialApp
(
title:
'Flutter Demo'
,
theme:
ThemeData
(
// This is the theme of your application.
...
...
@@ -30,7 +34,7 @@ class MyApp extends StatelessWidget {
primarySwatch:
Colors
.
blue
),
home:
MyHomePage
(
title:
'Flutter Demo Home Page'
)
);
)
)
;
}
}
...
...
@@ -74,7 +78,7 @@ class _MyHomePageState extends State<MyHomePage> {
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
...
...
This diff is collapsed.
Click to expand it.
example/lib/pages/custom_keyboard.dart
浏览文件 @
bbc3d000
...
...
@@ -28,7 +28,7 @@ class CustomKeyboardDemoState extends State<CustomKeyboardDemo>{
body:
ListView
(
children:
<
Widget
>[
TextField
(
keyboardType:
TextInputType
.
text
,
keyboardType:
NumberKeyboard
.
inputType
,
),
Container
(
height:
300.0
,
...
...
This diff is collapsed.
Click to expand it.
example/lib/pages/weui_toast_demo.dart
浏览文件 @
bbc3d000
...
...
@@ -30,13 +30,13 @@ class WeuiToastDemoState extends State<WeuiToastDemo>{
color:
Colors
.
blue
[
400
],
child:
Text
(
"成功"
,
style:
TextStyle
(
color:
Colors
.
white
),),
onPressed:
()=>
showWeuiSuccessToast
(
context:
context
,
message:
Text
(
"成功啦!"
)
),
onPressed:
()=>
showWeuiSuccessToast
(
context:
context
),
),
RaisedButton
(
color:
Colors
.
blue
[
400
],
child:
Text
(
"加载中"
,
style:
TextStyle
(
color:
Colors
.
white
),),
onPressed:
(){
var
hide
=
showWeuiLoadingToast
(
context:
context
,
message:
Text
(
"加载中"
)
);
var
hide
=
showWeuiLoadingToast
(
context:
context
);
Future
.
delayed
(
Duration
(
seconds:
5
),(){
hide
();
});
...
...
This diff is collapsed.
Click to expand it.
lib/cool_ui.dart
浏览文件 @
bbc3d000
...
...
@@ -4,6 +4,7 @@ import 'dart:async';
import
'dart:ui'
as
ui
;
import
'dart:core'
;
import
'package:back_button_interceptor/back_button_interceptor.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
...
...
This diff is collapsed.
Click to expand it.
lib/dialogs/weui_toast.dart
浏览文件 @
bbc3d000
差异被折叠。
点击展开。
lib/keyboards/keyboard_manager.dart
浏览文件 @
bbc3d000
...
...
@@ -27,7 +27,7 @@ class CoolKeyboard {
if
(
isInterceptor
)
return
;
isInterceptor
=
true
;
BinaryMessages
.
setMockMessageHandler
(
"flutter/textinput"
,
(
ByteData
data
)
async
{
defaultBinaryMessenger
.
setMockMessageHandler
(
"flutter/textinput"
,
(
ByteData
data
)
async
{
var
methodCall
=
_codec
.
decodeMethodCall
(
data
);
switch
(
methodCall
.
method
){
case
'TextInput.show'
:
...
...
@@ -69,7 +69,7 @@ class CoolKeyboard {
var
callbackMethodCall
=
MethodCall
(
"TextInputClient.updateEditingState"
,[
_keyboardController
.
client
.
connectionId
,
_keyboardController
.
value
.
toJSON
()]);
BinaryMessages
.
handlePlatformMessage
(
"flutter/textinput"
,
_codec
.
encodeMethodCall
(
callbackMethodCall
),
(
data
){
defaultBinaryMessenger
.
handlePlatformMessage
(
"flutter/textinput"
,
_codec
.
encodeMethodCall
(
callbackMethodCall
),
(
data
){
});
});
...
...
@@ -135,9 +135,15 @@ class CoolKeyboard {
});
Overlay
.
of
(
_context
).
insert
(
_keyboardEntry
);
BackButtonInterceptor
.
add
((
_
){
CoolKeyboard
.
sendPerformAction
(
TextInputAction
.
done
);
return
true
;
},
zIndex:
1
,
name:
'CustomKeyboard'
);
}
static
hideKeyboard
({
bool
animation
=
true
}){
BackButtonInterceptor
.
removeByName
(
'CustomKeyboard'
);
if
(
_keyboardEntry
!=
null
&&
_pageKey
!=
null
)
{
_keyboardHeight
=
null
;
_pageKey
.
currentState
.
animationController
.
addStatusListener
((
AnimationStatus
status
)
{
...
...
@@ -178,7 +184,7 @@ class CoolKeyboard {
_keyboardController
.
client
.
connectionId
,
action
.
toString
()
]);
BinaryMessages
.
handlePlatformMessage
(
defaultBinaryMessenger
.
handlePlatformMessage
(
"flutter/textinput"
,
_codec
.
encodeMethodCall
(
callbackMethodCall
),
(
data
)
{});
}
...
...
This diff is collapsed.
Click to expand it.
pubspec.lock
浏览文件 @
bbc3d000
# Generated by pub
# See https://
www.dartlang.org
/tools/pub/glossary#lockfile
# See https://
dart.dev
/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
...
...
@@ -7,7 +7,14 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
version: "2.2.0"
back_button_interceptor:
dependency: "direct main"
description:
name: back_button_interceptor
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.6"
boolean_selector:
dependency: transitive
description:
...
...
@@ -45,7 +52,7 @@ packages:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.
3+1
"
version: "0.12.
5
"
meta:
dependency: transitive
description:
...
...
@@ -60,13 +67,20 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.
1
"
version: "2.0.
3
"
sky_engine:
dependency: transitive
description: flutter
...
...
@@ -78,7 +92,7 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.
4.1
"
version: "1.
5.5
"
stack_trace:
dependency: transitive
description:
...
...
@@ -92,7 +106,7 @@ packages:
name: stream_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "
1.6.8
"
version: "
2.0.0
"
string_scanner:
dependency: transitive
description:
...
...
@@ -106,14 +120,14 @@ packages:
name: term_glyph
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.
0.1
"
version: "1.
1.0
"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.
1
"
version: "0.2.
5
"
typed_data:
dependency: transitive
description:
...
...
@@ -129,4 +143,5 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.0.0 <3.0.0"
dart: ">=2.2.2 <3.0.0"
flutter: ">=1.7.0 <2.0.0"
This diff is collapsed.
Click to expand it.
pubspec.yaml
浏览文件 @
bbc3d000
name
:
cool_ui
description
:
Some practical Widget for flutter,Popover,Weui,Custom Keyboard
version
:
0.
1.16
version
:
0.
2.0
author
:
Kevin <liangkaikevin@gmail.com>
homepage
:
https://github.com/Im-Kevin/cool_ui
...
...
@@ -9,6 +9,7 @@ environment:
flutter
:
"
>=1.7.0
<2.0.0"
dependencies
:
back_button_interceptor
:
^4.0.6
flutter
:
sdk
:
flutter
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论