提交 6f8911ed authored 作者: Kevin's avatar Kevin

升级0.5.5

上级 6c5b50a9
## [0.5.5]
* TODO: Popover添加了阴影效果
* TODO: Popover 添加了方向
## [0.5.4]
* TODO: Fix Bug Issues:47
......
......@@ -8,9 +8,11 @@ CupertinoPopoverButton({
this.child,
this.popoverBuild,
this.popoverColor=Colors.white,
this.popoverBoxShadow,
@required this.popoverWidth,
@required this.popoverHeight,
BoxConstraints popoverConstraints,
this.direction = CupertinoPopoverDirection.bottom,
this.onTap,
this.transitionDuration=const Duration(milliseconds: 200),
this.barrierColor = Colors.black54,
......@@ -25,8 +27,10 @@ CupertinoPopoverButton({
| [popoverWidth] | <code>double</code> | | 弹出框的宽度 |
| [popoverHeight] | <code>double</code> | | 弹出框的高度 |
| [popoverConstraints] | <code>BoxConstraints</code> | maxHeight:123.0 maxWidth:150.0 | 弹出框的最大最小高宽|
| [direction] | <code>CupertinoPopoverDirection</code> | CupertinoPopoverDirection.bottom | 方向|
| [onTap] | <code>BoolCallback</code> | | 按钮点击事件,返回true取消默认反应(不打开Popover) |
| [popoverColor] | <code>Color</code> | 白色 | 弹出框的背景颜色 |
| [popoverBoxShadow] | <code>BoxShadow</code> | | 弹出框的阴影 |
| [barrierColor] | <code>Color</code> | Colors.black54 | 遮罩层的颜色,目前不允许设置透明,如需要透明则使用Color.fromRGBO(0, 0, 0, 0.01)可达到类似效果|
| [transitionDuration] | <code>Duration</code> | 0.2s | 过度动画时间 |
| [radius] | <code>double</code> | 8.0 | 弹出框的圆角弧度 |
......@@ -77,6 +81,8 @@ const CupertinoPopoverMenuItem({
this.leading,
this.child,
this.onTap,
this.background = Colors.white,
this.activeBackground = const Color(0xFFd9d9d9),
this.isTapClosePopover=true
});
```
......@@ -85,6 +91,8 @@ const CupertinoPopoverMenuItem({
| [leading] | <code>Widget<Widget></code> | 菜单左边,一般放图标 |
| [child] | <code>Widget<Widget></code> | 菜单内容 |
| [onTap] | <code>BoolCallback</code> | | 按钮点击事件,返回true取消默认反应(不关闭Popover) |
| [activeBackground] | <code>Color</code> | Color(0xFFd9d9d9) | 按下时背景色 |
| [background] | <code>Color</code> | Colors.white | 默认背景色 |
| [isTapClosePopover] | <code>bool<Widget></code> | 是否点击关闭 |
#### 案例核心代码
......
......@@ -60,6 +60,10 @@ class PopoverDemoState extends State<PopoverDemo>{
return Padding(
padding: EdgeInsets.all(20.0),
child:CupertinoPopoverButton(
popoverBoxShadow: [
BoxShadow(color: Colors.black12,blurRadius: 5.0)
],
barrierColor: Color(0x01FFFFFF),
child: Container(
width: 80.0,
height: 40.0,
......
part of cool_ui;
class CupertinoPopoverMenuList extends StatelessWidget{
class CupertinoPopoverMenuList extends StatelessWidget {
final List<Widget> children;
const CupertinoPopoverMenuList({this.children});
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: children.length * 2 - 1,
shrinkWrap: true,
itemBuilder: (context,int i){
if(i.isOdd){
// 在每一列之前,添加一个1像素高的分隔线widget
return const Divider(height: 1.0,);
}
final int index=i ~/2;
return children[index];
},
padding: EdgeInsets.all(0.0),
itemCount: children.length * 2 - 1,
shrinkWrap: true,
itemBuilder: (context, int i) {
if (i.isOdd) {
// 在每一列之前,添加一个1像素高的分隔线widget
return const Divider(
height: 1.0,
);
}
final int index = i ~/ 2;
return children[index];
},
padding: EdgeInsets.all(0.0),
);
}
}
class CupertinoPopoverMenuItem extends StatefulWidget{
class CupertinoPopoverMenuItem extends StatefulWidget {
final Widget leading;
final Widget child;
final BoolCallback onTap;
final bool isTapClosePopover;
final Color activeBackground;
final Color background;
const CupertinoPopoverMenuItem({
this.leading,
this.child,
this.onTap,
this.isTapClosePopover=true
});
const CupertinoPopoverMenuItem(
{this.leading,
this.child,
this.onTap,
this.background = Colors.white,
this.activeBackground = const Color(0xFFd9d9d9),
this.isTapClosePopover = true});
@override
State<StatefulWidget> createState() =>CupertinoPopoverMenuItemState();
State<StatefulWidget> createState() => CupertinoPopoverMenuItemState();
}
class CupertinoPopoverMenuItemState extends State<CupertinoPopoverMenuItem>{
class CupertinoPopoverMenuItemState extends State<CupertinoPopoverMenuItem> {
bool isDown = false;
@override
Widget build(BuildContext context) {
List<Widget> widgets = [];
if(widget.leading != null){
if (widget.leading != null) {
widgets.add(Container(
padding: EdgeInsets.only(left:5.0,right: 5.0),
padding: EdgeInsets.only(left: 5.0, right: 5.0),
width: 35.0,
height: 35.0,
child: IconTheme(
data:IconThemeData(color: Color(0xff007aff),size: 20.0),
child: widget.leading
),
data: IconThemeData(color: Color(0xff007aff), size: 20.0),
child: widget.leading),
));
}
widgets.add(Expanded(child: DefaultTextStyle(style: TextStyle(
color: Color(0xff007aff),
fontSize: 17.0
), child: widget.child)));
widgets.add(Expanded(
child: DefaultTextStyle(
style: TextStyle(color: Color(0xff007aff), fontSize: 17.0),
child: widget.child)));
return GestureDetector(
onTapDown: (detail){
onTapDown: (detail) {
setState(() {
isDown = true;
});
},
onTapUp: (detail){
if(isDown){
onTapUp: (detail) {
if (isDown) {
setState(() {
isDown = false;
});
if(widget.onTap != null && widget.onTap()){
if (widget.onTap != null && widget.onTap()) {
return;
}
if(widget.isTapClosePopover){
if (widget.isTapClosePopover) {
Navigator.of(context).pop();
}
}
},
onTapCancel: (){
if(isDown){
onTapCancel: () {
if (isDown) {
setState(() {
isDown = false;
});
}
},
child: Container(
color:isDown?Color(0xFFd9d9d9):Colors.white,
color: isDown ? widget.activeBackground : widget.background,
child: Padding(
padding: EdgeInsets.only(top:2.5,bottom: 2.5),
child: Row(
children: widgets
),
padding: EdgeInsets.only(top: 2.5, bottom: 2.5),
child: Row(children: widgets),
),
),
);
}
}
\ No newline at end of file
}
name: cool_ui
description: Some practical Widget for flutter,Popover,Weui,Custom Keyboard
version: 0.5.4
version: 0.5.5
author: Kevin <liangkaikevin@gmail.com>
homepage: https://github.com/Im-Kevin/cool_ui
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论