浏览代码

Merge branches 'kgdev' and 'master' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into kgdev

# Conflicts:
#	Runtime/ui/painting/painting.cs
/main
kg 6 年前
当前提交
7197dd45
共有 55 个文件被更改,包括 7088 次插入134 次删除
  1. 1
      .editorconfig
  2. 7
      Runtime/animation/animation.cs
  3. 15
      Runtime/animation/tween.cs
  4. 148
      Runtime/painting/text_style.cs
  5. 74
      Runtime/rendering/box.cs
  6. 550
      Runtime/rendering/proxy_box.cs
  7. 9
      Runtime/ui/geometry.cs
  8. 24
      Runtime/ui/painting/painting.cs
  9. 193
      Runtime/widgets/basic.cs
  10. 14
      Runtime/widgets/icon_theme_data.cs
  11. 75
      Samples/UIWidgetSample/UIWidgetSample.unity
  12. 142
      Runtime/material/button.cs
  13. 11
      Runtime/material/button.cs.meta
  14. 507
      Runtime/material/button_theme.cs
  15. 11
      Runtime/material/button_theme.cs.meta
  16. 349
      Runtime/material/color_scheme.cs
  17. 11
      Runtime/material/color_scheme.cs.meta
  18. 662
      Runtime/material/colors.cs
  19. 11
      Runtime/material/colors.cs.meta
  20. 26
      Runtime/material/constants.cs
  21. 11
      Runtime/material/constants.cs.meta
  22. 51
      Runtime/material/debug.cs
  23. 11
      Runtime/material/debug.cs.meta
  24. 228
      Runtime/material/ink_decoration.cs
  25. 11
      Runtime/material/ink_decoration.cs.meta
  26. 124
      Runtime/material/ink_highlight.cs
  27. 11
      Runtime/material/ink_highlight.cs.meta
  28. 173
      Runtime/material/ink_splash.cs
  29. 11
      Runtime/material/ink_splash.cs.meta
  30. 364
      Runtime/material/ink_well.cs
  31. 11
      Runtime/material/ink_well.cs.meta
  32. 492
      Runtime/material/material.cs
  33. 11
      Runtime/material/material.cs.meta
  34. 131
      Runtime/material/material_button.cs
  35. 11
      Runtime/material/material_button.cs.meta
  36. 365
      Runtime/material/text_theme.cs
  37. 11
      Runtime/material/text_theme.cs.meta
  38. 134
      Runtime/material/theme.cs
  39. 11
      Runtime/material/theme.cs.meta
  40. 765
      Runtime/material/theme_data.cs
  41. 11
      Runtime/material/theme_data.cs.meta
  42. 449
      Runtime/material/typography.cs
  43. 11
      Runtime/material/typography.cs.meta
  44. 77
      Runtime/material/utils.cs
  45. 11
      Runtime/material/utils.cs.meta
  46. 63
      Runtime/painting/colors.cs
  47. 11
      Runtime/painting/colors.cs.meta
  48. 169
      Runtime/service/system_chrome.cs
  49. 11
      Runtime/service/system_chrome.cs.meta
  50. 353
      Runtime/widgets/implicit_animations.cs
  51. 11
      Runtime/widgets/implicit_animations.cs.meta
  52. 177
      Runtime/widgets/layout_builder.cs
  53. 11
      Runtime/widgets/layout_builder.cs.meta
  54. 69
      Samples/UIWidgetSample/MaterialCanvas.cs
  55. 11
      Samples/UIWidgetSample/MaterialCanvas.cs.meta

1
.editorconfig


# don't use 'private' whenever possible
csharp_default_private_modifier=implicit
csharp_default_internal_modifier=implicit
# not requirement for converting named arguments into positioned arguments whenever possible

7
Runtime/animation/animation.cs


D.assert(icon != null);
return icon;
}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<double>);
return child.animate(this as Animation<double>);
}
}
}

15
Runtime/animation/tween.cs


this.end = end;
}
public readonly T begin;
public T begin;
public readonly T end;
public T end;
public abstract T lerp(double t);

if (ReferenceEquals(null, other)) {
return false;
}
return EqualityComparer<T>.Default.Equals(this.begin, other.begin) &&
EqualityComparer<T>.Default.Equals(this.end, other.end);
}

return false;
}
return this.Equals((Tween<T>) obj);
}

}
public class DoubleTween : Tween<double> {
public DoubleTween(int begin, int end) : base(begin: begin, end: end) {
public DoubleTween(double begin, double end) : base(begin: begin, end: end) {
}
public override double lerp(double t) {

return (this.begin + (this.end - this.begin) * t);
}
}
public class CurveTween : Animatable<double> {
public CurveTween(Curve curve = null) {
D.assert(curve != null);

return $"{this.GetType()}(curve: {this.curve})";
}
}
}
}

148
Runtime/painting/text_style.cs


);
}
public TextStyle apply(
Color color = null,
TextDecoration decoration = null,
Color decorationColor = null,
TextDecorationStyle? decorationStyle = null,
string fontFamily = null,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
int fontWeightDelta = 0,
double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0,
double heightFactor = 1.0,
double heightDelta = 0.0
) {
D.assert(this.fontSize != null || (fontSizeFactor == 1.0 && fontSizeDelta == 0.0));
D.assert(this.fontWeight != null || fontWeightDelta == 0.0);
D.assert(this.letterSpacing != null || (letterSpacingFactor == 1.0 && letterSpacingDelta == 0.0));
D.assert(this.wordSpacing != null || (wordSpacingFactor == 1.0 && wordSpacingDelta == 0.0));
D.assert(heightFactor != null || (heightFactor == 1.0 && heightDelta == 0.0));
string modifiedDebugLabel = "";
D.assert(() => {
if (this.debugLabel != null)
modifiedDebugLabel = this.debugLabel + ".apply";
return true;
});
return new TextStyle(
inherit: this.inherit,
color: color ?? this.color,
fontFamily: fontFamily ?? this.fontFamily,
fontSize: this.fontSize == null ? null : this.fontSize * fontSizeFactor + fontSizeDelta,
fontWeight: this.fontWeight == null ? null : this.fontWeight,
fontStyle: this.fontStyle,
letterSpacing: this.letterSpacing == null
? null
: this.letterSpacing * letterSpacingFactor + letterSpacingDelta,
wordSpacing: this.wordSpacing == null ? null : this.wordSpacing * wordSpacingFactor + wordSpacingDelta,
textBaseline: this.textBaseline,
height: this.height == null ? null : this.height * heightFactor + heightDelta,
background: this.background,
decoration: decoration ?? this.decoration,
decorationColor: decorationColor ?? this.decorationColor,
decorationStyle: decorationStyle ?? this.decorationStyle,
debugLabel: modifiedDebugLabel
);
}
public TextStyle merge(TextStyle other) {
if (other == null) {
return this;

);
}
public TextStyle copyWith(Color color,
string fontFamily,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? letterSpacing,
double? wordSpacing,
public TextStyle copyWith(Color color = null,
string fontFamily = null,
double? fontSize = null,
FontWeight? fontWeight = null,
FontStyle? fontStyle = null,
double? letterSpacing = null,
double? wordSpacing = null,
TextBaseline? textBaseline = null,
double? height = null,
Paint background = null,

);
}
public static TextStyle lerp(TextStyle a, TextStyle b, double t) {
D.assert(t != null);
D.assert(a == null || b == null || a.inherit == b.inherit);
if (a == null && b == null) {
return null;
}
string lerpDebugLabel = "";
D.assert(() => {
lerpDebugLabel = "lerp" + (a?.debugLabel ?? _kDefaultDebugLabel) + "-" + t + "-" +
(b?.debugLabel ?? _kDefaultDebugLabel);
return true;
});
if (a == null) {
return new TextStyle(
inherit: b.inherit,
color: Color.lerp(null, b.color, t),
fontFamily: t < 0.5 ? null : b.fontFamily,
fontSize: t < 0.5 ? null : b.fontSize,
fontWeight: t < 0.5 ? null : b.fontWeight,
fontStyle: t < 0.5 ? null : b.fontStyle,
letterSpacing: t < 0.5 ? null : b.letterSpacing,
wordSpacing: t < 0.5 ? null : b.wordSpacing,
textBaseline: t < 0.5 ? null : b.textBaseline,
height: t < 0.5 ? null : b.height,
background: t < 0.5 ? null : b.background,
decoration: t < 0.5 ? null : b.decoration,
decorationColor: Color.lerp(null, b.decorationColor, t),
decorationStyle: t < 0.5 ? null : b.decorationStyle,
debugLabel: lerpDebugLabel
);
}
if (b == null) {
return new TextStyle(
inherit: a.inherit,
color: Color.lerp(a.color, null, t),
fontFamily: t < 0.5 ? a.fontFamily : null,
fontSize: t < 0.5 ? a.fontSize : null,
fontWeight: t < 0.5 ? a.fontWeight : null,
fontStyle: t < 0.5 ? a.fontStyle : null,
letterSpacing: t < 0.5 ? a.letterSpacing : null,
wordSpacing: t < 0.5 ? a.wordSpacing : null,
textBaseline: t < 0.5 ? a.textBaseline : null,
height: t < 0.5 ? a.height : null,
background: t < 0.5 ? a.background : null,
decoration: t < 0.5 ? a.decoration : null,
decorationColor: Color.lerp(a.decorationColor, null, t),
decorationStyle: t < 0.5 ? a.decorationStyle : null,
debugLabel: lerpDebugLabel
);
}
return new TextStyle(
inherit: b.inherit,
color: Color.lerp(a.color, b.color, t),
fontFamily: t < 0.5 ? a.fontFamily : b.fontFamily,
fontSize: MathUtils.lerpNullableDouble(a.fontSize ?? b.fontSize, b.fontSize ?? a.fontSize, t),
fontWeight: t < 0.5 ? a.fontWeight : b.fontWeight,
fontStyle: t < 0.5 ? a.fontStyle : b.fontStyle,
letterSpacing: MathUtils.lerpNullableDouble(a.letterSpacing ?? b.letterSpacing,
b.letterSpacing ?? a.letterSpacing, t),
wordSpacing: MathUtils.lerpNullableDouble(a.wordSpacing ?? b.wordSpacing,
b.wordSpacing ?? a.wordSpacing, t),
textBaseline: t < 0.5 ? a.textBaseline : b.textBaseline,
height: MathUtils.lerpNullableDouble(a.height ?? b.height, b.height ?? a.height, t),
background: t < 0.5 ? a.background : b.background,
decoration: t < 0.5 ? a.decoration : b.decoration,
decorationColor: Color.lerp(a.decorationColor, b.decorationColor, t),
decorationStyle: t < 0.5 ? a.decorationStyle : b.decorationStyle,
debugLabel: lerpDebugLabel
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);

if (this.decoration != null) {
decorationDescription.Add("$decoration");
}
D.assert(decorationDescription.isNotEmpty);
styles.Add(new MessageProperty("decoration", string.Join(" ", decorationDescription.ToArray())));
}

if (ReferenceEquals(null, other)) {
return false;
}
return this.inherit == other.inherit && Equals(this.color, other.color) &&
this.fontSize.Equals(other.fontSize) && this.fontWeight == other.fontWeight &&
this.fontStyle == other.fontStyle && this.letterSpacing.Equals(other.letterSpacing) &&

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((TextStyle) obj);
}

return this.GetType().FullName;
}
}
}
}

74
Runtime/rendering/box.cs


);
}
public static BoxConstraints lerp(BoxConstraints a, BoxConstraints b, double t) {
if (a == null && b == null)
return null;
if (a == null)
return b * t;
if (b == null)
return a * (1.0 - t);
D.assert(a.debugAssertIsValid());
D.assert(b.debugAssertIsValid());
D.assert(
(a.minWidth.isFinite() && b.minWidth.isFinite()) ||
(a.minWidth == double.PositiveInfinity && b.minWidth == double.PositiveInfinity),
"Cannot interpolate between finite constraints and unbounded constraints.");
D.assert(
(a.maxWidth.isFinite() && b.maxWidth.isFinite()) ||
(a.maxWidth == double.PositiveInfinity && b.maxWidth == double.PositiveInfinity),
"Cannot interpolate between finite constraints and unbounded constraints.");
D.assert(
(a.minHeight.isFinite() && b.minHeight.isFinite()) ||
(a.minHeight == double.PositiveInfinity && b.minHeight == double.PositiveInfinity),
"Cannot interpolate between finite constraints and unbounded constraints.");
D.assert(
(a.maxHeight.isFinite() && b.maxHeight.isFinite()) ||
(a.maxHeight == double.PositiveInfinity && b.maxHeight == double.PositiveInfinity),
"Cannot interpolate between finite constraints and unbounded constraints.");
return new BoxConstraints(
minWidth: a.minWidth.isFinite()
? MathUtils.lerpDouble(a.minWidth, b.minWidth, t)
: double.PositiveInfinity,
maxWidth: a.maxWidth.isFinite()
? MathUtils.lerpDouble(a.maxWidth, b.maxWidth, t)
: double.PositiveInfinity,
minHeight: a.minHeight.isFinite()
? MathUtils.lerpDouble(a.minHeight, b.minHeight, t)
: double.PositiveInfinity,
maxHeight: a.maxHeight.isFinite()
? MathUtils.lerpDouble(a.maxHeight, b.maxHeight, t)
: double.PositiveInfinity
);
}
public override bool isNormalized {
get {
return this.minWidth >= 0.0 &&

string whichFields;
if (affectedFieldsList.Count > 2) {
whichFields = string.Join(", ", affectedFieldsList.ToArray());
} else if (affectedFieldsList.Count == 2) {
}
else if (affectedFieldsList.Count == 2) {
} else {
}
else {
whichFields = affectedFieldsList.Single();
}

if (ReferenceEquals(null, other)) {
return false;
}
return this.minWidth.Equals(other.minWidth)
&& this.maxWidth.Equals(other.maxWidth)
&& this.minHeight.Equals(other.minHeight)

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((BoxConstraints) obj);
}

if (ReferenceEquals(null, other)) {
return false;
}
return this.dimension == other.dimension && this.argument.Equals(other.argument);
}

}
return this.Equals((_IntrinsicDimensionsCacheEntry) obj);
}

D.assert(this.sizedByParent);
violation = "It appears that the size setter was called from performLayout().";
hint = "";
} else {
}
else {
violation =
"The size setter was called from outside layout (neither performResize() nor performLayout() were being run for this object).";
if (this.owner != null && this.owner.debugDoingLayout) {

if (this.sizedByParent) {
contract =
"Because this RenderBox has sizedByParent set to true, it must set its size in performResize().";
} else {
}
else {
contract =
"Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().";
}

if (this.sizedByParent) {
contract =
"Because this RenderBox has sizedByParent set to true, it must set its size in performResize().\n";
} else {
}
else {
contract =
"Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().\n";
}

if (D.debugPaintPointersEnabled) {
if (evt is PointerDownEvent) {
this._debugActivePointers += 1;
} else if (evt is PointerUpEvent || evt is PointerCancelEvent) {
}
else if (evt is PointerUpEvent || evt is PointerCancelEvent) {
this._debugActivePointers -= 1;
}

candidate += childParentData.offset.dy;
if (result != null) {
result = Math.Min(result.Value, candidate.Value);
} else {
}
else {
result = candidate;
}
}

return result;
}
}
}
}

550
Runtime/rendering/proxy_box.cs


if (this.child != null) {
this.child.layout(this._additionalConstraints.enforce(this.constraints), parentUsesSize: true);
this.size = this.child.size;
} else {
}
else {
this.size = this._additionalConstraints.enforce(this.constraints).constrain(Size.zero);
}
}

if (this.child != null) {
this.child.layout(this._limitConstraints(this.constraints), parentUsesSize: true);
this.size = this.constraints.constrain(this.child.size);
} else {
}
else {
this.size = this._limitConstraints(this.constraints).constrain(Size.zero);
}
}

if (!double.IsInfinity(height)) {
return height * this._aspectRatio;
}
return 0.0;
}

}
if (this.child != null) {
return this.child.getMaxIntrinsicWidth(height);
}

if (!double.IsInfinity(width)) {
return width / this._aspectRatio;
}
if (this.child != null) {
return this.child.getMinIntrinsicHeight(width);
}

if (!double.IsInfinity(width)) {
return width / this._aspectRatio;
}
if (this.child != null) {
return this.child.getMaxIntrinsicHeight(width);
}

}
double _opacity;
public double opacity {
get { return this._opacity; }
set {

}
public class RenderAnimatedOpacity : RenderProxyBox {
RenderBox child = null
RenderBox child = null
) : base(child) {
D.assert(opacity != null);
this.opacity = opacity;

int _alpha;
public Animation<double> opacity {
public Animation<double> opacity {
get => this._opacity;
set {
D.assert(value != null);

this._updateOpacity();
}
}
public override void attach(object owner) {
base.attach(owner);
this._opacity.addListener(this._updateOpacity);

this._alpha = RenderOpacity._getAlphaFromOpacity(this._opacity.value.clamp(0.0, 1.0));
if (oldAlpha != this._alpha) {
bool didNeedCompositing = this._currentlyNeedsCompositing;
this._currentlyNeedsCompositing = this._alpha > 0 &&this. _alpha < 255;
this._currentlyNeedsCompositing = this._alpha > 0 && this._alpha < 255;
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
if (this._alpha == 0)

return;
}
}
}
}
public abstract class CustomClipper<T> {
public CustomClipper(Listenable reclip = null) {
this._reclip = reclip;
}
public readonly Listenable _reclip;
public abstract T getClip(Size size);
public Rect getApproximateClipRect(Size size) => Offset.zero & size;
public abstract bool shouldReclip(CustomClipper<T> oldClipper);
public string toString() => this.GetType() + "";
}
public class ShapeBorderClipper : CustomClipper<Path> {
public ShapeBorderClipper(
ShapeBorder shape = null) {
D.assert(shape != null);
this.shape = shape;
}
public readonly ShapeBorder shape;
public override Path getClip(Size size) {
return this.shape.getOuterPath(Offset.zero & size);
}
public override bool shouldReclip(CustomClipper<Path> oldClipper) {
if (oldClipper.GetType() != this.GetType())
return true;
ShapeBorderClipper typedOldClipper = (ShapeBorderClipper) oldClipper;
return typedOldClipper.shape != this.shape;
}
}
public abstract class _RenderCustomClip<T> : RenderProxyBox where T : class {
protected _RenderCustomClip(
RenderBox child = null,
CustomClipper<T> clipper = null,
Clip clipBehavior = Clip.antiAlias) : base(child: child) {
this.clipBehavior = clipBehavior;
this._clipper = clipper;
}
public CustomClipper<T> clipper {
get { return this._clipper; }
set {
if (this._clipper == value)
return;
CustomClipper<T> oldClipper = this._clipper;
this._clipper = value;
D.assert(value != null || oldClipper != null);
if (value == null || oldClipper == null ||
value.GetType() != oldClipper.GetType() ||
value.shouldReclip(oldClipper)) {
this._markNeedsClip();
}
if (this.attached) {
oldClipper?._reclip?.removeListener(this._markNeedsClip);
value?._reclip?.addListener(this._markNeedsClip);
}
}
}
protected CustomClipper<T> _clipper;
public override void attach(object owner) {
base.attach(owner);
this._clipper?._reclip?.addListener(this._markNeedsClip);
}
public override void detach() {
this._clipper?._reclip?.removeListener(this._markNeedsClip);
base.detach();
}
protected void _markNeedsClip() {
this._clip = null;
this.markNeedsPaint();
}
protected abstract T _defaultClip { get; }
protected T _clip;
public readonly Clip clipBehavior;
protected override void performLayout() {
Size oldSize = this.hasSize ? this.size : null;
base.performLayout();
if (oldSize != this.size)
this._clip = null;
}
protected void _updateClip() {
this._clip = this._clip ?? this._clipper?.getClip(this.size) ?? this._defaultClip;
}
public override Rect describeApproximatePaintClip(RenderObject child) {
return this._clipper?.getApproximateClipRect(this.size) ?? Offset.zero & this.size;
}
Paint _debugPaint;
TextPainter _debugText;
protected override void debugPaintSize(PaintingContext context, Offset offset) {
D.assert(() => {
// if (this._debugPaint == null) {
// this._debugPaint = new Paint();
// this._debugPaint.shader = Gradient.linear(
// new Offset(0.0, 0.0),
// new Offset(10.0, 10.0),
// new Color(0x00000000),
// new Color(0xFFFF00FF),
// TileMode.repeated);
// this._debugPaint.strokeWidth = 2.0;
// this._debugPaint.style = PaintingStyle.stroke;
// }
// if (this._debugText == null) {
// this._debugText = new TextPainter(
// text: new TextSpan(
// text: "x",
// style: new TextStyle(
// color: new Color(0xFFFF00FF),
// fontSize: 14.0)
// ));
// this._debugText.layout();
// }
return true;
});
}
}
public abstract class _RenderPhysicalModelBase<T> : _RenderCustomClip<T> where T : class {
public _RenderPhysicalModelBase(
RenderBox child = null,
double? elevation = null,
Color color = null,
Color shadowColor = null,
Clip clipBehavior = Clip.none,
CustomClipper<T> clipper = null
) : base(child: child, clipBehavior: clipBehavior, clipper: clipper) {
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
this._elevation = elevation ?? 0.0;
this._color = color;
this._shadowColor = shadowColor;
}
public double elevation {
get { return this._elevation; }
set {
if (this.elevation == value)
return;
bool didNeedCompositing = this.alwaysNeedsCompositing;
this._elevation = value;
if (didNeedCompositing != this.alwaysNeedsCompositing)
this.markNeedsCompositingBitsUpdate();
this.markNeedsPaint();
}
}
double _elevation;
public Color shadowColor {
get { return this._shadowColor; }
set {
D.assert(value != null);
if (this.shadowColor == value)
return;
this._shadowColor = value;
this.markNeedsPaint();
}
}
Color _shadowColor;
public Color color {
get { return this._color; }
set {
D.assert(value != null);
if (this.color == value)
return;
this._color = value;
this.markNeedsPaint();
}
}
Color _color;
static Paint _transparentPaint => new Paint {color = new Color(0x00000000)};
protected override bool alwaysNeedsCompositing => this._elevation != 0.0;
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DoubleProperty("elevation", this.elevation));
description.add(new DiagnosticsProperty<Color>("color", this.color));
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class RenderPhysicalModel : _RenderPhysicalModelBase<RRect> {
public RenderPhysicalModel(
RenderBox child = null,
BoxShape shape = BoxShape.rectangle,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double elevation = 0.0,
Color color = null,
Color shadowColor = null
) : base(clipBehavior: clipBehavior, child: child, elevation: elevation, color: color,
shadowColor: shadowColor ?? new Color(0xFF000000)) {
D.assert(color != null);
this._shape = shape;
this._borderRadius = borderRadius;
}
public BoxShape shape {
get { return this._shape; }
set {
if (this.shape == value)
return;
this._shape = value;
this._markNeedsClip();
}
}
BoxShape _shape;
public BorderRadius borderRadius {
get { return this._borderRadius; }
set {
if (this.borderRadius == value)
return;
this._borderRadius = value;
this._markNeedsClip();
}
}
BorderRadius _borderRadius;
protected override RRect _defaultClip {
get {
D.assert(this.hasSize);
switch (this._shape) {
case BoxShape.rectangle:
return (this.borderRadius ?? BorderRadius.zero).toRRect(Offset.zero & this.size);
case BoxShape.circle:
Rect rect = Offset.zero & this.size;
return RRect.fromRectXY(rect, rect.width / 2, rect.height / 2);
}
return null;
}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position))
return false;
}
return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
RRect offsetRRect = this._clip.shift(offset);
Rect offsetBounds = offsetRRect.outerRect;
Path offsetRRectAsPath = new Path();
offsetRRectAsPath.addRRect(offsetRRect);
Canvas canvas = context.canvas;
if (this.elevation != 0.0) {
//draw Shadow
/*canvas.drawRect(
offsetBounds.inflate(20.0),
_RenderPhysicalModelBase<RRect>._transparentPaint
);
canvas.drawShadow(
offsetRRectAsPath,
this.shadowColor,
this.elevation,
this.color.alpha != 0xFF
);*/
}
Paint paint = new Paint {color = this.color};
canvas.drawRRect(offsetRRect, paint);
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds,
() => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<BoxShape>("shape", this.shape));
description.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius));
}
}
public class RenderPhysicalShape : _RenderPhysicalModelBase<Path> {
public RenderPhysicalShape(
RenderBox child = null,
CustomClipper<Path> clipper = null,
Clip clipBehavior = Clip.none,
double elevation = 0.0,
Color color = null,
Color shadowColor = null
) : base(child: child,
elevation = elevation,
color: color,
shadowColor: shadowColor ?? new Color(0xFF000000),
clipper: clipper,
clipBehavior: clipBehavior) {
D.assert(clipper != null);
D.assert(color != null);
}
protected override Path _defaultClip {
get {
Path path = new Path();
path.addRect(Offset.zero & this.size);
return path;
}
}
public override bool hitTest(HitTestResult result, Offset position = null) {
if (this._clipper != null) {
this._updateClip();
D.assert(this._clip != null);
if (!this._clip.contains(position))
return false;
}
return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();
Rect offsetBounds = offset & this.size;
Path offsetPath = new Path();
offsetPath.addPath(this._clip, offset);
Canvas canvas = context.canvas;
// if (this.elevation != 0.0 && paintShadows) {
// canvas.drawRect(
// offsetBounds.inflate(20.0),
// _RenderPhysicalModelBase<Path>._transparentPaint
// );
// canvas.drawShadow(
// offsetPath,
// this.shadowColor,
// this.elevation,
// this.color.alpha != 0xFF,
// );
// }
Paint paint = new Paint {color = this.color, style = PaintingStyle.fill};
canvas.drawPath(offsetPath, paint);
context.clipPathAndPaint(offsetPath, this.clipBehavior,
offsetBounds, () => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<CustomClipper<Path>>("clipper", this.clipper));
}
}
public enum DecorationPosition {

}
public void rotateZ(double degrees) {
this._transform.preRotate((float)degrees);
this._transform.preRotate((float) degrees);
this.markNeedsPaint();
}

