浏览代码
Merge pull request #70 from Unity-Technologies/zxw/1.17/material
Merge pull request #70 from Unity-Technologies/zxw/1.17/material
upgrade more material widgets/siyaoH-1.17-PlatformMessage
GitHub
4 年前
当前提交
47846b43
共有 19 个文件被更改,包括 2796 次插入 和 604 次删除
-
36com.unity.uiwidgets/Runtime/material/bottom_sheet.cs
-
155com.unity.uiwidgets/Runtime/material/radio.cs
-
59com.unity.uiwidgets/Runtime/material/raised_button.cs
-
705com.unity.uiwidgets/Runtime/material/scaffold.cs
-
203com.unity.uiwidgets/Runtime/material/slider.cs
-
846com.unity.uiwidgets/Runtime/material/slider_theme.cs
-
297com.unity.uiwidgets/Runtime/material/snack_bar.cs
-
20com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs
-
24com.unity.uiwidgets/Runtime/material/stepper.cs
-
341com.unity.uiwidgets/Runtime/material/switch.cs
-
14com.unity.uiwidgets/Runtime/material/theme.cs
-
27com.unity.uiwidgets/Runtime/material/theme_data.cs
-
3com.unity.uiwidgets/Runtime/rendering/editable.cs
-
2com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
-
2com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
-
360com.unity.uiwidgets/Runtime/widgets/draggable_scrollable_sheet.cs
-
2com.unity.uiwidgets/Runtime/widgets/scroll_position_with_single_context.cs
-
117com.unity.uiwidgets/Runtime/material/ratio_list_tile.cs
-
187com.unity.uiwidgets/Runtime/material/swtich_list_tile.cs
705
com.unity.uiwidgets/Runtime/material/scaffold.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
846
com.unity.uiwidgets/Runtime/material/slider_theme.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class RadioListTile<T> : StatelessWidget where T : class { |
|||
public RadioListTile( |
|||
Key key = null, |
|||
T value = default, |
|||
T groupValue = default, |
|||
ValueChanged<T> onChanged = null, |
|||
bool toggleable = false, |
|||
Color activeColor = null, |
|||
Widget title = null, |
|||
Widget subtitle = null, |
|||
bool isThreeLine = false, |
|||
bool? dense = null, |
|||
Widget secondary = null, |
|||
bool selected = false, |
|||
ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform |
|||
) : base(key: key) { |
|||
D.assert(!isThreeLine || subtitle != null); |
|||
|
|||
this.value = value; |
|||
this.groupValue = groupValue; |
|||
this.onChanged = onChanged; |
|||
this.toggleable = toggleable; |
|||
this.activeColor = activeColor; |
|||
this.title = title; |
|||
this.subtitle = subtitle; |
|||
this.isThreeLine = isThreeLine; |
|||
this.dense = dense; |
|||
this.secondary = secondary; |
|||
this.selected = selected; |
|||
this.controlAffinity = controlAffinity; |
|||
} |
|||
|
|||
public readonly T value; |
|||
|
|||
public readonly T groupValue; |
|||
|
|||
public readonly ValueChanged<T> onChanged; |
|||
|
|||
public readonly bool toggleable; |
|||
|
|||
public readonly Color activeColor; |
|||
|
|||
public readonly Widget title; |
|||
|
|||
public readonly Widget subtitle; |
|||
|
|||
public readonly Widget secondary; |
|||
|
|||
public readonly bool isThreeLine; |
|||
|
|||
public readonly bool? dense; |
|||
|
|||
public readonly bool selected; |
|||
|
|||
public readonly ListTileControlAffinity controlAffinity; |
|||
|
|||
bool isChecked { |
|||
get { return value.Equals(groupValue); } |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Widget control = new Radio<T>( |
|||
value: value, |
|||
groupValue: groupValue, |
|||
onChanged: onChanged, |
|||
toggleable: toggleable, |
|||
activeColor: activeColor, |
|||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap |
|||
); |
|||
Widget leading = null; |
|||
Widget trailing = null; |
|||
switch (controlAffinity) { |
|||
case ListTileControlAffinity.leading: |
|||
case ListTileControlAffinity.platform: |
|||
leading = control; |
|||
trailing = secondary; |
|||
break; |
|||
case ListTileControlAffinity.trailing: |
|||
leading = secondary; |
|||
trailing = control; |
|||
break; |
|||
} |
|||
|
|||
return ListTileTheme.merge( |
|||
selectedColor: activeColor ?? Theme.of(context).accentColor, |
|||
child: new ListTile( |
|||
leading: leading, |
|||
title: title, |
|||
subtitle: subtitle, |
|||
trailing: trailing, |
|||
isThreeLine: isThreeLine, |
|||
dense: dense, |
|||
enabled: onChanged != null, |
|||
onTap: onChanged != null |
|||
? () => { |
|||
if (toggleable && isChecked) { |
|||
onChanged(null); |
|||
return; |
|||
} |
|||
|
|||
if (!isChecked) { |
|||
onChanged(value); |
|||
} |
|||
} |
|||
: (GestureTapCallback) null, |
|||
selected: selected |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public enum _SwitchListTileType { |
|||
material, |
|||
adaptive |
|||
} |
|||
|
|||
public class SwitchListTile : StatelessWidget { |
|||
public SwitchListTile( |
|||
Key key = null, |
|||
bool? value = null, |
|||
ValueChanged<bool?> onChanged = null, |
|||
Color activeColor = null, |
|||
Color activeTrackColor = null, |
|||
Color inactiveThumbColor = null, |
|||
Color inactiveTrackColor = null, |
|||
ImageProvider activeThumbImage = null, |
|||
ImageProvider inactiveThumbImage = null, |
|||
Widget title = null, |
|||
Widget subtitle = null, |
|||
bool isThreeLine = false, |
|||
bool? dense = null, |
|||
EdgeInsets contentPadding = null, |
|||
Widget secondary = null, |
|||
bool selected = false, |
|||
_SwitchListTileType _switchListTileType = _SwitchListTileType.material |
|||
) : base(key: key) { |
|||
D.assert(value != null); |
|||
D.assert(!isThreeLine || subtitle != null); |
|||
this.value = value.Value; |
|||
this.onChanged = onChanged; |
|||
this.activeColor = activeColor; |
|||
this.activeTrackColor = activeTrackColor; |
|||
this.inactiveThumbColor = inactiveThumbColor; |
|||
this.inactiveTrackColor = inactiveTrackColor; |
|||
this.activeThumbImage = activeThumbImage; |
|||
this.inactiveThumbImage = inactiveThumbImage; |
|||
this.title = title; |
|||
this.subtitle = subtitle; |
|||
this.isThreeLine = isThreeLine; |
|||
this.dense = dense; |
|||
this.contentPadding = contentPadding; |
|||
this.secondary = secondary; |
|||
this.selected = selected; |
|||
this._switchListTileType = _switchListTileType; |
|||
} |
|||
|
|||
public static SwitchListTile adaptive( |
|||
Key key = null, |
|||
bool? value = null, |
|||
ValueChanged<bool?> onChanged = null, |
|||
Color activeColor = null, |
|||
Color activeTrackColor = null, |
|||
Color inactiveThumbColor = null, |
|||
Color inactiveTrackColor = null, |
|||
ImageProvider activeThumbImage = null, |
|||
ImageProvider inactiveThumbImage = null, |
|||
Widget title = null, |
|||
Widget subtitle = null, |
|||
bool isThreeLine = false, |
|||
bool? dense = null, |
|||
EdgeInsets contentPadding = null, |
|||
Widget secondary = null, |
|||
bool selected = false) { |
|||
return new SwitchListTile( |
|||
key: key, |
|||
value: value, |
|||
onChanged: onChanged, |
|||
activeColor: activeColor, |
|||
activeTrackColor: activeTrackColor, |
|||
inactiveThumbColor: inactiveThumbColor, |
|||
inactiveTrackColor: inactiveTrackColor, |
|||
activeThumbImage: activeThumbImage, |
|||
inactiveThumbImage: inactiveThumbImage, |
|||
title: title, |
|||
subtitle: subtitle, |
|||
isThreeLine: isThreeLine, |
|||
dense: dense, |
|||
contentPadding: contentPadding, |
|||
secondary: secondary, |
|||
selected: selected, |
|||
_switchListTileType: _SwitchListTileType.adaptive |
|||
); |
|||
} |
|||
|
|||
|
|||
public readonly bool value; |
|||
|
|||
public readonly ValueChanged<bool?> onChanged; |
|||
|
|||
|
|||
public readonly Color activeColor; |
|||
|
|||
|
|||
public readonly Color activeTrackColor; |
|||
|
|||
|
|||
public readonly Color inactiveThumbColor; |
|||
|
|||
|
|||
public readonly Color inactiveTrackColor; |
|||
|
|||
|
|||
public readonly ImageProvider activeThumbImage; |
|||
|
|||
|
|||
public readonly ImageProvider inactiveThumbImage; |
|||
|
|||
|
|||
public readonly Widget title; |
|||
|
|||
|
|||
public readonly Widget subtitle; |
|||
|
|||
|
|||
public readonly Widget secondary; |
|||
|
|||
|
|||
public readonly bool isThreeLine; |
|||
|
|||
|
|||
public readonly bool? dense; |
|||
|
|||
|
|||
public readonly EdgeInsets contentPadding; |
|||
|
|||
|
|||
public readonly bool selected; |
|||
|
|||
|
|||
public readonly _SwitchListTileType _switchListTileType; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Widget control = null; |
|||
switch (_switchListTileType) { |
|||
case _SwitchListTileType.adaptive: |
|||
control = Switch.adaptive( |
|||
value: value, |
|||
onChanged: onChanged, |
|||
activeColor: activeColor, |
|||
activeThumbImage: activeThumbImage, |
|||
inactiveThumbImage: inactiveThumbImage, |
|||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, |
|||
activeTrackColor: activeTrackColor, |
|||
inactiveTrackColor: inactiveTrackColor, |
|||
inactiveThumbColor: inactiveThumbColor |
|||
); |
|||
break; |
|||
|
|||
case _SwitchListTileType.material: |
|||
control = new Switch( |
|||
value: value, |
|||
onChanged: onChanged, |
|||
activeColor: activeColor, |
|||
activeThumbImage: activeThumbImage, |
|||
inactiveThumbImage: inactiveThumbImage, |
|||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, |
|||
activeTrackColor: activeTrackColor, |
|||
inactiveTrackColor: inactiveTrackColor, |
|||
inactiveThumbColor: inactiveThumbColor |
|||
); |
|||
break; |
|||
} |
|||
|
|||
return ListTileTheme.merge( |
|||
selectedColor: activeColor ?? Theme.of(context).accentColor, |
|||
child: new ListTile( |
|||
leading: secondary, |
|||
title: title, |
|||
subtitle: subtitle, |
|||
trailing: control, |
|||
isThreeLine: isThreeLine, |
|||
dense: dense, |
|||
contentPadding: contentPadding, |
|||
enabled: onChanged != null, |
|||
onTap: onChanged != null ? () => { onChanged(!value); } : (GestureTapCallback) null, |
|||
selected: selected |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue