Skip to content

Commit

Permalink
v0.0.4发布
Browse files Browse the repository at this point in the history
  • Loading branch information
hxlovexc committed Apr 23, 2019
1 parent b168b77 commit d96c1df
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 35 deletions.
2 changes: 1 addition & 1 deletion flutter-weui-example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppState extends State {
warnColorDisabled: Color(0xfffaa7a3)
),
config: WeConfig(
toastInfoDuration: 1000
toastSuccessDuration: 5000
),
child: MaterialApp(
debugShowCheckedModeBanner: false,
Expand Down
18 changes: 16 additions & 2 deletions weui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.0.1] - TODO: Add release date.
## 0.0.4

* TODO: Describe initial release.
### 修改
- WeInput添加height参数, 设置高度
- WeInput添加maxLength参数, 限制最大输入数量
- WeInput添加focusNode参数, 原生FocusNode
- WeForm添加spacing参数, 设置表单内做边空白间距
- WeForm添加boxBorder参数, 控制表单外层是否显示边框
- WeToast.fail方法添加onClose回掉
- WeToast.success方法添加onClose回掉
### 新增
- 新增WeTheme类, 全局控制主题
- 新增WeCheckbox组件
- 新增WeRadio组件
### 修复
- 修复WeInput组件多行输入时无法点击键盘的换行
- 修复WeGrid组件中itemBuilder没有返回正确的index
31 changes: 28 additions & 3 deletions weui/lib/cell/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ class WeCells extends StatelessWidget {
decoration: BoxDecoration(
color: Colors.white
),
child: Column(
children: newChildren
child: _WeCellsScope(
weCells: this,
child: Column(
children: newChildren
),
)
);
}
Expand Down Expand Up @@ -98,6 +101,8 @@ class WeCell extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<Widget> children = [];
final _WeCellsScope weCellsScope = _WeCellsScope.of(context);
final double _spacing = weCellsScope == null ? spacing : weCellsScope.weCells.spacing;

// label
if (label is Widget) {
Expand Down Expand Up @@ -145,7 +150,7 @@ class WeCell extends StatelessWidget {
color: Colors.black
),
child: Padding(
padding: EdgeInsets.only(left: spacing, right: spacing),
padding: EdgeInsets.only(left: _spacing, right: _spacing),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: children
Expand All @@ -167,3 +172,23 @@ class WeCell extends StatelessWidget {
);
}
}

class _WeCellsScope extends InheritedWidget {
final WeCells weCells;

_WeCellsScope({
Key key,
child,
this.weCells,
}) : super(key: key, child: child);

static _WeCellsScope of(BuildContext context) {
return context.inheritFromWidgetOfExactType(_WeCellsScope);
}

@override
bool updateShouldNotify(_WeCellsScope oldWidget) {
return true;
}
}

