浏览代码

Merge branch 'zxw/1.17/material' of https://github.com/Unity-Technologies/com.unity.uiwidgets into siyaoH/1.17/material

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
7f8c427a
共有 21 个文件被更改,包括 1712 次插入60 次删除
  1. 292
      com.unity.uiwidgets/Runtime/material/button.cs
  2. 2
      com.unity.uiwidgets/Runtime/material/chip.cs
  3. 2
      com.unity.uiwidgets/Runtime/material/input_decorator.cs
  4. 2
      com.unity.uiwidgets/Runtime/material/list_tile.cs
  5. 159
      com.unity.uiwidgets/Runtime/material/toggleable.cs
  6. 2
      com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
  7. 2
      com.unity.uiwidgets/Runtime/rendering/box.cs
  8. 2
      com.unity.uiwidgets/Runtime/rendering/editable.cs
  9. 2
      com.unity.uiwidgets/Runtime/rendering/flex.cs
  10. 2
      com.unity.uiwidgets/Runtime/rendering/list_body.cs
  11. 2
      com.unity.uiwidgets/Runtime/rendering/paragraph.cs
  12. 2
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  13. 2
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs
  14. 4
      com.unity.uiwidgets/Runtime/rendering/shifted_box.cs
  15. 2
      com.unity.uiwidgets/Runtime/rendering/stack.cs
  16. 2
      com.unity.uiwidgets/Runtime/rendering/table.cs
  17. 2
      com.unity.uiwidgets/Runtime/rendering/wrap.cs
  18. 34
      com.unity.uiwidgets/Runtime/ui2/geometry.cs
  19. 2
      com.unity.uiwidgets/Runtime/widgets/overlay.cs
  20. 1001
      com.unity.uiwidgets/Runtime/material/toggle_buttons.cs
  21. 252
      com.unity.uiwidgets/Runtime/material/toggle_buttons_theme.cs

292
com.unity.uiwidgets/Runtime/material/button.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;

using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {

VoidCallback onPressed = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
float focusElevation = 4.0f,
float hoverElevation = 4.0f,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false,
Widget child = null) : base(key: key) {
D.assert(elevation >= 0.0);
D.assert(highlightElevation >= 0.0);
D.assert(disabledElevation >= 0.0);
Widget child = null,
bool enableFeedback = true) : base(key: key) {
D.assert(elevation >= 0.0f);
D.assert(focusElevation >= 0.0f);
D.assert(focusElevation >= 0.0f);
D.assert(highlightElevation >= 0.0f);
D.assert(disabledElevation >= 0.0f);
visualDensity = visualDensity ?? new VisualDensity();
this.onLongPress = onLongPress;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.focusElevation = focusElevation;
this.hoverElevation = hoverElevation;
this.visualDensity = visualDensity;
this.focusNode = focusNode;
this.autofocus = autofocus;
this.enableFeedback = enableFeedback;
this.materialTapTargetSize = _materialTapTargetSize;
this.child = child;
}

public readonly VoidCallback onLongPress;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly TextStyle textStyle;

public readonly Color focusColor;
public readonly Color hoverColor;
public readonly float hoverElevation;
public readonly float focusElevation;
public readonly float highlightElevation;

public readonly VisualDensity visualDensity;
public readonly BoxConstraints constraints;
public readonly ShapeBorder shape;

