Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 7ed8c58

Browse files
author
Yuncong Zhang
committed
[1.5.4] Upgrade most of the material widgets.
1 parent e3fa88f commit 7ed8c58

20 files changed

+598
-217
lines changed

Runtime/material/dialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ public static IPromise<object> showDialog(
292292
) {
293293
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
294294

295+
ThemeData theme = Theme.of(context, shadowThemeOnly: true);
295296
return widgets.DialogUtils.showGeneralDialog(
296297
context: context,
297298
pageBuilder: (buildContext, animation, secondaryAnimation) => {
298-
ThemeData theme = Theme.of(context, shadowThemeOnly: true);
299299
Widget pageChild = new Builder(builder: builder);
300300
return new SafeArea(
301301
child: new Builder(

Runtime/material/drawer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ public DrawerController(
5757
Widget child = null,
5858
DrawerAlignment? alignment = null,
5959
DrawerCallback drawerCallback = null,
60-
DragStartBehavior? dragStartBehavior = null
60+
DragStartBehavior dragStartBehavior = DragStartBehavior.start
6161
) : base(key: key) {
6262
D.assert(child != null);
6363
D.assert(alignment != null);
64-
D.assert(dragStartBehavior != null);
6564
this.child = child;
6665
this.alignment = alignment ?? DrawerAlignment.start;
6766
this.drawerCallback = drawerCallback;
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
using Unity.UIWidgets.foundation;
2+
using Unity.UIWidgets.painting;
3+
using Unity.UIWidgets.ui;
4+
5+
namespace Unity.UIWidgets.material {
6+
public class FloatingActionButtonThemeData : Diagnosticable {
7+
public FloatingActionButtonThemeData(
8+
Color backgroundColor = null,
9+
Color foregroundColor = null,
10+
float? elevation = null,
11+
float? disabledElevation = null,
12+
float? highlightElevation = null,
13+
ShapeBorder shape = null
14+
) {
15+
this.backgroundColor = backgroundColor;
16+
this.foregroundColor = foregroundColor;
17+
this.elevation = elevation;
18+
this.disabledElevation = disabledElevation;
19+
this.highlightElevation = highlightElevation;
20+
this.shape = shape;
21+
}
22+
23+
public readonly Color backgroundColor;
24+
25+
public readonly Color foregroundColor;
26+
27+
public readonly float? elevation;
28+
29+
public readonly float? disabledElevation;
30+
31+
public readonly float? highlightElevation;
32+
33+
public readonly ShapeBorder shape;
34+
35+
public FloatingActionButtonThemeData copyWith(
36+
Color backgroundColor,
37+
Color foregroundColor,
38+
float? elevation,
39+
float? disabledElevation,
40+
float? highlightElevation,
41+
ShapeBorder shape
42+
) {
43+
return new FloatingActionButtonThemeData(
44+
backgroundColor: backgroundColor ?? this.backgroundColor,
45+
foregroundColor: foregroundColor ?? this.foregroundColor,
46+
elevation: elevation ?? this.elevation,
47+
disabledElevation: disabledElevation ?? this.disabledElevation,
48+
highlightElevation: highlightElevation ?? this.highlightElevation,
49+
shape: shape ?? this.shape
50+
);
51+
}
52+
53+
public static FloatingActionButtonThemeData lerp(FloatingActionButtonThemeData a, FloatingActionButtonThemeData b,
54+
float t) {
55+
D.assert(t != null);
56+
if (a == null && b == null) {
57+
return null;
58+
}
59+
60+
return new FloatingActionButtonThemeData(
61+
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
62+
foregroundColor: Color.lerp(a?.foregroundColor, b?.foregroundColor, t),
63+
elevation: MathUtils.lerpFloat(a?.elevation ?? 0, b?.elevation ?? 0, t),
64+
disabledElevation: MathUtils.lerpFloat(a?.disabledElevation ?? 0, b?.disabledElevation ?? 0, t),
65+
highlightElevation: MathUtils.lerpFloat(a?.highlightElevation ?? 0, b?.highlightElevation ?? 0, t),
66+
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
67+
);
68+
}
69+
70+
public override int GetHashCode() {
71+
var hashCode = this.backgroundColor?.GetHashCode() ?? 0;
72+
hashCode = (hashCode * 397) ^ this.foregroundColor?.GetHashCode() ?? 0;
73+
hashCode = (hashCode * 397) ^ this.elevation?.GetHashCode() ?? 0;
74+
hashCode = (hashCode * 397) ^ this.disabledElevation?.GetHashCode() ?? 0;
75+
hashCode = (hashCode * 397) ^ this.highlightElevation?.GetHashCode() ?? 0;
76+
hashCode = (hashCode * 397) ^ this.shape?.GetHashCode() ?? 0;
77+
return hashCode;
78+
}
79+
80+
public bool Equals(FloatingActionButtonThemeData other) {
81+
if (ReferenceEquals(null, other)) {
82+
return false;
83+
}
84+
85+
if (ReferenceEquals(this, other)) {
86+
return true;
87+
}
88+
89+
return Equals(this.backgroundColor, other.backgroundColor)
90+
&& Equals(this.elevation, other.elevation)
91+
&& Equals(this.shape, other.shape)
92+
&& Equals(this.foregroundColor, other.foregroundColor)
93+
&& Equals(this.disabledElevation, other.disabledElevation)
94+
&& Equals(this.highlightElevation, other.highlightElevation);
95+
}
96+
97+
public override bool Equals(object obj) {
98+
if (ReferenceEquals(null, obj)) {
99+
return false;
100+
}
101+
102+
if (ReferenceEquals(this, obj)) {
103+
return true;
104+
}
105+
106+
if (obj.GetType() != this.GetType()) {
107+
return false;
108+
}
109+
110+
return this.Equals((FloatingActionButtonThemeData) obj);
111+
}
112+
113+
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
114+
base.debugFillProperties(properties);
115+
FloatingActionButtonThemeData defaultData = new FloatingActionButtonThemeData();
116+
117+
properties.add(new DiagnosticsProperty<Color>("backgroundColor", this.backgroundColor,
118+
defaultValue: defaultData.backgroundColor));
119+
properties.add(new DiagnosticsProperty<Color>("foregroundColor", this.foregroundColor,
120+
defaultValue: defaultData.foregroundColor));
121+
properties.add(new DiagnosticsProperty<float?>("elevation", this.elevation,
122+
defaultValue: defaultData.elevation));
123+
properties.add(new DiagnosticsProperty<float?>("disabledElevation", this.disabledElevation,
124+
defaultValue: defaultData.disabledElevation));
125+
properties.add(new DiagnosticsProperty<float?>("highlightElevation", this.highlightElevation,
126+
defaultValue: defaultData.highlightElevation));
127+
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: defaultData.shape));
128+
}
129+
}
130+
}

Runtime/material/floatting_action_button_theme.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/material/input_border.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Path _gapBorderPath(Canvas canvas, RRect center, float start, float extent) {
312312

313313
const float cornerArcSweep = Mathf.PI / 2.0f;
314314
float tlCornerArcSweep = start < center.tlRadiusX
315-
? Mathf.Asin(start / center.tlRadiusX)
315+
? Mathf.Asin((start / center.tlRadiusX).clamp(-1.0f, 1.0f))
316316
: Mathf.PI / 2.0f;
317317

318318
Path path = new Path();
@@ -361,7 +361,7 @@ public override void paint(Canvas canvas, Rect rect,
361361
}
362362
else {
363363
float extent = MathUtils.lerpFloat(0.0f, gapExtent + this.gapPadding * 2.0f, gapPercentage);
364-
Path path = this._gapBorderPath(canvas, center, gapStart - this.gapPadding, extent);
364+
Path path = this._gapBorderPath(canvas, center, Mathf.Max(0.0f,gapStart - this.gapPadding), extent);
365365
canvas.drawPath(path, paint);
366366
}
367367
}

0 commit comments

Comments
 (0)