11 changes: 10 additions & 1 deletion weui/lib/input/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ class WeInput extends StatefulWidget {
final String defaultValue;
// 最大行数
final int maxLines;
// 限制输入数量
final int maxLength;
// 提示文字
final String hintText;
// 光标
final FocusNode focusNode;
// footer
final Widget footer;
// 是否显示清除
Expand Down Expand Up @@ -43,7 +47,9 @@ class WeInput extends StatefulWidget {
this.height = 48,
this.defaultValue = '',
this.maxLines = 1,
this.maxLength,
this.hintText,
this.focusNode,
this.footer,
this.clearable = false,
this.textAlign = TextAlign.start,
Expand Down Expand Up @@ -157,11 +163,14 @@ class WeInputState extends State<WeInput> {
obscureText: widget.obscureText,
style: widget.style,
controller: controller,
focusNode: widget.focusNode,
onChanged: _onChange,
maxLines: widget.maxLines,
maxLength: widget.maxLength,
decoration: InputDecoration(
border: InputBorder.none,
hintText: widget.hintText
hintText: widget.hintText,
counterText: ''
)
)
)
Expand Down
34 changes: 22 additions & 12 deletions weui/lib/toast/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ typedef _info = Function(dynamic message, { int duration, WeToastInfoAlign align
// loading
typedef _loading = Function({ dynamic message, int duration, bool mask, Widget icon });
// success
typedef _success = Function({ dynamic message, int duration, bool mask, Widget icon });
typedef _success = Function({ dynamic message, int duration, bool mask, Widget icon, Function onClose });
// fail
typedef _fail = Function({ dynamic message, int duration, bool mask, Widget icon });
typedef _fail = Function({ dynamic message, int duration, bool mask, Widget icon, Function onClose });
// toast
typedef _toast = Function({ dynamic message, int duration, bool mask, Widget icon });
typedef _toast = Function({ dynamic message, int duration, bool mask, Widget icon, Function onClose });
// loading close
typedef _close = Function();

Expand Down Expand Up @@ -78,51 +78,61 @@ class WeToast {

// 成功
static _success success(BuildContext context) {
return ({ message, duration, mask = true, icon = _successIcon }) {
return ({ message, duration, mask = true, icon = _successIcon, onClose }) {
final int toastSuccessDuration = WeUi.getConfig(context).toastSuccessDuration;
WeToast.toast(context)(
icon: icon,
mask: mask,
message: message,
duration: duration == null ? toastSuccessDuration : duration
duration: duration == null ? toastSuccessDuration : duration,
onClose: onClose
);
};
}

// 失败
static _fail fail(BuildContext context) {
return ({ message, duration, mask = true, icon = _failIcon }) {
return ({ message, duration, mask = true, icon = _failIcon, onClose }) {
final int notifySuccessDuration = WeUi.getConfig(context).notifySuccessDuration;
print(notifySuccessDuration);
WeToast.toast(context)(
icon: icon,
mask: mask,
message: message,
duration: duration == null ? notifySuccessDuration : duration
duration: duration == null ? notifySuccessDuration : duration,
onClose: onClose
);
};
}

// 提示
static _toast toast(BuildContext context) {
return ({ message, duration, mask = true, icon }) {
return ({ message, duration, mask = true, icon, onClose }) {
// 转换
final Widget messageWidget = toTextWidget(message, 'message');
final remove = createOverlayEntry(
Function remove = createOverlayEntry(
context: context,
child: ToastWidget(
message: messageWidget,
mask: mask,
icon: icon
icon: icon,
)
);

void close() {
remove();
if (remove != null) {
remove();
remove = null;
}
}

// 自动关闭
if (duration != null) {
Future.delayed(Duration(milliseconds: duration), close);
Future.delayed(Duration(milliseconds: duration), () {
close();
// 关闭回调
if (onClose is Function) onClose();
});
}

return close;
Expand Down
32 changes: 17 additions & 15 deletions weui/lib/toast/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ToastWidget extends StatelessWidget {
this.message,
this.icon,
this.mask,
this.width = 115.0
this.width = 130.0
});

@override
Expand All @@ -23,11 +23,15 @@ class ToastWidget extends StatelessWidget {
children.add(icon);
}

// // 判断是否有文字
// 判断是否有文字
if (message != null) {
children.add(
Padding(
padding: EdgeInsets.only(top: 4.0),
padding: EdgeInsets.only(
top: 4.0,
right: 5.0,
left: 5.0,
),
child: DefaultTextStyle(
style: TextStyle(
fontSize: 16.0,
Expand All @@ -47,19 +51,17 @@ class ToastWidget extends StatelessWidget {
),
child: Padding(
padding: EdgeInsets.only(top: _padding, bottom: _padding),
child: SizedBox(
width: width,
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: width - (_padding * 2.2)
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: children
)
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: width,
minHeight: width - (_padding * 2.2)
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: children
)
)
),
)
);

Expand Down
2 changes: 1 addition & 1 deletion weui/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: weui
description: flutter版的weui
version: 0.0.3
version: 0.0.4
author: allan <[email protected]>
homepage: https://github.com/allan-hx/flutter-weui

Expand Down

0 comments on commit d96c1df

Please sign in to comment.