提交 7fd8f603 authored 作者: Kevin's avatar Kevin

CupertionPopoverButton添加了CupertionPopoverButton参数,用于设置最大最小宽度,取消必填的高宽

上级 afcfaa1a
## [0.1.5] - TODO:添加了popoverConstraints参数
* TODO: CupertionPopoverButton添加了CupertionPopoverButton参数,用于设置最大最小宽度,取消必填的高宽
## [0.1.4] - TODO:修改了onTap事件 ## [0.1.4] - TODO:修改了onTap事件
* TODO: CupertionPopoverButton添加了onTap事件,返回True不打开Popover * TODO: CupertionPopoverButton添加了onTap事件,返回True不打开Popover
* TODO: CupertinoPopoverMenuItem修改了onTap事件,返回True不关闭Popover * TODO: CupertinoPopoverMenuItem修改了onTap事件,返回True不关闭Popover
......
...@@ -7,7 +7,7 @@ Usage ...@@ -7,7 +7,7 @@ Usage
Add this to your package's pubspec.yaml file: Add this to your package's pubspec.yaml file:
``` yaml ``` yaml
dependencies: dependencies:
cool_ui: "^0.1.4" cool_ui: "^0.1.5"
``` ```
# 控件 # 控件
...@@ -31,6 +31,7 @@ CupertinoPopoverButton({ ...@@ -31,6 +31,7 @@ CupertinoPopoverButton({
this.popoverColor=Colors.white, this.popoverColor=Colors.white,
@required this.popoverWidth, @required this.popoverWidth,
@required this.popoverHeight, @required this.popoverHeight,
BoxConstraints popoverConstraints,
this.onTap, this.onTap,
this.transitionDuration=const Duration(milliseconds: 200), this.transitionDuration=const Duration(milliseconds: 200),
this.radius=8.0}); this.radius=8.0});
...@@ -41,8 +42,9 @@ CupertinoPopoverButton({ ...@@ -41,8 +42,9 @@ CupertinoPopoverButton({
| --- | --- | --- | --- | | --- | --- | --- | --- |
| child | <code>Widget</code> | | 按钮的内容 | | child | <code>Widget</code> | | 按钮的内容 |
| popoverBuild | <code>WidgetBuilder</code> | | 生成弹出框的内容 | | popoverBuild | <code>WidgetBuilder</code> | | 生成弹出框的内容 |
| popoverWidth | <code>double</code> | | 弹出框的宽度 | | [popoverWidth] | <code>double</code> | | 弹出框的宽度 |
| popoverHeight | <code>double</code> | | 弹出框的高度 | | [popoverHeight] | <code>double</code> | | 弹出框的高度 |
| [popoverConstraints] | <code>BoxConstraints</code> | maxHeight:123.0 maxWidth:150.0 | 弹出框的最大最小高宽|
| [onTap] | <code>BoolCallback</code> | | 按钮点击事件,返回true取消默认反应(不打开Popover) | | [onTap] | <code>BoolCallback</code> | | 按钮点击事件,返回true取消默认反应(不打开Popover) |
| [popoverColor] | <code>Color</code> | 白色 | 弹出框的背景颜色 | | [popoverColor] | <code>Color</code> | 白色 | 弹出框的背景颜色 |
| [transitionDuration] | <code>Duration</code> | 0.2s | 过度动画时间 | | [transitionDuration] | <code>Duration</code> | 0.2s | 过度动画时间 |
...@@ -70,9 +72,7 @@ CupertinoPopoverButton( ...@@ -70,9 +72,7 @@ CupertinoPopoverButton(
height: 100.0, height: 100.0,
child: Text('左上角内容'), child: Text('左上角内容'),
) )
}, });
popoverWidth: 100.0,
popoverHeight: 100.0);
``` ```
![Image text](./images/popover_demo.gif) ![Image text](./images/popover_demo.gif)
......
...@@ -60,7 +60,6 @@ class PopoverDemoState extends State<PopoverDemo>{ ...@@ -60,7 +60,6 @@ class PopoverDemoState extends State<PopoverDemo>{
return Padding( return Padding(
padding: EdgeInsets.all(20.0), padding: EdgeInsets.all(20.0),
child:CupertinoPopoverButton( child:CupertinoPopoverButton(
child: Container( child: Container(
width: 80.0, width: 80.0,
height: 40.0, height: 40.0,
...@@ -72,6 +71,7 @@ class PopoverDemoState extends State<PopoverDemo>{ ...@@ -72,6 +71,7 @@ class PopoverDemoState extends State<PopoverDemo>{
child: Center(child:Text(btnTitle)), child: Center(child:Text(btnTitle)),
), ),
popoverBuild: (context) { popoverBuild: (context) {
// return Text("satatastas");
return CupertinoPopoverMenuList( return CupertinoPopoverMenuList(
children: <Widget>[ children: <Widget>[
CupertinoPopoverMenuItem(leading: Icon(Icons.add),child: Text("新增"),), CupertinoPopoverMenuItem(leading: Icon(Icons.add),child: Text("新增"),),
...@@ -79,9 +79,7 @@ class PopoverDemoState extends State<PopoverDemo>{ ...@@ -79,9 +79,7 @@ class PopoverDemoState extends State<PopoverDemo>{
CupertinoPopoverMenuItem(leading: Icon(Icons.delete),child: Text("删除"),) CupertinoPopoverMenuItem(leading: Icon(Icons.delete),child: Text("删除"),)
], ],
); );
}, })
popoverWidth: 150.0,
popoverHeight: 123.0)
); );
......
...@@ -8,16 +8,18 @@ class CupertinoPopoverMenuList extends StatelessWidget{ ...@@ -8,16 +8,18 @@ class CupertinoPopoverMenuList extends StatelessWidget{
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListView.builder( return ListView.builder(
itemCount: children.length * 2 - 1, itemCount: children.length * 2 - 1,
itemBuilder: (context,int i){ shrinkWrap: true,
if(i.isOdd){ itemBuilder: (context,int i){
// 在每一列之前,添加一个1像素高的分隔线widget if(i.isOdd){
return const Divider(height: 1.0,); // 在每一列之前,添加一个1像素高的分隔线widget
} return const Divider(height: 1.0,);
final int index=i ~/2; }
return children[index]; final int index=i ~/2;
}, return children[index];
padding: EdgeInsets.all(0.0), },
padding: EdgeInsets.all(0.0),
); );
} }
......
...@@ -76,13 +76,6 @@ packages: ...@@ -76,13 +76,6 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_spinkit:
dependency: "direct main"
description:
name: flutter_spinkit
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
......
name: cool_ui name: cool_ui
description: 用flutter实现一些我认为好看的UI控件,目前暂时只有Popover,Weui,不过有什么觉得好看的可以提Issue description: 用flutter实现一些我认为好看的UI控件,目前暂时只有Popover,Weui,不过有什么觉得好看的可以提Issue
version: 0.1.4 version: 0.1.5
author: Kevin <liangkaikevin@gmail.com> author: Kevin <liangkaikevin@gmail.com>
homepage: https://github.com/Im-Kevin/cool_ui homepage: https://github.com/Im-Kevin/cool_ui
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论