Offset translation = null;
if (resolvedAlignment != null) {
translation = resolvedAlignment.alongSize(this.size);
translation = resolvedAlignment.alongSize(this.size);
result.preTranslate((float) translation.dx, (float) translation.dy);
}

if (childOffset == null) {
context.pushTransform(this.needsCompositing, offset, transform, base.paint);
} else {
}
else {
base.paint(context, offset + childOffset);
}
}

}
public class RenderFractionalTranslation : RenderProxyBox {
public RenderFractionalTranslation(
Offset translation = null,
bool transformHitTests = true,

this.markNeedsPaint();
}
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
D.assert(!this.debugNeedsLayout);
if (this.transformHitTests) {

);
}
public override void paint(PaintingContext context, Offset offset) {
D.assert(!this.debugNeedsLayout);
if (this.child != null) {

));
}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preTranslate((float)(this.translation.dx * this.size.width),
(float)(this.translation.dy * this.size.height));
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preTranslate((float) (this.translation.dx * this.size.width),
(float) (this.translation.dy * this.size.height));
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Offset>("translation", this.translation));
properties.add(new DiagnosticsProperty<bool>("transformHitTests", this.transformHitTests));
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Offset>("translation", this.translation));
properties.add(new DiagnosticsProperty<bool>("transformHitTests", this.transformHitTests));
}
}
public delegate void PointerDownEventListener(PointerDownEvent evt);

if (this.onPointerDown != null) {
listeners.Add("down");
}
if (listeners.isEmpty()) {
listeners.Add("<none>");
}

D.assert(() => {
if (includedParent && includedChild) {
this._debugSymmetricPaintCount += 1;
} else {
}
else {
this._debugAsymmetricPaintCount += 1;
}

inReleaseMode = false;
if (this.debugSymmetricPaintCount + this.debugAsymmetricPaintCount == 0) {
properties.add(new MessageProperty("usefulness ratio", "no metrics collected yet (never painted)"));
} else {
}
else {
double fraction = (double) this.debugAsymmetricPaintCount /
(this.debugSymmetricPaintCount + this.debugAsymmetricPaintCount);

} else if (fraction > 0.9) {
}
else if (fraction > 0.9) {
} else if (fraction > 0.5) {
}
else if (fraction > 0.5) {
} else if (fraction > 0.30) {
}
else if (fraction > 0.30) {
} else if (fraction > 0.1) {
}
else if (fraction > 0.1) {
} else if (this.debugAsymmetricPaintCount == 0) {
}
else if (this.debugAsymmetricPaintCount == 0) {
} else {
}
else {
diagnosis = "this repaint boundary is not very effective and should probably be removed";
}

public class RenderOffstage : RenderProxyBox {
public RenderOffstage(bool offstage = true,
RenderBox child = null): base(child) {
RenderBox child = null) : base(child) {
this._offstage = offstage;
}

this.markNeedsLayoutForSizedByParentChange();
}
}
protected override double computeMaxIntrinsicWidth(double height) {
if (this.offstage)
return 0.0;

protected override void performLayout() {
if (this.offstage) {
this.child?.layout(this.constraints);
} else {
}
else {
base.performLayout();
}
}

}
public override List<DiagnosticsNode> debugDescribeChildren() {
if (this.child == null)
return new List<DiagnosticsNode>();

};
}
}
) : base(child)
{
this._absorbing = absorbing;
}
) : base(child) {
this._absorbing = absorbing;
}
public bool absorbing
{
public bool absorbing {
set
{
this._absorbing = value;
}
set { this._absorbing = value; }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("absorbing", this.absorbing));
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("absorbing", this.absorbing));
}
public class RenderMetaData : RenderProxyBoxWithHitTestBehavior {
public RenderMetaData(
object metaData,

this.metaData = metaData;
}
public object metaData;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

}
}
}
}

9
Runtime/ui/geometry.cs


public static double lerpDouble(double a, double b, double t) {
return a + (b - a) * t;
}
public static double? lerpNullableDouble(double? a, double? b, double t) {
if (a == null && b == null) {
return null;
}
a = a ?? b;
b = b ?? a;
return (double) a + ((double) b - (double) a) * t;
}
public static float lerpFloat(float a, float b, float t) {
return a + (b - a) * t;

24
Runtime/ui/painting/painting.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using UnityEngine;
namespace Unity.UIWidgets.ui {

return fromARGB(this.alpha, this.red, this.green, b);
}
static double _linearizeColorComponent(double component) {
if (component <= 0.03928)
return component / 12.92;
return Math.Pow((component + 0.055) / 1.055, 2.4);
}
public double computeLuminance() {
double R = _linearizeColorComponent(this.red / 0xFF);
double G = _linearizeColorComponent(this.green / 0xFF);
double B = _linearizeColorComponent(this.blue / 0xFF);
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
}
public static Color lerp(Color a, Color b, double t) {
if (a == null && b == null) {
return null;

if (ReferenceEquals(null, other)) {
return false;
}
return this.value == other.value;
}

}
return this.Equals((Color) obj);
}

if (d > 0.0001f) {
dx /= d;
dy /= d;
} else {
}
else {
dx = 0;
dy = 1;
}

color,
luminosity,
}
}
}

193
Runtime/widgets/basic.cs


}
public class CustomPaint : SingleChildRenderObjectWidget {
public CustomPaint(
Key key = null,
CustomPainter painter = null,

public readonly Size size;
public readonly bool isComplex;
public readonly bool willChange;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderCustomPaint(
painter: this.painter,

willChange: this.willChange
);
}
((RenderCustomPaint)renderObject).willChange = this.willChange;
((RenderCustomPaint) renderObject).willChange = this.willChange;
((RenderCustomPaint)renderObject).painter = null;
((RenderCustomPaint)renderObject).foregroundPainter = null;
((RenderCustomPaint) renderObject).painter = null;
((RenderCustomPaint) renderObject).foregroundPainter = null;
}
}

string type;
if (this.width == double.PositiveInfinity && this.height == double.PositiveInfinity) {
type = this.GetType() + "expand";
} else if (this.width == 0.0 && this.height == 0.0) {
}
else if (this.width == 0.0 && this.height == 0.0) {
} else {
}
else {
type = this.GetType() + "";
}

if ((this.width == double.PositiveInfinity && this.height == double.PositiveInfinity) ||
(this.width == 0.0 && this.height == 0.0)) {
level = DiagnosticLevel.hidden;
} else {
}
else {
level = DiagnosticLevel.info;
}

}
public class Offstage : SingleChildRenderObjectWidget {
public Offstage(Key key = null, bool offstage = true, Widget child = null):base(key: key, child: child) {
public Offstage(Key key = null, bool offstage = true, Widget child = null) : base(key: key, child: child) {
((RenderOffstage)renderObject).offstage = this.offstage;
((RenderOffstage) renderObject).offstage = this.offstage;
class _OffstageElement: SingleChildRenderObjectElement {
internal _OffstageElement(Offstage widget) : base(widget) {}
class _OffstageElement : SingleChildRenderObjectElement {
internal _OffstageElement(Offstage widget) : base(widget) {
}
new Offstage widget => (Offstage) base.widget;

}
}
public class AspectRatio : SingleChildRenderObjectWidget {
public AspectRatio(
Key key = null,

right = end;
break;
}
return new Positioned(child, key: key, left: left, top: top, right: right, bottom: bottom, width: width,
height: height);
}

}
}
public class PhysicalModel : SingleChildRenderObjectWidget {
public PhysicalModel(
Key key = null,
BoxShape shape = BoxShape.rectangle,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double elevation = 0.0,
Color color = null,
Color shadowColor = null,
Widget child = null) : base(key: key, child: child) {
D.assert(color != null);
this.shape = shape;
this.clipBehavior = clipBehavior;
this.borderRadius = borderRadius;
this.elevation = elevation;
this.color = color;
this.shadowColor = shadowColor ?? new Color(0xFF000000);
}
public readonly BoxShape shape;
public readonly Clip clipBehavior;
public readonly BorderRadius borderRadius;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderPhysicalModel(
shape: this.shape,
clipBehavior: this.clipBehavior,
borderRadius: this.borderRadius,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderPhysicalModel _renderObject = (RenderPhysicalModel) renderObject;
_renderObject.shape = this.shape;
_renderObject.borderRadius = this.borderRadius;
_renderObject.elevation = this.elevation;
_renderObject.color = this.color;
_renderObject.shadowColor = this.shadowColor;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<BoxShape>("shape", this.shape));
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class PhysicalShape : SingleChildRenderObjectWidget {
public PhysicalShape(
Key key = null,
CustomClipper<Path> clipper = null,
Clip clipBehavior = Clip.none,
double elevation = 0.0,
Color color = null,
Color shadowColor = null,
Widget child = null) : base(key: key, child: child) {
D.assert(clipper != null);
D.assert(color != null);
this.clipper = clipper;
this.clipBehavior = clipBehavior;
this.elevation = elevation;
this.color = color;
this.shadowColor = shadowColor ?? new Color(0xFF000000);
}
public readonly CustomClipper<Path> clipper;
public readonly Clip clipBehavior;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderPhysicalShape(
clipper: this.clipper,
clipBehavior: this.clipBehavior,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderPhysicalShape _renderObject = (RenderPhysicalShape) renderObject;
_renderObject.clipper = this.clipper;
_renderObject.elevation = this.elevation;
_renderObject.color = this.color;
_renderObject.shadowColor = this.shadowColor;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<CustomClipper<Path>>("clipper", this.clipper));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class Padding : SingleChildRenderObjectWidget {
public Padding(
Key key = null,

bool transformHitTests = true, Widget child = null) : base(key: key, child: child) {
this.translation = translation;
this.transformHitTests = transformHitTests;
}
}
public override RenderObject createRenderObject(BuildContext context) {
return new RenderFractionalTranslation(
translation: this.translation,

((RenderFractionalTranslation)renderObject).translation = this.translation;
((RenderFractionalTranslation)renderObject).transformHitTests = this.transformHitTests;
((RenderFractionalTranslation) renderObject).translation = this.translation;
((RenderFractionalTranslation) renderObject).transformHitTests = this.transformHitTests;
public class Align : SingleChildRenderObjectWidget {
public Align(
Key key = null,

if (this.onPointerLeave != null) {
listeners.Add("leave");
}
properties.add(new EnumerableProperty<string>("listeners", listeners, ifEmpty: "<none>"));
properties.add(new EnumProperty<HitTestBehavior>("behavior", this.behavior));
}

}
public class AbsorbPointer : SingleChildRenderObjectWidget {
public override void updateRenderObject(BuildContext context, RenderObject renderObject)
{
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
public class MetaData : SingleChildRenderObjectWidget {
public MetaData(
object metaData,

return this.builder(context);
}
}
}
}

14
Runtime/widgets/icon_theme_data.cs


public readonly double? size;
public static IconThemeData lerp(IconThemeData a, IconThemeData b, double t) {
return new IconThemeData(
color: Color.lerp(a.color, b.color, t),
opacity: MathUtils.lerpNullableDouble(a.opacity, b.opacity, t),
size: MathUtils.lerpNullableDouble(a.size, b.size, t));
}
return Equals(this.color, other.color) &&
this._opacity.Equals(other._opacity) &&
this.size.Equals(other.size);

if (ReferenceEquals(null, obj)) {
return false;
}
return this.Equals((IconThemeData) obj);
}

defaultValue: Diagnostics.kNullDefaultValue));
}
}
}
}

75
Samples/UIWidgetSample/UIWidgetSample.unity


- {fileID: 895510406}
- {fileID: 1399904531}
- {fileID: 432951246}
- {fileID: 552752111}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &432951246
RectTransform:
m_ObjectHideFlags: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 484983222}
m_CullTransparentMesh: 0
--- !u!1 &552752110
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 552752111}
- component: {fileID: 552752113}
- component: {fileID: 552752112}
m_Layer: 5
m_Name: Material
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &552752111
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552752110}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 304189374}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &552752112
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552752110}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7c3be43dd8b94a349f26e3e7173c3f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!222 &552752113
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 552752110}
m_CullTransparentMesh: 0
--- !u!1 &554372217
GameObject:

142
Runtime/material/button.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 RawMaterialButton : StatefulWidget {
public RawMaterialButton(
Key key = null,
VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
TextStyle textStyle = null,
Color fillColor = null,
Color highlightColor = null,
Color splashColor = null,
double elevation = 2.0,
double highlightElevation = 8.0,
double disabledElevation = 0.0,
EdgeInsets padding = null,
BoxConstraints constraints = null,
ShapeBorder shape = null,
TimeSpan? animationDuration = null,
Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget child = null) : base(key: key) {
D.assert(onPressed != null);
MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
shape = shape ?? new RoundedRectangleBorder();
padding = padding ?? EdgeInsets.zero;
constraints = constraints ?? new BoxConstraints(minWidth: 88.0, minHeight: 36.0);
TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.onPressed = onPressed;
this.onHighlightChanged = onHighlightChanged;
this.textStyle = textStyle;
this.fillColor = fillColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.elevation = elevation;
this.highlightElevation = highlightElevation;
this.disabledElevation = disabledElevation;
this.padding = padding;
this.constraints = constraints;
this.shape = shape;
this.animationDuration = _animationDuration;
this.clipBehavior = clipBehavior;
this.materialTapTargetSize = _materialTapTargetSize;
this.child = child;
}
public readonly VoidCallback onPressed;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly TextStyle textStyle;
public readonly Color fillColor;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly double elevation;
public readonly double highlightElevation;
public readonly double disabledElevation;
public readonly EdgeInsets padding;
public readonly BoxConstraints constraints;
public readonly ShapeBorder shape;
public readonly TimeSpan animationDuration;
public readonly Widget child;
public bool enabled => this.onPressed != null;
public readonly MaterialTapTargetSize materialTapTargetSize;
public readonly Clip clipBehavior;
public override State createState() => new _RawMaterialButtonState();
}
class _RawMaterialButtonState : State<RawMaterialButton> {
bool _highlight = false;
void _handleHighlightChanged(bool value) {
this.setState(() => {
this._highlight = value;
if (this.widget.onHighlightChanged != null) {
this.widget.onHighlightChanged(value);
}
});
}
public override Widget build(BuildContext context) {
double elevation = this.widget.enabled
? (this._highlight ? this.widget.highlightElevation : this.widget.elevation)
: this.widget.disabledElevation;
Widget result = new ConstrainedBox(
constraints: this.widget.constraints,
child: new Material(
elevation: elevation,
textStyle: this.widget.textStyle,
shape: this.widget.shape,
color: this.widget.fillColor,
type: this.widget.fillColor == null ? MaterialType.transparency : MaterialType.button,
animationDuration: this.widget.animationDuration,
clipBehavior: this.widget.clipBehavior,
child: new InkWell(
onHighlightChanged: this._handleHighlightChanged,
splashColor: this.widget.splashColor,
highlightColor: this.widget.highlightColor,
onTap: () => this.widget.onPressed(),
customBorder: this.widget.shape,
child: IconTheme.merge(
data: new IconThemeData(color: this.widget.textStyle?.color),
child: new Container(
padding: this.widget.padding,
child: new Center(
widthFactor: 1.0,
heightFactor: 1.0,
child: this.widget.child)
)
)
)
)
);
return result;
}
}
}

11
Runtime/material/button.cs.meta


fileFormatVersion: 2
guid: 5452e0dd1a19646fda9cc8dc0b388ee4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

507
Runtime/material/button_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public enum ButtonTextTheme {
normal,
accent,
primary
}
public enum ButtonBarLayoutBehavior {
constrained,
padded
}
public class ButtonTheme : InheritedWidget {
public ButtonTheme(
Key key = null,
ButtonTextTheme textTheme = ButtonTextTheme.normal,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded,
double minWidth = 88.0,
double height = 36.0,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool alignedDropdown = false,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget child = null) : base(key: key, child: child) {
D.assert(minWidth >= 0.0);
D.assert(height >= 0.0);
this.data = new ButtonThemeData(
textTheme: textTheme,
minWidth: minWidth,
height: height,
padding: padding,
shape: shape,
alignedDropdown: alignedDropdown,
layoutBehavior: layoutBehavior,
buttonColor: buttonColor,
disabledColor: disabledColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorScheme: colorScheme,
materialTapTargetSize: materialTapTargetSize);
}
public ButtonTheme(
Key key = null,
ButtonThemeData data = null,
Widget child = null) : base(key: key, child: child) {
D.assert(data != null);
this.data = data;
}
public readonly ButtonThemeData data;
public static ButtonThemeData of(BuildContext context) {
ButtonTheme inheritedButtonTheme = (ButtonTheme) context.inheritFromWidgetOfExactType(typeof(ButtonTheme));
ButtonThemeData buttonTheme = inheritedButtonTheme?.data;
if (buttonTheme?.colorScheme == null) {
ThemeData theme = Theme.of(context);
buttonTheme = buttonTheme ?? theme.buttonTheme;
if (buttonTheme.colorScheme == null) {
buttonTheme = buttonTheme.copyWith(
colorScheme: theme.buttonTheme.colorScheme ?? theme.colorScheme);
D.assert(buttonTheme.colorScheme != null);
}
}
return buttonTheme;
}
public override bool updateShouldNotify(InheritedWidget oldWidget) =>
this.data != ((ButtonTheme) oldWidget).data;
}
public class ButtonThemeData : Diagnosticable {
public ButtonThemeData(
ButtonTextTheme textTheme = ButtonTextTheme.normal,
double minWidth = 88.0,
double height = 36.0,
EdgeInsets padding = null,
ShapeBorder shape = null,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded,
bool alignedDropdown = false,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
MaterialTapTargetSize? materialTapTargetSize = null
) {
D.assert(minWidth >= 0.0);
D.assert(height >= 0.0);
this.textTheme = textTheme;
this.minWidth = minWidth;
this.height = height;
this.layoutBehavior = layoutBehavior;
this.alignedDropdown = alignedDropdown;
this.colorScheme = colorScheme;
this._buttonColor = buttonColor;
this._disabledColor = disabledColor;
this._highlightColor = highlightColor;
this._splashColor = splashColor;
this._padding = padding;
this._shape = shape;
this._materialTapTargetSize = materialTapTargetSize;
}
public readonly double minWidth;
public readonly double height;
public readonly ButtonTextTheme textTheme;
public readonly ButtonBarLayoutBehavior layoutBehavior;
public BoxConstraints constraints {
get {
return new BoxConstraints(minWidth: this.minWidth,
minHeight: this.height);
}
}
public EdgeInsets padding {
get {
if (this._padding != null)
return this._padding;
switch (this.textTheme) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return EdgeInsets.symmetric(horizontal: 16.0);
case ButtonTextTheme.primary:
return EdgeInsets.symmetric(horizontal: 24.0);
}
D.assert(false);
return EdgeInsets.zero;
}
}
readonly EdgeInsets _padding;
public ShapeBorder shape {
get {
if (this._shape != null)
return this._shape;
switch (this.textTheme) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)));
case ButtonTextTheme.primary:
return new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0)));
}
return new RoundedRectangleBorder();
}
}
readonly ShapeBorder _shape;
public readonly bool alignedDropdown;
readonly Color _buttonColor;
readonly Color _disabledColor;
readonly Color _highlightColor;
readonly Color _splashColor;
public readonly ColorScheme colorScheme;
readonly MaterialTapTargetSize? _materialTapTargetSize;
public Brightness getBrightness(MaterialButton button) {
return button.colorBrightness ?? this.colorScheme.brightness;
}
public ButtonTextTheme getTextTheme(MaterialButton button) {
return button.textTheme ?? this.textTheme;
}
Color _getDisabledColor(MaterialButton button) {
return this.getBrightness(button) == Brightness.dark
? this.colorScheme.onSurface.withOpacity(0.30)
: this.colorScheme.onSurface.withOpacity(0.38);
}
Color getDisabledTextColor(MaterialButton button) {
if (button.disabledTextColor != null)
return button.disabledTextColor;
return this._getDisabledColor(button);
}
Color getDisabledFillColor(MaterialButton button) {
if (button.disabledColor != null)
return button.disabledColor;
if (this._disabledColor != null)
return this._disabledColor;
return this._getDisabledColor(button);
}
Color getFillColor(MaterialButton button) {
Color fillColor = button.enabled ? button.color : button.disabledColor;
if (fillColor != null)
return fillColor;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton & RaisedButton are ready
// if (button is FlatButton || button is OutlineButton)
// return null;
//
//
// if (button.enabled && button is RaisedButton && this._buttonColor != null)
// return this._buttonColor;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return button.enabled ? this.colorScheme.primary : this.getDisabledFillColor(button);
case ButtonTextTheme.primary:
return button.enabled
? this._buttonColor ?? this.colorScheme.primary
: this.colorScheme.onSurface.withOpacity(0.12);
}
D.assert(false);
return null;
}
public Color getTextColor(MaterialButton button) {
if (!button.enabled)
return this.getDisabledTextColor(button);
if (button.textColor != null)
return button.textColor;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
return this.getBrightness(button) == Brightness.dark ? Colors.white : Colors.black87;
case ButtonTextTheme.accent:
return this.colorScheme.secondary;
case ButtonTextTheme.primary: {
Color fillColor = this.getFillColor(button);
bool fillIsDark = fillColor != null
? ThemeData.estimateBrightnessForColor(fillColor) == Brightness.dark
: this.getBrightness(button) == Brightness.dark;
if (fillIsDark)
return Colors.white;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton are ready
// if (button is FlatButton || button is OutlineButton)
// return this.colorScheme.primary;
return Colors.black;
}
}
D.assert(false);
return null;
}
public Color getSplashColor(MaterialButton button) {
if (button.splashColor != null)
return button.splashColor;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton & RaisedButton are ready
// if (this._splashColor != null && (button is RaisedButton || button is OutlineButton)) {
// return this._splashColor;
// }
//
// if (this._splashColor != null && button is FlatButton) {
// switch (this.getTextTheme(button)) {
// case ButtonTextTheme.normal:
// case ButtonTextTheme.accent:
// return this._splashColor;
// case ButtonTextTheme.primary:
// break;
// }
// }
return this.getTextColor(button).withOpacity(0.12);
}
public Color getHighlightColor(MaterialButton button) {
if (button.highlightColor != null)
return button.highlightColor;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return this._highlightColor ?? this.getTextColor(button).withOpacity(0.16);
case ButtonTextTheme.primary:
return Colors.transparent;
}
D.assert(false);
return Colors.transparent;
}
public double getElevation(MaterialButton button) {
if (button.elevation != null)
return button.elevation ?? 0.0;
// todo xingwei.zhu: uncomment these when FlatButton are ready
// if (button is FlatButton)
// return 0.0;
return 2.0;
}
public double getHighlightElevation(MaterialButton button) {
if (button.highlightElevation != null)
return button.highlightElevation ?? 0.0;
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton are ready
// if (button is FlatButton)
// return 0.0;
// if (button is OutlineButton)
// return 2.0;
return 8.0;
}
public double getDisabledElevation(MaterialButton button) {
if (button.disabledElevation != null)
return button.disabledElevation ?? 0.0;
return 0.0;
}
public EdgeInsets getPadding(MaterialButton button) {
if (button.padding != null)
return button.padding;
// todo xingwei.zhu: uncomment these when MaterialButtonWithIconMixin are ready
// if (button is MaterialButtonWithIconMixin)
// return const EdgeInsetsDirectional.only(start: 12.0, end: 16.0);
if (this._padding != null)
return this._padding;
switch (this.getTextTheme(button)) {
case ButtonTextTheme.normal:
case ButtonTextTheme.accent:
return EdgeInsets.symmetric(horizontal: 16.0);
case ButtonTextTheme.primary:
return EdgeInsets.symmetric(horizontal: 24.0);
}
D.assert(false);
return EdgeInsets.zero;
}
public ShapeBorder getShape(MaterialButton button) {
return button.shape ?? this.shape;
}
public TimeSpan getAnimationDuration(MaterialButton button) {
return button.animationDuration ?? Constants.kThemeChangeDuration;
}
public BoxConstraints getConstraints(MaterialButton button) => this.constraints;
public MaterialTapTargetSize getMaterialTapTargetSize(MaterialButton button) {
return button.materialTapTargetSize ?? this._materialTapTargetSize ?? MaterialTapTargetSize.padded;
}
public ButtonThemeData copyWith(
ButtonTextTheme? textTheme = null,
ButtonBarLayoutBehavior? layoutBehavior = null,
double? minWidth = null,
double? height = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool? alignedDropdown = null,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
MaterialTapTargetSize? materialTapTargetSize = null) {
return new ButtonThemeData(
textTheme: textTheme ?? this.textTheme,
layoutBehavior: layoutBehavior ?? this.layoutBehavior,
minWidth: minWidth ?? this.minWidth,
height: height ?? this.height,
padding: padding ?? this.padding,
shape: shape ?? this.shape,
alignedDropdown: alignedDropdown ?? this.alignedDropdown,
buttonColor: buttonColor ?? this._buttonColor,
disabledColor: disabledColor ?? this._disabledColor,
highlightColor: highlightColor ?? this._highlightColor,
splashColor: splashColor ?? this._splashColor,
colorScheme: colorScheme ?? this.colorScheme,
materialTapTargetSize: materialTapTargetSize ?? this._materialTapTargetSize);
}
public bool Equals(ButtonThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.textTheme == other.textTheme
&& this.minWidth == other.minWidth
&& this.height == other.height
&& this.padding == other.padding
&& this.shape == other.shape
&& this.alignedDropdown == other.alignedDropdown
&& this._buttonColor == other._buttonColor
&& this._disabledColor == other._disabledColor
&& this._highlightColor == other._highlightColor
&& this._splashColor == other._splashColor
&& this.colorScheme == other.colorScheme
&& this._materialTapTargetSize == other._materialTapTargetSize;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ButtonThemeData) obj);
}
public static bool operator ==(ButtonThemeData left, ButtonThemeData right) {
return Equals(left, right);
}
public static bool operator !=(ButtonThemeData left, ButtonThemeData right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.textTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.minWidth.GetHashCode();
hashCode = (hashCode * 397) ^ this.height.GetHashCode();
hashCode = (hashCode * 397) ^ this.padding.GetHashCode();
hashCode = (hashCode * 397) ^ this.shape.GetHashCode();
hashCode = (hashCode * 397) ^ this.alignedDropdown.GetHashCode();
hashCode = (hashCode * 397) ^ this._buttonColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._disabledColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._highlightColor.GetHashCode();
hashCode = (hashCode * 397) ^ this._splashColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.colorScheme.GetHashCode();
hashCode = (hashCode * 397) ^ this._materialTapTargetSize.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
ButtonThemeData defaultTheme = new ButtonThemeData();
properties.add(new EnumProperty<ButtonTextTheme>("textTheme", this.textTheme,
defaultValue: defaultTheme.textTheme));
properties.add(new DoubleProperty("minWidth", this.minWidth, defaultValue: defaultTheme.minWidth));
properties.add(new DoubleProperty("height", this.height, defaultValue: defaultTheme.height));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding,
defaultValue: defaultTheme.padding));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: defaultTheme.shape));
properties.add(new FlagProperty("alignedDropdown",
value: this.alignedDropdown,
defaultValue: defaultTheme.alignedDropdown,
ifTrue: "dropdown width matches button"
));
properties.add(new DiagnosticsProperty<Color>("buttonColor", this._buttonColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledColor", this._disabledColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("highlightColor", this._highlightColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("splashColor", this._splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<ColorScheme>("colorScheme", this.colorScheme,
defaultValue: defaultTheme.colorScheme));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize?>("materialTapTargetSize",
this._materialTapTargetSize, defaultValue: null));
}
}
}

