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

Commit 1916cfb

Browse files
committed
1. fix some bugs in notched shape.
2. add conicTo, arcToPoint in canvas. 3. fix some bugs in the animation.
1 parent ed60ea9 commit 1916cfb

File tree

14 files changed

+356
-48
lines changed

14 files changed

+356
-48
lines changed

Runtime/animation/animations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ void _maybeNotifyStatusListeners(AnimationStatus _) {
544544
T _lastValue;
545545

546546
void _maybeNotifyListeners() {
547-
if (Equals(this.value, this._lastValue)) {
547+
if (!Equals(this.value, this._lastValue)) {
548548
this._lastValue = this.value;
549549
this.notifyListeners();
550550
}

Runtime/animation/tween.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ protected Tween(T begin, T end) {
7070
this.end = end;
7171
}
7272

73-
public T begin;
73+
public virtual T begin { get; set; }
7474

75-
public T end;
75+
public virtual T end { get; set; }
7676

7777
public abstract T lerp(float t);
7878

Runtime/async/timer.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,43 +99,38 @@ public Timer periodic(TimeSpan duration, Action callback) {
9999
return timer;
100100
}
101101

102+
static readonly List<TimerImpl> _timers = new List<TimerImpl>();
103+
static readonly List<TimerImpl> _appendList = new List<TimerImpl>();
104+
102105
public void update(Action flushMicroTasks = null) {
103106
var now = Timer.timeSinceStartup;
104107

105-
List<TimerImpl> timers = null;
106-
List<TimerImpl> appendList = null;
107-
108+
_timers.Clear();
109+
_appendList.Clear();
110+
108111
lock (this._queue) {
109112
while (this._queue.count > 0 && this._queue.peek().deadline <= now) {
110113
var timer = this._queue.dequeue();
111-
if (timers == null) {
112-
timers = new List<TimerImpl>();
113-
}
114-
115-
timers.Add(timer);
114+
_timers.Add(timer);
116115
}
117116
}
118117

119-
if (timers != null) {
120-
foreach (var timer in timers) {
118+
if (_timers.Count != 0) {
119+
foreach (var timer in _timers) {
121120
if (flushMicroTasks != null) {
122121
flushMicroTasks();
123122
}
124123

125124
timer.invoke();
126125
if (timer.periodic && !timer.done) {
127-
if (appendList == null) {
128-
appendList = new List<TimerImpl>();
129-
}
130-
131-
appendList.Add(timer);
126+
_appendList.Add(timer);
132127
}
133128
}
134129
}
135130

136-
if (appendList != null) {
131+
if (_appendList.Count != 0) {
137132
lock (this._queue) {
138-
foreach (var timer in appendList) {
133+
foreach (var timer in _appendList) {
139134
this._queue.enqueue(timer);
140135
}
141136
}

Runtime/foundation/change_notifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public ValueNotifier(T value) {
115115
this._value = value;
116116
}
117117

118-
public T value {
118+
public virtual T value {
119119
get { return this._value; }
120120
set {
121121
if (Equals(value, this._value)) {

Runtime/material/arc.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public float? endAngle {
159159

160160
float? _endAngle;
161161

162-
public new Offset begin {
162+
public override Offset begin {
163163
get { return base.begin; }
164164
set {
165165
if (value != base.begin) {
@@ -169,7 +169,7 @@ public float? endAngle {
169169
}
170170
}
171171

172-
public new Offset end {
172+
public override Offset end {
173173
get { return base.end; }
174174
set {
175175
if (value != base.end) {
@@ -300,7 +300,7 @@ public MaterialPointArcTween endArc {
300300

301301
MaterialPointArcTween _endArc;
302302

303-
public new Rect begin {
303+
public override Rect begin {
304304
get { return base.begin; }
305305
set {
306306
if (value != base.begin) {
@@ -310,7 +310,7 @@ public MaterialPointArcTween endArc {
310310
}
311311
}
312312

313-
public new Rect end {
313+
public override Rect end {
314314
get { return base.end; }
315315
set {
316316
if (value != base.end) {
@@ -375,7 +375,7 @@ public MaterialPointArcTween centerArc {
375375
MaterialPointArcTween _centerArc;
376376

377377

378-
public new Rect begin {
378+
public override Rect begin {
379379
get { return base.begin; }
380380
set {
381381
if (value != base.begin) {
@@ -385,7 +385,7 @@ public MaterialPointArcTween centerArc {
385385
}
386386
}
387387

388-
public new Rect end {
388+
public override Rect end {
389389
get { return base.end; }
390390
set {
391391
if (value != base.end) {

Runtime/material/chip.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,12 +1249,12 @@ public override void initState() {
12491249
vsync: this
12501250
);
12511251

1252-
float checkmarkPercentage = ChipUtils._kCheckmarkDuration.Milliseconds /
1253-
ChipUtils._kSelectDuration.Milliseconds;
1254-
float checkmarkReversePercentage = ChipUtils._kCheckmarkReverseDuration.Milliseconds /
1255-
ChipUtils._kSelectDuration.Milliseconds;
1256-
float avatarDrawerReversePercentage = ChipUtils._kReverseDrawerDuration.Milliseconds /
1257-
ChipUtils._kSelectDuration.Milliseconds;
1252+
float checkmarkPercentage = (float) (ChipUtils._kCheckmarkDuration.TotalMilliseconds /
1253+
ChipUtils._kSelectDuration.TotalMilliseconds);
1254+
float checkmarkReversePercentage = (float) (ChipUtils._kCheckmarkReverseDuration.TotalMilliseconds /
1255+
ChipUtils._kSelectDuration.TotalMilliseconds);
1256+
float avatarDrawerReversePercentage = (float) (ChipUtils._kReverseDrawerDuration.TotalMilliseconds /
1257+
ChipUtils._kSelectDuration.TotalMilliseconds);
12581258
this.checkmarkAnimation = new CurvedAnimation(
12591259
parent: this.selectController,
12601260
curve: new Interval(1.0f - checkmarkPercentage, 1.0f, curve: Curves.fastOutSlowIn),

Runtime/material/list_tile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ void add(RenderBox child, string name) {
697697
return value;
698698
}
699699

700-
public new bool sizedByParent {
700+
protected override bool sizedByParent {
701701
get { return false; }
702702
}
703703

Runtime/material/scaffold.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public _ScaffoldGeometryNotifier(
166166

167167
ScaffoldGeometry geometry;
168168

169-
public new ScaffoldGeometry value {
169+
public override ScaffoldGeometry value {
170170
get {
171171
D.assert(() => {
172172
RenderObject renderObject = this.context.findRenderObject();

Runtime/painting/notched_shapes.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public override Path getOuterPath(Rect host, Rect guest) {
2424

2525
float notchRadius = guest.width / 2.0f;
2626

27-
2827
const float s1 = 15.0f;
2928
const float s2 = 1.0f;
3029

@@ -38,7 +37,7 @@ public override Path getOuterPath(Rect host, Rect guest) {
3837
float p2yA = Mathf.Sqrt(r * r - p2xA * p2xA);
3938
float p2yB = Mathf.Sqrt(r * r - p2xB * p2xB);
4039

41-
List<Offset> p = new List<Offset>(6);
40+
Offset[] p = new Offset[6];
4241

4342
p[0] = new Offset(a - s1, b);
4443
p[1] = new Offset(a, b);
@@ -49,17 +48,18 @@ public override Path getOuterPath(Rect host, Rect guest) {
4948
p[4] = new Offset(-1.0f * p[1].dx, p[1].dy);
5049
p[5] = new Offset(-1.0f * p[0].dx, p[0].dy);
5150

52-
for (int i = 0; i < p.Count; i += 1) {
51+
for (int i = 0; i < p.Length; i += 1) {
5352
p[i] += guest.center;
5453
}
5554

5655
Path ret = new Path();
5756
ret.moveTo(host.left, host.top);
5857
ret.lineTo(p[0].dx, p[0].dy);
5958
ret.quadraticBezierTo(p[1].dx, p[1].dy, p[2].dx, p[2].dy);
60-
// TODO: replace this lineTo() with arcToPoint when arcToPoint is ready
61-
ret.lineTo(p[3].dx, p[3].dy);
62-
// ret.arcToPoint(p[3], p[3], radius: Radius.circular(notchRadius), clockwise: false);
59+
ret.arcToPoint(
60+
p[3],
61+
radius: Radius.circular(notchRadius),
62+
clockwise: false);
6363
ret.quadraticBezierTo(p[4].dx, p[4].dy, p[5].dx, p[5].dy);
6464
ret.lineTo(host.right, host.top);
6565
ret.lineTo(host.right, host.bottom);

Runtime/rendering/object.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ public void pushTransform(bool needsCompositing, Offset offset, Matrix3 transfor
297297
if (needsCompositing) {
298298
var inverse = Matrix3.I();
299299
var invertible = effectiveTransform.invert(inverse);
300-
D.assert(invertible);
300+
301+
// it could just be "scale == 0", ignore the assertion.
302+
// D.assert(invertible);
301303

302304
this.pushLayer(
303305
new TransformLayer(effectiveTransform),

0 commit comments

Comments
 (0)