@@ -104,7 +104,78 @@ public _BottomNavigationTile(
104
104
public readonly bool selected ;
105
105
public readonly string indexLabel ;
106
106
107
- Widget _buildIcon ( ) {
107
+ public override Widget build ( BuildContext context ) {
108
+ int size ;
109
+ Widget label ;
110
+ switch ( this . type ) {
111
+ case BottomNavigationBarType . fix :
112
+ size = 1 ;
113
+ label = new _FixedLabel ( colorTween : this . colorTween , animation : this . animation , item : this . item ) ;
114
+ break ;
115
+ case BottomNavigationBarType . shifting :
116
+ size = ( ( this . flex * 1000.0f ) ?? 0.0f ) . round ( ) ;
117
+ label = new _ShiftingLabel ( animation : this . animation , item : this . item ) ;
118
+ break ;
119
+ default :
120
+ throw new Exception ( "Unknown BottomNavigationBarType: " + this . type ) ;
121
+ }
122
+
123
+ return new Expanded (
124
+ flex : size ,
125
+ child : new Stack (
126
+ children : new List < Widget > {
127
+ new InkResponse (
128
+ onTap : this . onTap == null ? ( GestureTapCallback ) null : ( ) => { this . onTap ( ) ; } ,
129
+ child : new Column (
130
+ crossAxisAlignment : CrossAxisAlignment . center ,
131
+ mainAxisAlignment : MainAxisAlignment . spaceBetween ,
132
+ mainAxisSize : MainAxisSize . min ,
133
+ children : new List < Widget > {
134
+ new _TileIcon (
135
+ type : this . type ,
136
+ colorTween : this . colorTween ,
137
+ animation : this . animation ,
138
+ iconSize : this . iconSize ,
139
+ selected : this . selected ,
140
+ item : this . item
141
+ ) ,
142
+ label
143
+ }
144
+ )
145
+ )
146
+ }
147
+ )
148
+ ) ;
149
+ }
150
+ }
151
+
152
+
153
+ class _TileIcon : StatelessWidget {
154
+ public _TileIcon (
155
+ Key key = null ,
156
+ BottomNavigationBarType ? type = null ,
157
+ ColorTween colorTween = null ,
158
+ Animation < float > animation = null ,
159
+ float ? iconSize = null ,
160
+ bool ? selected = null ,
161
+ BottomNavigationBarItem item = null
162
+ ) : base ( key : key ) {
163
+ this . type = type ;
164
+ this . colorTween = colorTween ;
165
+ this . animation = animation ;
166
+ this . iconSize = iconSize ;
167
+ this . selected = selected ;
168
+ this . item = item ;
169
+ }
170
+
171
+ BottomNavigationBarType ? type ;
172
+ ColorTween colorTween ;
173
+ Animation < float > animation ;
174
+ float ? iconSize ;
175
+ bool ? selected ;
176
+ BottomNavigationBarItem item ;
177
+
178
+ public override Widget build ( BuildContext context ) {
108
179
float tweenStart ;
109
180
Color iconColor ;
110
181
switch ( this . type ) {
@@ -135,13 +206,30 @@ Widget _buildIcon() {
135
206
color : iconColor ,
136
207
size : this . iconSize
137
208
) ,
138
- child : this . selected ? this . item . activeIcon : this . item . icon
209
+ child : this . selected == true ? this . item . activeIcon : this . item . icon
139
210
)
140
211
)
141
212
) ;
142
213
}
214
+ }
215
+
216
+ class _FixedLabel : StatelessWidget {
217
+ public _FixedLabel (
218
+ Key key = null ,
219
+ ColorTween colorTween = null ,
220
+ Animation < float > animation = null ,
221
+ BottomNavigationBarItem item = null
222
+ ) : base ( key : key ) {
223
+ this . colorTween = colorTween ;
224
+ this . animation = animation ;
225
+ this . item = item ;
226
+ }
143
227
144
- Widget _buildFixedLabel ( ) {
228
+ ColorTween colorTween ;
229
+ Animation < float > animation ;
230
+ BottomNavigationBarItem item ;
231
+
232
+ public override Widget build ( BuildContext context ) {
145
233
float t = new FloatTween (
146
234
begin : BottomNavigationBarUtils . _kInactiveFontSize / BottomNavigationBarUtils . _kActiveFontSize ,
147
235
end : 1.0f
@@ -165,8 +253,22 @@ Widget _buildFixedLabel() {
165
253
)
166
254
) ;
167
255
}
256
+ }
168
257
169
- Widget _buildShiftingLabel ( ) {
258
+ class _ShiftingLabel : StatelessWidget {
259
+ public _ShiftingLabel (
260
+ Key key = null ,
261
+ Animation < float > animation = null ,
262
+ BottomNavigationBarItem item = null
263
+ ) : base ( key : key ) {
264
+ this . animation = animation ;
265
+ this . item = item ;
266
+ }
267
+
268
+ Animation < float > animation ;
269
+ BottomNavigationBarItem item ;
270
+
271
+ public override Widget build ( BuildContext context ) {
170
272
return new Align (
171
273
alignment : Alignment . bottomCenter ,
172
274
heightFactor : 1.0f ,
@@ -190,42 +292,9 @@ Widget _buildShiftingLabel() {
190
292
)
191
293
) ;
192
294
}
193
-
194
- public override Widget build ( BuildContext context ) {
195
- int size ;
196
- Widget label ;
197
- switch ( this . type ) {
198
- case BottomNavigationBarType . fix :
199
- size = 1 ;
200
- label = this . _buildFixedLabel ( ) ;
201
- break ;
202
- case BottomNavigationBarType . shifting :
203
- size = ( ( this . flex * 1000.0f ) ?? 0.0f ) . round ( ) ;
204
- label = this . _buildShiftingLabel ( ) ;
205
- break ;
206
- default :
207
- throw new Exception ( "Unknown BottomNavigationBarType: " + this . type ) ;
208
- }
209
-
210
- return new Expanded (
211
- flex : size ,
212
- child : new Stack (
213
- children : new List < Widget > {
214
- new InkResponse (
215
- onTap : this . onTap == null ? ( GestureTapCallback ) null : ( ) => { this . onTap ( ) ; } ,
216
- child : new Column (
217
- crossAxisAlignment : CrossAxisAlignment . center ,
218
- mainAxisAlignment : MainAxisAlignment . spaceBetween ,
219
- mainAxisSize : MainAxisSize . min ,
220
- children : new List < Widget > { this . _buildIcon ( ) , label }
221
- )
222
- )
223
- }
224
- )
225
- ) ;
226
- }
227
295
}
228
296
297
+
229
298
class _BottomNavigationBarState : TickerProviderStateMixin < BottomNavigationBar > {
230
299
public List < AnimationController > _controllers = new List < AnimationController > { } ;
231
300
public List < CurvedAnimation > _animations ;
@@ -390,7 +459,8 @@ List<Widget> _createTiles() {
390
459
} ,
391
460
colorTween : colorTween ,
392
461
selected : i == this . widget . currentIndex ,
393
- indexLabel : localizations . tabLabel ( tabIndex : i + 1 , tabCount : this . widget . items . Count )
462
+ indexLabel : localizations . tabLabel ( tabIndex : i + 1 ,
463
+ tabCount : this . widget . items . Count )
394
464
)
395
465
) ;
396
466
}
@@ -410,7 +480,8 @@ List<Widget> _createTiles() {
410
480
flex :
411
481
this . _evaluateFlex ( this . _animations [ i ] ) ,
412
482
selected : i == this . widget . currentIndex ,
413
- indexLabel : localizations . tabLabel ( tabIndex : i + 1 , tabCount : this . widget . items . Count )
483
+ indexLabel : localizations . tabLabel ( tabIndex : i + 1 ,
484
+ tabCount : this . widget . items . Count )
414
485
)
415
486
) ;
416
487
}
0 commit comments