11
Runtime/material/button_theme.cs.meta


fileFormatVersion: 2
guid: c00e9535ad31f481cbe2b83d490d714d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

349
Runtime/material/color_scheme.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class ColorScheme : Diagnosticable {
public ColorScheme(
Color primary,
Color primaryVariant,
Color secondary,
Color secondaryVariant,
Color surface,
Color background,
Color error,
Color onPrimary,
Color onSecondary,
Color onSurface,
Color onBackground,
Color onError,
Brightness brightness) {
D.assert(primary != null);
D.assert(primaryVariant != null);
D.assert(secondary != null);
D.assert(secondaryVariant != null);
D.assert(surface != null);
D.assert(background != null);
D.assert(error != null);
D.assert(onPrimary != null);
D.assert(onSecondary != null);
D.assert(onSurface != null);
D.assert(onBackground != null);
D.assert(onError != null);
this.primary = primary;
this.primaryVariant = primaryVariant;
this.secondary = secondary;
this.secondaryVariant = secondaryVariant;
this.surface = surface;
this.background = background;
this.error = error;
this.onPrimary = onPrimary;
this.onSecondary = onSecondary;
this.onSurface = onSurface;
this.onBackground = onBackground;
this.onError = onError;
this.brightness = brightness;
}
public static ColorScheme light(
Color primary = null,
Color primaryVariant = null,
Color secondary = null,
Color secondaryVariant = null,
Color surface = null,
Color background = null,
Color error = null,
Color onPrimary = null,
Color onSecondary = null,
Color onSurface = null,
Color onBackground = null,
Color onError = null,
Brightness brightness = Brightness.light
) {
primary = primary ?? new Color(0xFF6200EE);
primaryVariant = primaryVariant ?? new Color(0xFF3700B3);
secondary = secondary ?? new Color(0xFF03DAC6);
secondaryVariant = secondaryVariant ?? new Color(0xFF018786);
surface = surface ?? Colors.white;
background = background ?? Colors.white;
error = error ?? new Color(0xFFB00020);
onPrimary = onPrimary ?? Colors.white;
onSecondary = onSecondary ?? Colors.black;
onSurface = onSurface ?? Colors.black;
onBackground = onBackground ?? Colors.black;
onError = onError ?? Colors.white;
return new ColorScheme(
primary: primary,
primaryVariant: primaryVariant,
secondary: secondary,
secondaryVariant: secondaryVariant,
surface: surface,
background: background,
error: error,
onPrimary: onPrimary,
onSecondary: onSecondary,
onSurface: onSurface,
onBackground: onBackground,
onError: onError,
brightness: brightness
);
}
public static ColorScheme dark(
Color primary = null,
Color primaryVariant = null,
Color secondary = null,
Color secondaryVariant = null,
Color surface = null,
Color background = null,
Color error = null,
Color onPrimary = null,
Color onSecondary = null,
Color onSurface = null,
Color onBackground = null,
Color onError = null,
Brightness brightness = Brightness.dark
) {
primary = primary ?? new Color(0xFFBB86FC);
primaryVariant = primaryVariant ?? new Color(0xFF4B01D0);
secondary = secondary ?? new Color(0xFF03DAC6);
secondaryVariant = secondaryVariant ?? new Color(0xFF03DAC6);
surface = surface ?? Colors.black;
background = background ?? Colors.black;
error = error ?? new Color(0xFFB00020);
onPrimary = onPrimary ?? Colors.black;
onSecondary = onSecondary ?? Colors.black;
onSurface = onSurface ?? Colors.white;
onBackground = onBackground ?? Colors.white;
onError = onError ?? Colors.black;
return new ColorScheme(
primary: primary,
primaryVariant: primaryVariant,
secondary: secondary,
secondaryVariant: secondaryVariant,
surface: surface,
background: background,
error: error,
onPrimary: onPrimary,
onSecondary: onSecondary,
onSurface: onSurface,
onBackground: onBackground,
onError: onError,
brightness: brightness
);
}
public static ColorScheme fromSwatch(
MaterialColor primarySwatch = null,
Color primaryColorDark = null,
Color accentColor = null,
Color cardColor = null,
Color backgroundColor = null,
Color errorColor = null,
Brightness? brightness = Brightness.light) {
D.assert(brightness != null);
primarySwatch = primarySwatch ?? Colors.blue;
bool isDark = brightness == Brightness.dark;
bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark;
Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch);
bool secondaryIsDark = _brightnessFor(secondary) == Brightness.dark;
return new ColorScheme(
primary: primarySwatch,
primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]),
secondary: secondary,
secondaryVariant: isDark ? Colors.tealAccent[700] : primarySwatch[700],
surface: cardColor ?? (isDark ? Colors.grey[800] : Colors.white),
background: backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]),
error: errorColor ?? Colors.red[700],
onPrimary: primaryIsDark ? Colors.white : Colors.black,
onSecondary: secondaryIsDark ? Colors.white : Colors.black,
onSurface: isDark ? Colors.white : Colors.black,
onBackground: primaryIsDark ? Colors.white : Colors.black,
onError: isDark ? Colors.black : Colors.white,
brightness: brightness ?? Brightness.light
);
}
static Brightness _brightnessFor(Color color) => ThemeData.estimateBrightnessForColor(color);
public readonly Color primary;
public readonly Color primaryVariant;
public readonly Color secondary;
public readonly Color secondaryVariant;
public readonly Color surface;
public readonly Color background;
public readonly Color error;
public readonly Color onPrimary;
public readonly Color onSecondary;
public readonly Color onSurface;
public readonly Color onBackground;
public readonly Color onError;
public readonly Brightness brightness;
public ColorScheme copyWith(
Color primary = null,
Color primaryVariant = null,
Color secondary = null,
Color secondaryVariant = null,
Color surface = null,
Color background = null,
Color error = null,
Color onPrimary = null,
Color onSecondary = null,
Color onSurface = null,
Color onBackground = null,
Color onError = null,
Brightness? brightness = null) {
return new ColorScheme(
primary: primary ?? this.primary,
primaryVariant: primaryVariant ?? this.primaryVariant,
secondary: secondary ?? this.secondary,
secondaryVariant: secondaryVariant ?? this.secondaryVariant,
surface: surface ?? this.surface,
background: background ?? this.background,
error: error ?? this.error,
onPrimary: onPrimary ?? this.onPrimary,
onSecondary: onSecondary ?? this.onSecondary,
onSurface: onSurface ?? this.onSurface,
onBackground: onBackground ?? this.onBackground,
onError: onError ?? this.onError,
brightness: brightness ?? this.brightness
);
}
public static ColorScheme lerp(ColorScheme a, ColorScheme b, double t) {
return new ColorScheme(
primary: Color.lerp(a.primary, b.primary, t),
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t),
secondary: Color.lerp(a.secondary, b.secondary, t),
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t),
surface: Color.lerp(a.surface, b.surface, t),
background: Color.lerp(a.background, b.background, t),
error: Color.lerp(a.error, b.error, t),
onPrimary: Color.lerp(a.onPrimary, b.onPrimary, t),
onSecondary: Color.lerp(a.onSecondary, b.onSecondary, t),
onSurface: Color.lerp(a.onSurface, b.onSurface, t),
onBackground: Color.lerp(a.onBackground, b.onBackground, t),
onError: Color.lerp(a.onError, b.onError, t),
brightness: t < 0.5 ? a.brightness : b.brightness
);
}
public bool Equals(ColorScheme other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other.primary == this.primary
&& other.primaryVariant == this.primaryVariant
&& other.secondary == this.secondary
&& other.secondaryVariant == this.secondaryVariant
&& other.surface == this.surface
&& other.background == this.background
&& other.error == this.error
&& other.onPrimary == this.onPrimary
&& other.onSecondary == this.onSecondary
&& other.onSurface == this.onSurface
&& other.onBackground == this.onBackground
&& other.onError == this.onError
&& other.brightness == this.brightness;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ColorScheme) obj);
}
public static bool operator ==(ColorScheme left, ColorScheme right) {
return Equals(left, right);
}
public static bool operator !=(ColorScheme left, ColorScheme right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.primary.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryVariant.GetHashCode();
hashCode = (hashCode * 397) ^ this.secondary.GetHashCode();
hashCode = (hashCode * 397) ^ this.secondaryVariant.GetHashCode();
hashCode = (hashCode * 397) ^ this.surface.GetHashCode();
hashCode = (hashCode * 397) ^ this.background.GetHashCode();
hashCode = (hashCode * 397) ^ this.error.GetHashCode();
hashCode = (hashCode * 397) ^ this.onPrimary.GetHashCode();
hashCode = (hashCode * 397) ^ this.onSecondary.GetHashCode();
hashCode = (hashCode * 397) ^ this.onSurface.GetHashCode();
hashCode = (hashCode * 397) ^ this.onBackground.GetHashCode();
hashCode = (hashCode * 397) ^ this.onError.GetHashCode();
hashCode = (hashCode * 397) ^ this.brightness.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
ColorScheme defaultScheme = light();
properties.add(new DiagnosticsProperty<Color>("primary", this.primary,
defaultValue: defaultScheme.primary));
properties.add(new DiagnosticsProperty<Color>("primaryVariant", this.primaryVariant,
defaultValue: defaultScheme.primaryVariant));
properties.add(new DiagnosticsProperty<Color>("secondary", this.secondary,
defaultValue: defaultScheme.secondary));
properties.add(new DiagnosticsProperty<Color>("secondaryVariant", this.secondaryVariant,
defaultValue: defaultScheme.secondaryVariant));
properties.add(new DiagnosticsProperty<Color>("surface", this.surface,
defaultValue: defaultScheme.surface));
properties.add(new DiagnosticsProperty<Color>("background", this.background,
defaultValue: defaultScheme.background));
properties.add(new DiagnosticsProperty<Color>("error", this.error, defaultValue: defaultScheme.error));
properties.add(new DiagnosticsProperty<Color>("onPrimary", this.onPrimary,
defaultValue: defaultScheme.onPrimary));
properties.add(new DiagnosticsProperty<Color>("onSecondary", this.onSecondary,
defaultValue: defaultScheme.onSecondary));
properties.add(new DiagnosticsProperty<Color>("onSurface", this.onSurface,
defaultValue: defaultScheme.onSurface));
properties.add(new DiagnosticsProperty<Color>("onBackground", this.onBackground,
defaultValue: defaultScheme.onBackground));
properties.add(new DiagnosticsProperty<Color>("onError", this.onError,
defaultValue: defaultScheme.onError));
properties.add(new DiagnosticsProperty<Brightness>("brightness", this.brightness,
defaultValue: defaultScheme.brightness));
}
}
}

11
Runtime/material/color_scheme.cs.meta


fileFormatVersion: 2
guid: a610420b7a8ec44bfa84e81a1e5ff449
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

662
Runtime/material/colors.cs


using System.Collections.Generic;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class MaterialColor : ColorSwatch<int> {
public MaterialColor(
long primary,
Dictionary<int, Color> swatch) : base(primary: primary, swatch: swatch) {}
public Color shade50 => this[50];
public Color shade100 => this[100];
public Color shade200 => this[200];
public Color shade300 => this[300];
public Color shade400 => this[400];
public Color shade500 => this[500];
public Color shade600 => this[600];
public Color shade700 => this[700];
public Color shade800 => this[800];
public Color shade900 => this[900];
}
public class MaterialAccentColor : ColorSwatch<int> {
public MaterialAccentColor(
long primary,
Dictionary<int, Color> swatch) : base(primary: primary, swatch: swatch) {
}
public Color shade50 => this[50];
public Color shade100 => this[100];
public Color shade200 => this[200];
public Color shade400 => this[400];
public Color shade700 => this[700];
}
public class Colors {
public static readonly Color transparent = new Color(0x00000000);
public static readonly Color black = new Color(0xFF000000);
public static readonly Color black87 = new Color(0xDD000000);
public static readonly Color black54 = new Color(0x8A000000);
public static readonly Color black45 = new Color(0x73000000);
public static readonly Color black38 = new Color(0x61000000);
public static readonly Color black26 = new Color(0x42000000);
public static readonly Color black12 = new Color(0x1F000000);
public static readonly Color white = new Color(0xFFFFFFFF);
public static readonly Color white70 = new Color(0xB3FFFFFF);
public static readonly Color white54 = new Color(0x8AFFFFFF);
public static readonly Color white30 = new Color(0x4DFFFFFF);
public static readonly Color white24 = new Color(0x3DFFFFFF);
public static readonly Color white12 = new Color(0x1FFFFFFF);
public static readonly Color white10 = new Color(0x1AFFFFFF);
public static readonly MaterialColor red = new MaterialColor(
_redPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFFEBEE)},
{100, new Color(0xFFFFCDD2)},
{200, new Color(0xFFEF9A9A)},
{300, new Color(0xFFE57373)},
{400, new Color(0xFFEF5350)},
{500, new Color(_redPrimaryValue)},
{600, new Color(0xFFE53935)},
{700, new Color(0xFFD32F2F)},
{800, new Color(0xFFC62828)},
{900, new Color(0xFFB71C1C)}
}
);
const long _redPrimaryValue = 0xFFF44336;
public static readonly MaterialAccentColor redAccent = new MaterialAccentColor(
_redAccentValue,
new Dictionary<int, Color> {
{100, new Color(0xFFFF8A80)},
{200, new Color(_redAccentValue)},
{400, new Color(0xFFFF1744)},
{700, new Color(0xFFD50000)}
}
);
const long _redAccentValue = 0xFFFF5252;
public static readonly MaterialColor pink = new MaterialColor(
_pinkPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFCE4EC)},
{100, new Color(0xFFF8BBD0)},
{200, new Color(0xFFF48FB1)},
{300, new Color(0xFFF06292)},
{400, new Color(0xFFEC407A)},
{500, new Color(_pinkPrimaryValue)},
{600, new Color(0xFFD81B60)},
{700, new Color(0xFFC2185B)},
{800, new Color(0xFFAD1457)},
{900, new Color(0xFF880E4F)}
}
);
const long _pinkPrimaryValue = 0xFFE91E63;
public static readonly MaterialAccentColor pinkAccent = new MaterialAccentColor(
_pinkAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFFF80AB)},
{200, new Color(_pinkAccentPrimaryValue)},
{400, new Color(0xFFF50057)},
{700, new Color(0xFFC51162)}
}
);
const long _pinkAccentPrimaryValue = 0xFFFF4081;
public static readonly MaterialColor purple = new MaterialColor(
_purplePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFF3E5F5)},
{100, new Color(0xFFE1BEE7)},
{200, new Color(0xFFCE93D8)},
{300, new Color(0xFFBA68C8)},
{400, new Color(0xFFAB47BC)},
{500, new Color(_purplePrimaryValue)},
{600, new Color(0xFF8E24AA)},
{700, new Color(0xFF7B1FA2)},
{800, new Color(0xFF6A1B9A)},
{900, new Color(0xFF4A148C)}
}
);
const long _purplePrimaryValue = 0xFF9C27B0;
public static readonly MaterialAccentColor purpleAccent = new MaterialAccentColor(
_purpleAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFEA80FC)},
{200, new Color(_purpleAccentPrimaryValue)},
{400, new Color(0xFFD500F9)},
{700, new Color(0xFFAA00FF)}
}
);
const long _purpleAccentPrimaryValue = 0xFFE040FB;
public static readonly MaterialColor deepPurple = new MaterialColor(
_deepPurplePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFEDE7F6)},
{100, new Color(0xFFD1C4E9)},
{200, new Color(0xFFB39DDB)},
{300, new Color(0xFF9575CD)},
{400, new Color(0xFF7E57C2)},
{500, new Color(_deepPurplePrimaryValue)},
{600, new Color(0xFF5E35B1)},
{700, new Color(0xFF512DA8)},
{800, new Color(0xFF4527A0)},
{900, new Color(0xFF311B92)}
}
);
const long _deepPurplePrimaryValue = 0xFF673AB7;
public static readonly MaterialAccentColor deepPurpleAccent = new MaterialAccentColor(
_deepPurpleAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFB388FF)},
{200, new Color(_deepPurpleAccentPrimaryValue)},
{400, new Color(0xFF651FFF)},
{700, new Color(0xFF6200EA)}
}
);
const long _deepPurpleAccentPrimaryValue = 0xFF7C4DFF;
public static readonly MaterialColor indigo = new MaterialColor(
_indigoPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFE8EAF6)},
{100, new Color(0xFFC5CAE9)},
{200, new Color(0xFF9FA8DA)},
{300, new Color(0xFF7986CB)},
{400, new Color(0xFF5C6BC0)},
{500, new Color(_indigoPrimaryValue)},
{600, new Color(0xFF3949AB)},
{700, new Color(0xFF303F9F)},
{800, new Color(0xFF283593)},
{900, new Color(0xFF1A237E)}
}
);
const long _indigoPrimaryValue = 0xFF3F51B5;
public static readonly MaterialAccentColor indigoAccent = new MaterialAccentColor(
_indigoAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFF8C9EFF)},
{200, new Color(_indigoAccentPrimaryValue)},
{400, new Color(0xFF3D5AFE)},
{700, new Color(0xFF304FFE)}
}
);
const long _indigoAccentPrimaryValue = 0xFF536DFE;
public static readonly MaterialColor blue = new MaterialColor(
_bluePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFE3F2FD)},
{100, new Color(0xFFBBDEFB)},
{200, new Color(0xFF90CAF9)},
{300, new Color(0xFF64B5F6)},
{400, new Color(0xFF42A5F5)},
{500, new Color(_bluePrimaryValue)},
{600, new Color(0xFF1E88E5)},
{700, new Color(0xFF1976D2)},
{800, new Color(0xFF1565C0)},
{900, new Color(0xFF0D47A1)}
}
);
const long _bluePrimaryValue = 0xFF2196F3;
public static readonly MaterialAccentColor blueAccent = new MaterialAccentColor(
_blueAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFF82B1FF)},
{200, new Color(_blueAccentPrimaryValue)},
{400, new Color(0xFF2979FF)},
{700, new Color(0xFF2962FF)}
}
);
const long _blueAccentPrimaryValue = 0xFF448AFF;
public static readonly MaterialColor lightBlue = new MaterialColor(
_lightBluePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFE1F5FE)},
{100, new Color(0xFFB3E5FC)},
{200, new Color(0xFF81D4FA)},
{300, new Color(0xFF4FC3F7)},
{400, new Color(0xFF29B6F6)},
{500, new Color(_lightBluePrimaryValue)},
{600, new Color(0xFF039BE5)},
{700, new Color(0xFF0288D1)},
{800, new Color(0xFF0277BD)},
{900, new Color(0xFF01579B)},
}
);
const long _lightBluePrimaryValue = 0xFF03A9F4;
public static readonly MaterialAccentColor lightBlueAccent = new MaterialAccentColor(
_lightBlueAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFF80D8FF)},
{200, new Color(_lightBlueAccentPrimaryValue)},
{400, new Color(0xFF00B0FF)},
{700, new Color(0xFF0091EA)}
}
);
const long _lightBlueAccentPrimaryValue = 0xFF40C4FF;
public static readonly MaterialColor cyan = new MaterialColor(
_cyanPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFE0F7FA)},
{100, new Color(0xFFB2EBF2)},
{200, new Color(0xFF80DEEA)},
{300, new Color(0xFF4DD0E1)},
{400, new Color(0xFF26C6DA)},
{500, new Color(_cyanPrimaryValue)},
{600, new Color(0xFF00ACC1)},
{700, new Color(0xFF0097A7)},
{800, new Color(0xFF00838F)},
{900, new Color(0xFF006064)}
}
);
const long _cyanPrimaryValue = 0xFF00BCD4;
public static readonly MaterialAccentColor cyanAccent = new MaterialAccentColor(
_cyanAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFF84FFFF)},
{200, new Color(_cyanAccentPrimaryValue)},
{400, new Color(0xFF00E5FF)},
{700, new Color(0xFF00B8D4)}
}
);
const long _cyanAccentPrimaryValue = 0xFF18FFFF;
public static readonly MaterialColor teal = new MaterialColor(
_tealPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFE0F2F1)},
{100, new Color(0xFFB2DFDB)},
{200, new Color(0xFF80CBC4)},
{300, new Color(0xFF4DB6AC)},
{400, new Color(0xFF26A69A)},
{500, new Color(_tealPrimaryValue)},
{600, new Color(0xFF00897B)},
{700, new Color(0xFF00796B)},
{800, new Color(0xFF00695C)},
{900, new Color(0xFF004D40)}
}
);
const long _tealPrimaryValue = 0xFF009688;
public static readonly MaterialAccentColor tealAccent = new MaterialAccentColor(
_tealAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFA7FFEB)},
{200, new Color(_tealAccentPrimaryValue)},
{400, new Color(0xFF1DE9B6)},
{700, new Color(0xFF00BFA5)}
}
);
const long _tealAccentPrimaryValue = 0xFF64FFDA;
public static readonly MaterialColor green = new MaterialColor(
_greenPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFE8F5E9)},
{100, new Color(0xFFC8E6C9)},
{200, new Color(0xFFA5D6A7)},
{300, new Color(0xFF81C784)},
{400, new Color(0xFF66BB6A)},
{500, new Color(_greenPrimaryValue)},
{600, new Color(0xFF43A047)},
{700, new Color(0xFF388E3C)},
{800, new Color(0xFF2E7D32)},
{900, new Color(0xFF1B5E20)}
}
);
const long _greenPrimaryValue = 0xFF4CAF50;
public static readonly MaterialAccentColor greenAccent = new MaterialAccentColor(
_greenAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFB9F6CA)},
{200, new Color(_greenAccentPrimaryValue)},
{400, new Color(0xFF00E676)},
{700, new Color(0xFF00C853)}
}
);
const long _greenAccentPrimaryValue = 0xFF69F0AE;
public static readonly MaterialColor lightGreen = new MaterialColor(
_lightGreenPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFF1F8E9)},
{100, new Color(0xFFDCEDC8)},
{200, new Color(0xFFC5E1A5)},
{300, new Color(0xFFAED581)},
{400, new Color(0xFF9CCC65)},
{500, new Color(_lightGreenPrimaryValue)},
{600, new Color(0xFF7CB342)},
{700, new Color(0xFF689F38)},
{800, new Color(0xFF558B2F)},
{900, new Color(0xFF33691E)}
}
);
const long _lightGreenPrimaryValue = 0xFF8BC34A;
public static readonly MaterialAccentColor lightGreenAccent = new MaterialAccentColor(
_lightGreenAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFCCFF90)},
{200, new Color(_lightGreenAccentPrimaryValue)},
{400, new Color(0xFF76FF03)},
{700, new Color(0xFF64DD17)}
}
);
const long _lightGreenAccentPrimaryValue = 0xFFB2FF59;
public static readonly MaterialColor lime = new MaterialColor(
_limePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFF9FBE7)},
{100, new Color(0xFFF0F4C3)},
{200, new Color(0xFFE6EE9C)},
{300, new Color(0xFFDCE775)},
{400, new Color(0xFFD4E157)},
{500, new Color(_limePrimaryValue)},
{600, new Color(0xFFC0CA33)},
{700, new Color(0xFFAFB42B)},
{800, new Color(0xFF9E9D24)},
{900, new Color(0xFF827717)}
}
);
const long _limePrimaryValue = 0xFFCDDC39;
public static readonly MaterialAccentColor limeAccent = new MaterialAccentColor(
_limeAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFF4FF81)},
{200, new Color(_limeAccentPrimaryValue)},
{400, new Color(0xFFC6FF00)},
{700, new Color(0xFFAEEA00)}
}
);
const long _limeAccentPrimaryValue = 0xFFEEFF41;
public static readonly MaterialColor yellow = new MaterialColor(
_yellowPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFFFDE7)},
{100, new Color(0xFFFFF9C4)},
{200, new Color(0xFFFFF59D)},
{300, new Color(0xFFFFF176)},
{400, new Color(0xFFFFEE58)},
{500, new Color(_yellowPrimaryValue)},
{600, new Color(0xFFFDD835)},
{700, new Color(0xFFFBC02D)},
{800, new Color(0xFFF9A825)},
{900, new Color(0xFFF57F17)}
}
);
const long _yellowPrimaryValue = 0xFFFFEB3B;
public static readonly MaterialAccentColor yellowAccent = new MaterialAccentColor(
_yellowAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFFFFF8D)},
{200, new Color(_yellowAccentPrimaryValue)},
{400, new Color(0xFFFFEA00)},
{700, new Color(0xFFFFD600)}
}
);
const long _yellowAccentPrimaryValue = 0xFFFFFF00;
public static readonly MaterialColor amber = new MaterialColor(
_amberPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFFF8E1)},
{100, new Color(0xFFFFECB3)},
{200, new Color(0xFFFFE082)},
{300, new Color(0xFFFFD54F)},
{400, new Color(0xFFFFCA28)},
{500, new Color(_amberPrimaryValue)},
{600, new Color(0xFFFFB300)},
{700, new Color(0xFFFFA000)},
{800, new Color(0xFFFF8F00)},
{900, new Color(0xFFFF6F00)}
}
);
const long _amberPrimaryValue = 0xFFFFC107;
public static readonly MaterialAccentColor amberAccent = new MaterialAccentColor(
_amberAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFFFE57F)},
{200, new Color(_amberAccentPrimaryValue)},
{400, new Color(0xFFFFC400)},
{700, new Color(0xFFFFAB00)}
}
);
const long _amberAccentPrimaryValue = 0xFFFFD740;
public static readonly MaterialColor orange = new MaterialColor(
_orangePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFFF3E0)},
{100, new Color(0xFFFFE0B2)},
{200, new Color(0xFFFFCC80)},
{300, new Color(0xFFFFB74D)},
{400, new Color(0xFFFFA726)},
{500, new Color(_orangePrimaryValue)},
{600, new Color(0xFFFB8C00)},
{700, new Color(0xFFF57C00)},
{800, new Color(0xFFEF6C00)},
{900, new Color(0xFFE65100)}
}
);
const long _orangePrimaryValue = 0xFFFF9800;
public static readonly MaterialAccentColor orangeAccent = new MaterialAccentColor(
_orangeAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFFFD180)},
{200, new Color(_orangeAccentPrimaryValue)},
{400, new Color(0xFFFF9100)},
{700, new Color(0xFFFF6D00)}
}
);
const long _orangeAccentPrimaryValue = 0xFFFFAB40;
public static readonly MaterialColor deepOrange = new MaterialColor(
_deepOrangePrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFBE9E7)},
{100, new Color(0xFFFFCCBC)},
{200, new Color(0xFFFFAB91)},
{300, new Color(0xFFFF8A65)},
{400, new Color(0xFFFF7043)},
{500, new Color(_deepOrangePrimaryValue)},
{600, new Color(0xFFF4511E)},
{700, new Color(0xFFE64A19)},
{800, new Color(0xFFD84315)},
{900, new Color(0xFFBF360C)}
}
);
const long _deepOrangePrimaryValue = 0xFFFF5722;
public static readonly MaterialAccentColor deepOrangeAccent = new MaterialAccentColor(
_deepOrangeAccentPrimaryValue,
new Dictionary<int, Color> {
{100, new Color(0xFFFF9E80)},
{200, new Color(_deepOrangeAccentPrimaryValue)},
{400, new Color(0xFFFF3D00)},
{700, new Color(0xFFDD2C00)}
}
);
const long _deepOrangeAccentPrimaryValue = 0xFFFF6E40;
public static readonly MaterialColor brown = new MaterialColor(
_brownPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFEFEBE9)},
{100, new Color(0xFFD7CCC8)},
{200, new Color(0xFFBCAAA4)},
{300, new Color(0xFFA1887F)},
{400, new Color(0xFF8D6E63)},
{500, new Color(_brownPrimaryValue)},
{600, new Color(0xFF6D4C41)},
{700, new Color(0xFF5D4037)},
{800, new Color(0xFF4E342E)},
{900, new Color(0xFF3E2723)}
}
);
const long _brownPrimaryValue = 0xFF795548;
public static readonly MaterialColor grey = new MaterialColor(
_greyPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFFAFAFA)},
{100, new Color(0xFFF5F5F5)},
{200, new Color(0xFFEEEEEE)},
{300, new Color(0xFFE0E0E0)},
{350, new Color(0xFFD6D6D6)},
{400, new Color(0xFFBDBDBD)},
{500, new Color(_greyPrimaryValue)},
{600, new Color(0xFF757575)},
{700, new Color(0xFF616161)},
{800, new Color(0xFF424242)},
{850, new Color(0xFF303030)},
{900, new Color(0xFF212121)}
}
);
const long _greyPrimaryValue = 0xFF9E9E9E;
public static readonly MaterialColor blueGrey = new MaterialColor(
_blueGreyPrimaryValue,
new Dictionary<int, Color> {
{50, new Color(0xFFECEFF1)},
{100, new Color(0xFFCFD8DC)},
{200, new Color(0xFFB0BEC5)},
{300, new Color(0xFF90A4AE)},
{400, new Color(0xFF78909C)},
{500, new Color(_blueGreyPrimaryValue)},
{600, new Color(0xFF546E7A)},
{700, new Color(0xFF455A64)},
{800, new Color(0xFF37474F)},
{900, new Color(0xFF263238)}
}
);
const long _blueGreyPrimaryValue = 0xFF607D8B;
public static readonly List<MaterialColor> primaries = new List<MaterialColor> {
red,
pink,
purple,
deepPurple,
indigo,
blue,
lightBlue,
cyan,
teal,
green,
lightGreen,
lime,
yellow,
amber,
orange,
deepOrange,
brown,
blueGrey
};
public static readonly List<MaterialAccentColor> accents = new List<MaterialAccentColor> {
redAccent,
pinkAccent,
purpleAccent,
deepPurpleAccent,
indigoAccent,
blueAccent,
lightBlueAccent,
cyanAccent,
tealAccent,
greenAccent,
lightGreenAccent,
limeAccent,
yellowAccent,
amberAccent,
orangeAccent,
deepOrangeAccent
};
}
}

11
Runtime/material/colors.cs.meta


fileFormatVersion: 2
guid: dfc0e036c07e1441d8dbd3158bb6f923
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Runtime/material/constants.cs


using System;
using Unity.UIWidgets.painting;
namespace Unity.UIWidgets.material {
public static class Constants {
public static readonly double kToolbarHeight = 56.0;
public static readonly double kBottomNavigationBarHeight = 56.0;
public static readonly double kTextTabBarHeight = 48.0;
public static readonly TimeSpan kThemeChangeDuration = new TimeSpan(0, 0, 0, 0, 200);
public static readonly double kRadialReactionRadius = 20.0;
public static readonly TimeSpan kRadialReactionDuration = new TimeSpan(0, 0, 0, 0, 100);
public static readonly int kRadialReactionAlpha = 0x1F;
public static readonly TimeSpan kTabScrollDuration = new TimeSpan(0, 0, 0, 0, 300);
public static readonly EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0);
public static readonly EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0);
}
}

11
Runtime/material/constants.cs.meta


fileFormatVersion: 2
guid: 0364fdae877454fb1babca8f67c2561e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

51
Runtime/material/debug.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public static class MaterialDebug {
public static bool debugCheckHasMaterial(BuildContext context) {
D.assert(() => {
if (!(context.widget is Material) && context.ancestorWidgetOfExactType(typeof(Material)) == null) {
string message = "No Material widget found.";
message += context.widget.GetType() + " widgets require a Material widget ancestor.";
message += "In material design, most widgets are conceptually \"printed\" on " +
"a sheet of material. In Flutter\'s material library, that " +
"material is represented by the Material widget. It is the " +
"Material widget that renders ink splashes, for instance. " +
"Because of this, many material library widgets require that " +
"there be a Material widget in the tree above them.";
message += "To introduce a Material widget, you can either directly " +
"include one, or use a widget that contains Material itself, " +
"such as a Card, Dialog, Drawer, or Scaffold.";
message += "The specific widget that could not find a Material ancestor was:";
message += context.widget.toString();
List<Widget> ancestors = new List<Widget>();
context.visitAncestorElements((Element element) => {
ancestors.Add(element.widget);
return true;
});
if (ancestors.isNotEmpty()) {
message += "The ancestors of this widget were:";
foreach (Widget ancestor in ancestors)
message += "\n $ancestor";
}
else {
message += "This widget is the root of the tree, so it has no " +
"ancestors, let alone a \"Material\" ancestor.";
}
throw new UIWidgetsError(message);
}
return true;
});
return true;
}
}
}

11
Runtime/material/debug.cs.meta


fileFormatVersion: 2
guid: 353f6a1d0791640349fe94187f15ad33
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

228
Runtime/material/ink_decoration.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using ImageUtils = Unity.UIWidgets.widgets.ImageUtils;
namespace Unity.UIWidgets.material {
public class Ink : StatefulWidget {
public Ink(
Key key = null,
EdgeInsets padding = null,
Color color = null,
Decoration decoration = null,
double? width = null,
double? height = null,
Widget child = null) : base(key: key) {
D.assert(padding == null || padding.isNonNegative);
D.assert(decoration == null || decoration.debugAssertIsValid());
D.assert(color == null || decoration == null,
"Cannot provide both a color and a decoration\n" +
"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\".");
decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null);
this.padding = padding;
this.width = width;
this.height = height;
this.child = child;
this.decoration = decoration;
}
public static Ink image(
Key key = null,
EdgeInsets padding = null,
ImageProvider image = null,
ColorFilter colorFilter = null,
BoxFit? fit = null,
Alignment alignment = null,
Rect centerSlice = null,
ImageRepeat repeat = ImageRepeat.noRepeat,
double? width = null,
double? height = null,
Widget child = null
) {
D.assert(padding == null || padding.isNonNegative);
D.assert(image != null);
alignment = alignment ?? Alignment.center;
Decoration decoration = new BoxDecoration(
image: new DecorationImage(
image: image,
colorFilter: colorFilter,
fit: fit,
alignment: alignment,
centerSlice: centerSlice,
repeat: repeat)
);
return new Ink(
key: key,
padding: padding,
decoration: decoration,
width: width,
height: height,
child: child);
}
public readonly Widget child;
public readonly EdgeInsets padding;
public readonly Decoration decoration;
public readonly double? width;
public readonly double? height;
public EdgeInsets _paddingIncludingDecoration {
get {
if (this.decoration == null || this.decoration.padding == null)
return this.padding;
EdgeInsets decorationPadding = this.decoration.padding;
if (this.padding == null)
return decorationPadding;
return this.padding.add(decorationPadding);
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding, defaultValue: null));
properties.add(new DiagnosticsProperty<Decoration>("bg", this.decoration, defaultValue: null));
}
public override State createState() => new _InkState();
}
class _InkState : State<Ink> {
InkDecoration _ink;
void _handleRemoved() {
this._ink = null;
}
public override void deactivate() {
this._ink?.dispose();
D.assert(this._ink == null);
base.deactivate();
}
public Widget _build(BuildContext context, BoxConstraints constraints) {
if (this._ink == null) {
this._ink = new InkDecoration(
decoration: this.widget.decoration,
configuration: ImageUtils.createLocalImageConfiguration(context),
controller: Material.of(context),
referenceBox: (RenderBox) context.findRenderObject(),
onRemoved: this._handleRemoved
);
}
else {
this._ink.decoration = this.widget.decoration;
this._ink.configuration = ImageUtils.createLocalImageConfiguration(context);
}
Widget current = this.widget.child;
EdgeInsets effectivePadding = this.widget._paddingIncludingDecoration;
if (effectivePadding != null)
current = new Padding(
padding: effectivePadding,
child: current);
return current;
}
public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
Widget result = new LayoutBuilder(
builder: this._build
);
if (this.widget.width != null || this.widget.height != null) {
result = new SizedBox(
width: this.widget.width,
height: this.widget.height,
child: result);
}
return result;
}
}
class InkDecoration : InkFeature {
public InkDecoration(
Decoration decoration = null,
ImageConfiguration configuration = null,
MaterialInkController controller = null,
RenderBox referenceBox = null,
VoidCallback onRemoved = null
) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) {
D.assert(configuration != null);
D.assert(decoration != null);
D.assert(controller != null);
D.assert(referenceBox != null);
this._configuration = configuration;
this.decoration = decoration;
this.controller.addInkFeature(this);
}
BoxPainter _painter;
public Decoration decoration {
get { return this._decoration; }
set {
if (value == this._decoration)
return;
this._decoration = value;
this._painter?.Dispose();
this._painter = this._decoration?.createBoxPainter(this._handleChanged);
this.controller.markNeedsPaint();
}
}
Decoration _decoration;
public ImageConfiguration configuration {
get { return this._configuration; }
set {
D.assert(value != null);
if (value == this._configuration)
return;
this._configuration = value;
this.controller.markNeedsPaint();
}
}
ImageConfiguration _configuration;
void _handleChanged() {
this.controller.markNeedsPaint();
}
public override void dispose() {
this._painter?.Dispose();
base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
if (this._painter == null)
return;
Offset originOffset = transform.getAsTranslation();
ImageConfiguration sizedConfiguration = this.configuration.copyWith(
size: this.referenceBox.size);
if (originOffset == null) {
canvas.save();
canvas.concat(transform);
this._painter.paint(canvas, Offset.zero, sizedConfiguration);
canvas.restore();
}
else {
this._painter.paint(canvas, originOffset, sizedConfiguration);
}
}
}
}

11
Runtime/material/ink_decoration.cs.meta


fileFormatVersion: 2
guid: 2aa14ff76c10f4d459b55674f0a2b57f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

124
Runtime/material/ink_highlight.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class InkHighlight : InteractiveInkFeature {
public InkHighlight(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Color color = null,
BoxShape shape = BoxShape.rectangle,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
RectCallback rectCallback = null,
VoidCallback onRemoved = null) : base(
controller: controller,
referenceBox: referenceBox,
color: color,
onRemoved: onRemoved) {
D.assert(color != null);
D.assert(controller != null);
D.assert(referenceBox != null);
this._shape = shape;
this._borderRadius = borderRadius ?? BorderRadius.zero;
this._customBorder = customBorder;
this._rectCallback = rectCallback;
this._alphaController = new AnimationController(
duration: InkHighlightUtils._kHighlightFadeDuration,
vsync: controller.vsync);
this._alphaController.addListener(controller.markNeedsPaint);
this._alphaController.addStatusListener(this._handleAlphaStatusChanged);
this._alphaController.forward();
this._alpha = this._alphaController.drive(new IntTween(
begin: 0, end: color.alpha));
this.controller.addInkFeature(this);
}
readonly BoxShape _shape;
readonly BorderRadius _borderRadius;
readonly ShapeBorder _customBorder;
readonly RectCallback _rectCallback;
Animation<int> _alpha;
AnimationController _alphaController;
public bool active => this._active;
bool _active = true;
public void activate() {
this._active = true;
this._alphaController.forward();
}
public void deactivate() {
this._active = false;
this._alphaController.reverse();
}
void _handleAlphaStatusChanged(AnimationStatus status) {
if (status == AnimationStatus.dismissed && !this._active)
this.dispose();
}
public override void dispose() {
this._alphaController.dispose();
base.dispose();
}
void _paintHighlight(Canvas canvas, Rect rect, Paint paint) {
D.assert(this._shape != null);
canvas.save();
if (this._customBorder != null) {
canvas.clipPath(this._customBorder.getOuterPath(rect));
}
switch (this._shape) {
case BoxShape.circle: {
canvas.drawCircle(rect.center, Material.defaultSplashRadius, paint);
break;
}
case BoxShape.rectangle: {
if (this._borderRadius != BorderRadius.zero) {
RRect clipRRect = RRect.fromRectAndCorners(
rect,
topLeft: this._borderRadius.topLeft,
topRight: this._borderRadius.topRight,
bottomLeft: this._borderRadius.bottomLeft,
bottomRight: this._borderRadius.bottomRight);
canvas.drawRRect(clipRRect, paint);
}
else {
canvas.drawRect(rect, paint);
}
break;
}
}
canvas.restore();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
Paint paint = new Paint {color = this.color.withAlpha(this._alpha.value)};
Offset originOffset = transform.getAsTranslation();
Rect rect = this._rectCallback != null ? this._rectCallback() : Offset.zero & this.referenceBox.size;
if (originOffset == null) {
canvas.save();
canvas.concat(transform);
this._paintHighlight(canvas, rect, paint);
canvas.restore();
}
else {
this._paintHighlight(canvas, rect.shift(originOffset), paint);
}
}
}
}

11
Runtime/material/ink_highlight.cs.meta


fileFormatVersion: 2
guid: 96f34a8540bb74c7687149b4b2514998
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

173
Runtime/material/ink_splash.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class _InkSplashFactory : InteractiveInkFeatureFactory {
public _InkSplashFactory() {
}
public override InteractiveInkFeature create(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Offset position = null,
Color color = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
VoidCallback onRemoved = null
) {
D.assert(controller != null);
D.assert(referenceBox != null);
D.assert(position != null);
D.assert(color != null);
return new InkSplash(
controller: controller,
referenceBox: referenceBox,
position: position,
color: color,
containedInkWell: containedInkWell,
rectCallback: rectCallback,
borderRadius: borderRadius,
customBorder: customBorder,
radius: radius,
onRemoved: onRemoved);
}
}
public class InkSplash : InteractiveInkFeature {
public InkSplash(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Offset position = null,
Color color = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
VoidCallback onRemoved = null
) : base(
controller: controller,
referenceBox: referenceBox,
color: color,
onRemoved: onRemoved) {
D.assert(controller != null);
D.assert(referenceBox != null);
this._position = position;
this._borderRadius = borderRadius ?? BorderRadius.zero;
this._customBorder = customBorder;
this._targetRadius =
radius ?? InkSplashUtils._getTargetRadius(referenceBox, containedInkWell, rectCallback, position);
this._clipCallback = InkSplashUtils._getClipCallback(referenceBox, containedInkWell, rectCallback);
this._repositionToReferenceBox = !containedInkWell;
D.assert(this._borderRadius != null);
this._radiusController = new AnimationController(
duration: InkSplashUtils._kUnconfirmedSplashDuration,
vsync: controller.vsync);
this._radiusController.addListener(controller.markNeedsPaint);
this._radiusController.forward();
this._radius = this._radiusController.drive(new DoubleTween(
begin: InkSplashUtils._kSplashInitialSize,
end: this._targetRadius));
this._alphaController = new AnimationController(
duration: InkSplashUtils._kSplashFadeDuration,
vsync: controller.vsync);
this._alphaController.addListener(controller.markNeedsPaint);
this._alphaController.addStatusListener(this._handleAlphaStatusChanged);
this._alpha = this._alphaController.drive(new IntTween(
begin: color.alpha,
end: 0));
controller.addInkFeature(this);
}
readonly Offset _position;
readonly BorderRadius _borderRadius;
readonly ShapeBorder _customBorder;
readonly double _targetRadius;
readonly RectCallback _clipCallback;
readonly bool _repositionToReferenceBox;
Animation<double> _radius;
AnimationController _radiusController;
Animation<int> _alpha;
AnimationController _alphaController;
public static InteractiveInkFeatureFactory splashFactory = new _InkSplashFactory();
public override void confirm() {
int duration = (this._targetRadius / InkSplashUtils._kSplashConfirmedVelocity).floor();
this._radiusController.duration = new TimeSpan(0, 0, 0, 0, duration);
this._radiusController.forward();
this._alphaController.forward();
}
public override void cancel() {
this._alphaController?.forward();
}
void _handleAlphaStatusChanged(AnimationStatus status) {
if (status == AnimationStatus.completed)
this.dispose();
}
public override void dispose() {
this._radiusController.dispose();
this._alphaController.dispose();
this._alphaController = null;
base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
Paint paint = new Paint {color = this.color.withAlpha(this._alpha.value)};
Offset center = this._position;
if (this._repositionToReferenceBox)
center = Offset.lerp(center, this.referenceBox.size.center(Offset.zero), this._radiusController.value);
Offset originOffset = transform.getAsTranslation();
canvas.save();
if (originOffset == null) {
canvas.concat(transform);
}
else {
canvas.translate(originOffset.dx, originOffset.dy);
}
if (this._clipCallback != null) {
Rect rect = this._clipCallback();
if (this._customBorder != null) {
canvas.clipPath(this._customBorder.getOuterPath(rect));
}
else if (this._borderRadius != BorderRadius.zero) {
canvas.clipRRect(RRect.fromRectAndCorners(
rect,
topLeft: this._borderRadius.topLeft,
topRight: this._borderRadius.topRight,
bottomLeft: this._borderRadius.bottomLeft,
bottomRight: this._borderRadius.bottomRight));
}
else {
canvas.clipRect(rect);
}
}
//todo xingwei.zhu: remove this condition when drawCircle bug fixed (when radius.value == 0)
if (this._radius.value != 0)
canvas.drawCircle(center, this._radius.value, paint);
canvas.restore();
}
}
}

