siyao
4 年前
当前提交
24eccf24
共有 7 个文件被更改,包括 346 次插入 和 100 次删除
-
82com.unity.uiwidgets/Runtime/material/app.cs
-
2com.unity.uiwidgets/Runtime/material/banner_theme.cs
-
9com.unity.uiwidgets/Runtime/material/bottom_app_bar.cs
-
2com.unity.uiwidgets/Runtime/material/bottom_app_bar_theme.cs
-
170com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs
-
66com.unity.uiwidgets/Runtime/painting/edge_insets.cs
-
115com.unity.uiwidgets/Runtime/material/banner.cs
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
class MaterialBanner : StatelessWidget { |
|||
public MaterialBanner( |
|||
Key key = null, |
|||
Widget content = null, |
|||
TextStyle contentTextStyle = null, |
|||
List<Widget> actions = null, |
|||
Widget leading = null, |
|||
Color backgroundColor = null, |
|||
EdgeInsetsGeometry padding = null, |
|||
EdgeInsetsGeometry leadingPadding = null, |
|||
bool forceActionsBelow = false |
|||
) : base(key: key) { |
|||
D.assert(content != null); |
|||
D.assert(actions != null); |
|||
this.content = content; |
|||
this.contentTextStyle = contentTextStyle; |
|||
this.actions = actions; |
|||
this.leading = leading; |
|||
this.backgroundColor = backgroundColor; |
|||
this.padding = padding; |
|||
this.leadingPadding = leadingPadding; |
|||
this.forceActionsBelow = forceActionsBelow; |
|||
} |
|||
|
|||
public readonly Widget content; |
|||
|
|||
public readonly TextStyle contentTextStyle; |
|||
|
|||
public readonly List<Widget> actions; |
|||
|
|||
public readonly Widget leading; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly EdgeInsetsGeometry padding; |
|||
|
|||
public readonly EdgeInsetsGeometry leadingPadding; |
|||
|
|||
public readonly bool forceActionsBelow; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(actions.isNotEmpty); |
|||
|
|||
ThemeData theme = Theme.of(context); |
|||
MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context); |
|||
|
|||
bool isSingleRow = actions.Count == 1 && !forceActionsBelow; |
|||
EdgeInsetsGeometry padding = this.padding ?? bannerTheme.padding ?? (isSingleRow |
|||
? EdgeInsetsDirectional.only(start: 16.0f, top: 2.0f) |
|||
: EdgeInsetsDirectional.only(start: 16.0f, top: 24.0f, end: 16.0f, |
|||
bottom: 4.0f)); |
|||
EdgeInsetsGeometry leadingPadding = this.leadingPadding |
|||
?? bannerTheme.padding |
|||
?? EdgeInsetsDirectional.only(end: 16.0f); |
|||
|
|||
Widget buttonBar = new ButtonBar( |
|||
layoutBehavior: ButtonBarLayoutBehavior.constrained, |
|||
children: actions |
|||
); |
|||
|
|||
Color backgroundColor = this.backgroundColor |
|||
?? bannerTheme.backgroundColor |
|||
?? theme.colorScheme.surface; |
|||
TextStyle textStyle = contentTextStyle |
|||
?? bannerTheme.contentTextStyle |
|||
?? theme.textTheme.bodyText2; |
|||
|
|||
var rowList = new List<Widget>(); |
|||
if (leading != null) { |
|||
rowList.Add(new Padding( |
|||
padding: (EdgeInsets) leadingPadding, |
|||
child: leading |
|||
)); |
|||
} |
|||
|
|||
rowList.Add(new Expanded( |
|||
child: new DefaultTextStyle( |
|||
style: textStyle, |
|||
child: content |
|||
) |
|||
)); |
|||
if (isSingleRow) { |
|||
rowList.Add(buttonBar); |
|||
} |
|||
|
|||
var columnList = new List<Widget>(); |
|||
columnList.Add(new Padding( |
|||
padding: (EdgeInsets) padding, |
|||
child: new Row( |
|||
children: rowList |
|||
) |
|||
)); |
|||
if (!isSingleRow) { |
|||
columnList.Add(buttonBar); |
|||
} |
|||
|
|||
columnList.Add(new Divider(height: 0)); |
|||
|
|||
return new Container( |
|||
color: backgroundColor, |
|||
child: new Column( |
|||
children: columnList |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue