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

Commit e56b8c9

Browse files
author
Yuncong Zhang
committed
Code cleanup.
1 parent ae81682 commit e56b8c9

File tree

1 file changed

+26
-40
lines changed

1 file changed

+26
-40
lines changed

Samples/UIWidgetSample/BenchMarkLayout.cs

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,16 @@
1010
using FontStyle = Unity.UIWidgets.ui.FontStyle;
1111
using Material = Unity.UIWidgets.material.Material;
1212

13-
namespace UIWidgetsSample
14-
{
15-
public class BenchMarkLayout : UIWidgetsSamplePanel
16-
{
17-
protected override Widget createWidget()
18-
{
13+
namespace UIWidgetsSample {
14+
public class BenchMarkLayout : UIWidgetsSamplePanel {
15+
protected override Widget createWidget() {
1916
return new MaterialApp(
2017
showPerformanceOverlay: false,
2118
home: new Material(
2219
child: new BenchMarkLayoutWidget()),
23-
builder: (_, child) =>
24-
{
20+
builder: (_, child) => {
2521
return new Builder(builder:
26-
context =>
27-
{
22+
context => {
2823
return new MediaQuery(
2924
data: MediaQuery.of(context).copyWith(
3025
textScaleFactor: 1.0f
@@ -34,35 +29,29 @@ protected override Widget createWidget()
3429
});
3530
}
3631

37-
protected override void OnEnable()
38-
{
32+
protected override void OnEnable() {
3933
base.OnEnable();
4034
FontManager.instance.addFont(Resources.Load<Font>(path: "MaterialIcons-Regular"), "Material Icons");
4135
}
4236
}
4337

44-
internal class BenchMarkLayoutWidget : StatefulWidget
45-
{
46-
public BenchMarkLayoutWidget(Key key = null) : base(key)
47-
{
38+
class BenchMarkLayoutWidget : StatefulWidget {
39+
public BenchMarkLayoutWidget(Key key = null) : base(key) {
4840
}
4941

50-
public override State createState()
51-
{
42+
public override State createState() {
5243
return new BenchMarkLayoutWidgetState();
5344
}
5445
}
5546

56-
internal class BenchMarkLayoutWidgetState : State<BenchMarkLayoutWidget>
57-
{
58-
private int width = 260;
59-
private bool visible = true;
47+
class BenchMarkLayoutWidgetState : State<BenchMarkLayoutWidget> {
48+
int width = 260;
49+
bool visible = true;
6050

61-
private Widget richtext = new Container(
51+
Widget richtext = new Container(
6252
child: new RichText(
6353
text: new TextSpan("", children:
64-
new List<TextSpan>()
65-
{
54+
new List<TextSpan>() {
6655
new TextSpan("Real-time 3D revolutioni\t淡粉色的方式地方\tzes the animation pipeline "),
6756
new TextSpan(style: new TextStyle(color: Color.fromARGB(255, 255, 0, 0)),
6857
text: "for Disney Television Animation's\t “Baymax Dreams"),
@@ -104,53 +93,50 @@ internal class BenchMarkLayoutWidgetState : State<BenchMarkLayoutWidget>
10493
)
10594
);
10695

107-
public override Widget build(BuildContext context)
108-
{
96+
public override Widget build(BuildContext context) {
10997
Widget buttons = new Column(
11098
mainAxisAlignment: MainAxisAlignment.end,
111-
children: new List<Widget>
112-
{
113-
new Text($"Width: {width}"),
99+
children: new List<Widget> {
100+
new Text($"Width: {this.width}"),
114101
new RaisedButton(
115-
onPressed: () => { setState(() => { width += 10; }); },
102+
onPressed: () => { this.setState(() => { this.width += 10; }); },
116103
child: new Text("Add Width")
117104
),
118105
new Divider(),
119106
new RaisedButton(
120-
onPressed: () => { setState(() => { width -= 10; }); },
107+
onPressed: () => { this.setState(() => { this.width -= 10; }); },
121108
child: new Text("Dec Width")
122109
),
123110
new Divider(),
124111
new RaisedButton(
125-
onPressed: () => { setState(() => { visible = true; }); },
112+
onPressed: () => { this.setState(() => { this.visible = true; }); },
126113
child: new Text("Show")
127114
),
128115
new Divider(),
129116
new RaisedButton(
130-
onPressed: () => { setState(() => { visible = false; }); },
117+
onPressed: () => { this.setState(() => { this.visible = false; }); },
131118
child: new Text("Hide")
132119
)
133120
}
134121
);
135122
Widget child = new Column(
136-
children: new List<Widget>
137-
{
138-
visible ? richtext : new Text(""),
139-
visible
123+
children: new List<Widget> {
124+
this.visible ? this.richtext : new Text(""),
125+
this.visible
140126
? new Text(
141127
"Very Very Very Very Very Very Very Very Very Very Very Very Very Very\nVery Very Very Very Very Very Very Very Very Very Very Long Text",
142128
maxLines: 3, overflow: TextOverflow.ellipsis, textAlign: TextAlign.justify
143129
)
144130
: new Text("")
145131
});
146132
child = new Stack(
147-
children: new List<Widget>{
133+
children: new List<Widget> {
148134
child,
149135
buttons
150136
}
151137
);
152138
child = new Container(
153-
width: width,
139+
width: this.width,
154140
color: Colors.black12,
155141
child: child
156142
);

0 commit comments

Comments
 (0)