File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
views/widgets/animated_theme_switch Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ Future<void> main() async {
1717 MultiProvider (
1818 providers: [
1919 ChangeNotifierProvider (create: (context) => ThemeProvider (pref: pref)),
20- ChangeNotifierProvider (create: (context) => AnimatedBoxesProvider (pref: pref)),
20+ ChangeNotifierProvider (
21+ create: (context) => AnimatedBoxesProvider (pref: pref)),
2122 ],
2223 child: const MyApp (),
2324 ),
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class ThemeSwitchPainter extends CustomPainter {
3333 canvas.translate (center.dx, center.dy);
3434
3535 // rotate canvas with animation value
36- canvas.rotate (1 - animation.value * pi);
36+ canvas.rotate (animation.value * pi);
3737
3838 // draw a box with an additional path to clip center circle
3939 canvas.drawPath (
@@ -61,16 +61,16 @@ class ThemeSwitchPainter extends CustomPainter {
6161
6262 // now draw a circle at the center
6363 // and translate it with animation to form a moon shape from center to top-right
64- final moonRadius = radius - 2 ;
64+ final moonRadius = radius * . 70 ;
6565
6666 final translateX = size.width / 2 + (animation.value * size.width * .10 );
67- final translateY = size.height / 2 - (animation.value * size.height * .10 );
67+ final translateY = size.height / 2 - (animation.value * size.height * .125 );
6868
6969 canvas.drawCircle (Offset (translateX, translateY), moonRadius, canvasPaint);
7070 }
7171
7272 @override
73- bool shouldRepaint (covariant CustomPainter oldDelegate) {
74- return false ;
73+ bool shouldRepaint (covariant ThemeSwitchPainter oldDelegate) {
74+ return oldDelegate.animation.value != animation.value ;
7575 }
7676}
You can’t perform that action at this time.
0 commit comments