10
10
using FontStyle = Unity . UIWidgets . ui . FontStyle ;
11
11
using Material = Unity . UIWidgets . material . Material ;
12
12
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 ( ) {
19
16
return new MaterialApp (
20
17
showPerformanceOverlay : false ,
21
18
home : new Material (
22
19
child : new BenchMarkLayoutWidget ( ) ) ,
23
- builder : ( _ , child ) =>
24
- {
20
+ builder : ( _ , child ) => {
25
21
return new Builder ( builder :
26
- context =>
27
- {
22
+ context => {
28
23
return new MediaQuery (
29
24
data : MediaQuery . of ( context ) . copyWith (
30
25
textScaleFactor : 1.0f
@@ -34,35 +29,29 @@ protected override Widget createWidget()
34
29
} ) ;
35
30
}
36
31
37
- protected override void OnEnable ( )
38
- {
32
+ protected override void OnEnable ( ) {
39
33
base . OnEnable ( ) ;
40
34
FontManager . instance . addFont ( Resources . Load < Font > ( path : "MaterialIcons-Regular" ) , "Material Icons" ) ;
41
35
}
42
36
}
43
37
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 ) {
48
40
}
49
41
50
- public override State createState ( )
51
- {
42
+ public override State createState ( ) {
52
43
return new BenchMarkLayoutWidgetState ( ) ;
53
44
}
54
45
}
55
46
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 ;
60
50
61
- private Widget richtext = new Container (
51
+ Widget richtext = new Container (
62
52
child : new RichText (
63
53
text : new TextSpan ( "" , children :
64
- new List < TextSpan > ( )
65
- {
54
+ new List < TextSpan > ( ) {
66
55
new TextSpan ( "Real-time 3D revolutioni\t 淡粉色的方式地方\t zes the animation pipeline " ) ,
67
56
new TextSpan ( style : new TextStyle ( color : Color . fromARGB ( 255 , 255 , 0 , 0 ) ) ,
68
57
text : "for Disney Television Animation's\t “Baymax Dreams" ) ,
@@ -104,53 +93,50 @@ internal class BenchMarkLayoutWidgetState : State<BenchMarkLayoutWidget>
104
93
)
105
94
) ;
106
95
107
- public override Widget build ( BuildContext context )
108
- {
96
+ public override Widget build ( BuildContext context ) {
109
97
Widget buttons = new Column (
110
98
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 } ") ,
114
101
new RaisedButton (
115
- onPressed : ( ) => { setState ( ( ) => { width += 10 ; } ) ; } ,
102
+ onPressed : ( ) => { this . setState ( ( ) => { this . width += 10 ; } ) ; } ,
116
103
child : new Text ( "Add Width" )
117
104
) ,
118
105
new Divider ( ) ,
119
106
new RaisedButton (
120
- onPressed : ( ) => { setState ( ( ) => { width -= 10 ; } ) ; } ,
107
+ onPressed : ( ) => { this . setState ( ( ) => { this . width -= 10 ; } ) ; } ,
121
108
child : new Text ( "Dec Width" )
122
109
) ,
123
110
new Divider ( ) ,
124
111
new RaisedButton (
125
- onPressed : ( ) => { setState ( ( ) => { visible = true ; } ) ; } ,
112
+ onPressed : ( ) => { this . setState ( ( ) => { this . visible = true ; } ) ; } ,
126
113
child : new Text ( "Show" )
127
114
) ,
128
115
new Divider ( ) ,
129
116
new RaisedButton (
130
- onPressed : ( ) => { setState ( ( ) => { visible = false ; } ) ; } ,
117
+ onPressed : ( ) => { this . setState ( ( ) => { this . visible = false ; } ) ; } ,
131
118
child : new Text ( "Hide" )
132
119
)
133
120
}
134
121
) ;
135
122
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
140
126
? new Text (
141
127
"Very Very Very Very Very Very Very Very Very Very Very Very Very Very\n Very Very Very Very Very Very Very Very Very Very Very Long Text" ,
142
128
maxLines : 3 , overflow : TextOverflow . ellipsis , textAlign : TextAlign . justify
143
129
)
144
130
: new Text ( "" )
145
131
} ) ;
146
132
child = new Stack (
147
- children : new List < Widget > {
133
+ children : new List < Widget > {
148
134
child ,
149
135
buttons
150
136
}
151
137
) ;
152
138
child = new Container (
153
- width : width ,
139
+ width : this . width ,
154
140
color : Colors . black12 ,
155
141
child : child
156
142
) ;
0 commit comments