浏览代码

update

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
5255fa62
共有 6 个文件被更改,包括 236 次插入84 次删除
  1. 44
      com.unity.uiwidgets/Runtime/material/expand_icon.cs
  2. 104
      com.unity.uiwidgets/Runtime/material/expansion_panel.cs
  3. 7
      com.unity.uiwidgets/Runtime/material/expansion_tile.cs
  4. 22
      com.unity.uiwidgets/Runtime/material/feedback.cs
  5. 69
      com.unity.uiwidgets/Runtime/material/flat_button.cs
  6. 74
      com.unity.uiwidgets/Runtime/material/icon_button.cs

44
com.unity.uiwidgets/Runtime/material/expand_icon.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
public class ExpandIcon : StatefulWidget {

float size = 24.0f,
ValueChanged<bool> onPressed = null,
EdgeInsets padding = null) : base(key: key) {
EdgeInsets padding = null,
Color color = null,
Color disabledColor = null,
Color expandedColor = null
) : base(key: key) {
this.color = color;
this.disabledColor = disabledColor;
this.expandedColor = expandedColor;
}
public readonly bool isExpanded;

public readonly ValueChanged<bool> onPressed;
public readonly EdgeInsets padding;
public readonly Color color;
public readonly Color disabledColor;
public readonly Color expandedColor;
public override State createState() {
return new _ExpandIconState();

}
}
Color _iconColor {
get {
if (widget.isExpanded && widget.expandedColor != null) {
return widget.expandedColor;
}
if (widget.color != null) {
return widget.color;
}
switch (Theme.of(context).brightness) {
case Brightness.light:
return Colors.black54;
case Brightness.dark:
return Colors.white60;
}
D.assert(false);
return null;
}
}
ThemeData theme = Theme.of(context);
D.assert(material_.debugCheckHasMaterialLocalizations(context));
color: theme.brightness == Brightness.dark ? Colors.white54 : Colors.black54,
iconSize: widget.size,
color: _iconColor,
disabledColor: widget.disabledColor,
onPressed: widget.onPressed == null ? (VoidCallback) null : _handlePressed,
icon: new RotationTransition(
turns: _iconTurns,

104
com.unity.uiwidgets/Runtime/material/expansion_panel.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class ExpansionPanelUtils {
public const float _kPanelHeaderCollapsedHeight = 48.0f;
public const float _kPanelHeaderExpandedHeight = 64.0f;
public partial class material_ {
public const float _kPanelHeaderCollapsedHeight = kMinInteractiveDimension;
public static readonly EdgeInsets _kPanelHeaderExpandedDefaultPadding = EdgeInsets.symmetric(
vertical: 64.0f - _kPanelHeaderCollapsedHeight);
}

Key key = null,
List<ExpansionPanel> children = null,
ExpansionPanelCallback expansionCallback = null,
TimeSpan? animationDuration = null) : base(key: key) {
TimeSpan? animationDuration = null,
EdgeInsets expandedHeaderPadding = null
) : base(key: key) {
this.expandedHeaderPadding = expandedHeaderPadding ?? material_._kPanelHeaderExpandedDefaultPadding;
_allowOnlyOnePanelOpen = false;
initialOpenPanelValue = null;
}

List<ExpansionPanel> children = null,
ExpansionPanelCallback expansionCallback = null,
TimeSpan? animationDuration = null,
object initialOpenPanelValue = null) : base(key: key) {
object initialOpenPanelValue = null,
EdgeInsets expandedHeaderPadding = null
) : base(key: key) {
this.expandedHeaderPadding = expandedHeaderPadding ?? material_._kPanelHeaderExpandedDefaultPadding;
_allowOnlyOnePanelOpen = true;
this.initialOpenPanelValue = initialOpenPanelValue;
}

public readonly object initialOpenPanelValue;
public readonly EdgeInsets expandedHeaderPadding;
public override State createState() {
return new _ExpansionPanelListState();
}

