Yuncong Zhang
6 年前
当前提交
d0ebc7bf
共有 2 个文件被更改,包括 91 次插入 和 29 次删除
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public class ButtonBar : StatelessWidget { |
|||
|
|||
public ButtonBar( |
|||
Key key = null, |
|||
MainAxisAlignment alignment = MainAxisAlignment.end, |
|||
MainAxisSize mainAxisSize = MainAxisSize.max, |
|||
List<Widget> children = null |
|||
) : base(key : key) { |
|||
this.alignment = alignment; |
|||
this.mainAxisSize = mainAxisSize; |
|||
this.children = children ?? new List<Widget>(); |
|||
} |
|||
|
|||
public readonly MainAxisAlignment alignment; |
|||
public readonly MainAxisSize mainAxisSize; |
|||
public readonly List<Widget> children; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
double paddingUnit = buttonTheme.padding.horizontal / 4.0; |
|||
List<Widget> _children = new List<Widget>(); |
|||
foreach(Widget _child in children) { |
|||
_children.Add(new Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: paddingUnit), |
|||
child: _child |
|||
)); |
|||
} |
|||
Widget child = new Row( |
|||
mainAxisAlignment: alignment, |
|||
mainAxisSize: mainAxisSize, |
|||
children: _children |
|||
); |
|||
switch(buttonTheme.layoutBehavior) { |
|||
case ButtonBarLayoutBehavior.padded: |
|||
return new Padding( |
|||
padding: EdgeInsets.symmetric( |
|||
vertical: 2.0 * paddingUnit, |
|||
horizontal: paddingUnit |
|||
), |
|||
child: child |
|||
); |
|||
case ButtonBarLayoutBehavior.constrained: |
|||
return new Container( |
|||
padding: EdgeInsets.symmetric(horizontal: paddingUnit), |
|||
constraints: new BoxConstraints(minHeight: 52.0), |
|||
alignment: Alignment.center, |
|||
child: child |
|||
); |
|||
} |
|||
D.assert(false); |
|||
return null; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue