Skip to content

Commit 8ea50a8

Browse files
authored
Merge pull request #197 from Pavel401/drawer-fix
Redesigned the Nav Drawer
2 parents 4ef5f8e + 732986f commit 8ea50a8

File tree

3 files changed

+125
-125
lines changed

3 files changed

+125
-125
lines changed

lib/config/theme_switcher_clipper.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ class _ThemeSwitcherClipperState extends State<ThemeSwitcherClipper> {
3131
width: 60,
3232
height: 60,
3333
child: Center(
34-
child: AnimatedSwitcher(
35-
duration: const Duration(seconds: 2),
36-
child: Icon(
37-
widget.isDarkMode ? Icons.dark_mode : Icons.light_mode,
38-
key: ValueKey<bool>(widget.isDarkMode),
39-
color: widget.isDarkMode ? Colors.white : Colors.black,
40-
size: 40,
41-
),
34+
child: AnimatedSwitcher(
35+
duration: const Duration(seconds: 2),
36+
child: Icon(
37+
widget.isDarkMode ? Icons.dark_mode : Icons.light_mode,
38+
key: UniqueKey(),
39+
color: widget.isDarkMode ? Colors.white : Colors.black,
40+
size: 40,
4241
),
43-
),
42+
)),
4443
),
4544
),
4645
),

lib/drawer/nav_drawer.dart

Lines changed: 115 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// ignore_for_file: library_private_types_in_public_api
22

33
import 'package:flutter/material.dart';
4-
4+
import 'package:sizer/sizer.dart';
55
import 'package:taskwarrior/config/app_settings.dart';
66
import 'package:taskwarrior/model/storage/storage_widget.dart';
7-
import 'package:taskwarrior/routes/pageroute.dart';
87
import 'package:taskwarrior/views/about/about.dart';
8+
import 'package:taskwarrior/views/profile/profile.dart';
99
import 'package:taskwarrior/views/reports/reports_home.dart';
1010
import 'package:taskwarrior/config/theme_switcher_clipper.dart';
1111
import 'package:taskwarrior/views/settings/settings.dart';
@@ -29,129 +29,130 @@ class _NavDrawerState extends State<NavDrawer> {
2929
Widget build(BuildContext context) {
3030
return Drawer(
3131
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,
6348
color:
6449
AppSettings.isDarkMode ? Colors.white : Colors.black,
65-
size: 15,
6650
),
6751
),
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+
),
7075
),
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,
8479
),
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+
},
9891
),
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+
},
112102
),
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+
},
128113
),
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,
143144
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
144145
),
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+
),
155156
),
156157
);
157158
}

lib/views/profile/profile.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'package:google_fonts/google_fonts.dart';
33

44
import 'package:taskwarrior/config/app_settings.dart';
55
import 'package:taskwarrior/model/storage/savefile.dart';
6-
import 'package:taskwarrior/routes/pageroute.dart';
76
import 'package:taskwarrior/taskserver/ntaskserver.dart';
87
import 'package:taskwarrior/widgets/pallete.dart';
98
import 'package:taskwarrior/widgets/profilefunctions.dart';
@@ -35,7 +34,8 @@ class _ProfilePageState extends State<ProfilePage> {
3534
),
3635
leading: IconButton(
3736
onPressed: () {
38-
Navigator.pushReplacementNamed(context, PageRoutes.home);
37+
// Navigator.pushReplacementNamed(context, PageRoutes.home);
38+
Navigator.of(context).pop();
3939
},
4040
icon: const Icon(
4141
Icons.chevron_left,

0 commit comments

Comments
 (0)