public override void initState() {
base.initState();
if (widget._allowOnlyOnePanelOpen) {
D.assert(_allIdentifierUnique(), () => "All object identifiers are not unique!");
D.assert(_allIdentifierUnique(), () => "All ExpansionPanelRadio identifier values must be unique.");
if (widget.initialOpenPanelValue != null &&
child.value == widget.initialOpenPanelValue) {
_currentOpenPanel = child;
if (widget.initialOpenPanelValue != null) {
_currentOpenPanel =
searchPanelByValue(widget.children.Cast<ExpansionPanelRadio>().ToList(),
widget.initialOpenPanelValue);
}
}
}

base.didUpdateWidget(oldWidget);
ExpansionPanelList _oldWidget = (ExpansionPanelList) oldWidget;
if (widget._allowOnlyOnePanelOpen) {
D.assert(_allIdentifierUnique(), () => "All object identifiers are not unique!");
foreach (ExpansionPanelRadio newChild in widget.children) {
if (widget.initialOpenPanelValue != null &&
newChild.value == widget.initialOpenPanelValue) {
_currentOpenPanel = newChild;
}
D.assert(_allIdentifierUnique(), () => "All ExpansionPanelRadio identifier values must be unique.");
if (!_oldWidget._allowOnlyOnePanelOpen) {
_currentOpenPanel =
searchPanelByValue(widget.children.Cast<ExpansionPanelRadio>().ToList(),
widget.initialOpenPanelValue);
else if (_oldWidget._allowOnlyOnePanelOpen) {
else {
_currentOpenPanel = null;
}
}

foreach (ExpansionPanelRadio child in widget.children) {
foreach (ExpansionPanelRadio child in widget.children.Cast<ExpansionPanelRadio>()) {
identifierMap[child.value] = true;
}

}
}
_currentOpenPanel = isExpanded ? null : pressedChild;
setState(() => { _currentOpenPanel = isExpanded ? null : pressedChild; });
}
setState(() => { });
public ExpansionPanelRadio searchPanelByValue(List<ExpansionPanelRadio> panels, Object value) {
foreach (ExpansionPanelRadio panel in panels) {
if (panel.value == value)
return panel;
}
return null;
EdgeInsets kExpandedEdgeInsets = EdgeInsets.symmetric(
vertical: ExpansionPanelUtils._kPanelHeaderExpandedHeight -
ExpansionPanelUtils._kPanelHeaderCollapsedHeight);
for (int index = 0; index < widget.children.Count; index++) {
int expandIndex = index;

context,
_isChildExpanded(index)
);
Row header = new Row(
Widget expandIconContainer = new Container(
//TODO: update to EdgeInsetsGeometry
margin: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(end: 8.0f),
child: new ExpandIcon(
isExpanded: _isChildExpanded(index),
padding: EdgeInsets.all(16.0f),
onPressed: !child.canTapOnHeader
? (bool isExpanded) => _handlePressed(isExpanded, index)
: (ValueChanged<bool>) null
)
);
Widget header = new Row(
margin: _isChildExpanded(index) ? kExpandedEdgeInsets : EdgeInsets.zero,
margin: _isChildExpanded(index) ? widget.expandedHeaderPadding : EdgeInsets.zero,
minHeight: ExpansionPanelUtils._kPanelHeaderCollapsedHeight),
minHeight: material_._kPanelHeaderCollapsedHeight),
new Container(
margin: EdgeInsets.fromLTRB(0, 0, 8, 0),
child: new ExpandIcon(
isExpanded: _isChildExpanded(index),
padding: EdgeInsets.all(16.0f),
onPressed: !child.canTapOnHeader
? (ValueChanged<bool>) ((bool isExpanded) => {
_handlePressed(isExpanded, expandIndex);
})
: null
)
)
expandIconContainer,
if (child.canTapOnHeader) {
header = new InkWell(
onTap: () => _handlePressed(_isChildExpanded(index), index),
child: header
);
}
child.canTapOnHeader
? (Widget) new InkWell(
onTap: () =>
_handlePressed(_isChildExpanded(expandIndex), expandIndex),
child: header
)
: header,
header,
new AnimatedCrossFade(
firstChild: new Container(height: 0.0f),
secondChild: child.body,

7
com.unity.uiwidgets/Runtime/material/expansion_tile.cs


Key key = null,
Widget leading = null,
Widget title = null,
Widget subtitle = null,
Color backgroundColor = null,
ValueChanged<bool> onExpansionChanged = null,
List<Widget> children = null,

D.assert(title != null);
this.leading = leading;
this.title = title;
this.subtitle = subtitle;
this.backgroundColor = backgroundColor;
this.onExpansionChanged = onExpansionChanged;
this.children = children ?? new List<Widget>();

public readonly Widget leading;
public readonly Widget title;
public readonly Widget subtitle;
public readonly ValueChanged<bool> onExpansionChanged;

onTap: _handleTap,
leading: widget.leading,
title: widget.title,
subtitle: widget.subtitle,
trailing: widget.trailing ?? new RotationTransition(
turns: _iconTurns,
child: new Icon(Icons.expand_more)

public override void didChangeDependencies() {
ThemeData theme = Theme.of(context);
_borderColorTween.end = theme.dividerColor;
_headerColorTween.begin = theme.textTheme.subhead.color;
_headerColorTween.begin = theme.textTheme.subtitle1.color;
_headerColorTween.end = theme.accentColor;
_iconColorTween.begin = theme.unselectedWidgetColor;
_iconColorTween.end = theme.accentColor;

22
com.unity.uiwidgets/Runtime/material/feedback.cs


using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.widgets;
using UnityEngine;

case RuntimePlatform.Android:
return
Future.value(); // SystemSound.play(SystemSoundType.click); TODO: replace with unity equivalent
default:
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.LinuxEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
D.assert(false, () => $"Unhandled TargetPlatform {_platform(context)}");
return Future.value();
}
public static GestureTapCallback wrapForTap(GestureTapCallback callback, BuildContext context) {

switch (_platform(context)) {
case RuntimePlatform.Android:
return Future.value(); // HapticFeedback.vibrate(); TODO
default:
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.LinuxEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
D.assert(false, ()=>$"Unhandled TargetPlatform {_platform(context)}");
return Future.value();
}
public static GestureLongPressCallback

69
com.unity.uiwidgets/Runtime/material/flat_button.cs


Key key = null,
VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
VisualDensity visualDensity = null,
Clip? clipBehavior = Clip.none,
Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
onLongPress: onLongPress,
focusColor: focusColor,
hoverColor: hoverColor,
color: color,
disabledColor: disabledColor,
highlightColor: highlightColor,

visualDensity: visualDensity,
focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
child: child) {
}

VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Clip? clipBehavior = null,
Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget icon = null,
Widget label = null) {

return new _FlatButtonWithIcon(
key: key,
onPressed: onPressed,
onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,

focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorBrightness: colorBrightness,

focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
icon: icon,
label: label

return new RawMaterialButton(
onPressed: onPressed,
onLongPress: () => onLongPress(),
clipBehavior: clipBehavior ?? Clip.none,
focusColor: buttonTheme.getFocusColor(this),
hoverColor: buttonTheme.getHoverColor(this),
focusElevation: buttonTheme.getFocusElevation(this),
hoverElevation: buttonTheme.getHoverElevation(this),
visualDensity: visualDensity ?? theme.visualDensity,
clipBehavior: clipBehavior ?? Clip.none,
focusNode: focusNode,
autofocus: autofocus ?? false,
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new ObjectFlagProperty<VoidCallback>("onPressed", onPressed, ifNull: "disabled"));
properties.add(new DiagnosticsProperty<ButtonTextTheme?>("textTheme", textTheme, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("textColor", textColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledTextColor", disabledTextColor,
defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledColor", disabledColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("highlightColor", highlightColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("splashColor", splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Brightness?>("colorBrightness", colorBrightness,
defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize?>("materialTapTargetSize",
materialTapTargetSize, defaultValue: null));
}
}
class _FlatButtonWithIcon : FlatButton, MaterialButtonWithIconMixin {

ValueChanged<bool> onHighlightChanged = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Clip? clipBehavior = null,
Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,

focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorBrightness: colorBrightness,

focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
child: new Row(
mainAxisSize: MainAxisSize.min,

74
com.unity.uiwidgets/Runtime/material/icon_button.cs


using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
static class IconButtonUtils {
public const float _kMinButtonSize = 48.0f;
public partial class material_ {
public const float _kMinButtonSize = kMinInteractiveDimension;
}

float iconSize = 24.0f,
VisualDensity visualDensity = null,
Color focusColor = null,
Color hoverColor = null,
Color disableColor = null,
Color disabledColor = null,
string tooltip = null) : base(key: key) {
FocusNode focusNode = null,
bool autofocus = false,
string tooltip = null,
bool? enableFeedback = true,
BoxConstraints constraints = null
) : base(key: key) {
this.visualDensity = visualDensity;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
disabledColor = disableColor;
this.disabledColor = disabledColor;
this.focusNode = focusNode;
this.autofocus = autofocus;
this.enableFeedback = enableFeedback;
this.constraints = constraints;
public readonly VisualDensity visualDensity;
public readonly EdgeInsets padding;

public readonly Color focusColor;
public readonly Color hoverColor;
public readonly Color color;
public readonly Color splashColor;

public readonly VoidCallback onPressed;
public readonly FocusNode focusNode;
public readonly bool autofocus;
public readonly bool? enableFeedback;
public readonly BoxConstraints constraints;
ThemeData theme = Theme.of(context);
Color currentColor;
if (onPressed != null) {
currentColor = color;

}
VisualDensity effectiveVisualDensity = visualDensity ?? theme.visualDensity;
BoxConstraints unadjustedConstraints = constraints ?? new BoxConstraints(
minWidth: material_._kMinButtonSize,
minHeight: material_._kMinButtonSize
);
BoxConstraints adjustedConstraints = effectiveVisualDensity.effectiveConstraints(unadjustedConstraints);
constraints: new BoxConstraints(minWidth: IconButtonUtils._kMinButtonSize,
minHeight: IconButtonUtils._kMinButtonSize),
constraints: adjustedConstraints,
child: new Padding(
padding: padding,
child: new SizedBox(

child: IconTheme.merge(
data: new IconThemeData(
size: iconSize,
color: currentColor),
child: icon)
color: currentColor
),
child: icon
)
)
)
)

}
return new InkResponse(
focusNode: focusNode,
autofocus: autofocus,
canRequestFocus: onPressed != null,
enableFeedback: enableFeedback ?? false,
focusColor: focusColor ?? Theme.of(context).focusColor,
hoverColor: hoverColor ?? Theme.of(context).hoverColor,
highlightColor: highlightColor ?? Theme.of(context).highlightColor,
splashColor: splashColor ?? Theme.of(context).splashColor,
radius: Mathf.Max(

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Widget>("icon", icon, showName: false));
properties.add(new StringProperty("tooltip", tooltip, defaultValue: null, quoted: false));
properties.add(new ColorProperty("color", color, defaultValue: null));
properties.add(new ColorProperty("disabledColor", disabledColor, defaultValue: null));
properties.add(new ColorProperty("focusColor", focusColor, defaultValue: null));
properties.add(new ColorProperty("hoverColor", hoverColor, defaultValue: null));
properties.add(new ColorProperty("highlightColor", highlightColor, defaultValue: null));
properties.add(new ColorProperty("splashColor", splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding, defaultValue: null));
properties.add(new DiagnosticsProperty<FocusNode>("focusNode", focusNode, defaultValue: null));
}
}
}
正在加载...
取消
保存