11import 'package:flutter/material.dart' ;
2+ import 'package:flutter_animate/flutter_animate.dart' ;
23import 'package:flutter_curve_visualizer/utils/theme/theme_provider.dart' ;
3- import 'package:flutter_curve_visualizer/views/widgets/animated_theme_switch/widget .dart' ;
4+ import 'package:flutter_curve_visualizer/views/widgets/screen_mode .dart' ;
45import 'package:flutter_svg/flutter_svg.dart' ;
6+ import 'package:light_dark_theme_toggle/light_dark_theme_toggle.dart' ;
57import 'package:provider/provider.dart' ;
68import 'package:url_launcher/url_launcher.dart' ;
79
@@ -12,34 +14,56 @@ class HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
1214 Widget build (BuildContext context) {
1315 final theme = Theme .of (context);
1416
17+ final screenMode = ScreenModeWidget .of (context);
18+
1519 final actionPadding = const EdgeInsets .only (right: 12.0 );
1620
17- return AppBar (
18- title: const Text ('Flutter Curve Visualizer' ),
19- actions: [
20- Padding (
21- padding: actionPadding,
22- child: IconButton (
23- onPressed: () {
24- launchUrl (Uri .parse (
25- "https://github.com/vchib1/flutter-curve-visualizer" ));
26- },
27- icon: SvgPicture .asset (
28- "assets/svg/github.svg" ,
29- width: theme.iconTheme.size ?? 24 ,
30- height: theme.iconTheme.size ?? 24 ,
31- colorFilter: ColorFilter .mode (
32- theme.iconTheme.color ?? Colors .black,
33- BlendMode .srcIn,
21+ final width = MediaQuery .sizeOf (context).width;
22+
23+ double hPadding = switch (screenMode) {
24+ ScreenMode .mobile => 0 ,
25+ ScreenMode .tablet => 0 ,
26+ ScreenMode .web => width * 0.075 ,
27+ };
28+
29+ return Padding (
30+ padding: EdgeInsets .symmetric (horizontal: hPadding),
31+ child: AppBar (
32+ title: const Text ('Flutter Curve Visualizer' ),
33+ actions: [
34+ Padding (
35+ padding: actionPadding,
36+ child: IconButton (
37+ onPressed: () {
38+ launchUrl (Uri .parse (
39+ "https://github.com/vchib1/flutter-curve-visualizer" ));
40+ },
41+ icon: SvgPicture .asset (
42+ "assets/svg/github.svg" ,
43+ width: theme.iconTheme.size ?? 24 ,
44+ height: theme.iconTheme.size ?? 24 ,
45+ colorFilter: ColorFilter .mode (
46+ theme.iconTheme.color ?? Colors .black,
47+ BlendMode .srcIn,
48+ ),
3449 ),
3550 ),
3651 ),
37- ),
38- Padding (
39- padding: actionPadding,
40- child: AnimatedThemeSwitcher (),
41- ),
42- ],
52+ Padding (
53+ padding: actionPadding,
54+ child: Consumer <ThemeProvider >(builder: (context, value, child) {
55+ return LightDarkThemeToggle (
56+ themeIconType: ThemeIconType .expand,
57+ duration: 500. milliseconds,
58+ reverseDuration: 500. milliseconds,
59+ value: value.getThemeMode () == ThemeMode .dark,
60+ onChanged: (isDark) {
61+ value.toggleTheme ();
62+ });
63+ }),
64+ ),
65+ ],
66+ ),
4367 );
4468 }
4569
0 commit comments