11
Runtime/material/ink_splash.cs.meta


fileFormatVersion: 2
guid: 068260026dcf947b0af4c9d7f706ab97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

364
Runtime/material/ink_well.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public abstract class InteractiveInkFeature : InkFeature {
public InteractiveInkFeature(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Color color = null,
VoidCallback onRemoved = null
) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) {
D.assert(controller != null);
D.assert(referenceBox != null);
this._color = color;
}
public virtual void confirm() {
}
public virtual void cancel() {
}
public Color color {
get { return this._color; }
set {
if (value == this._color)
return;
this._color = value;
this.controller.markNeedsPaint();
}
}
Color _color;
}
public abstract class InteractiveInkFeatureFactory {
public InteractiveInkFeatureFactory() {
}
public abstract InteractiveInkFeature create(
MaterialInkController controller = null,
RenderBox referenceBox = null,
Offset position = null,
Color color = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
double? radius = null,
VoidCallback onRemoved = null);
}
public class InkResponse : StatefulWidget {
public InkResponse(
Key key = null,
Widget child = null,
GestureTapCallback onTap = null,
GestureTapDownCallback onTapDown = null,
GestureTapCallback onTapCancel = null,
GestureTapCallback onDoubleTap = null,
GestureLongPressCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null,
bool containedInkWell = false,
BoxShape highlightShape = BoxShape.circle,
double? radius = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null) : base(key: key) {
this.child = child;
this.onTap = onTap;
this.onTapDown = onTapDown;
this.onTapCancel = onTapCancel;
this.onDoubleTap = onDoubleTap;
this.onLongPress = onLongPress;
this.onHighlightChanged = onHighlightChanged;
this.containedInkWell = containedInkWell;
this.highlightShape = highlightShape;
this.radius = radius;
this.borderRadius = borderRadius;
this.customBorder = customBorder;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.splashFactory = splashFactory;
}
public readonly Widget child;
public readonly GestureTapCallback onTap;
public readonly GestureTapDownCallback onTapDown;
public readonly GestureTapCallback onTapCancel;
public readonly GestureTapCallback onDoubleTap;
public readonly GestureLongPressCallback onLongPress;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly bool containedInkWell;
public readonly BoxShape highlightShape;
public readonly double? radius;
public readonly BorderRadius borderRadius;
public readonly ShapeBorder customBorder;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly InteractiveInkFeatureFactory splashFactory;
public virtual RectCallback getRectCallback(RenderBox referenceBox) => null;
public virtual bool debugCheckContext(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
return true;
}
public override State createState() => new _InkResponseState<InkResponse>();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
List<string> gestures = new List<string>();
if (this.onTap != null)
gestures.Add("tap");
if (this.onDoubleTap != null)
gestures.Add("double tap");
if (this.onLongPress != null)
gestures.Add("long press");
if (this.onTapDown != null)
gestures.Add("tap down");
if (this.onTapCancel != null)
gestures.Add("tap cancel");
properties.add(new EnumerableProperty<string>("gestures", gestures, ifEmpty: "<none>"));
properties.add(new DiagnosticsProperty<bool>("containedInkWell", this.containedInkWell,
level: DiagnosticLevel.fine));
properties.add(new DiagnosticsProperty<BoxShape>(
"highlightShape",
this.highlightShape,
description: (this.containedInkWell ? "clipped to" : "") + this.highlightShape,
showName: false
));
}
}
public class _InkResponseState<T> : AutomaticKeepAliveClientMixin<T> where T : InkResponse {
HashSet<InteractiveInkFeature> _splashes;
InteractiveInkFeature _currentSplash;
InkHighlight _lastHighlight;
protected override bool wantKeepAlive =>
this._lastHighlight != null || (this._splashes != null && this._splashes.isNotEmpty());
public void updateHighlight(bool value) {
if (value == (this._lastHighlight != null && this._lastHighlight.active))
return;
if (value) {
if (this._lastHighlight == null) {
RenderBox referenceBox = (RenderBox) this.context.findRenderObject();
this._lastHighlight = new InkHighlight(
controller: Material.of(this.context),
referenceBox: referenceBox,
color: this.widget.highlightColor ?? Theme.of(this.context).highlightColor,
shape: this.widget.highlightShape,
borderRadius: this.widget.borderRadius,
customBorder: this.widget.customBorder,
rectCallback: this.widget.getRectCallback(referenceBox),
onRemoved: this._handleInkHighlightRemoval);
this.updateKeepAlive();
}
else {
this._lastHighlight.activate();
}
}
else {
this._lastHighlight.deactivate();
}
D.assert(value == (this._lastHighlight != null && this._lastHighlight.active));
if (this.widget.onHighlightChanged != null)
this.widget.onHighlightChanged(value);
}
void _handleInkHighlightRemoval() {
D.assert(this._lastHighlight != null);
this._lastHighlight = null;
this.updateKeepAlive();
}
InteractiveInkFeature _createInkFeature(TapDownDetails details) {
MaterialInkController inkController = Material.of(this.context);
RenderBox referenceBox = (RenderBox) this.context.findRenderObject();
Offset position = referenceBox.globalToLocal(details.globalPosition);
Color color = this.widget.splashColor ?? Theme.of(this.context).splashColor;
RectCallback rectCallback = this.widget.containedInkWell ? this.widget.getRectCallback(referenceBox) : null;
BorderRadius borderRadius = this.widget.borderRadius;
ShapeBorder customBorder = this.widget.customBorder;
InteractiveInkFeature splash = null;
void OnRemoved() {
if (this._splashes != null) {
D.assert(this._splashes.Contains(splash));
this._splashes.Remove(splash);
if (this._currentSplash == splash) this._currentSplash = null;
this.updateKeepAlive();
}
}
splash = (this.widget.splashFactory ?? Theme.of(this.context).splashFactory).create(
controller: inkController,
referenceBox: referenceBox,
position: position,
color: color,
containedInkWell: this.widget.containedInkWell,
rectCallback: rectCallback,
radius: this.widget.radius,
borderRadius: borderRadius,
customBorder: customBorder,
onRemoved: OnRemoved);
return splash;
}
void _handleTapDown(TapDownDetails details) {
InteractiveInkFeature splash = this._createInkFeature(details);
this._splashes = this._splashes ?? new HashSet<InteractiveInkFeature>();
this._splashes.Add(splash);
this._currentSplash = splash;
if (this.widget.onTapDown != null) {
this.widget.onTapDown(details);
}
this.updateKeepAlive();
this.updateHighlight(true);
}
void _handleTap(BuildContext context) {
this._currentSplash?.confirm();
this._currentSplash = null;
this.updateHighlight(false);
if (this.widget.onTap != null) {
this.widget.onTap();
}
}
void _handleTapCancel() {
this._currentSplash?.cancel();
this._currentSplash = null;
if (this.widget.onTapCancel != null) {
this.widget.onTapCancel();
}
this.updateHighlight(false);
}
void _handleDoubleTap() {
this._currentSplash?.confirm();
this._currentSplash = null;
if (this.widget.onDoubleTap != null) {
this.widget.onDoubleTap();
}
}
void _handleLongPress(BuildContext context) {
this._currentSplash?.confirm();
this._currentSplash = null;
if (this.widget.onLongPress != null) {
this.widget.onLongPress();
}
}
public override void deactivate() {
if (this._splashes != null) {
HashSet<InteractiveInkFeature> splashes = this._splashes;
this._splashes = null;
foreach (InteractiveInkFeature splash in splashes)
splash.dispose();
this._currentSplash = null;
}
D.assert(this._currentSplash == null);
this._lastHighlight?.dispose();
this._lastHighlight = null;
base.deactivate();
}
public override Widget build(BuildContext context) {
D.assert(this.widget.debugCheckContext(context));
base.build(context);
ThemeData themeData = Theme.of(context);
if (this._lastHighlight != null)
this._lastHighlight.color = this.widget.highlightColor ?? themeData.highlightColor;
if (this._currentSplash != null)
this._currentSplash.color = this.widget.splashColor ?? themeData.splashColor;
bool enabled = this.widget.onTap != null || this.widget.onDoubleTap != null ||
this.widget.onLongPress != null;
return new GestureDetector(
onTapDown: enabled ? (GestureTapDownCallback) this._handleTapDown : null,
onTap: enabled ? (GestureTapCallback) (() => this._handleTap(context)) : null,
onTapCancel: enabled ? (GestureTapCancelCallback) this._handleTapCancel : null,
onDoubleTap: this.widget.onDoubleTap != null ? (GestureDoubleTapCallback) (details => this._handleDoubleTap()) : null,
onLongPress: this.widget.onLongPress != null
? (GestureLongPressCallback) (() => this._handleLongPress(context))
: null,
behavior: HitTestBehavior.opaque,
child: this.widget.child
);
}
}
public class InkWell : InkResponse {
public InkWell(
Key key = null,
Widget child = null,
GestureTapCallback onTap = null,
GestureTapCallback onDoubleTap = null,
GestureLongPressCallback onLongPress = null,
GestureTapDownCallback onTapDown = null,
GestureTapCancelCallback onTapCancel = null,
ValueChanged<bool> onHighlightChanged = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
double? radius = null,
BorderRadius borderRadius = null,
ShapeBorder customBorder = null
) : base(
key: key,
child: child,
onTap: onTap,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
onTapDown: onTapDown,
onTapCancel: () => onTapCancel(),
onHighlightChanged: onHighlightChanged,
containedInkWell: true,
highlightColor: highlightColor,
splashColor: splashColor,
splashFactory: splashFactory,
radius: radius,
borderRadius: borderRadius,
customBorder: customBorder) {
}
}
}

11
Runtime/material/ink_well.cs.meta


fileFormatVersion: 2
guid: 9a7302f1a187741b88618822daf7a657
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

492
Runtime/material/material.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public delegate Rect RectCallback();
public enum MaterialType {
canvas,
card,
circle,
button,
transparency
}
public interface MaterialInkController {
Color color { get; set; }
TickerProvider vsync { get; }
void addInkFeature(InkFeature feature);
void markNeedsPaint();
}
public class Material : StatefulWidget {
public Material(
Key key = null,
MaterialType type = MaterialType.canvas,
double elevation = 0.0,
Color color = null,
Color shadowColor = null,
TextStyle textStyle = null,
BorderRadius borderRadius = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
TimeSpan? animationDuration = null,
Widget child = null
) : base(key: key) {
D.assert(!(shape != null && borderRadius != null));
D.assert(!(type == MaterialType.circle && (borderRadius != null || shape != null)));
this.type = type;
this.elevation = elevation;
this.color = color;
this.shadowColor = shadowColor ?? new Color(0xFF000000);
this.textStyle = textStyle;
this.borderRadius = borderRadius;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.child = child;
}
public readonly Widget child;
public readonly MaterialType type;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public readonly TextStyle textStyle;
public readonly ShapeBorder shape;
public readonly Clip clipBehavior;
public readonly TimeSpan animationDuration;
public readonly BorderRadius borderRadius;
public static MaterialInkController of(BuildContext context) {
_RenderInkFeatures result =
(_RenderInkFeatures) context.ancestorRenderObjectOfType(new TypeMatcher<_RenderInkFeatures>());
return result;
}
public override State createState() => new _MaterialState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<MaterialType>("type", this.type));
properties.add(new DoubleProperty("elevation", this.elevation, defaultValue: 0.0));
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor,
defaultValue: new Color(0xFF000000)));
this.textStyle?.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: null));
properties.add(new EnumProperty<BorderRadius>("borderRadius", this.borderRadius, defaultValue: null));
}
public const double defaultSplashRadius = 35.0;
}
class _MaterialState : TickerProviderStateMixin<Material> {
readonly GlobalKey _inkFeatureRenderer = GlobalKey.key(debugLabel: "ink renderer");
Color _getBackgroundColor(BuildContext context) {
if (this.widget.color != null)
return this.widget.color;
switch (this.widget.type) {
case MaterialType.canvas:
return Theme.of(context).canvasColor;
case MaterialType.card:
return Theme.of(context).cardColor;
default:
return null;
}
}
public override Widget build(BuildContext context) {
Color backgroundColor = this._getBackgroundColor(context);
D.assert(backgroundColor != null || this.widget.type == MaterialType.transparency);
Widget contents = this.widget.child;
if (contents != null) {
contents = new AnimatedDefaultTextStyle(
style: this.widget.textStyle ?? Theme.of(context).textTheme.body1,
duration: this.widget.animationDuration,
child: contents
);
}
contents = new NotificationListener<LayoutChangedNotification>(
onNotification: (LayoutChangedNotification notification) => {
_RenderInkFeatures renderer =
(_RenderInkFeatures) this._inkFeatureRenderer.currentContext.findRenderObject();
renderer._didChangeLayout();
return true;
},
child: new _InkFeatures(
key: this._inkFeatureRenderer,
color: backgroundColor,
child: contents,
vsync: this
)
);
if (this.widget.type == MaterialType.canvas && this.widget.shape == null &&
this.widget.borderRadius == null) {
return new AnimatedPhysicalModel(
curve: Curves.fastOutSlowIn,
duration: this.widget.animationDuration,
shape: BoxShape.rectangle,
clipBehavior: this.widget.clipBehavior,
borderRadius: BorderRadius.zero,
elevation: this.widget.elevation,
color: backgroundColor,
shadowColor: this.widget.shadowColor,
animateColor: false,
child: contents
);
}
ShapeBorder shape = this._getShape();
//todo xingwei.zhu: add support for transparentInterior Material
if (this.widget.type == MaterialType.transparency) {
D.assert(false, "material widget is not completely implemented yet.");
return null;
// return this._transparentInterior(
// shape: shape,
// clipBehavior: this.widget.clipBehavior,
// contents: contents);
}
return new _MaterialInterior(
curve: Curves.fastOutSlowIn,
duration: this.widget.animationDuration,
shape: shape,
clipBehavior: this.widget.clipBehavior,
elevation: this.widget.elevation,
color: backgroundColor,
shadowColor: this.widget.shadowColor,
child: contents
);
}
ShapeBorder _getShape() {
if (this.widget.shape != null)
return this.widget.shape;
if (this.widget.borderRadius != null)
return new RoundedRectangleBorder(borderRadius: this.widget.borderRadius);
switch (this.widget.type) {
case MaterialType.canvas:
case MaterialType.transparency:
return new RoundedRectangleBorder();
case MaterialType.card:
case MaterialType.button:
return new RoundedRectangleBorder(
borderRadius: this.widget.borderRadius ?? MaterialConstantsUtils.kMaterialEdges[this.widget.type]);
case MaterialType.circle:
return new CircleBorder();
}
return new RoundedRectangleBorder();
}
}
public class _RenderInkFeatures : RenderProxyBox, MaterialInkController {
public _RenderInkFeatures(
RenderBox child = null,
TickerProvider vsync = null,
Color color = null) : base(child: child) {
D.assert(vsync != null);
this._vsync = vsync;
this._color = color;
}
public TickerProvider vsync {
get { return this._vsync; }
}
readonly TickerProvider _vsync;
public Color color {
get { return this._color; }
set { this._color = value; }
}
Color _color;
List<InkFeature> _inkFeatures;
public void addInkFeature(InkFeature feature) {
D.assert(!feature._debugDisposed);
D.assert(feature._controller == this);
this._inkFeatures = this._inkFeatures ?? new List<InkFeature>();
D.assert(!this._inkFeatures.Contains(feature));
this._inkFeatures.Add(feature);
this.markNeedsPaint();
}
public void _removeFeature(InkFeature feature) {
D.assert(this._inkFeatures != null);
this._inkFeatures.Remove(feature);
this.markNeedsPaint();
}
public void _didChangeLayout() {
if (this._inkFeatures != null && this._inkFeatures.isNotEmpty())
this.markNeedsPaint();
}
protected override bool hitTestSelf(Offset position) => true;
public override void paint(PaintingContext context, Offset offset) {
if (this._inkFeatures != null && this._inkFeatures.isNotEmpty()) {
Canvas canvas = context.canvas;
canvas.save();
canvas.translate(offset.dx, offset.dy);
canvas.clipRect(Offset.zero & this.size);
foreach (InkFeature inkFeature in this._inkFeatures)
inkFeature._paint(canvas);
canvas.restore();
}
base.paint(context, offset);
}
}
public class _InkFeatures : SingleChildRenderObjectWidget {
public _InkFeatures(
Key key = null,
Color color = null,
TickerProvider vsync = null,
Widget child = null) : base(key: key, child: child) {
D.assert(vsync != null);
this.color = color;
this.vsync = vsync;
}
public readonly Color color;
public readonly TickerProvider vsync;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderInkFeatures(
color: this.color,
vsync: this.vsync);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
_RenderInkFeatures _renderObject = (_RenderInkFeatures) renderObject;
_renderObject.color = this.color;
D.assert(this.vsync == _renderObject.vsync);
}
}
public abstract class InkFeature {
public InkFeature(
MaterialInkController controller = null,
RenderBox referenceBox = null,
VoidCallback onRemoved = null) {
D.assert(controller != null);
D.assert(referenceBox != null);
this._controller = (_RenderInkFeatures) controller;
this.referenceBox = referenceBox;
this.onRemoved = onRemoved;
}
public MaterialInkController controller => this._controller;
public _RenderInkFeatures _controller;
public readonly RenderBox referenceBox;
public readonly VoidCallback onRemoved;
public bool _debugDisposed = false;
public virtual void dispose() {
D.assert(!this._debugDisposed);
D.assert(() => {
this._debugDisposed = true;
return true;
});
this._controller._removeFeature(this);
if (this.onRemoved != null)
this.onRemoved();
}
public void _paint(Canvas canvas) {
D.assert(this.referenceBox.attached);
D.assert(!this._debugDisposed);
List<RenderObject> descendants = new List<RenderObject> {this.referenceBox};
RenderObject node = this.referenceBox;
while (node != this._controller) {
node = (RenderObject) node.parent;
D.assert(node != null);
descendants.Add(node);
}
Matrix3 transform = Matrix3.I();
D.assert(descendants.Count >= 2);
for (int index = descendants.Count - 1; index > 0; index -= 1)
descendants[index].applyPaintTransform(descendants[index - 1], transform);
this.paintFeature(canvas, transform);
}
protected abstract void paintFeature(Canvas canvas, Matrix3 transform);
public string toString() => this.GetType() + "";
}
public class ShapeBorderTween : Tween<ShapeBorder> {
public ShapeBorderTween(
ShapeBorder begin = null,
ShapeBorder end = null) : base(begin: begin, end: end) {
}
public override ShapeBorder lerp(double t) {
return ShapeBorder.lerp(this.begin, this.end, t);
}
}
public class _MaterialInterior : ImplicitlyAnimatedWidget {
public _MaterialInterior(
Key key = null,
Widget child = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
double? elevation = null,
Color color = null,
Color shadowColor = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
D.assert(child != null);
D.assert(shape != null);
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
D.assert(duration != null);
this.child = child;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.elevation = elevation ?? 0.0;
this.color = color;
this.shadowColor = shadowColor;
}
public readonly Widget child;
public readonly ShapeBorder shape;
public readonly Clip clipBehavior;
public readonly double elevation;
public readonly Color color;
public readonly Color shadowColor;
public override State createState() => new _MaterialInteriorState();
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape));
description.add(new DoubleProperty("elevation", this.elevation));
description.add(new DiagnosticsProperty<Color>("color", this.color));
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
}
}
public class _MaterialInteriorState : AnimatedWidgetBaseState<_MaterialInterior> {
DoubleTween _elevation;
ColorTween _shadowColor;
ShapeBorderTween _border;
protected override void forEachTween(ITweenVisitor visitor) {
this._elevation = (DoubleTween) visitor.visit(this, this._elevation, this.widget.elevation,
(double value) => new DoubleTween(begin: value, end: value));
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor,
(Color value) => new ColorTween(begin: value));
this._border = (ShapeBorderTween) visitor.visit(this, this._border, this.widget.shape,
(ShapeBorder value) => new ShapeBorderTween(begin: value));
}
public override Widget build(BuildContext context) {
ShapeBorder shape = this._border.evaluate(this.animation);
return new PhysicalShape(
child: new _ShapeBorderPaint(
child: this.widget.child,
shape: shape),
clipper: new ShapeBorderClipper(
shape: shape),
clipBehavior: this.widget.clipBehavior,
elevation: this._elevation.evaluate(this.animation),
color: this.widget.color,
shadowColor: this._shadowColor.evaluate(this.animation)
);
}
}
class _ShapeBorderPaint : StatelessWidget {
public _ShapeBorderPaint(
Widget child = null,
ShapeBorder shape = null) {
D.assert(child != null);
D.assert(shape != null);
this.child = child;
this.shape = shape;
}
public readonly Widget child;
public readonly ShapeBorder shape;
public override Widget build(BuildContext context) {
return new CustomPaint(
child: this.child,
foregroundPainter: new _ShapeBorderPainter(this.shape));
}
}
class _ShapeBorderPainter : CustomPainter {
public _ShapeBorderPainter(ShapeBorder border = null) : base(null) {
this.border = border;
}
public readonly ShapeBorder border;
public override void paint(Canvas canvas, Size size) {
this.border.paint(canvas, Offset.zero & size);
}
public override bool shouldRepaint(CustomPainter oldDelegate) {
_ShapeBorderPainter _oldDelegate = (_ShapeBorderPainter) oldDelegate;
return _oldDelegate.border != this.border;
}
}
}

11
Runtime/material/material.cs.meta


fileFormatVersion: 2
guid: 7c1f7bd49df00452d9a3be75a9e7b213
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

131
Runtime/material/material_button.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class MaterialButton : StatelessWidget {
public MaterialButton(
Key key = null,
VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
ButtonTextTheme? textTheme = null,
Color textColor = null,
Color disabledTextColor = null,
Color color = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,
double? elevation = null,
double? highlightElevation = null,
double? disabledElevation = null,
EdgeInsets padding = null,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
TimeSpan? animationDuration = null,
double? minWidth = null,
double? height = null,
Widget child = null
) : base(key: key) {
D.assert(onPressed != null);
this.onPressed = onPressed;
this.onHighlightChanged = onHighlightChanged;
this.textTheme = textTheme;
this.textColor = textColor;
this.disabledTextColor = disabledTextColor;
this.color = color;
this.disabledColor = disabledColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.colorBrightness = colorBrightness;
this.elevation = elevation;
this.highlightElevation = highlightElevation;
this.disabledElevation = disabledElevation;
this.padding = padding;
this.shape = shape;
this.clipBehavior = clipBehavior;
this.materialTapTargetSize = materialTapTargetSize;
this.animationDuration = animationDuration;
this.minWidth = minWidth;
this.height = height;
this.child = child;
}
public readonly VoidCallback onPressed;
public readonly ValueChanged<bool> onHighlightChanged;
public readonly ButtonTextTheme? textTheme;
public readonly Color textColor;
public readonly Color disabledTextColor;
public readonly Color color;
public readonly Color disabledColor;
public readonly Color splashColor;
public readonly Color highlightColor;
public readonly double? elevation;
public readonly double? highlightElevation;
public readonly double? disabledElevation;
public readonly Brightness? colorBrightness;
public readonly Widget child;
public bool enabled => this.onPressed != null;
public readonly EdgeInsets padding;
public readonly ShapeBorder shape;
public readonly Clip? clipBehavior;
public readonly TimeSpan? animationDuration;
public readonly MaterialTapTargetSize? materialTapTargetSize;
public readonly double? minWidth;
public readonly double? height;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
ButtonThemeData buttonTheme = ButtonTheme.of(context);
return new RawMaterialButton(
onPressed: this.onPressed,
fillColor: this.color,
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)),
highlightColor: this.highlightColor ?? theme.highlightColor,
splashColor: this.splashColor ?? theme.splashColor,
elevation: buttonTheme.getElevation(this),
highlightElevation: buttonTheme.getHighlightElevation(this),
padding: buttonTheme.getPadding(this),
constraints: buttonTheme.getConstraints(this).copyWith(
minWidth: this.minWidth,
minHeight: this.height),
shape: buttonTheme.shape,
clipBehavior: this.clipBehavior ?? Clip.none,
animationDuration: buttonTheme.getAnimationDuration(this),
child: this.child,
materialTapTargetSize: this.materialTapTargetSize ?? theme.materialTapTargetSize);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("enabled", value: this.enabled, ifFalse: "disabled"));
}
}
}

11
Runtime/material/material_button.cs.meta


