@@ -215,14 +215,14 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
215215 return (leftWeights + _flex (_animations[index]) / 2.0 ) / allWeights;
216216 }
217217
218- FractionalOffset _circleOffset (int index) {
218+ Alignment _circleOffset (int index) {
219219 final double iconSize = widget.iconSize;
220220 final Tween <double > yOffsetTween = new Tween <double >(
221221 begin: (18.0 + iconSize / 2.0 ) / kBottomNavigationBarHeight, // 18dp + icon center
222222 end: (6.0 + iconSize / 2.0 ) / kBottomNavigationBarHeight // 6dp + icon center
223223 );
224224
225- return new FractionalOffset (
225+ return new Alignment (
226226 _xOffset (index),
227227 yOffsetTween.evaluate (_animations[index])
228228 );
@@ -283,10 +283,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
283283 widget.onTap (i);
284284 },
285285 child: new Stack (
286- alignment: FractionalOffset .center,
286+ alignment: Alignment .center,
287287 children: < Widget > [
288288 new Align (
289- alignment: FractionalOffset .topCenter,
289+ alignment: Alignment .topCenter,
290290 child: new Container (
291291 margin: new EdgeInsets .only (
292292 top: new Tween <double >(
@@ -304,7 +304,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
304304 ),
305305 ),
306306 new Align (
307- alignment: FractionalOffset .bottomCenter,
307+ alignment: Alignment .bottomCenter,
308308 child: new Container (
309309 margin: const EdgeInsets .only (bottom: 10.0 ),
310310 child: DefaultTextStyle .merge (
@@ -319,7 +319,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
319319 end: 1.0 ,
320320 ).evaluate (_animations[i]),
321321 )),
322- alignment: FractionalOffset .bottomCenter,
322+ alignment: Alignment .bottomCenter,
323323 child: widget.items[i].title,
324324 ),
325325 ),
@@ -352,10 +352,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
352352 widget.onTap (i);
353353 },
354354 child: new Stack (
355- alignment: FractionalOffset .center,
355+ alignment: Alignment .center,
356356 children: < Widget > [
357357 new Align (
358- alignment: FractionalOffset .topCenter,
358+ alignment: Alignment .topCenter,
359359 child: new Container (
360360 margin: new EdgeInsets .only (
361361 top: new Tween <double >(
@@ -373,7 +373,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
373373 ),
374374 ),
375375 new Align (
376- alignment: FractionalOffset .bottomCenter,
376+ alignment: Alignment .bottomCenter,
377377 child: new Container (
378378 margin: const EdgeInsets .only (bottom: 10.0 ),
379379 child: new FadeTransition (
@@ -465,7 +465,7 @@ class _Circle {
465465 AnimationController controller;
466466 CurvedAnimation animation;
467467
468- FractionalOffset get offset {
468+ Alignment get offset {
469469 return state._circleOffset (index);
470470 }
471471
@@ -487,11 +487,13 @@ class _RadialPainter extends CustomPainter {
487487 // bounding rectangle's corners touches the egde of the circle. Drawing a
488488 // circle beyond this radius is futile since there is no perceivable
489489 // difference within the cropped rectangle.
490- double _maxRadius (FractionalOffset offset, Size size) {
491- final double dx = offset.dx;
492- final double dy = offset.dy;
493- final double x = (dx > 0.5 ? dx : 1.0 - dx) * size.width;
494- final double y = (dy > 0.5 ? dy : 1.0 - dy) * size.height;
490+ double _maxRadius (Alignment alignment, Size size) {
491+ final double dx = alignment.x;
492+ final double dy = alignment.y;
493+ final double halfWidth = size.width / 2.0 ;
494+ final double halfHeight = size.height / 2.0 ;
495+ final double x = halfWidth + dx.abs () * halfWidth;
496+ final double y = halfHeight + dy.abs () * halfHeight;
495497 return math.sqrt (x * x + y * y);
496498 }
497499
@@ -517,20 +519,22 @@ class _RadialPainter extends CustomPainter {
517519 for (_Circle circle in circles) {
518520 final Tween <double > radiusTween = new Tween <double >(
519521 begin: 0.0 ,
520- end: _maxRadius (circle.offset, size)
522+ end: _maxRadius (circle.offset, size),
521523 );
522524 final Paint paint = new Paint ()..color = circle.color;
523525 final Rect rect = new Rect .fromLTWH (0.0 , 0.0 , size.width, size.height);
524526 canvas.clipRect (rect);
525527 final double navWidth = math.min (bottomNavMaxWidth, size.width);
528+ final double halfNavWidth = navWidth / 2.0 ;
529+ final double halfHeight = size.height / 2.0 ;
526530 final Offset center = new Offset (
527- (size.width - navWidth) / 2.0 + circle.offset.dx * navWidth ,
528- circle.offset.dy * size.height
531+ (size.width - navWidth) / 2.0 + halfNavWidth + circle.offset.x * halfNavWidth ,
532+ halfHeight + circle.offset.y * halfHeight,
529533 );
530534 canvas.drawCircle (
531535 center,
532536 radiusTween.lerp (circle.animation.value),
533- paint
537+ paint,
534538 );
535539 }
536540 }
0 commit comments