|
| 1 | +// ignore_for_file: library_private_types_in_public_api |
| 2 | + |
1 | 3 | import 'package:flutter/material.dart';
|
2 |
| -import 'package:google_fonts/google_fonts.dart'; |
3 | 4 |
|
4 | 5 | import 'package:taskwarrior/config/app_settings.dart';
|
5 | 6 | import 'package:taskwarrior/model/storage/storage_widget.dart';
|
6 | 7 | import 'package:taskwarrior/routes/pageroute.dart';
|
7 | 8 | import 'package:taskwarrior/views/about/about.dart';
|
8 | 9 | import 'package:taskwarrior/views/reports/reports_home.dart';
|
9 | 10 | import 'package:taskwarrior/config/theme_switcher_clipper.dart';
|
| 11 | +import 'package:taskwarrior/views/settings/settings.dart'; |
10 | 12 |
|
11 | 13 | class NavDrawer extends StatefulWidget {
|
12 | 14 | final InheritedStorage storageWidget;
|
13 | 15 | final Function() notifyParent;
|
14 | 16 |
|
15 |
| - const NavDrawer( |
16 |
| - {Key? key, required this.storageWidget, required this.notifyParent}) |
17 |
| - : super(key: key); |
| 17 | + const NavDrawer({ |
| 18 | + Key? key, |
| 19 | + required this.storageWidget, |
| 20 | + required this.notifyParent, |
| 21 | + }) : super(key: key); |
18 | 22 |
|
19 | 23 | @override
|
20 |
| - // ignore: library_private_types_in_public_api |
21 | 24 | _NavDrawerState createState() => _NavDrawerState();
|
22 | 25 | }
|
23 | 26 |
|
24 | 27 | class _NavDrawerState extends State<NavDrawer> {
|
25 |
| - late InheritedStorage storageWidget = widget.storageWidget; |
26 |
| - |
27 | 28 | @override
|
28 | 29 | Widget build(BuildContext context) {
|
29 | 30 | return Drawer(
|
30 |
| - backgroundColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
31 |
| - child: ListView( |
32 |
| - padding: EdgeInsets.zero, |
33 |
| - children: [ |
34 |
| - ListTile( |
35 |
| - tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
36 |
| - textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
37 |
| - contentPadding: const EdgeInsets.only(top: 40, left: 10), |
38 |
| - title: Row( |
39 |
| - mainAxisAlignment: MainAxisAlignment.spaceBetween, |
40 |
| - children: [ |
41 |
| - Text( |
42 |
| - 'Menu', |
43 |
| - style: TextStyle( |
44 |
| - fontSize: 25, |
45 |
| - fontWeight: FontWeight.bold, |
46 |
| - ), |
47 |
| - ), |
48 |
| - Padding( |
49 |
| - padding: EdgeInsets.only(right: 10), |
50 |
| - child: ThemeSwitcherClipper( |
51 |
| - isDarkMode: AppSettings.isDarkMode, |
52 |
| - onTap: (bool newMode) async { |
53 |
| - AppSettings.isDarkMode = newMode; |
| 31 | + backgroundColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 32 | + child: ListView( |
| 33 | + padding: EdgeInsets.zero, |
| 34 | + children: [ |
| 35 | + ListTile( |
| 36 | + tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 37 | + textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 38 | + contentPadding: const EdgeInsets.only(top: 40, left: 10), |
| 39 | + title: Row( |
| 40 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 41 | + children: [ |
| 42 | + const Text( |
| 43 | + 'Menu', |
| 44 | + style: TextStyle( |
| 45 | + fontSize: 25, |
| 46 | + fontWeight: FontWeight.bold, |
| 47 | + ), |
| 48 | + ), |
| 49 | + Padding( |
| 50 | + padding: const EdgeInsets.only(right: 10), |
| 51 | + child: ThemeSwitcherClipper( |
| 52 | + isDarkMode: AppSettings.isDarkMode, |
| 53 | + onTap: (bool newMode) async { |
| 54 | + AppSettings.isDarkMode = newMode; |
| 55 | + setState(() {}); |
| 56 | + await SelectedTheme.saveMode(AppSettings.isDarkMode); |
| 57 | + widget.notifyParent(); |
| 58 | + }, |
| 59 | + child: Icon( |
| 60 | + AppSettings.isDarkMode |
| 61 | + ? Icons.dark_mode |
| 62 | + : Icons.light_mode, |
| 63 | + color: |
| 64 | + AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 65 | + size: 15, |
| 66 | + ), |
| 67 | + ), |
| 68 | + ), |
| 69 | + ], |
| 70 | + ), |
| 71 | + onTap: () async { |
| 72 | + AppSettings.isDarkMode = !AppSettings.isDarkMode; |
54 | 73 | setState(() {});
|
55 | 74 | await SelectedTheme.saveMode(AppSettings.isDarkMode);
|
56 | 75 | widget.notifyParent();
|
57 | 76 | },
|
58 |
| - child: Icon( |
59 |
| - AppSettings.isDarkMode ? Icons.dark_mode : Icons.light_mode, |
| 77 | + ), |
| 78 | + ListTile( |
| 79 | + tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 80 | + textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 81 | + leading: Icon( |
| 82 | + Icons.person_rounded, |
60 | 83 | color: AppSettings.isDarkMode ? Colors.white : Colors.black,
|
61 |
| - size: 15, |
62 |
| - children: [ |
63 |
| - ListTile( |
64 |
| - tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
65 |
| - textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
66 |
| - contentPadding: const EdgeInsets.only(top: 40, left: 10), |
67 |
| - title: Text( |
68 |
| - 'Menu', |
69 |
| - style: GoogleFonts.poppins( |
70 |
| - fontSize: 25, |
71 |
| - fontWeight: FontWeight.bold, |
72 |
| - ), |
73 |
| - ), |
74 |
| - onTap: () => Navigator.pop(context), |
75 | 84 | ),
|
| 85 | + title: const Text('Profile'), |
| 86 | + onTap: () { |
| 87 | + Navigator.pushNamed(context, PageRoutes.profile); |
| 88 | + }, |
76 | 89 | ),
|
77 |
| - ), |
78 |
| - ], |
79 |
| - ), |
80 |
| - onTap: () async { |
81 |
| - AppSettings.isDarkMode = !AppSettings.isDarkMode; |
82 |
| - setState(() {}); |
83 |
| - await SelectedTheme.saveMode(AppSettings.isDarkMode); |
84 |
| - widget.notifyParent(); |
85 |
| - }, |
86 |
| - ), |
87 |
| - ListTile( |
88 |
| - tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
89 |
| - textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
90 |
| - leading: Icon( |
91 |
| - Icons.person_rounded, |
92 |
| - color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
93 |
| - ), |
94 |
| - title: const Text('Profile'), |
95 |
| - onTap: () { |
96 |
| - // Update the state of the app |
97 |
| - // ... |
98 |
| - Navigator.pushNamed(context, PageRoutes.profile); |
99 |
| - // Then close the drawer |
100 |
| - // Navigator.pop(context); |
101 |
| - }, |
| 90 | + // Uncomment the following ListTile if you want to enable the "Refresh" button |
| 91 | + /* |
| 92 | + ListTile( |
| 93 | + tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 94 | + textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 95 | + leading: Icon( |
| 96 | + Icons.refresh, |
| 97 | + color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
102 | 98 | ),
|
103 |
| - //We dont need 2 sync buttons |
104 |
| - // ListTile( |
105 |
| - // tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
106 |
| - // textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
107 |
| - // leading: Icon( |
108 |
| - // Icons.refresh, |
109 |
| - // color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
110 |
| - // ), |
111 |
| - // onTap: () { |
112 |
| - // Navigator.pop(context); |
113 |
| - // storageWidget.synchronize(context, true); |
114 |
| - // }, |
115 |
| - // title: const Text("Refresh"), |
116 |
| - // ), |
117 |
| - ListTile( |
118 |
| - tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
119 |
| - textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
120 |
| - leading: Icon( |
121 |
| - Icons.summarize, |
122 |
| - color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
123 |
| - ), |
124 |
| - onTap: () { |
125 |
| - Navigator.of(context).push(MaterialPageRoute( |
126 |
| - builder: (context) => const ReportsHome())); |
127 |
| - }, |
128 |
| - title: const Text("Reports"), |
| 99 | + onTap: () { |
| 100 | + Navigator.pop(context); |
| 101 | + widget.storageWidget.synchronize(context, true); |
| 102 | + }, |
| 103 | + title: const Text("Refresh"), |
| 104 | + ), |
| 105 | + */ |
| 106 | + ListTile( |
| 107 | + tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 108 | + textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 109 | + leading: Icon( |
| 110 | + Icons.summarize, |
| 111 | + color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
129 | 112 | ),
|
130 |
| - ListTile( |
131 |
| - tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
132 |
| - textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
133 |
| - leading: Icon( |
134 |
| - Icons.info, |
135 |
| - color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
136 |
| - ), |
137 |
| - onTap: () { |
138 |
| - Navigator.of(context).push( |
139 |
| - MaterialPageRoute(builder: (context) => const AboutPage())); |
140 |
| - }, |
141 |
| - title: const Text("About"), |
| 113 | + onTap: () { |
| 114 | + Navigator.of(context).push( |
| 115 | + MaterialPageRoute( |
| 116 | + builder: (context) => const ReportsHome(), |
| 117 | + ), |
| 118 | + ); |
| 119 | + }, |
| 120 | + title: const Text("Reports"), |
| 121 | + ), |
| 122 | + ListTile( |
| 123 | + tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 124 | + textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 125 | + leading: Icon( |
| 126 | + Icons.info, |
| 127 | + color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
142 | 128 | ),
|
143 |
| - ListTile( |
144 |
| - tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
145 |
| - textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
146 |
| - leading: Icon( |
147 |
| - Icons.settings, |
148 |
| - color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
149 |
| - ), |
150 |
| - onTap: () { |
151 |
| - Navigator.of(context).push(MaterialPageRoute( |
152 |
| - builder: (context) => const SettingsPage())); |
153 |
| - }, |
154 |
| - title: const Text("Settings"), |
| 129 | + onTap: () { |
| 130 | + Navigator.of(context).push( |
| 131 | + MaterialPageRoute( |
| 132 | + builder: (context) => const AboutPage(), |
| 133 | + ), |
| 134 | + ); |
| 135 | + }, |
| 136 | + title: const Text("About"), |
| 137 | + ), |
| 138 | + ListTile( |
| 139 | + tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white, |
| 140 | + textColor: AppSettings.isDarkMode ? Colors.white : Colors.black, |
| 141 | + leading: Icon( |
| 142 | + Icons.settings, |
| 143 | + color: AppSettings.isDarkMode ? Colors.white : Colors.black, |
155 | 144 | ),
|
156 |
| - ], |
157 |
| - )); |
| 145 | + onTap: () { |
| 146 | + Navigator.of(context).push( |
| 147 | + MaterialPageRoute( |
| 148 | + builder: (context) => const SettingsPage(), |
| 149 | + ), |
| 150 | + ); |
| 151 | + }, |
| 152 | + title: const Text("Settings"), |
| 153 | + ), |
| 154 | + ], |
| 155 | + ), |
| 156 | + ); |
158 | 157 | }
|
159 | 158 | }
|
0 commit comments