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 {
17
17
MultiProvider (
18
18
providers: [
19
19
ChangeNotifierProvider (create: (context) => ThemeProvider (pref: pref)),
20
- ChangeNotifierProvider (create: (context) => AnimatedBoxesProvider (pref: pref)),
20
+ ChangeNotifierProvider (
21
+ create: (context) => AnimatedBoxesProvider (pref: pref)),
21
22
],
22
23
child: const MyApp (),
23
24
),
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class ThemeSwitchPainter extends CustomPainter {
33
33
canvas.translate (center.dx, center.dy);
34
34
35
35
// rotate canvas with animation value
36
- canvas.rotate (1 - animation.value * pi);
36
+ canvas.rotate (animation.value * pi);
37
37
38
38
// draw a box with an additional path to clip center circle
39
39
canvas.drawPath (
@@ -61,16 +61,16 @@ class ThemeSwitchPainter extends CustomPainter {
61
61
62
62
// now draw a circle at the center
63
63
// 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 ;
65
65
66
66
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 );
68
68
69
69
canvas.drawCircle (Offset (translateX, translateY), moonRadius, canvasPaint);
70
70
}
71
71
72
72
@override
73
- bool shouldRepaint (covariant CustomPainter oldDelegate) {
74
- return false ;
73
+ bool shouldRepaint (covariant ThemeSwitchPainter oldDelegate) {
74
+ return oldDelegate.animation.value != animation.value ;
75
75
}
76
76
}
You can’t perform that action at this time.
0 commit comments