public readonly Widget child;
public bool enabled {
get { return onPressed != null; }
get { return onPressed != null || onLongPress != null; }
public readonly FocusNode focusNode;
public readonly bool autofocus;
public readonly bool enableFeedback;
public override State createState() {
return new _RawMaterialButtonState();
}

class _RawMaterialButtonState : State<RawMaterialButton> {
bool _highlight = false;
readonly HashSet<MaterialState> _states = new HashSet<MaterialState>();
bool _hovered {
get { return _states.Contains(MaterialState.hovered); }
}
bool _focused {
get { return _states.Contains(MaterialState.focused); }
}
bool _pressed {
get { return _states.Contains(MaterialState.pressed); }
}
bool _disabled {
get { return _states.Contains(MaterialState.disabled); }
}
void _updateState(MaterialState state, bool value) {
if (value) {
_states.Add(state);
}
else {
_states.Remove(state);
}
}
if (_highlight != value) {
if (_pressed != value) {
_highlight = value;
_updateState(MaterialState.pressed, value);
if (widget.onHighlightChanged != null) {
widget.onHighlightChanged(value);
}

void _handleHoveredChanged(bool value) {
if (_hovered != value) {
setState(() => { _updateState(MaterialState.hovered, value); });
}
}
void _handleFocusedChanged(bool value) {
if (_focused != value) {
setState(() => { _updateState(MaterialState.focused, value); });
}
}
public override void initState() {
base.initState();
_updateState(MaterialState.disabled, !widget.enabled);
}
if (_highlight && !widget.enabled) {
_highlight = false;
if (widget.onHighlightChanged != null) {
widget.onHighlightChanged(false);
_updateState(MaterialState.disabled, !widget.enabled);
if (_disabled && _pressed) {
_handleHighlightChanged(false);
}
}
float _effectiveElevation {
get {
if (_disabled) {
return widget.disabledElevation;
}
if (_pressed) {
return widget.highlightElevation;
if (_hovered) {
return widget.hoverElevation;
}
if (_focused) {
return widget.focusElevation;
}
return widget.elevation;
float elevation = widget.enabled
? (_highlight ? widget.highlightElevation : widget.elevation)
: widget.disabledElevation;
Color effectiveTextColor = MaterialStateProperty.resolveAs<Color>(widget.textStyle?.color, _states);
ShapeBorder effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder>(widget.shape, _states);
Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment;
BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints);
EdgeInsets padding = widget.padding.add(
EdgeInsets.only(
left: densityAdjustment.dx,
top: densityAdjustment.dy,
right: densityAdjustment.dx,
bottom: densityAdjustment.dy
)
).clamp(EdgeInsets.zero, EdgeInsets.infinity) as EdgeInsets;
constraints: widget.constraints,
constraints: effectiveConstraints,
elevation: elevation,
textStyle: widget.textStyle,
shape: widget.shape,
elevation: _effectiveElevation,
textStyle: widget.textStyle?.copyWith(color: effectiveTextColor),
shape: effectiveShape,
focusNode: widget.focusNode,
canRequestFocus: widget.enabled,
onFocusChange: _handleFocusedChanged,
autofocus: widget.autofocus,
focusColor: widget.focusColor,
hoverColor: widget.hoverColor,
onHover: _handleHoveredChanged,
onTap: widget.onPressed == null
? (GestureTapCallback) null
: () => {

},
customBorder: widget.shape,
onLongPress: widget.onLongPress,
enableFeedback: widget.enableFeedback,
customBorder: effectiveShape,
data: new IconThemeData(color: widget.textStyle?.color),
data: new IconThemeData(color: effectiveTextColor),
padding: widget.padding,
padding: padding,
child: new Center(
widthFactor: 1.0f,
heightFactor: 1.0f,

)
);
return result;
Size minSize = null;
switch (widget.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
minSize = new Size(
Constants.kMinInteractiveDimension + densityAdjustment.dx,
Constants.kMinInteractiveDimension + densityAdjustment.dy
);
D.assert(minSize.width >= 0.0f);
D.assert(minSize.height >= 0.0f);
break;
case MaterialTapTargetSize.shrinkWrap:
minSize = Size.zero;
break;
}
return new _InputPadding(
minSize: minSize,
child: result
);
}
}
class _InputPadding : SingleChildRenderObjectWidget {
public _InputPadding(
Key key = null,
Widget child = null,
Size minSize = null) : base(key: key, child: child) {
this.minSize = minSize;
}
public readonly Size minSize;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderInputPadding(minSize);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
var _renderObject = (_RenderInputPadding) renderObject;
_renderObject.minSize = minSize;
}
}
class _RenderInputPadding : RenderShiftedBox {
public _RenderInputPadding(
Size minSize,
RenderBox child = null
) : base(child: child) {
_minSize = minSize;
}
public Size minSize {
get { return _minSize; }
set {
if (_minSize == value) {
return;
}
_minSize = value;
markNeedsLayout();
}
}
Size _minSize;
protected internal override float computeMinIntrinsicWidth(float height) {
if (child != null) {
return Mathf.Max(child.getMinIntrinsicWidth(height), minSize.width);
}
return 0.0f;
}
protected internal override float computeMinIntrinsicHeight(float width) {
if (child != null) {
return Mathf.Max(child.getMinIntrinsicHeight(width), minSize.height);
}
return 0.0f;
}
protected internal override float computeMaxIntrinsicWidth(float height) {
if (child != null) {
return Mathf.Max(child.getMaxIntrinsicWidth(height), minSize.width);
}
return 0.0f;
}
protected internal override float computeMaxIntrinsicHeight(float width) {
if (child != null) {
return Mathf.Max(child.getMaxIntrinsicHeight(width), minSize.height);
}
return 0.0f;
}
protected override void performLayout() {
BoxConstraints constraints = this.constraints;
if (child != null) {
child.layout(constraints, parentUsesSize: true);
float height = Mathf.Max(child.size.width, minSize.width);
float width = Mathf.Max(child.size.height, minSize.height);
size = constraints.constrain(new Size(height, width));
BoxParentData childParentData = child.parentData as BoxParentData;
childParentData.offset = Alignment.center.alongOffset(size - child.size as Offset);
}
else {
size = Size.zero;
}
}
public override bool hitTest(BoxHitTestResult result, Offset position = null) {
if (base.hitTest(result, position: position)) {
return true;
}
Offset center = child.size.center(Offset.zero);
return result.addWithRawTransform(
transform: MatrixUtils.forceToPoint(center),
position: center,
hitTest: (BoxHitTestResult result, Offset position) => {
D.assert(position == center);
return child.hitTest(result, position: center);
}
);
}
}
}

2
com.unity.uiwidgets/Runtime/material/chip.cs


return computeMinIntrinsicHeight(width);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
return label.getDistanceToActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/material/input_decorator.cs


return computeMinIntrinsicHeight(width);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
return _boxParentData(input).offset.dy + input.getDistanceToActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/material/list_tile.cs


return computeMinIntrinsicHeight(width);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
D.assert(title != null);
BoxParentData parentData = (BoxParentData) title.parentData;
return parentData.offset.dy + title.getDistanceToActualBaseline(baseline);

159
com.unity.uiwidgets/Runtime/material/toggleable.cs


public static readonly Animatable<float> _kRadialReactionRadiusTween =
new FloatTween(begin: 0.0f, end: Constants.kRadialReactionRadius);
public static readonly TimeSpan _kReactionFadeDuration = new TimeSpan(0, 0, 0, 0, 50);
}
public abstract class RenderToggleable : RenderConstrainedBox {

Color activeColor = null,
Color inactiveColor = null,
Color hoverColor = null,
Color focusColor = null,
TickerProvider vsync = null
TickerProvider vsync = null,
bool hasFocus = false,
bool hovering = false
) : base(additionalConstraints: additionalConstraints) {
D.assert(tristate || value != null);
D.assert(activeColor != null);

_tristate = tristate;
_activeColor = activeColor;
_inactiveColor = inactiveColor;
_hoverColor = hoverColor ?? activeColor.withAlpha(Constants.kRadialReactionAlpha);
_focusColor = focusColor ?? activeColor.withAlpha(Constants.kRadialReactionAlpha);
_hasFocus = hasFocus;
_hovering = hovering;
_vsync = vsync;
_tap = new TapGestureRecognizer {

parent: _positionController,
curve: Curves.linear);
_position.addListener(markNeedsPaint);
_position.addStatusListener(_handlePositionStateChanged);
_reactionHoverFadeController = new AnimationController(
duration: ToggleableUtils._kReactionFadeDuration,
value: hovering || hasFocus ? 1.0f : 0.0f,
vsync: vsync
);
_reactionHoverFade = new CurvedAnimation(
parent: _reactionHoverFadeController,
curve: Curves.fastOutSlowIn
);
_reactionHoverFade.addListener(markNeedsPaint);
_reactionFocusFadeController = new AnimationController(
duration: ToggleableUtils._kReactionFadeDuration,
value: hovering || hasFocus ? 1.0f : 0.0f,
vsync: vsync
);
_reactionFocusFade = new CurvedAnimation(
parent: _reactionFocusFadeController,
curve: Curves.fastOutSlowIn
);
_reactionFocusFade.addListener(markNeedsPaint);
}
protected AnimationController positionController {

}
AnimationController _reactionController;
Animation<float> _reaction;
Animation<float> _reaction;
protected AnimationController reactionFocusFadeController {
get { return _reactionFocusFadeController; }
}
AnimationController _reactionFocusFadeController;
Animation<float> _reactionFocusFade;
protected AnimationController reactionHoverFadeController {
get { return _reactionHoverFadeController; }
}
AnimationController _reactionHoverFadeController;
Animation<float> _reactionHoverFade;
public bool hasFocus {
get { return _hasFocus; }
set {
if (value == _hasFocus) {
return;
}
_hasFocus = value;
if (_hasFocus) {
_reactionFocusFadeController.forward();
}
else {
_reactionFocusFadeController.reverse();
}
markNeedsPaint();
}
}
bool _hasFocus;
public bool hovering {
get { return _hovering; }
set {
if (value == _hovering) {
return;
}
_hovering = value;
if (_hovering) {
_reactionHoverFadeController.forward();
}
else {
_reactionHoverFadeController.reverse();
}
markNeedsPaint();
}
}
bool _hovering;
public TickerProvider vsync {
get { return _vsync; }

}
}
public Color hoverColor {
get { return _hoverColor; }
set {
if (value == _hoverColor) {
return;
}
_hoverColor = value;
markNeedsPaint();
}
}
Color _hoverColor;
public Color focusColor {
get { return _focusColor; }
set {
if (value == _focusColor) {
return;
}
_focusColor = value;
markNeedsPaint();
}
}
Color _focusColor;
public Color reactionColor {
get { return _reactionColor; }
set {
if (value == _reactionColor) {
return;
}
_reactionColor = value;
markNeedsPaint();
}
}
Color _reactionColor;
ValueChanged<bool?> _onChanged;
public bool isInteractive {

base.detach();
}
void _handlePositionStateChanged(AnimationStatus status) {
if (isInteractive && !tristate) {
if (status == AnimationStatus.completed && _value == false) {
onChanged(true);
}
else if (status == AnimationStatus.dismissed && _value != false) {
onChanged(false);
}
}
}
void _handleTapDown(TapDownDetails details) {
if (isInteractive) {
_downPosition = globalToLocal(details.globalPosition);

}
public void paintRadialReaction(Canvas canvas, Offset offset, Offset origin) {
if (!_reaction.isDismissed) {
Paint reactionPaint = new Paint {color = activeColor.withAlpha(Constants.kRadialReactionAlpha)};
if (!_reaction.isDismissed || !_reactionFocusFade.isDismissed || !_reactionHoverFade.isDismissed) {
Paint reactionPaint = new Paint();
reactionPaint.color = Color.lerp(
Color.lerp(activeColor.withAlpha(Constants.kRadialReactionAlpha), hoverColor,
_reactionHoverFade.value),
focusColor,
_reactionFocusFade.value);
float radius = ToggleableUtils._kRadialReactionRadiusTween.evaluate(_reaction);
canvas.drawCircle(center + offset, radius, reactionPaint);
float reactionRadius = hasFocus || hovering
? Constants.kRadialReactionRadius
: ToggleableUtils._kRadialReactionRadiusTween.evaluate(_reaction);
if (reactionRadius > 0.0f) {
canvas.drawCircle(center + offset, reactionRadius, reactionPaint);
}
}
}

2
com.unity.uiwidgets/Runtime/painting/matrix_utils.cs


return result;
}
static Matrix4 forceToPoint(Offset offset) {
internal static Matrix4 forceToPoint(Offset offset) {
var result = Matrix4.identity();
result.setRow(0, new Vector4(0, 0, 0, offset.dx));
result.setRow(1, new Vector4(0, 0, 0, offset.dy));

2
com.unity.uiwidgets/Runtime/rendering/box.cs


return _cachedBaselines.putIfAbsent(baseline, () => computeDistanceToActualBaseline(baseline));
}
protected virtual float? computeDistanceToActualBaseline(TextBaseline baseline) {
public virtual float? computeDistanceToActualBaseline(TextBaseline baseline) {
D.assert(_debugDoingBaseline,
() =>
"Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.");

2
com.unity.uiwidgets/Runtime/rendering/editable.cs


return _preferredHeight(width);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
_layoutText(constraints.maxWidth);
return _textPainter.computeDistanceToActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/flex.cs


);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
if (_direction == Axis.horizontal) {
return defaultComputeDistanceToHighestActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/list_body.cs


}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
return defaultComputeDistanceToFirstActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/paragraph.cs


return _computeIntrinsicHeight(width);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
_layoutTextWithConstraints(constraints);
return _textPainter.computeDistanceToActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


return base.computeMaxIntrinsicHeight(width);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
if (offstage) {
return null;
}

2
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs


return 0.0f;
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
if (child != null) {
return child.getDistanceToActualBaseline(baseline);
}

4
com.unity.uiwidgets/Runtime/rendering/shifted_box.cs


return 0.0f;
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
float? result;
if (child != null) {

return _requestedSize.height;
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
if (child != null) {
return child.getDistanceToActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/stack.cs


return _getIntrinsicDimension((RenderBox child) => child.getMaxIntrinsicHeight(width));
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
return defaultComputeDistanceToHighestActualBaseline(baseline);
}

2
com.unity.uiwidgets/Runtime/rendering/table.cs


float? _baselineDistance;
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
return _baselineDistance;
}

2
com.unity.uiwidgets/Runtime/rendering/wrap.cs


throw new Exception("Unknown axis: " + direction);
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
return defaultComputeDistanceToHighestActualBaseline(baseline);
}

34
com.unity.uiwidgets/Runtime/ui2/geometry.cs


}
RRect _scaled;
public RRect scaleRadii() {
float scale = 1.0f;
scale = _getMin(scale, blRadiusY, tlRadiusY, height);
scale = _getMin(scale, tlRadiusX, trRadiusX, width);
scale = _getMin(scale, trRadiusY, brRadiusY, height);
scale = _getMin(scale, brRadiusX, blRadiusX, width);
void _scaleRadii() {
if (scale < 1.0) {
return fromLTRBAndCorners(
top: top,
left: left,
right: right,
bottom: bottom,
topLeft: tlRadius * scale,
topRight: trRadius * scale,
bottomLeft: blRadius * scale,
bottomRight: brRadius * scale
);
}
return fromLTRBAndCorners(
top: top,
left: left,
right: right,
bottom: bottom,
topLeft: tlRadius,
topRight: trRadius,
bottomLeft: blRadius,
bottomRight: brRadius
);
}
internal void _scaleRadii() {
if (_scaled == null) {
float scale = 1.0f;

2
com.unity.uiwidgets/Runtime/widgets/overlay.cs


(RenderBox child) => child.getMaxIntrinsicHeight(width));
}
protected override float? computeDistanceToActualBaseline(TextBaseline baseline) {
public override float? computeDistanceToActualBaseline(TextBaseline baseline) {
D.assert(!debugNeedsLayout);
float? result = null;
RenderBox child = _firstOnstageChild;

1001
com.unity.uiwidgets/Runtime/material/toggle_buttons.cs
文件差异内容过多而无法显示
查看文件

252
com.unity.uiwidgets/Runtime/material/toggle_buttons_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class ToggleButtonsThemeData : Diagnosticable,IEquatable<ToggleButtonsThemeData> {
public ToggleButtonsThemeData(
TextStyle textStyle = null,
BoxConstraints constraints = null,
Color color = null,
Color selectedColor = null,
Color disabledColor = null,
Color fillColor = null,
Color focusColor = null,
Color highlightColor = null,
Color hoverColor = null,
Color splashColor = null,
Color borderColor = null,
Color selectedBorderColor = null,
Color disabledBorderColor = null,
BorderRadius borderRadius = null,
float? borderWidth = null
) {
this.textStyle = textStyle;
this.constraints = constraints;
this.color = color;
this.selectedColor = selectedColor;
this.disabledColor = disabledColor;
this.fillColor = fillColor;
this.focusColor = focusColor;
this.highlightColor = highlightColor;
this.hoverColor = hoverColor;
this.splashColor = splashColor;
this.borderColor = borderColor;
this.selectedBorderColor = selectedBorderColor;
this.disabledBorderColor = disabledBorderColor;
this.borderRadius = borderRadius;
this.borderWidth = borderWidth;
}
public readonly TextStyle textStyle;
public readonly BoxConstraints constraints;
public readonly Color color;
public readonly Color selectedColor;
public readonly Color disabledColor;
public readonly Color fillColor;
public readonly Color focusColor;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly Color hoverColor;
public readonly Color borderColor;
public readonly Color selectedBorderColor;
public readonly Color disabledBorderColor;
public readonly float? borderWidth;
public readonly BorderRadius borderRadius;
public ToggleButtonsThemeData copyWith(
TextStyle textStyle = null,
BoxConstraints constraints = null,
Color color = null,
Color selectedColor = null,
Color disabledColor = null,
Color fillColor = null,
Color focusColor = null,
Color highlightColor = null,
Color splashColor = null,
Color hoverColor = null,
Color borderColor = null,
Color selectedBorderColor = null,
Color disabledBorderColor = null,
BorderRadius borderRadius = null,
float? borderWidth = null) {
return new ToggleButtonsThemeData(
textStyle: textStyle ?? this.textStyle,
constraints: constraints ?? this.constraints,
color: color ?? this.color,
selectedColor: selectedColor ?? this.selectedColor,
disabledColor: disabledColor ?? this.disabledColor,
fillColor: fillColor ?? this.fillColor,
focusColor: focusColor ?? this.focusColor,
highlightColor: highlightColor ?? this.highlightColor,
hoverColor: hoverColor ?? this.hoverColor,
splashColor: splashColor ?? this.splashColor,
borderColor: borderColor ?? this.borderColor,
selectedBorderColor: selectedBorderColor ?? this.selectedBorderColor,
disabledBorderColor: disabledBorderColor ?? this.disabledBorderColor,
borderRadius: borderRadius ?? this.borderRadius,
borderWidth: borderWidth ?? this.borderWidth
);
}
public static ToggleButtonsThemeData lerp(ToggleButtonsThemeData a, ToggleButtonsThemeData b, float t) {
if (a == null && b == null) {
return null;
}
return new ToggleButtonsThemeData(
textStyle: TextStyle.lerp(a?.textStyle, b?.textStyle, t),
constraints: BoxConstraints.lerp(a?.constraints, b?.constraints, t),
color: Color.lerp(a?.color, b?.color, t),
selectedColor: Color.lerp(a?.selectedColor, b?.selectedColor, t),
disabledColor: Color.lerp(a?.disabledColor, b?.disabledColor, t),
fillColor: Color.lerp(a?.fillColor, b?.fillColor, t),
focusColor: Color.lerp(a?.focusColor, b?.focusColor, t),
highlightColor: Color.lerp(a?.highlightColor, b?.highlightColor, t),
hoverColor: Color.lerp(a?.hoverColor, b?.hoverColor, t),
splashColor: Color.lerp(a?.splashColor, b?.splashColor, t),
borderColor: Color.lerp(a?.borderColor, b?.borderColor, t),
selectedBorderColor: Color.lerp(a?.selectedBorderColor, b?.selectedBorderColor, t),
disabledBorderColor: Color.lerp(a?.disabledBorderColor, b?.disabledBorderColor, t),
borderRadius: BorderRadius.lerp(a?.borderRadius, b?.borderRadius, t),
borderWidth: MathUtils.lerpNullableFloat(a?.borderWidth, b?.borderWidth, t)
);
}
public bool Equals(ToggleButtonsThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return textStyle.Equals(other.textStyle)
&& constraints.Equals(other.constraints)
&& color.Equals(other.color)
&& selectedColor.Equals(other.selectedColor)
&& disabledColor.Equals(other.disabledColor)
&& fillColor.Equals(other.fillColor)
&& focusColor.Equals(other.focusColor)
&& highlightColor.Equals(other.highlightColor)
&& hoverColor.Equals(other.hoverColor)
&& splashColor.Equals(other.splashColor)
&& borderColor.Equals(other.borderColor)
&& selectedBorderColor.Equals(other.selectedBorderColor)
&& disabledBorderColor.Equals(other.disabledBorderColor)
&& borderRadius.Equals(other.borderRadius)
&& borderWidth.Equals(other.borderWidth);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((ToggleButtonsThemeData) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (textStyle != null ? textStyle.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (constraints != null ? constraints.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (color != null ? color.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (selectedColor != null ? selectedColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (disabledColor != null ? disabledColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (fillColor != null ? fillColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (focusColor != null ? focusColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (highlightColor != null ? highlightColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (hoverColor != null ? hoverColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (splashColor != null ? splashColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (borderColor != null ? borderColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (selectedBorderColor != null ? selectedBorderColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (disabledBorderColor != null ? disabledBorderColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (borderRadius != null ? borderRadius.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (borderWidth != null ? borderWidth.GetHashCode() : 0);
return hashCode;
}
}
public static bool operator ==(ToggleButtonsThemeData left, ToggleButtonsThemeData right) {
return Equals(left, right);
}
public static bool operator !=(ToggleButtonsThemeData left, ToggleButtonsThemeData right) {
return !Equals(left, right);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
textStyle?.debugFillProperties(properties, prefix: "textStyle.");
properties.add( new DiagnosticsProperty<BoxConstraints>("constraints", constraints, defaultValue: null));
properties.add( new ColorProperty("color", color, defaultValue: null));
properties.add( new ColorProperty("selectedColor", selectedColor, defaultValue: null));
properties.add( new ColorProperty("disabledColor", disabledColor, defaultValue: null));
properties.add( new ColorProperty("fillColor", fillColor, defaultValue: null));
properties.add( new ColorProperty("focusColor", focusColor, defaultValue: null));
properties.add( new ColorProperty("highlightColor", highlightColor, defaultValue: null));
properties.add( new ColorProperty("hoverColor", hoverColor, defaultValue: null));
properties.add( new ColorProperty("splashColor", splashColor, defaultValue: null));
properties.add( new ColorProperty("borderColor", borderColor, defaultValue: null));
properties.add( new ColorProperty("selectedBorderColor", selectedBorderColor, defaultValue: null));
properties.add( new ColorProperty("disabledBorderColor", disabledBorderColor, defaultValue: null));
properties.add( new DiagnosticsProperty<BorderRadius>("borderRadius", borderRadius, defaultValue: null));
properties.add( new FloatProperty("borderWidth", borderWidth, defaultValue: null));
}
}
public class ToggleButtonsTheme : InheritedTheme {
public ToggleButtonsTheme(
Key key = null,
ToggleButtonsThemeData data = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(data != null);
this.data = data;
}
public readonly ToggleButtonsThemeData data;
public static ToggleButtonsThemeData of(BuildContext context) {
ToggleButtonsTheme toggleButtonsTheme = context.dependOnInheritedWidgetOfExactType<ToggleButtonsTheme>();
return toggleButtonsTheme?.data ?? Theme.of(context).toggleButtonsTheme;
}
public override Widget wrap(BuildContext context, Widget child) {
ToggleButtonsTheme ancestorTheme = context.findAncestorWidgetOfExactType<ToggleButtonsTheme>();
return ReferenceEquals(this, ancestorTheme) ? child : new ToggleButtonsTheme(data: data, child: child);
}
public override bool updateShouldNotify(InheritedWidget oldWidget) {
D.assert(oldWidget is ToggleButtonsTheme);
return data != ((ToggleButtonsTheme)oldWidget).data;
}
}
}
正在加载...
取消
保存