1
1
// ignore_for_file: library_private_types_in_public_api
2
2
3
3
import 'package:flutter/material.dart' ;
4
-
4
+ import 'package:sizer/sizer.dart' ;
5
5
import 'package:taskwarrior/config/app_settings.dart' ;
6
6
import 'package:taskwarrior/model/storage/storage_widget.dart' ;
7
- import 'package:taskwarrior/routes/pageroute.dart' ;
8
7
import 'package:taskwarrior/views/about/about.dart' ;
8
+ import 'package:taskwarrior/views/profile/profile.dart' ;
9
9
import 'package:taskwarrior/views/reports/reports_home.dart' ;
10
10
import 'package:taskwarrior/config/theme_switcher_clipper.dart' ;
11
11
import 'package:taskwarrior/views/settings/settings.dart' ;
@@ -29,129 +29,130 @@ class _NavDrawerState extends State<NavDrawer> {
29
29
Widget build (BuildContext context) {
30
30
return Drawer (
31
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,
32
+ child: Container (
33
+ color: AppSettings .isDarkMode ? Colors .black : Colors .white,
34
+ child: ListView (
35
+ padding: EdgeInsets .zero,
36
+ children: [
37
+ Container (
38
+ color: AppSettings .isDarkMode ? Colors .black : Colors .white,
39
+ padding: const EdgeInsets .only (top: 50 , left: 15 , right: 10 ),
40
+ child: Row (
41
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
42
+ children: [
43
+ Text (
44
+ 'Menu' ,
45
+ style: TextStyle (
46
+ fontSize: 25 ,
47
+ fontWeight: FontWeight .bold,
63
48
color:
64
49
AppSettings .isDarkMode ? Colors .white : Colors .black,
65
- size: 15 ,
66
50
),
67
51
),
68
- ),
69
- ],
52
+ Padding (
53
+ padding: const EdgeInsets .only (right: 10 ),
54
+ child: ThemeSwitcherClipper (
55
+ isDarkMode: AppSettings .isDarkMode,
56
+ onTap: (bool newMode) async {
57
+ AppSettings .isDarkMode = newMode;
58
+ setState (() {});
59
+ await SelectedTheme .saveMode (AppSettings .isDarkMode);
60
+ widget.notifyParent ();
61
+ },
62
+ child: Icon (
63
+ AppSettings .isDarkMode
64
+ ? Icons .dark_mode
65
+ : Icons .light_mode,
66
+ color: AppSettings .isDarkMode
67
+ ? Colors .white
68
+ : Colors .black,
69
+ size: 15 ,
70
+ ),
71
+ ),
72
+ ),
73
+ ],
74
+ ),
70
75
),
71
- onTap: () async {
72
- AppSettings .isDarkMode = ! AppSettings .isDarkMode;
73
- setState (() {});
74
- await SelectedTheme .saveMode (AppSettings .isDarkMode);
75
- widget.notifyParent ();
76
- },
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,
83
- color: AppSettings .isDarkMode ? Colors .white : Colors .black,
76
+ Container (
77
+ color: AppSettings .isDarkMode ? Colors .black : Colors .white,
78
+ height: 3. h,
84
79
),
85
- title: const Text ('Profile' ),
86
- onTap: () {
87
- Navigator .pushNamed (context, PageRoutes .profile);
88
- },
89
- ),
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,
80
+ buildMenuItem (
81
+ icon: Icons .person_rounded,
82
+ text: 'Profile' ,
83
+ onTap: () {
84
+ Navigator .of (context).push (
85
+ MaterialPageRoute (
86
+ builder: (context) => const ProfilePage (),
87
+ ),
88
+ );
89
+ // Navigator.pushNamed(context, PageRoutes.profile);
90
+ },
98
91
),
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,
92
+ buildMenuItem (
93
+ icon: Icons .summarize,
94
+ text: 'Reports' ,
95
+ onTap: () {
96
+ Navigator .of (context).push (
97
+ MaterialPageRoute (
98
+ builder: (context) => const ReportsHome (),
99
+ ),
100
+ );
101
+ },
112
102
),
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,
103
+ buildMenuItem (
104
+ icon: Icons .info,
105
+ text: 'About' ,
106
+ onTap: () {
107
+ Navigator .of (context).push (
108
+ MaterialPageRoute (
109
+ builder: (context) => const AboutPage (),
110
+ ),
111
+ );
112
+ },
128
113
),
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,
114
+ buildMenuItem (
115
+ icon: Icons .settings,
116
+ text: 'Settings' ,
117
+ onTap: () {
118
+ Navigator .of (context).push (
119
+ MaterialPageRoute (
120
+ builder: (context) => const SettingsPage (),
121
+ ),
122
+ );
123
+ },
124
+ ),
125
+ ],
126
+ ),
127
+ ),
128
+ );
129
+ }
130
+
131
+ Widget buildMenuItem (
132
+ {required IconData icon,
133
+ required String text,
134
+ required VoidCallback onTap}) {
135
+ return InkWell (
136
+ onTap: onTap,
137
+ child: Container (
138
+ color: AppSettings .isDarkMode ? Colors .black : Colors .white,
139
+ padding: const EdgeInsets .symmetric (vertical: 12 , horizontal: 10 ),
140
+ child: Row (
141
+ children: [
142
+ Icon (
143
+ icon,
143
144
color: AppSettings .isDarkMode ? Colors .white : Colors .black,
144
145
),
145
- onTap : () {
146
- Navigator . of (context). push (
147
- MaterialPageRoute (
148
- builder : (context) => const SettingsPage (),
149
- ) ,
150
- );
151
- } ,
152
- title : const Text ( "Settings" ),
153
- ) ,
154
- ] ,
146
+ const SizedBox (width : 10 ),
147
+ Text (
148
+ text,
149
+ style : TextStyle (
150
+ color : AppSettings .isDarkMode ? Colors .white : Colors .black ,
151
+ fontSize : 18 ,
152
+ ) ,
153
+ ),
154
+ ] ,
155
+ ) ,
155
156
),
156
157
);
157
158
}
0 commit comments