fileFormatVersion: 2
guid: ea3964e7af24d4b059ac6e10ec862a3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

365
Runtime/material/text_theme.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class TextTheme : Diagnosticable {
public TextTheme(
TextStyle display4 = null,
TextStyle display3 = null,
TextStyle display2 = null,
TextStyle display1 = null,
TextStyle headline = null,
TextStyle title = null,
TextStyle subhead = null,
TextStyle body2 = null,
TextStyle body1 = null,
TextStyle caption = null,
TextStyle button = null,
TextStyle subtitle = null,
TextStyle overline = null
) {
this.display4 = display4;
this.display3 = display3;
this.display2 = display2;
this.display1 = display1;
this.headline = headline;
this.title = title;
this.subhead = subhead;
this.body2 = body2;
this.body1 = body1;
this.caption = caption;
this.button = button;
this.subtitle = subtitle;
this.overline = overline;
}
public readonly TextStyle display4;
public readonly TextStyle display3;
public readonly TextStyle display2;
public readonly TextStyle display1;
public readonly TextStyle headline;
public readonly TextStyle title;
public readonly TextStyle subhead;
public readonly TextStyle body2;
public readonly TextStyle body1;
public readonly TextStyle caption;
public readonly TextStyle button;
public readonly TextStyle subtitle;
public readonly TextStyle overline;
public TextTheme copyWith(
TextStyle display4 = null,
TextStyle display3 = null,
TextStyle display2 = null,
TextStyle display1 = null,
TextStyle headline = null,
TextStyle title = null,
TextStyle subhead = null,
TextStyle body2 = null,
TextStyle body1 = null,
TextStyle caption = null,
TextStyle button = null,
TextStyle subtitle = null,
TextStyle overline = null
) {
return new TextTheme(
display4: display4 ?? this.display4,
display3: display3 ?? this.display3,
display2: display2 ?? this.display2,
display1: display1 ?? this.display1,
headline: headline ?? this.headline,
title: title ?? this.title,
subhead: subhead ?? this.subhead,
body2: body2 ?? this.body2,
body1: body1 ?? this.body1,
caption: caption ?? this.caption,
button: button ?? this.button,
subtitle: subtitle ?? this.subtitle,
overline: overline ?? this.overline
);
}
public TextTheme merge(TextTheme other) {
if (other == null)
return this;
return this.copyWith(
display4: this.display4?.merge(other.display4) ?? other.display4,
display3: this.display3?.merge(other.display3) ?? other.display3,
display2: this.display2?.merge(other.display2) ?? other.display2,
display1: this.display1?.merge(other.display1) ?? other.display1,
headline: this.headline?.merge(other.headline) ?? other.headline,
title: this.title?.merge(other.title) ?? other.title,
subhead: this.subhead?.merge(other.subhead) ?? other.subhead,
body2: this.body2?.merge(other.body2) ?? other.body2,
body1: this.body1?.merge(other.body1) ?? other.body1,
caption: this.caption?.merge(other.caption) ?? other.caption,
button: this.button?.merge(other.button) ?? other.button,
subtitle: this.subtitle?.merge(other.subtitle) ?? other.subtitle,
overline: this.overline?.merge(other.overline) ?? other.overline
);
}
public TextTheme apply(
string fontFamily = null,
double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0,
Color displayColor = null,
Color bodyColor = null,
TextDecoration decoration = null,
Color decorationColor = null,
TextDecorationStyle? decorationStyle = null
) {
return new TextTheme(
display4: this.display4?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
display3: this.display3?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
display2: this.display2?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
display1: this.display1?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
headline: this.headline?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
title: this.title?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
subhead: this.subhead?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
body2: this.body2?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
body1: this.body1?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
caption: this.caption?.apply(
color: displayColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
button: this.button?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
subtitle: this.subtitle?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
),
overline: this.overline?.apply(
color: bodyColor,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
fontFamily: fontFamily,
fontSizeFactor: fontSizeFactor,
fontSizeDelta: fontSizeDelta
)
);
}
public static TextTheme lerp(TextTheme a, TextTheme b, double t) {
D.assert(a != null);
D.assert(b != null);
D.assert(t != null);
return new TextTheme(
display4: TextStyle.lerp(a.display4, b.display4, t),
display3: TextStyle.lerp(a.display3, b.display3, t),
display2: TextStyle.lerp(a.display2, b.display2, t),
display1: TextStyle.lerp(a.display1, b.display1, t),
headline: TextStyle.lerp(a.headline, b.headline, t),
title: TextStyle.lerp(a.title, b.title, t),
subhead: TextStyle.lerp(a.subhead, b.subhead, t),
body2: TextStyle.lerp(a.body2, b.body2, t),
body1: TextStyle.lerp(a.body1, b.body1, t),
caption: TextStyle.lerp(a.caption, b.caption, t),
button: TextStyle.lerp(a.button, b.button, t),
subtitle: TextStyle.lerp(a.subtitle, b.subtitle, t),
overline: TextStyle.lerp(a.overline, b.overline, t)
);
}
public bool Equals(TextTheme other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.display4 == other.display4
&& this.display3 == other.display3
&& this.display2 == other.display2
&& this.display1 == other.display1
&& this.headline == other.headline
&& this.title == other.title
&& this.subhead == other.subhead
&& this.body2 == other.body2
&& this.body1 == other.body1
&& this.caption == other.caption
&& this.button == other.button
&& this.subtitle == other.subtitle
&& this.overline == other.overline;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((TextTheme) obj);
}
public static bool operator ==(TextTheme left, TextTheme right) {
return Equals(left, right);
}
public static bool operator !=(TextTheme left, TextTheme right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.display4.GetHashCode();
hashCode = (hashCode * 397) ^ this.display3.GetHashCode();
hashCode = (hashCode * 397) ^ this.display2.GetHashCode();
hashCode = (hashCode * 397) ^ this.display1.GetHashCode();
hashCode = (hashCode * 397) ^ this.headline.GetHashCode();
hashCode = (hashCode * 397) ^ this.title.GetHashCode();
hashCode = (hashCode * 397) ^ this.subhead.GetHashCode();
hashCode = (hashCode * 397) ^ this.body2.GetHashCode();
hashCode = (hashCode * 397) ^ this.body1.GetHashCode();
hashCode = (hashCode * 397) ^ this.caption.GetHashCode();
hashCode = (hashCode * 397) ^ this.button.GetHashCode();
hashCode = (hashCode * 397) ^ this.subtitle.GetHashCode();
hashCode = (hashCode * 397) ^ this.overline.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
TextTheme defaultTheme = new Typography().black;
properties.add(new DiagnosticsProperty<TextStyle>("display4", this.display4,
defaultValue: defaultTheme.display4));
properties.add(new DiagnosticsProperty<TextStyle>("display3", this.display3,
defaultValue: defaultTheme.display3));
properties.add(new DiagnosticsProperty<TextStyle>("display2", this.display2,
defaultValue: defaultTheme.display2));
properties.add(new DiagnosticsProperty<TextStyle>("display1", this.display1,
defaultValue: defaultTheme.display1));
properties.add(new DiagnosticsProperty<TextStyle>("headline", this.headline,
defaultValue: defaultTheme.headline));
properties.add(new DiagnosticsProperty<TextStyle>("title", this.title, defaultValue: defaultTheme.title));
properties.add(
new DiagnosticsProperty<TextStyle>("subhead", this.subhead, defaultValue: defaultTheme.subhead));
properties.add(new DiagnosticsProperty<TextStyle>("body2", this.body2, defaultValue: defaultTheme.body2));
properties.add(new DiagnosticsProperty<TextStyle>("body1", this.body1, defaultValue: defaultTheme.body1));
properties.add(
new DiagnosticsProperty<TextStyle>("caption", this.caption, defaultValue: defaultTheme.caption));
properties.add(
new DiagnosticsProperty<TextStyle>("button", this.button, defaultValue: defaultTheme.button));
properties.add(new DiagnosticsProperty<TextStyle>("subtitle)", this.subtitle,
defaultValue: defaultTheme.subtitle));
properties.add(new DiagnosticsProperty<TextStyle>("overline", this.overline,
defaultValue: defaultTheme.overline));
}
}
}

11
Runtime/material/text_theme.cs.meta


fileFormatVersion: 2
guid: 48eff72daf6ec48e5805ff0698990499
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

134
Runtime/material/theme.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class Theme : StatelessWidget {
public Theme(
Key key = null,
ThemeData data = null,
bool isMaterialAppTheme = false,
Widget child = null
) : base(key: key) {
D.assert(child != null);
D.assert(data != null);
this.data = data;
this.isMaterialAppTheme = isMaterialAppTheme;
this.child = child;
}
public readonly ThemeData data;
public readonly bool isMaterialAppTheme;
readonly Widget child;
static readonly ThemeData _kFallbackTheme = ThemeData.fallback();
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) {
_InheritedTheme inheritedTheme =
(_InheritedTheme) context.inheritFromWidgetOfExactType(typeof(_InheritedTheme));
if (shadowThemeOnly) {
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme)
return null;
return inheritedTheme.theme.data;
}
//todo:xingwei.zhu: material Localizations
return inheritedTheme?.theme?.data ?? _kFallbackTheme;
}
public override Widget build(BuildContext context) {
return new _InheritedTheme(
theme: this,
child: new IconTheme(
data: this.data.iconTheme,
child: this.child
)
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ThemeData>("data", this.data, showName: false));
}
}
class _InheritedTheme : InheritedWidget {
public _InheritedTheme(
Key key = null,
Theme theme = null,
Widget child = null) : base(key: key, child: child) {
D.assert(theme != null);
D.assert(child != null);
this.theme = theme;
}
public readonly Theme theme;
public override bool updateShouldNotify(InheritedWidget old) =>
this.theme.data != ((_InheritedTheme) old).theme.data;
}
class ThemeDataTween : Tween<ThemeData> {
public ThemeDataTween(
ThemeData begin = null,
ThemeData end = null
) : base(begin: begin, end: end) {
}
public override ThemeData lerp(double t) => ThemeData.lerp(this.begin, this.end, t);
}
class AnimatedTheme : ImplicitlyAnimatedWidget {
public AnimatedTheme(
Key key = null,
ThemeData data = null,
bool isMaterialAppTheme = false,
Curve curve = null,
TimeSpan? duration = null,
Widget child = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration ?? ThemeUtils.kThemeAnimationDuration) {
D.assert(child != null);
D.assert(data != null);
this.data = data;
this.isMaterialAppTheme = isMaterialAppTheme;
this.child = child;
}
public readonly ThemeData data;
public readonly bool isMaterialAppTheme;
public readonly Widget child;
public override State createState() => new _AnimatedThemeState();
}
class _AnimatedThemeState : AnimatedWidgetBaseState<AnimatedTheme> {
ThemeDataTween _data;
protected override void forEachTween(ITweenVisitor visitor) {
this._data = (ThemeDataTween) visitor.visit(this, this._data, this.widget.data,
(ThemeData value) => new ThemeDataTween(begin: value));
}
public override Widget build(BuildContext context) {
return new Theme(
isMaterialAppTheme: this.widget.isMaterialAppTheme,
child: this.widget.child,
data: this._data.evaluate(this.animation)
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(
new DiagnosticsProperty<ThemeDataTween>("data", this._data, showName: false, defaultValue: null));
}
}
}

11
Runtime/material/theme.cs.meta


fileFormatVersion: 2
guid: 8aeba6b651be2405387572671ac527f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

765
Runtime/material/theme_data.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public enum MaterialTapTargetSize {
padded,
shrinkWrap
}
public class ThemeData : Diagnosticable {
public ThemeData(
Brightness? brightness = null,
MaterialColor primarySwatch = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,
Color primaryColorLight = null,
Color primaryColorDark = null,
Color accentColor = null,
Brightness? accentColorBrightness = null,
Color canvasColor = null,
Color scaffoldBackgroundColor = null,
Color bottomAppBarColor = null,
Color cardColor = null,
Color dividerColor = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
Color selectedRowColor = null,
Color unselectedWidgetColor = null,
Color disabledColor = null,
Color buttonColor = null,
ButtonThemeData buttonTheme = null,
Color secondaryHeaderColor = null,
Color textSelectionColor = null,
Color cursorColor = null,
Color textSelectionHandleColor = null,
Color backgroundColor = null,
Color dialogBackgroundColor = null,
Color indicatorColor = null,
Color hintColor = null,
Color errorColor = null,
Color toggleableActiveColor = null,
string fontFamily = null,
TextTheme textTheme = null,
TextTheme primaryTextTheme = null,
TextTheme accentTextTheme = null,
IconThemeData iconTheme = null,
IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
MaterialTapTargetSize? materialTapTargetSize = null,
ColorScheme colorScheme = null,
Typography typography = null
) {
brightness = brightness ?? Brightness.light;
bool isDark = brightness == Brightness.dark;
primarySwatch = primarySwatch ?? Colors.blue;
primaryColor = primaryColor ?? (isDark ? Colors.grey[900] : primarySwatch);
primaryColorBrightness = primaryColorBrightness ?? estimateBrightnessForColor(primaryColor);
primaryColorLight = primaryColorLight ?? (isDark ? Colors.grey[500] : primarySwatch[100]);
primaryColorDark = primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]);
bool primaryIsDark = primaryColorBrightness == Brightness.dark;
toggleableActiveColor = toggleableActiveColor ??
(isDark ? Colors.tealAccent[200] : (accentColor ?? primarySwatch[600]));
accentColor = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch[500]);
accentColorBrightness = accentColorBrightness ?? estimateBrightnessForColor(accentColor);
bool accentIsDark = accentColorBrightness == Brightness.dark;
canvasColor = canvasColor ?? (isDark ? Colors.grey[850] : Colors.grey[50]);
scaffoldBackgroundColor = scaffoldBackgroundColor ?? canvasColor;
bottomAppBarColor = bottomAppBarColor ?? (isDark ? Colors.grey[800] : Colors.white);
cardColor = cardColor ?? (isDark ? Colors.grey[800] : Colors.white);
dividerColor = dividerColor ?? (isDark ? new Color(0x1FFFFFFF) : new Color(0x1F000000));
colorScheme = colorScheme ?? ColorScheme.fromSwatch(
primarySwatch: primarySwatch,
primaryColorDark: primaryColorDark,
accentColor: accentColor,
cardColor: cardColor,
backgroundColor: backgroundColor,
errorColor: errorColor,
brightness: brightness);
splashFactory = splashFactory ?? InkSplash.splashFactory;
selectedRowColor = selectedRowColor ?? Colors.grey[100];
unselectedWidgetColor = unselectedWidgetColor ?? (isDark ? Colors.white70 : Colors.black54);
secondaryHeaderColor = secondaryHeaderColor ?? (isDark ? Colors.grey[700] : primarySwatch[50]);
textSelectionColor = textSelectionColor ?? (isDark ? accentColor : primarySwatch[200]);
cursorColor = cursorColor ?? Color.fromRGBO(66, 133, 244, 1.0);
textSelectionHandleColor =
textSelectionHandleColor ?? (isDark ? Colors.tealAccent[400] : primarySwatch[300]);
backgroundColor = backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]);
dialogBackgroundColor = dialogBackgroundColor ?? (isDark ? Colors.grey[800] : Colors.white);
indicatorColor = indicatorColor ?? (accentColor == primaryColor ? Colors.white : accentColor);
hintColor = hintColor ?? (isDark ? new Color(0x80FFFFFF) : new Color(0x8A000000));
errorColor = errorColor ?? Colors.red[700];
primaryIconTheme = primaryIconTheme ??
(primaryIsDark
? new IconThemeData(color: Colors.white)
: new IconThemeData(color: Colors.black));
accentIconTheme = accentIconTheme ??
(accentIsDark
? new IconThemeData(color: Colors.white)
: new IconThemeData(color: Colors.black));
iconTheme = iconTheme ??
(isDark ? new IconThemeData(color: Colors.white) : new IconThemeData(color: Colors.black87));
typography = typography ?? new Typography();
TextTheme defaultTextTheme = isDark ? typography.white : typography.black;
textTheme = defaultTextTheme.merge(textTheme);
TextTheme defaultPrimaryTextTheme = primaryIsDark ? typography.white : typography.black;
primaryTextTheme = defaultPrimaryTextTheme.merge(primaryTextTheme);
TextTheme defaultAccentTextTheme = accentIsDark ? typography.white : typography.black;
accentTextTheme = defaultAccentTextTheme.merge(accentTextTheme);
materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
if (fontFamily != null) {
textTheme = textTheme.apply(fontFamily: fontFamily);
primaryTextTheme = primaryTextTheme.apply(fontFamily: fontFamily);
accentTextTheme = accentTextTheme.apply(fontFamily: fontFamily);
}
buttonColor = buttonColor ?? (isDark ? primarySwatch[600] : Colors.grey[300]);
buttonTheme = buttonTheme ?? new ButtonThemeData(
colorScheme: colorScheme,
buttonColor: buttonColor,
disabledColor: disabledColor,
highlightColor: highlightColor,
splashColor: splashColor,
materialTapTargetSize: materialTapTargetSize);
disabledColor = disabledColor ?? (isDark ? Colors.white30 : Colors.black38);
highlightColor = highlightColor ??
(isDark
? ThemeDataUtils._kDarkThemeHighlightColor
: ThemeDataUtils._kLightThemeHighlightColor);
splashColor = splashColor ??
(isDark
? ThemeDataUtils._kDarkThemeSplashColor
: ThemeDataUtils._kLightThemeSplashColor);
D.assert(brightness != null);
D.assert(primaryColor != null);
D.assert(primaryColorBrightness != null);
D.assert(primaryColorLight != null);
D.assert(primaryColorDark != null);
D.assert(accentColor != null);
D.assert(accentColorBrightness != null);
D.assert(canvasColor != null);
D.assert(scaffoldBackgroundColor != null);
D.assert(bottomAppBarColor != null);
D.assert(cardColor != null);
D.assert(dividerColor != null);
D.assert(highlightColor != null);
D.assert(splashColor != null);
D.assert(splashFactory != null);
D.assert(selectedRowColor != null);
D.assert(unselectedWidgetColor != null);
D.assert(disabledColor != null);
D.assert(toggleableActiveColor != null);
D.assert(buttonTheme != null);
D.assert(secondaryHeaderColor != null);
D.assert(textSelectionColor != null);
D.assert(cursorColor != null);
D.assert(textSelectionHandleColor != null);
D.assert(backgroundColor != null);
D.assert(dialogBackgroundColor != null);
D.assert(indicatorColor != null);
D.assert(hintColor != null);
D.assert(errorColor != null);
D.assert(textTheme != null);
D.assert(primaryTextTheme != null);
D.assert(accentTextTheme != null);
D.assert(iconTheme != null);
D.assert(primaryIconTheme != null);
D.assert(accentIconTheme != null);
D.assert(materialTapTargetSize != null);
D.assert(colorScheme != null);
D.assert(typography != null);
D.assert(buttonColor != null);
this.brightness = brightness ?? Brightness.light;
this.primaryColor = primaryColor;
this.primaryColorBrightness = primaryColorBrightness ?? Brightness.light;
this.primaryColorLight = primaryColorLight;
this.primaryColorDark = primaryColorDark;
this.canvasColor = canvasColor;
this.accentColor = accentColor;
this.accentColorBrightness = accentColorBrightness ?? Brightness.light;
this.scaffoldBackgroundColor = scaffoldBackgroundColor;
this.bottomAppBarColor = bottomAppBarColor;
this.cardColor = cardColor;
this.dividerColor = dividerColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.splashFactory = splashFactory;
this.selectedRowColor = selectedRowColor;
this.unselectedWidgetColor = unselectedWidgetColor;
this.disabledColor = disabledColor;
this.buttonTheme = buttonTheme;
this.buttonColor = buttonColor;
this.secondaryHeaderColor = secondaryHeaderColor;
this.textSelectionColor = textSelectionColor;
this.cursorColor = cursorColor;
this.textSelectionHandleColor = textSelectionHandleColor;
this.backgroundColor = backgroundColor;
this.dialogBackgroundColor = dialogBackgroundColor;
this.indicatorColor = indicatorColor;
this.hintColor = hintColor;
this.errorColor = errorColor;
this.toggleableActiveColor = toggleableActiveColor;
this.textTheme = textTheme;
this.primaryTextTheme = primaryTextTheme;
this.accentTextTheme = accentTextTheme;
this.iconTheme = iconTheme;
this.primaryIconTheme = primaryIconTheme;
this.accentIconTheme = accentIconTheme;
this.materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
this.colorScheme = colorScheme;
this.typography = typography;
}
public static ThemeData raw(
Brightness? brightness,
Color primaryColor,
Brightness? primaryColorBrightness,
Color primaryColorLight,
Color primaryColorDark,
Color canvasColor,
Color accentColor,
Brightness? accentColorBrightness,
Color scaffoldBackgroundColor,
Color bottomAppBarColor,
Color cardColor,
Color dividerColor,
Color highlightColor,
Color splashColor,
InteractiveInkFeatureFactory splashFactory,
Color selectedRowColor,
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
Color textSelectionHandleColor,
Color backgroundColor,
Color dialogBackgroundColor,
Color indicatorColor,
Color hintColor,
Color errorColor,
Color toggleableActiveColor,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
IconThemeData iconTheme,
IconThemeData primaryIconTheme,
IconThemeData accentIconTheme,
MaterialTapTargetSize materialTapTargetSize,
ColorScheme colorScheme,
Typography typography
) {
D.assert(brightness != null);
D.assert(primaryColor != null);
D.assert(primaryColorBrightness != null);
D.assert(primaryColorLight != null);
D.assert(primaryColorDark != null);
D.assert(accentColor != null);
D.assert(accentColorBrightness != null);
D.assert(canvasColor != null);
D.assert(scaffoldBackgroundColor != null);
D.assert(bottomAppBarColor != null);
D.assert(cardColor != null);
D.assert(dividerColor != null);
D.assert(highlightColor != null);
D.assert(splashColor != null);
D.assert(splashFactory != null);
D.assert(selectedRowColor != null);
D.assert(unselectedWidgetColor != null);
D.assert(disabledColor != null);
D.assert(toggleableActiveColor != null);
D.assert(buttonTheme != null);
D.assert(secondaryHeaderColor != null);
D.assert(textSelectionColor != null);
D.assert(cursorColor != null);
D.assert(textSelectionHandleColor != null);
D.assert(backgroundColor != null);
D.assert(dialogBackgroundColor != null);
D.assert(indicatorColor != null);
D.assert(hintColor != null);
D.assert(errorColor != null);
D.assert(textTheme != null);
D.assert(primaryTextTheme != null);
D.assert(accentTextTheme != null);
D.assert(iconTheme != null);
D.assert(primaryIconTheme != null);
D.assert(accentIconTheme != null);
D.assert(materialTapTargetSize != null);
D.assert(colorScheme != null);
D.assert(typography != null);
D.assert(buttonColor != null);
return new ThemeData(
brightness: brightness,
primaryColor: primaryColor,
primaryColorBrightness: primaryColorBrightness,
primaryColorLight: primaryColorLight,
primaryColorDark: primaryColorDark,
accentColor: accentColor,
accentColorBrightness: accentColorBrightness,
canvasColor: canvasColor,
scaffoldBackgroundColor: scaffoldBackgroundColor,
bottomAppBarColor: bottomAppBarColor,
cardColor: cardColor,
dividerColor: dividerColor,
highlightColor: highlightColor,
splashColor: splashColor,
splashFactory: splashFactory,
selectedRowColor: selectedRowColor,
unselectedWidgetColor: unselectedWidgetColor,
disabledColor: disabledColor,
buttonTheme: buttonTheme,
buttonColor: buttonColor,
toggleableActiveColor: toggleableActiveColor,
secondaryHeaderColor: secondaryHeaderColor,
textSelectionColor: textSelectionColor,
cursorColor: cursorColor,
textSelectionHandleColor: textSelectionHandleColor,
backgroundColor: backgroundColor,
dialogBackgroundColor: dialogBackgroundColor,
indicatorColor: indicatorColor,
hintColor: hintColor,
errorColor: errorColor,
textTheme: textTheme,
primaryTextTheme: primaryTextTheme,
accentTextTheme: accentTextTheme,
iconTheme: iconTheme,
primaryIconTheme: primaryIconTheme,
accentIconTheme: accentIconTheme,
materialTapTargetSize: materialTapTargetSize,
colorScheme: colorScheme,
typography: typography);
}
public static ThemeData light() => new ThemeData(brightness: Brightness.light);
public static ThemeData dark() => new ThemeData(brightness: Brightness.dark);
public static ThemeData fallback() => light();
public readonly Brightness brightness;
public readonly Color primaryColor;
public readonly Brightness primaryColorBrightness;
public readonly Color primaryColorLight;
public readonly Color primaryColorDark;
public readonly Color canvasColor;
public readonly Color accentColor;
public readonly Brightness accentColorBrightness;
public readonly Color scaffoldBackgroundColor;
public readonly Color bottomAppBarColor;
public readonly Color cardColor;
public readonly Color dividerColor;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly InteractiveInkFeatureFactory splashFactory;
public readonly Color selectedRowColor;
public readonly Color unselectedWidgetColor;
public readonly Color disabledColor;
public readonly ButtonThemeData buttonTheme;
public readonly Color buttonColor;
public readonly Color secondaryHeaderColor;
public readonly Color textSelectionColor;
public readonly Color cursorColor;
public readonly Color textSelectionHandleColor;
public readonly Color backgroundColor;
public readonly Color dialogBackgroundColor;
public readonly Color indicatorColor;
public readonly Color hintColor;
public readonly Color errorColor;
public readonly Color toggleableActiveColor;
public readonly TextTheme textTheme;
public readonly TextTheme primaryTextTheme;
public readonly TextTheme accentTextTheme;
public readonly IconThemeData iconTheme;
public readonly IconThemeData primaryIconTheme;
public readonly IconThemeData accentIconTheme;
public readonly MaterialTapTargetSize materialTapTargetSize;
public readonly ColorScheme colorScheme;
public readonly Typography typography;
public ThemeData copyWith(
Brightness? brightness,
Color primaryColor,
Brightness? primaryColorBrightness,
Color primaryColorLight,
Color primaryColorDark,
Color accentColor,
Brightness? accentColorBrightness,
Color canvasColor,
Color scaffoldBackgroundColor,
Color bottomAppBarColor,
Color cardColor,
Color dividerColor,
Color highlightColor,
Color splashColor,
InteractiveInkFeatureFactory splashFactory,
Color selectedRowColor,
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
Color textSelectionHandleColor,
Color backgroundColor,
Color dialogBackgroundColor,
Color indicatorColor,
Color hintColor,
Color errorColor,
Color toggleableActiveColor,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
IconThemeData iconTheme,
IconThemeData primaryIconTheme,
IconThemeData accentIconTheme,
MaterialTapTargetSize? materialTapTargetSize,
ColorScheme colorScheme,
Typography typography
) {
return raw(
brightness: brightness ?? this.brightness,
primaryColor: primaryColor ?? this.primaryColor,
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
primaryColorLight: primaryColorLight ?? this.primaryColorLight,
primaryColorDark: primaryColorDark ?? this.primaryColorDark,
accentColor: accentColor ?? this.accentColor,
accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness,
canvasColor: canvasColor ?? this.canvasColor,
scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor,
bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor,
cardColor: cardColor ?? this.cardColor,
dividerColor: dividerColor ?? this.dividerColor,
highlightColor: highlightColor ?? this.highlightColor,
splashColor: splashColor ?? this.splashColor,
splashFactory: splashFactory ?? this.splashFactory,
selectedRowColor: selectedRowColor ?? this.selectedRowColor,
unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
disabledColor: disabledColor ?? this.disabledColor,
buttonTheme: buttonTheme ?? this.buttonTheme,
buttonColor: buttonColor ?? this.buttonColor,
secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
textSelectionColor: textSelectionColor ?? this.textSelectionColor,
cursorColor: cursorColor ?? this.cursorColor,
textSelectionHandleColor: textSelectionHandleColor ?? this.textSelectionHandleColor,
backgroundColor: backgroundColor ?? this.backgroundColor,
dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
indicatorColor: indicatorColor ?? this.indicatorColor,
hintColor: hintColor ?? this.hintColor,
errorColor: errorColor ?? this.errorColor,
toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
textTheme: textTheme ?? this.textTheme,
primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
accentTextTheme: accentTextTheme ?? this.accentTextTheme,
iconTheme: iconTheme ?? this.iconTheme,
primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
accentIconTheme: accentIconTheme ?? this.accentIconTheme,
materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
colorScheme: colorScheme ?? this.colorScheme,
typography: typography ?? this.typography
);
}
public static Brightness estimateBrightnessForColor(Color color) {
double relativeLuminance = color.computeLuminance();
double kThreshold = 0.15;
if ((relativeLuminance + 0.05) * (relativeLuminance + 0.05) > kThreshold)
return Brightness.light;
return Brightness.dark;
}
public static ThemeData lerp(ThemeData a, ThemeData b, double t) {
D.assert(a != null);
D.assert(b != null);
return raw(
brightness: t < 0.5 ? a.brightness : b.brightness,
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t),
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t),
primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t),
canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t),
accentColor: Color.lerp(a.accentColor, b.accentColor, t),
accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness,
scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t),
bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t),
cardColor: Color.lerp(a.cardColor, b.cardColor, t),
dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t),
highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t),
splashColor: Color.lerp(a.splashColor, b.splashColor, t),
splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t),
unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t),
disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t),
buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t),
textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t),
cursorColor: Color.lerp(a.cursorColor, b.cursorColor, t),
textSelectionHandleColor: Color.lerp(a.textSelectionHandleColor, b.textSelectionHandleColor, t),
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t),
indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t),
hintColor: Color.lerp(a.hintColor, b.hintColor, t),
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t),
primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t),
accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t),
iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t),
primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t),
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
typography: Typography.lerp(a.typography, b.typography, t)
);
}
public bool Equals(ThemeData other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other.brightness == this.brightness &&
other.primaryColor == this.primaryColor &&
other.primaryColorBrightness == this.primaryColorBrightness &&
other.primaryColorLight == this.primaryColorLight &&
other.primaryColorDark == this.primaryColorDark &&
other.accentColor == this.accentColor &&
other.accentColorBrightness == this.accentColorBrightness &&
other.canvasColor == this.canvasColor &&
other.scaffoldBackgroundColor == this.scaffoldBackgroundColor &&
other.bottomAppBarColor == this.bottomAppBarColor &&
other.cardColor == this.cardColor &&
other.dividerColor == this.dividerColor &&
other.highlightColor == this.highlightColor &&
other.splashColor == this.splashColor &&
other.splashFactory == this.splashFactory &&
other.selectedRowColor == this.selectedRowColor &&
other.unselectedWidgetColor == this.unselectedWidgetColor &&
other.disabledColor == this.disabledColor &&
other.buttonTheme == this.buttonTheme &&
other.buttonColor == this.buttonColor &&
other.secondaryHeaderColor == this.secondaryHeaderColor &&
other.textSelectionColor == this.textSelectionColor &&
other.cursorColor == this.cursorColor &&
other.textSelectionHandleColor == this.textSelectionHandleColor &&
other.backgroundColor == this.backgroundColor &&
other.dialogBackgroundColor == this.dialogBackgroundColor &&
other.indicatorColor == this.indicatorColor &&
other.hintColor == this.hintColor &&
other.errorColor == this.errorColor &&
other.textTheme == this.textTheme &&
other.primaryTextTheme == this.primaryTextTheme &&
other.accentTextTheme == this.accentTextTheme &&
other.toggleableActiveColor == this.toggleableActiveColor &&
other.iconTheme == this.iconTheme &&
other.primaryIconTheme == this.primaryIconTheme &&
other.accentIconTheme == this.accentIconTheme &&
other.materialTapTargetSize == this.materialTapTargetSize &&
other.colorScheme == this.colorScheme &&
other.typography == this.typography;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ThemeData) obj);
}
public static bool operator ==(ThemeData left, ThemeData right) {
return Equals(left, right);
}
public static bool operator !=(ThemeData left, ThemeData right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.brightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColorBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColorLight.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryColorDark.GetHashCode();
hashCode = (hashCode * 397) ^ this.canvasColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentColorBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.scaffoldBackgroundColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.bottomAppBarColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.cardColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.dividerColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.highlightColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.splashColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.splashFactory.GetHashCode();
hashCode = (hashCode * 397) ^ this.selectedRowColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.unselectedWidgetColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.disabledColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.buttonTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.buttonColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.secondaryHeaderColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.textSelectionColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.cursorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.textSelectionHandleColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.backgroundColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.dialogBackgroundColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.indicatorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.hintColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.errorColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.toggleableActiveColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.textTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryTextTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentTextTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.iconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.materialTapTargetSize.GetHashCode();
hashCode = (hashCode * 397) ^ this.colorScheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.typography.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
ThemeData defaultData = fallback();
properties.add(new EnumProperty<Brightness>("brightness", this.brightness,
defaultValue: defaultData.brightness));
properties.add(new DiagnosticsProperty<Color>("primaryColor", this.primaryColor,
defaultValue: defaultData.primaryColor));
properties.add(new EnumProperty<Brightness>("primaryColorBrightness", this.primaryColorBrightness,
defaultValue: defaultData.primaryColorBrightness));
properties.add(new DiagnosticsProperty<Color>("accentColor", this.accentColor,
defaultValue: defaultData.accentColor));
properties.add(new EnumProperty<Brightness>("accentColorBrightness", this.accentColorBrightness,
defaultValue: defaultData.accentColorBrightness));
properties.add(new DiagnosticsProperty<Color>("canvasColor", this.canvasColor,
defaultValue: defaultData.canvasColor));
properties.add(new DiagnosticsProperty<Color>("scaffoldBackgroundColor", this.scaffoldBackgroundColor,
defaultValue: defaultData.scaffoldBackgroundColor));
properties.add(new DiagnosticsProperty<Color>("bottomAppBarColor", this.bottomAppBarColor,
defaultValue: defaultData.bottomAppBarColor));
properties.add(new DiagnosticsProperty<Color>("cardColor", this.cardColor,
defaultValue: defaultData.cardColor));
properties.add(new DiagnosticsProperty<Color>("dividerColor", this.dividerColor,
defaultValue: defaultData.dividerColor));
properties.add(new DiagnosticsProperty<Color>("highlightColor", this.highlightColor,
defaultValue: defaultData.highlightColor));
properties.add(new DiagnosticsProperty<Color>("splashColor", this.splashColor,
defaultValue: defaultData.splashColor));
properties.add(new DiagnosticsProperty<Color>("selectedRowColor", this.selectedRowColor,
defaultValue: defaultData.selectedRowColor));
properties.add(new DiagnosticsProperty<Color>("unselectedWidgetColor", this.unselectedWidgetColor,
defaultValue: defaultData.unselectedWidgetColor));
properties.add(new DiagnosticsProperty<Color>("disabledColor", this.disabledColor,
defaultValue: defaultData.disabledColor));
properties.add(new DiagnosticsProperty<ButtonThemeData>("buttonTheme", this.buttonTheme));
properties.add(new DiagnosticsProperty<Color>("buttonColor", this.buttonColor,
defaultValue: defaultData.buttonColor));
properties.add(new DiagnosticsProperty<Color>("secondaryHeaderColor", this.secondaryHeaderColor,
defaultValue: defaultData.secondaryHeaderColor));
properties.add(new DiagnosticsProperty<Color>("textSelectionColor", this.textSelectionColor,
defaultValue: defaultData.textSelectionColor));
properties.add(new DiagnosticsProperty<Color>("cursorColor", this.cursorColor,
defaultValue: defaultData.cursorColor));
properties.add(new DiagnosticsProperty<Color>("textSelectionHandleColor", this.textSelectionHandleColor,
defaultValue: defaultData.textSelectionHandleColor));
properties.add(new DiagnosticsProperty<Color>("backgroundColor", this.backgroundColor,
defaultValue: defaultData.backgroundColor));
properties.add(new DiagnosticsProperty<Color>("dialogBackgroundColor", this.dialogBackgroundColor,
defaultValue: defaultData.dialogBackgroundColor));
properties.add(new DiagnosticsProperty<Color>("indicatorColor", this.indicatorColor,
defaultValue: defaultData.indicatorColor));
properties.add(new DiagnosticsProperty<Color>("hintColor", this.hintColor,
defaultValue: defaultData.hintColor));
properties.add(new DiagnosticsProperty<Color>("errorColor", this.errorColor,
defaultValue: defaultData.errorColor));
properties.add(new DiagnosticsProperty<TextTheme>("textTheme", this.textTheme));
properties.add(new DiagnosticsProperty<TextTheme>("primaryTextTheme", this.primaryTextTheme));
properties.add(new DiagnosticsProperty<TextTheme>("accentTextTheme", this.accentTextTheme));
properties.add(new DiagnosticsProperty<Color>("toggleableActiveColor", this.toggleableActiveColor,
defaultValue: defaultData.toggleableActiveColor));
properties.add(new DiagnosticsProperty<IconThemeData>("iconTheme", this.iconTheme));
properties.add(new DiagnosticsProperty<IconThemeData>("primaryIconTheme", this.primaryIconTheme));
properties.add(new DiagnosticsProperty<IconThemeData>("accentIconTheme", this.accentIconTheme));
properties.add(
new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", this.materialTapTargetSize));
properties.add(new DiagnosticsProperty<ColorScheme>("colorScheme", this.colorScheme,
defaultValue: defaultData.colorScheme));
properties.add(new DiagnosticsProperty<Typography>("typography", this.typography,
defaultValue: defaultData.typography));
}
}
}

11
Runtime/material/theme_data.cs.meta


fileFormatVersion: 2
guid: 68fb5edae4e8440669205d4e5b27ea30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

449
Runtime/material/typography.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public enum ScriptCategory {
englishLike,
dense,
tall
}
public class Typography : Diagnosticable {
public Typography(
TextTheme black = null,
TextTheme white = null,
TextTheme englishLike = null,
TextTheme dense = null,
TextTheme tall = null
) {
black = black ?? blackMountainView;
white = white ?? whiteMountainView;
englishLike = englishLike ?? englishLike2014;
dense = dense ?? dense2014;
tall = tall ?? tall2014;
D.assert(black != null);
D.assert(white != null);
D.assert(englishLike != null);
D.assert(dense != null);
D.assert(tall != null);
this.black = black;
this.white = white;
this.englishLike = englishLike;
this.dense = dense;
this.tall = tall;
}
public readonly TextTheme black;
public readonly TextTheme white;
public readonly TextTheme englishLike;
public readonly TextTheme dense;
public readonly TextTheme tall;
public TextTheme geometryThemeFor(ScriptCategory category) {
switch (category) {
case ScriptCategory.englishLike:
return this.englishLike;
case ScriptCategory.dense:
return this.dense;
case ScriptCategory.tall:
return this.tall;
}
return null;
}
public Typography copyWith(
TextTheme black = null,
TextTheme white = null,
TextTheme englishLike = null,
TextTheme dense = null,
TextTheme tall = null) {
return new Typography(
black: black ?? this.black,
white: white ?? this.white,
englishLike: englishLike ?? this.englishLike,
dense: dense ?? this.dense,
tall: tall ?? this.tall);
}
public static Typography lerp(Typography a, Typography b, double t) {
return new Typography(
black: TextTheme.lerp(a.black, b.black, t),
white: TextTheme.lerp(a.white, b.white, t),
englishLike: TextTheme.lerp(a.englishLike, b.englishLike, t),
dense: TextTheme.lerp(a.dense, b.dense, t),
tall: TextTheme.lerp(a.tall, b.tall, t)
);
}
public bool Equals(Typography other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.black == other.black
&& this.white == other.white
&& this.englishLike == other.englishLike
&& this.dense == other.dense
&& this.tall == other.tall;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Typography) obj);
}
public static bool operator ==(Typography left, Typography right) {
return Equals(left, right);
}
public static bool operator !=(Typography left, Typography right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this.black.GetHashCode();
hashCode = (hashCode * 397) ^ this.white.GetHashCode();
hashCode = (hashCode * 397) ^ this.englishLike.GetHashCode();
hashCode = (hashCode * 397) ^ this.dense.GetHashCode();
hashCode = (hashCode * 397) ^ this.tall.GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
Typography defaultTypography = new Typography();
properties.add(
new DiagnosticsProperty<TextTheme>("black", this.black, defaultValue: defaultTypography.black));
properties.add(
new DiagnosticsProperty<TextTheme>("white", this.white, defaultValue: defaultTypography.white));
properties.add(new DiagnosticsProperty<TextTheme>("englishLike", this.englishLike,
defaultValue: defaultTypography.englishLike));
properties.add(
new DiagnosticsProperty<TextTheme>("dense", this.dense, defaultValue: defaultTypography.dense));
properties.add(new DiagnosticsProperty<TextTheme>("tall", this.tall, defaultValue: defaultTypography.tall));
}
public static readonly TextTheme blackMountainView = new TextTheme(
display4: new TextStyle(debugLabel: "blackMountainView display4", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "blackMountainView display3", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "blackMountainView display2", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "blackMountainView display1", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "blackMountainView headline", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "blackMountainView title", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "blackMountainView subhead", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "blackMountainView body2", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "blackMountainView body1", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "blackMountainView caption", fontFamily: "Roboto", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "blackMountainView button", fontFamily: "Roboto", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "blackMountainView subtitle", fontFamily: "Roboto", inherit: true,
color: Colors.black, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "blackMountainView overline", fontFamily: "Roboto", inherit: true,
color: Colors.black, decoration: TextDecoration.none)
);
public static readonly TextTheme whiteMountainView = new TextTheme(
display4: new TextStyle(debugLabel: "whiteMountainView display4", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "whiteMountainView display3", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "whiteMountainView display2", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "whiteMountainView display1", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "whiteMountainView headline", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "whiteMountainView title", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "whiteMountainView subhead", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "whiteMountainView body2", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "whiteMountainView body1", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "whiteMountainView caption", fontFamily: "Roboto", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "whiteMountainView button", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "whiteMountainView subtitle", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "whiteMountainView overline", fontFamily: "Roboto", inherit: true,
color: Colors.white, decoration: TextDecoration.none)
);
public static readonly TextTheme blackCupertino = new TextTheme(
display4: new TextStyle(debugLabel: "blackCupertino display4", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "blackCupertino display3", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "blackCupertino display2", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "blackCupertino display1", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "blackCupertino headline", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "blackCupertino title", fontFamily: ".SF UI Display", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "blackCupertino subhead", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "blackCupertino body2", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "blackCupertino body1", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "blackCupertino caption", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black54, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "blackCupertino button", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black87, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "blackCupertino subtitle", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "blackCupertino overline", fontFamily: ".SF UI Text", inherit: true,
color: Colors.black, decoration: TextDecoration.none)
);
public static readonly TextTheme whiteCupertino = new TextTheme(
display4: new TextStyle(debugLabel: "whiteCupertino display4", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display3: new TextStyle(debugLabel: "whiteCupertino display3", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display2: new TextStyle(debugLabel: "whiteCupertino display2", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
display1: new TextStyle(debugLabel: "whiteCupertino display1", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
headline: new TextStyle(debugLabel: "whiteCupertino headline", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
title: new TextStyle(debugLabel: "whiteCupertino title", fontFamily: ".SF UI Display", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subhead: new TextStyle(debugLabel: "whiteCupertino subhead", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body2: new TextStyle(debugLabel: "whiteCupertino body2", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
body1: new TextStyle(debugLabel: "whiteCupertino body1", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
caption: new TextStyle(debugLabel: "whiteCupertino caption", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white70, decoration: TextDecoration.none),
button: new TextStyle(debugLabel: "whiteCupertino button", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
subtitle: new TextStyle(debugLabel: "whiteCupertino subtitle", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none),
overline: new TextStyle(debugLabel: "whiteCupertino overline", fontFamily: ".SF UI Text", inherit: true,
color: Colors.white, decoration: TextDecoration.none)
);
public static readonly TextTheme englishLike2014 = new TextTheme(
display4: new TextStyle(debugLabel: "englishLike display4 2014", inherit: false, fontSize: 112.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display3: new TextStyle(debugLabel: "englishLike display3 2014", inherit: false, fontSize: 56.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display2: new TextStyle(debugLabel: "englishLike display2 2014", inherit: false, fontSize: 45.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display1: new TextStyle(debugLabel: "englishLike display1 2014", inherit: false, fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
headline: new TextStyle(debugLabel: "englishLike headline 2014", inherit: false, fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
title: new TextStyle(debugLabel: "englishLike title 2014", inherit: false, fontSize: 20.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
subhead: new TextStyle(debugLabel: "englishLike subhead 2014", inherit: false, fontSize: 16.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
body2: new TextStyle(debugLabel: "englishLike body2 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
body1: new TextStyle(debugLabel: "englishLike body1 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
caption: new TextStyle(debugLabel: "englishLike caption 2014", inherit: false, fontSize: 12.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
button: new TextStyle(debugLabel: "englishLike button 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2014", inherit: false, fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1),
overline: new TextStyle(debugLabel: "englishLike overline 2014", inherit: false, fontSize: 10.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5)
);
public static readonly TextTheme englishLike2018 = new TextTheme(
display4: new TextStyle(debugLabel: "englishLike display4 2018", fontSize: 96.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -1.5),
display3: new TextStyle(debugLabel: "englishLike display3 2018", fontSize: 60.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -0.5),
display2: new TextStyle(debugLabel: "englishLike display2 2018", fontSize: 48.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0),
display1: new TextStyle(debugLabel: "englishLike display1 2018", fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25),
headline: new TextStyle(debugLabel: "englishLike headline 2018", fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0),
title: new TextStyle(debugLabel: "englishLike title 2018", fontSize: 20.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15),
subhead: new TextStyle(debugLabel: "englishLike subhead 2018", fontSize: 16.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15),
body2: new TextStyle(debugLabel: "englishLike body2 2018", fontSize: 14.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25),
body1: new TextStyle(debugLabel: "englishLike body1 2018", fontSize: 16.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.5),
button: new TextStyle(debugLabel: "englishLike button 2018", fontSize: 14.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.75),
caption: new TextStyle(debugLabel: "englishLike caption 2018", fontSize: 12.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.4),
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2018", fontSize: 14.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1),
overline: new TextStyle(debugLabel: "englishLike overline 2018", fontSize: 10.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5)
);
public static readonly TextTheme dense2014 = new TextTheme(
display4: new TextStyle(debugLabel: "dense display4 2014", inherit: false, fontSize: 112.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
display3: new TextStyle(debugLabel: "dense display3 2014", inherit: false, fontSize: 56.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
display2: new TextStyle(debugLabel: "dense display2 2014", inherit: false, fontSize: 45.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
display1: new TextStyle(debugLabel: "dense display1 2014", inherit: false, fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
headline: new TextStyle(debugLabel: "dense headline 2014", inherit: false, fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
title: new TextStyle(debugLabel: "dense title 2014", inherit: false, fontSize: 21.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
subhead: new TextStyle(debugLabel: "dense subhead 2014", inherit: false, fontSize: 17.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
body2: new TextStyle(debugLabel: "dense body2 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
body1: new TextStyle(debugLabel: "dense body1 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
caption: new TextStyle(debugLabel: "dense caption 2014", inherit: false, fontSize: 13.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
button: new TextStyle(debugLabel: "dense button 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
subtitle: new TextStyle(debugLabel: "dense subtitle 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic),
overline: new TextStyle(debugLabel: "dense overline 2014", inherit: false, fontSize: 11.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic)
);
public static readonly TextTheme dense2018 = new TextTheme(
display4: new TextStyle(debugLabel: "dense display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
display3: new TextStyle(debugLabel: "dense display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
display2: new TextStyle(debugLabel: "dense display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
display1: new TextStyle(debugLabel: "dense display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
headline: new TextStyle(debugLabel: "dense headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
title: new TextStyle(debugLabel: "dense title 2018", fontSize: 21.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
subhead: new TextStyle(debugLabel: "dense subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
body2: new TextStyle(debugLabel: "dense body2 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
body1: new TextStyle(debugLabel: "dense body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
caption: new TextStyle(debugLabel: "dense caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
button: new TextStyle(debugLabel: "dense button 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
subtitle: new TextStyle(debugLabel: "dense subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic),
overline: new TextStyle(debugLabel: "dense overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.ideographic)
);
public static readonly TextTheme tall2014 = new TextTheme(
display4: new TextStyle(debugLabel: "tall display4 2014", inherit: false, fontSize: 112.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display3: new TextStyle(debugLabel: "tall display3 2014", inherit: false, fontSize: 56.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display2: new TextStyle(debugLabel: "tall display2 2014", inherit: false, fontSize: 45.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
display1: new TextStyle(debugLabel: "tall display1 2014", inherit: false, fontSize: 34.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
headline: new TextStyle(debugLabel: "tall headline 2014", inherit: false, fontSize: 24.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
title: new TextStyle(debugLabel: "tall title 2014", inherit: false, fontSize: 21.0,
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic),
subhead: new TextStyle(debugLabel: "tall subhead 2014", inherit: false, fontSize: 17.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
body2: new TextStyle(debugLabel: "tall body2 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic),
body1: new TextStyle(debugLabel: "tall body1 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
caption: new TextStyle(debugLabel: "tall caption 2014", inherit: false, fontSize: 13.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
button: new TextStyle(debugLabel: "tall button 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic),
subtitle: new TextStyle(debugLabel: "tall subtitle 2014", inherit: false, fontSize: 15.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
overline: new TextStyle(debugLabel: "tall overline 2014", inherit: false, fontSize: 11.0,
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic)
);
public static readonly TextTheme tall2018 = new TextTheme(
display4: new TextStyle(debugLabel: "tall display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
display3: new TextStyle(debugLabel: "tall display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
display2: new TextStyle(debugLabel: "tall display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
display1: new TextStyle(debugLabel: "tall display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
headline: new TextStyle(debugLabel: "tall headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
title: new TextStyle(debugLabel: "tall title 2018", fontSize: 21.0, fontWeight: FontWeight.w700,
textBaseline: TextBaseline.alphabetic),
subhead: new TextStyle(debugLabel: "tall subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
body2: new TextStyle(debugLabel: "tall body2 2018", fontSize: 17.0, fontWeight: FontWeight.w700,
textBaseline: TextBaseline.alphabetic),
body1: new TextStyle(debugLabel: "tall body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
button: new TextStyle(debugLabel: "tall button 2018", fontSize: 15.0, fontWeight: FontWeight.w700,
textBaseline: TextBaseline.alphabetic),
caption: new TextStyle(debugLabel: "tall caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
subtitle: new TextStyle(debugLabel: "tall subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic),
overline: new TextStyle(debugLabel: "tall overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400,
textBaseline: TextBaseline.alphabetic)
);
}
}

11
Runtime/material/typography.cs.meta


fileFormatVersion: 2
guid: a7dbdefd2b4fd44dd9ff8d23eb224a31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

77
Runtime/material/utils.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public static class ThemeDataUtils {
public static readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC);
public static readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8);
public static readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC);
public static readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC);
}
public static class ThemeUtils {
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200);
}
public static class MaterialConstantsUtils {
public static readonly Dictionary<MaterialType, BorderRadius> kMaterialEdges =
new Dictionary<MaterialType, BorderRadius> {
{MaterialType.canvas, null},
{MaterialType.card, BorderRadius.circular(2.0)},
{MaterialType.circle, null},
{MaterialType.button, BorderRadius.circular(2.0)},
{MaterialType.transparency, null}
};
}
public static class InkHighlightUtils {
public static readonly TimeSpan _kHighlightFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
}
public static class InkSplashUtils {
public static readonly TimeSpan _kUnconfirmedSplashDuration = new TimeSpan(0, 0, 0, 1, 0);
public static readonly TimeSpan _kSplashFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
public const double _kSplashInitialSize = 0.0;
public const double _kSplashConfirmedVelocity = 1.0;
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell,
RectCallback rectCallback) {
if (rectCallback != null) {
D.assert(containedInkWell);
return rectCallback;
}
if (containedInkWell)
return () => Offset.zero & referenceBox.size;
return null;
}
public static double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
Offset position) {
if (containedInkWell) {
Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
return _getSplashRadiusForPositionInSize(size, position);
}
return Material.defaultSplashRadius;
}
static double _getSplashRadiusForPositionInSize(Size bounds, Offset position) {
double d1 = (position - bounds.topLeft(Offset.zero)).distance;
double d2 = (position - bounds.topRight(Offset.zero)).distance;
double d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
double d4 = (position - bounds.bottomRight(Offset.zero)).distance;
return Math.Max(Math.Max(d1, d2), Math.Max(d3, d4)).ceil();
}
}
}

11
Runtime/material/utils.cs.meta


fileFormatVersion: 2
guid: 39236c38160ee4c0e928e3658102fd71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

63
Runtime/painting/colors.cs


using System.Collections.Generic;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {
public class ColorSwatch<T> : Color {
public ColorSwatch(
long primary,
Dictionary<T, Color> swatch) : base(primary) {
this._swatch = swatch;
}
protected readonly Dictionary<T, Color> _swatch;
public Color this[T index] => this._swatch[index];
public bool Equals(ColorSwatch<T> other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.value == other.value && this._swatch == other._swatch;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((ColorSwatch<T>) obj);
}
public static bool operator ==(ColorSwatch<T> left, ColorSwatch<T> right) {
return Equals(left, right);
}
public static bool operator !=(ColorSwatch<T> left, ColorSwatch<T> right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = (int) this.value;
hashCode = (hashCode * 397) ^ this._swatch.GetHashCode();
return hashCode;
}
}
public override string ToString() => this.GetType() + "(primary value: " + base.ToString() + ")";
}
}

11
Runtime/painting/colors.cs.meta


fileFormatVersion: 2
guid: 8589f247e5dcd4f4e8cc22eee9fdbf36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

169
Runtime/service/system_chrome.cs


using System.Collections.Generic;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.service {
public enum DeviceOrientation {
potraitUp,
landscapeLeft,
portraitDown,
landscapeRight
}
public class ApplicationSwitcherDescription {
public ApplicationSwitcherDescription(
string label = null,
int? primaryColor = null
) {
this.label = label;
this.primaryColor = primaryColor;
}
public readonly string label;
public readonly int? primaryColor;
}
public enum SystemUiOverlay {
top,
bottom
}
public enum Brightness {
dark,
light
}
public class SystemUiOverlayStyle {
public SystemUiOverlayStyle(
Color systemNavigationBarColor = null,
Color systemNavigationBarDividerColor = null,
Brightness? systemNavigationBarIconBrightness = null,
Color statusBarColor = null,
Brightness? statusBarBrightness = null,
Brightness? statusBarIconBrightness = null
) {
this.systemNavigationBarColor = systemNavigationBarColor;
this.systemNavigationBarDividerColor = systemNavigationBarDividerColor;
this.systemNavigationBarIconBrightness = systemNavigationBarIconBrightness;
this.statusBarColor = statusBarColor;
this.statusBarBrightness = statusBarBrightness;
this.statusBarIconBrightness = statusBarIconBrightness;
}
public readonly Color systemNavigationBarColor;
public readonly Color systemNavigationBarDividerColor;
public readonly Brightness? systemNavigationBarIconBrightness;
public readonly Color statusBarColor;
public readonly Brightness? statusBarBrightness;
public readonly Brightness? statusBarIconBrightness;
public static readonly SystemUiOverlayStyle light = new SystemUiOverlayStyle(
systemNavigationBarColor: new Color(0xFF000000),
systemNavigationBarDividerColor: null,
statusBarColor: null,
systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.dark
);
public static readonly SystemUiOverlayStyle dark = new SystemUiOverlayStyle(
systemNavigationBarColor: new Color(0xFF000000),
systemNavigationBarDividerColor: null,
statusBarColor: null,
systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light
);
public Dictionary<string, object> _toMap() {
return new Dictionary<string, object> {
{"systemNavigationBarColor", this.systemNavigationBarColor?.value},
{"systemNavigationBarDividerColor", this.systemNavigationBarDividerColor?.value},
{"statusBarColor", this.statusBarColor?.value},
{"statusBarBrightness", this.statusBarBrightness?.ToString()},
{"statusBarIconBrightness", this.statusBarIconBrightness?.ToString()},
{"systemNavigationBarIconBrightness", this.systemNavigationBarIconBrightness?.ToString()}
};
}
public string toString() => this._toMap().ToString();
public SystemUiOverlayStyle copyWith(
Color systemNavigationBarColor = null,
Color systemNavigationBarDividerColor = null,
Color statusBarColor = null,
Brightness? statusBarBrightness = null,
Brightness? statusBarIconBrightness = null,
Brightness? systemNavigationBarIconBrightness = null
) {
return new SystemUiOverlayStyle(
systemNavigationBarColor: systemNavigationBarColor ?? this.systemNavigationBarColor,
systemNavigationBarDividerColor:
systemNavigationBarDividerColor ?? this.systemNavigationBarDividerColor,
statusBarColor: statusBarColor ?? this.statusBarColor,
statusBarIconBrightness: statusBarIconBrightness ?? this.statusBarIconBrightness,
statusBarBrightness: statusBarBrightness ?? this.statusBarBrightness,
systemNavigationBarIconBrightness: systemNavigationBarIconBrightness ??
this.systemNavigationBarIconBrightness
);
}
public int GetHashCode() {
var hashCode = this.systemNavigationBarColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.systemNavigationBarDividerColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.statusBarColor.GetHashCode();
hashCode = (hashCode * 397) ^ this.statusBarBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.statusBarIconBrightness.GetHashCode();
hashCode = (hashCode * 397) ^ this.systemNavigationBarIconBrightness.GetHashCode();
return hashCode;
}
public bool Equals(SystemUiOverlayStyle other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other.systemNavigationBarColor == this.systemNavigationBarColor &&
other.systemNavigationBarDividerColor == this.systemNavigationBarDividerColor &&
other.statusBarColor == this.statusBarColor &&
other.statusBarIconBrightness == this.statusBarIconBrightness &&
other.statusBarBrightness == this.statusBarIconBrightness &&
other.systemNavigationBarIconBrightness == this.systemNavigationBarIconBrightness;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((SystemUiOverlayStyle) obj);
}
public static bool operator ==(SystemUiOverlayStyle left, SystemUiOverlayStyle right) {
return Equals(left, right);
}
public static bool operator !=(SystemUiOverlayStyle left, SystemUiOverlayStyle right) {
return !Equals(left, right);
}
}
}

11
Runtime/service/system_chrome.cs.meta


fileFormatVersion: 2
guid: 7dec1d416078846ec89141bd833cb550
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

353
Runtime/widgets/implicit_animations.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.widgets {
public class BoxConstraintsTween : Tween<BoxConstraints> {
public BoxConstraintsTween(
BoxConstraints begin = null,
BoxConstraints end = null
) : base(begin: begin, end: end) {
}
public override BoxConstraints lerp(double t) => BoxConstraints.lerp(this.begin, this.end, t);
}
public class BorderRadiusTween : Tween<BorderRadius> {
public BorderRadiusTween(
BorderRadius begin = null,
BorderRadius end = null) : base(begin: begin, end: end) {
}
public override BorderRadius lerp(double t) => BorderRadius.lerp(this.begin, this.end, t);
}
public class TextStyleTween : Tween<TextStyle> {
public TextStyleTween(
TextStyle begin = null,
TextStyle end = null) : base(begin: begin, end: end) {
}
public override TextStyle lerp(double t) => TextStyle.lerp(this.begin, this.end, t);
}
public abstract class ImplicitlyAnimatedWidget : StatefulWidget {
public ImplicitlyAnimatedWidget(
Key key = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key) {
D.assert(duration != null);
this.curve = curve ?? Curves.linear;
this.duration = duration ?? TimeSpan.Zero;
}
public readonly Curve curve;
public readonly TimeSpan duration;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IntProperty("duration", (int) this.duration.TotalMilliseconds, unit: "ms"));
}
}
public delegate Tween<T> TweenConstructor<T>(T targetValue);
public interface ITweenVisitor {
Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue,
TweenConstructor<T> constructor) where T2 : ImplicitlyAnimatedWidget;
}
public class TweenVisitorUpdateTween : ITweenVisitor {
public Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue,
TweenConstructor<T> constructor)
where T2 : ImplicitlyAnimatedWidget {
state._updateTween(tween, targetValue);
return tween;
}
}
public class TweenVisitorCheckStartAnimation : ITweenVisitor {
public bool shouldStartAnimation;
public TweenVisitorCheckStartAnimation() {
this.shouldStartAnimation = false;
}
public Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue,
TweenConstructor<T> constructor)
where T2 : ImplicitlyAnimatedWidget {
if (targetValue != null) {
tween = tween ?? constructor(targetValue);
if (state._shouldAnimateTween(tween, targetValue))
this.shouldStartAnimation = true;
}
else {
tween = null;
}
return tween;
}
}
public abstract class ImplicitlyAnimatedWidgetState<T> : SingleTickerProviderStateMixin<T>
where T : ImplicitlyAnimatedWidget {
protected AnimationController controller => this._controller;
AnimationController _controller;
public Animation<double> animation => this._animation;
Animation<double> _animation;
public override void initState() {
base.initState();
this._controller = new AnimationController(
duration: this.widget.duration,
debugLabel: "{" + this.widget.toStringShort() + "}",
vsync: this
);
this._updateCurve();
this._constructTweens();
this.didUpdateTweens();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (this.widget.curve != ((ImplicitlyAnimatedWidget) oldWidget).curve)
this._updateCurve();
this._controller.duration = this.widget.duration;
if (this._constructTweens()) {
var visitor = new TweenVisitorUpdateTween();
this.forEachTween(visitor);
this._controller.setValue(0.0);
this._controller.forward();
this.didUpdateTweens();
}
}
void _updateCurve() {
if (this.widget.curve != null)
this._animation = new CurvedAnimation(parent: this._controller, curve: this.widget.curve);
else
this._animation = this._controller;
}
public override void dispose() {
this._controller.dispose();
base.dispose();
}
public bool _shouldAnimateTween<T2>(Tween<T2> tween, T2 targetValue) {
return !targetValue.Equals(tween.end == null ? tween.begin : tween.end);
}
public void _updateTween<T2>(Tween<T2> tween, T2 targetValue) {
if (tween == null)
return;
tween.begin = tween.evaluate(this._animation);
tween.end = targetValue;
}
bool _constructTweens() {
var visitor = new TweenVisitorCheckStartAnimation();
this.forEachTween(visitor);
return visitor.shouldStartAnimation;
}
protected abstract void forEachTween(ITweenVisitor visitor);
protected virtual void didUpdateTweens() {
}
}
public abstract class AnimatedWidgetBaseState<T> : ImplicitlyAnimatedWidgetState<T>
where T : ImplicitlyAnimatedWidget {
public override void initState() {
base.initState();
this.controller.addListener(this._handleAnimationChanged);
}
void _handleAnimationChanged() {
this.setState(() => { });
}
}
public class AnimatedDefaultTextStyle : ImplicitlyAnimatedWidget {
public AnimatedDefaultTextStyle(
Key key = null,
Widget child = null,
TextStyle style = null,
TextAlign? textAlign = null,
bool softWrap = true,
TextOverflow? overflow = null,
int? maxLines = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
D.assert(duration != null);
D.assert(style != null);
D.assert(child != null);
D.assert(maxLines == null || maxLines > 0);
this.child = child;
this.style = style;
this.textAlign = textAlign;
this.softWrap = softWrap;
this.overflow = overflow ?? TextOverflow.clip;
this.maxLines = maxLines;
}
public readonly Widget child;
public readonly TextStyle style;
public readonly bool softWrap;
public readonly TextAlign? textAlign;
public readonly TextOverflow overflow;
public readonly int? maxLines;
public override State createState() => new _AnimatedDefaultTextStyleState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
this.style?.debugFillProperties(properties);
properties.add(new EnumProperty<TextAlign>("textAlign", this.textAlign ?? TextAlign.center,
defaultValue: null));
properties.add(new FlagProperty("softWrap", value: this.softWrap, ifTrue: "wrapping at box width",
ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextOverflow>("overflow", this.overflow, defaultValue: null));
properties.add(new IntProperty("maxLines", this.maxLines, defaultValue: null));
}
}
public class _AnimatedDefaultTextStyleState : AnimatedWidgetBaseState<AnimatedDefaultTextStyle> {
TextStyleTween _style;
protected override void forEachTween(ITweenVisitor visitor) {
this._style = (TextStyleTween) visitor.visit(this, this._style, this.widget.style,
(TextStyle value) => new TextStyleTween(begin: value));
}
public override Widget build(BuildContext context) {
return new DefaultTextStyle(
style: this._style.evaluate(this.animation),
textAlign: this.widget.textAlign,
softWrap: this.widget.softWrap,
overflow: this.widget.overflow,
maxLines: this.widget.maxLines,
child: this.widget.child);
}
}
public class AnimatedPhysicalModel : ImplicitlyAnimatedWidget {
public AnimatedPhysicalModel(
Key key = null,
Widget child = null,
BoxShape? shape = null,
Clip clipBehavior = Clip.none,
BorderRadius borderRadius = null,
double? elevation = null,
Color color = null,
bool animateColor = true,
Color shadowColor = null,
bool animateShadowColor = true,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
D.assert(child != null);
D.assert(shape != null);
D.assert(elevation != null);
D.assert(color != null);
D.assert(shadowColor != null);
D.assert(duration != null);
this.child = child;
this.shape = shape ?? BoxShape.circle;
this.clipBehavior = clipBehavior;
this.borderRadius = borderRadius ?? BorderRadius.zero;
this.elevation = elevation ?? 0.0;
this.color = color;
this.animateColor = animateColor;
this.shadowColor = shadowColor;
this.animateShadowColor = animateShadowColor;
}
public readonly Widget child;
public readonly BoxShape shape;
public readonly Clip clipBehavior;
public readonly BorderRadius borderRadius;
public readonly double elevation;
public readonly Color color;
public readonly bool animateColor;
public readonly Color shadowColor;
public readonly bool animateShadowColor;
public override State createState() => new _AnimatedPhysicalModelState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<BoxShape>("shape", this.shape));
properties.add(new DiagnosticsProperty<BorderRadius>("borderRadius", this.borderRadius));
properties.add(new DoubleProperty("elevation", this.elevation));
properties.add(new DiagnosticsProperty<Color>("color", this.color));
properties.add(new DiagnosticsProperty<bool>("animateColor", this.animateColor));
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor));
properties.add(new DiagnosticsProperty<bool>("animateShadowColor", this.animateShadowColor));
}
}
public class _AnimatedPhysicalModelState : AnimatedWidgetBaseState<AnimatedPhysicalModel> {
BorderRadiusTween _borderRadius;
DoubleTween _elevation;
ColorTween _color;
ColorTween _shadowColor;
protected override void forEachTween(ITweenVisitor visitor) {
this._borderRadius = (BorderRadiusTween) visitor.visit(this, this._borderRadius, this.widget.borderRadius,
(BorderRadius value) => new BorderRadiusTween(begin: value));
this._elevation = (DoubleTween) visitor.visit(this, this._elevation, this.widget.elevation,
(double value) => new DoubleTween(begin: value, end: value));
this._color = (ColorTween) visitor.visit(this, this._color, this.widget.color,
(Color value) => new ColorTween(begin: value));
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor,
(Color value) => new ColorTween(begin: value));
}
public override Widget build(BuildContext context) {
return new PhysicalModel(
child: this.widget.child,
shape: this.widget.shape,
clipBehavior: this.widget.clipBehavior,
borderRadius: this._borderRadius.evaluate(this.animation),
elevation: this._elevation.evaluate(this.animation),
color: this.widget.animateColor ? this._color.evaluate(this.animation) : this.widget.color,
shadowColor: this.widget.animateShadowColor
? this._shadowColor.evaluate(this.animation)
: this.widget.shadowColor);
}
}
}

11
Runtime/widgets/implicit_animations.cs.meta


fileFormatVersion: 2
guid: ecf39d43bfae547a7ba543edafc67b19
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

177
Runtime/widgets/layout_builder.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints);
class LayoutBuilder : RenderObjectWidget {
public LayoutBuilder(
Key key = null,
LayoutWidgetBuilder builder = null) : base(key: key) {
D.assert(builder != null);
this.builder = builder;
}
public readonly LayoutWidgetBuilder builder;
public override Element createElement() => new _LayoutBuilderElement(this);
public override RenderObject createRenderObject(BuildContext context) => new _RenderLayoutBuilder();
}
class _LayoutBuilderElement : RenderObjectElement {
public _LayoutBuilderElement(
LayoutBuilder widget) : base(widget) {
}
new LayoutBuilder widget => (LayoutBuilder) base.widget;
new _RenderLayoutBuilder renderObject => (_RenderLayoutBuilder) base.renderObject;
Element _child;
public override void visitChildren(ElementVisitor visitor) {
if (this._child != null)
visitor(this._child);
}
protected override void forgetChild(Element child) {
D.assert(child == this._child);
this._child = null;
}
public override void mount(Element parent, object newSlot) {
base.mount(parent, newSlot);
this.renderObject.callback = this._layout;
}
public override void update(Widget newWidget) {
D.assert(this.widget != newWidget);
base.update(newWidget);
D.assert(this.widget == newWidget);
this.renderObject.callback = this._layout;
this.renderObject.markNeedsLayout();
}
protected override void performRebuild() {
this.renderObject.markNeedsLayout();
base.performRebuild();
}
public override void unmount() {
this.renderObject.callback = null;
base.unmount();
}
void _layout(BoxConstraints constraints) {
this.owner.buildScope(this, () => {
Widget built = null;
if (this.widget.builder != null) {
built = this.widget.builder(this, constraints);
WidgetsD.debugWidgetBuilderValue(this.widget, built);
}
this._child = this.updateChild(this._child, built, null);
D.assert(this._child != null);
});
}
protected override void insertChildRenderObject(RenderObject child, object slot) {
_RenderLayoutBuilder renderObject = this.renderObject;
D.assert(slot == null);
D.assert(renderObject.debugValidateChild(child));
renderObject.child = (RenderBox) child;
D.assert(renderObject == this.renderObject);
}
protected override void moveChildRenderObject(RenderObject child, object slot) {
D.assert(false);
}
protected override void removeChildRenderObject(RenderObject child) {
_RenderLayoutBuilder renderObject = this.renderObject;
D.assert(renderObject.child == child);
renderObject.child = null;
D.assert(renderObject == this.renderObject);
}
}
public class _RenderLayoutBuilder : RenderObjectWithChildMixinRenderBox<RenderBox> {
public _RenderLayoutBuilder(
LayoutCallback<BoxConstraints> callback = null) {
this._callback = callback;
}
public LayoutCallback<BoxConstraints> callback {
get { return this._callback; }
set {
if (value == this._callback)
return;
this._callback = value;
this.markNeedsLayout();
}
}
LayoutCallback<BoxConstraints> _callback;
bool _debugThrowIfNotCheckingIntrinsics() {
D.assert(() => {
if (!debugCheckingIntrinsics) {
throw new UIWidgetsError(
"LayoutBuilder does not support returning intrinsic dimensions.\n" +
"Calculating the intrinsic dimensions would require running the layout " +
"callback speculatively, which might mutate the live render object tree."
);
}
return true;
});
return true;
}
protected override double computeMinIntrinsicWidth(double height) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override double computeMaxIntrinsicWidth(double height) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override double computeMinIntrinsicHeight(double width) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override double computeMaxIntrinsicHeight(double width) {
D.assert(this._debugThrowIfNotCheckingIntrinsics());
return 0.0;
}
protected override void performLayout() {
D.assert(this.callback != null);
this.invokeLayoutCallback(this.callback);
if (this.child != null) {
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.constraints.constrain(this.child.size);
}
else {
this.size = this.constraints.biggest;
}
}
protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
return this.child?.hitTest(result, position: position) ?? false;
}
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null)
context.paintChild(this.child, offset);
}
}
}

11
Runtime/widgets/layout_builder.cs.meta


fileFormatVersion: 2
guid: d29b34cdfd63d4edb97960beede8a990
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

69
Samples/UIWidgetSample/MaterialCanvas.cs


using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
namespace UIWidgetsSample {
public class MaterialCanvas : WidgetCanvas {
protected override Widget getWidget() {
return new MaterialApp();
}
class MaterialApp : StatefulWidget {
public MaterialApp(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialWidgetState();
}
}
class MaterialWidget : StatefulWidget {
public MaterialWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialWidgetState();
}
}
// test-case: material button
class MaterialWidgetState : State<MaterialWidget> {
public override Widget build(BuildContext context) {
return new Material(
child: new Center(
child: new MaterialButton(
color: Colors.blue,
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
onPressed: () => { Debug.Log("pressed here");}
)
)
);
}
}
// // test-case: ink well
// class MaterialWidgetState : State<MaterialWidget> {
// public override Widget build(BuildContext context) {
// return new Material(
// child: new Center(
// child: new Container(
// width: 30,
// height: 30,
// child : new InkWell(
// borderRadius: BorderRadius.circular(2.0),
// highlightColor: new Color(0xAAFF0000),
// splashColor: new Color(0xAA0000FF),
// //radius : 20,
// onTap: () => { }
// ))
// )
// );
// }
// }
}
}

11
Samples/UIWidgetSample/MaterialCanvas.cs.meta


fileFormatVersion: 2
guid: d7c3be43dd8b94a349f26e3e7173c3f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存