Skip to content

Commit e99b8b1

Browse files
Merge pull request #32 from 100RAV-AGGARWAL/theme-consistency
Theme consistency
2 parents 5edad4d + 64288e9 commit e99b8b1

File tree

18 files changed

+399
-151
lines changed

18 files changed

+399
-151
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"editor.minimap.enabled": false,
2+
// "editor.minimap.enabled": false,
33
"html.format.wrapAttributesIndentSize": 4,
44
"[dart]": {
55
"editor.tabSize": 4,

lib/config/app_settings.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/scheduler.dart';
3+
4+
class AppSettings {
5+
static bool isDarkMode =
6+
(SchedulerBinding.instance.window.platformBrightness == Brightness.dark);
7+
}

lib/drawer/filter_drawer.dart

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// ignore_for_file: prefer_const_constructors
2+
13
import 'package:flutter/material.dart';
4+
import 'package:taskwarrior/config/app_settings.dart';
25
import 'package:taskwarrior/model/storage/storage_widget.dart';
36
import 'package:taskwarrior/views/home/home.dart';
47
import 'package:taskwarrior/widgets/project_filter.dart';
@@ -13,6 +16,9 @@ class FilterDrawer extends StatelessWidget {
1316
Widget build(BuildContext context) {
1417
var storageWidget = StorageWidget.of(context);
1518
return Drawer(
19+
backgroundColor: AppSettings.isDarkMode
20+
? Color.fromARGB(255, 29, 29, 29)
21+
: Colors.white,
1622
child: SafeArea(
1723
child: Padding(
1824
padding: const EdgeInsets.all(8),
@@ -26,6 +32,12 @@ class FilterDrawer extends StatelessWidget {
2632
'filter:${filters.pendingFilter ? 'status : pending' : ''}',
2733
),
2834
onTap: filters.togglePendingFilter,
35+
tileColor: AppSettings.isDarkMode
36+
? Color.fromARGB(255, 48, 46, 46)
37+
: Color.fromARGB(255, 220, 216, 216),
38+
textColor: AppSettings.isDarkMode
39+
? Colors.white
40+
: Color.fromARGB(255, 48, 46, 46),
2941
),
3042
),
3143
const Divider(),
@@ -37,9 +49,13 @@ class FilterDrawer extends StatelessWidget {
3749
const Divider(),
3850
TagFiltersWrap(filters.tagFilters),
3951
const Divider(),
40-
const Text(
52+
Text(
4153
'Sort By : ',
42-
style: TextStyle(fontStyle: FontStyle.normal, fontSize: 20),
54+
style: TextStyle(
55+
color:
56+
(AppSettings.isDarkMode ? Colors.white : Colors.black),
57+
fontStyle: FontStyle.normal,
58+
fontSize: 20),
4359
textAlign: TextAlign.left,
4460
),
4561
const Divider(),
@@ -71,6 +87,13 @@ class FilterDrawer extends StatelessWidget {
7187
storageWidget.selectSort('$sort+');
7288
}
7389
},
90+
labelStyle: TextStyle(
91+
color: AppSettings.isDarkMode
92+
? Colors.black
93+
: Colors.white),
94+
backgroundColor: AppSettings.isDarkMode
95+
? Color.fromARGB(255, 220, 216, 216)
96+
: Color.fromARGB(255, 48, 46, 46),
7497
),
7598
],
7699
),

lib/drawer/nav_drawer.dart

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:taskwarrior/config/app_settings.dart';
3+
import 'package:taskwarrior/model/storage/storage_widget.dart';
4+
import 'package:taskwarrior/routes/pageroute.dart';
5+
6+
class NavDrawer extends StatefulWidget {
7+
InheritedStorage storageWidget;
8+
final Function() notifyParent;
9+
10+
NavDrawer({Key? key, required this.storageWidget, required this.notifyParent})
11+
: super(key: key);
12+
13+
@override
14+
_NavDrawerState createState() => _NavDrawerState();
15+
}
16+
17+
class _NavDrawerState extends State<NavDrawer> {
18+
late InheritedStorage storageWidget = widget.storageWidget;
19+
20+
@override
21+
Widget build(BuildContext context) {
22+
return Drawer(
23+
backgroundColor: AppSettings.isDarkMode ? Colors.black : Colors.white,
24+
child: ListView(
25+
padding: EdgeInsets.zero,
26+
children: [
27+
ListTile(
28+
tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white,
29+
textColor: AppSettings.isDarkMode ? Colors.white : Colors.black,
30+
contentPadding: const EdgeInsets.only(top: 40, left: 10),
31+
title: const Text(
32+
'Menu',
33+
style: TextStyle(
34+
fontSize: 25,
35+
fontWeight: FontWeight.bold,
36+
),
37+
),
38+
onTap: () => Navigator.pop(context),
39+
),
40+
ListTile(
41+
tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white,
42+
textColor: AppSettings.isDarkMode ? Colors.white : Colors.black,
43+
leading: Icon(
44+
Icons.person_rounded,
45+
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
46+
),
47+
title: const Text('Profile'),
48+
onTap: () {
49+
// Update the state of the app
50+
// ...
51+
Navigator.pushNamed(context, PageRoutes.profile);
52+
// Then close the drawer
53+
// Navigator.pop(context);
54+
},
55+
),
56+
ListTile(
57+
tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white,
58+
textColor: AppSettings.isDarkMode ? Colors.white : Colors.black,
59+
leading: Icon(
60+
Icons.refresh,
61+
color: AppSettings.isDarkMode ? Colors.white : Colors.black,
62+
),
63+
onTap: () {
64+
storageWidget.synchronize(context);
65+
Navigator.pop(context);
66+
},
67+
title: const Text("Refresh"),
68+
),
69+
ListTile(
70+
tileColor: AppSettings.isDarkMode ? Colors.black : Colors.white,
71+
textColor: AppSettings.isDarkMode ? Colors.white : Colors.black,
72+
leading: AppSettings.isDarkMode
73+
? const Icon(
74+
Icons.light_mode,
75+
color: Color.fromARGB(255, 216, 196, 15),
76+
size: 25,
77+
)
78+
: const Icon(
79+
Icons.dark_mode,
80+
color: Colors.black,
81+
size: 25,
82+
),
83+
title: const Text("Switch Theme"),
84+
onTap: () {
85+
if (AppSettings.isDarkMode) {
86+
AppSettings.isDarkMode = false;
87+
} else {
88+
AppSettings.isDarkMode = true;
89+
}
90+
setState(() {});
91+
widget.notifyParent();
92+
Navigator.pop(context);
93+
},
94+
)
95+
],
96+
));
97+
}
98+
}

lib/services/task_details.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import 'package:flutter/material.dart';
44
import 'package:built_collection/built_collection.dart';
55
import 'package:google_fonts/google_fonts.dart';
6+
import 'package:taskwarrior/config/app_settings.dart';
67
import 'package:taskwarrior/model/storage/storage_widget.dart';
78
import 'package:taskwarrior/widgets/pallete.dart';
89
import 'package:taskwarrior/widgets/taskdetails.dart';
@@ -41,6 +42,9 @@ class _DetailRouteState extends State<DetailRoute> {
4142
@override
4243
Widget build(BuildContext context) {
4344
return Scaffold(
45+
backgroundColor: AppSettings.isDarkMode
46+
? const Color.fromARGB(255, 29, 29, 29)
47+
: Colors.white,
4448
appBar: AppBar(
4549
leading: const BackButton(color: Colors.white),
4650
backgroundColor: Palette.kToDark,
@@ -212,15 +216,23 @@ class AttributeWidget extends StatelessWidget {
212216
// );
213217
default:
214218
return Card(
215-
color: const Color(0x00000000),
216-
elevation: 0,
219+
color: AppSettings.isDarkMode
220+
? const Color.fromARGB(255, 57, 57, 57)
221+
: Colors.white,
217222
child: ListTile(
223+
textColor: AppSettings.isDarkMode
224+
? Colors.white
225+
: const Color.fromARGB(255, 48, 46, 46),
218226
title: SingleChildScrollView(
219227
scrollDirection: Axis.horizontal,
220228
child: Row(
221229
children: [
222230
Text(
223231
'${'$name:'.padRight(13)}$localValue',
232+
style: TextStyle(
233+
color:
234+
AppSettings.isDarkMode ? Colors.white : Colors.black,
235+
),
224236
),
225237
],
226238
),
@@ -245,13 +257,19 @@ class TagsWidget extends StatelessWidget {
245257
@override
246258
Widget build(BuildContext context) {
247259
return Card(
260+
color: AppSettings.isDarkMode
261+
? const Color.fromARGB(255, 57, 57, 57)
262+
: Colors.white,
248263
child: ListTile(
264+
textColor: AppSettings.isDarkMode
265+
? Colors.white
266+
: const Color.fromARGB(255, 48, 46, 46),
249267
title: SingleChildScrollView(
250268
scrollDirection: Axis.horizontal,
251269
child: Row(
252270
children: [
253271
Text(
254-
'${'$name:'.padRight(13)}${(value as ListBuilder?)?.build()}',
272+
'${'$name: '}${(value as ListBuilder?)?.build()}',
255273
style: GoogleFonts.firaMono(),
256274
),
257275
],

lib/views/home/home.dart

Lines changed: 13 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// ignore_for_file: use_key_in_widget_constructors, prefer_const_constructors, deprecated_member_use, avoid_unnecessary_containers, unused_element, prefer_const_literals_to_create_immutables, library_private_types_in_public_api
22

33
import 'package:flutter/material.dart';
4-
import 'package:flutter/scheduler.dart';
4+
import 'package:taskwarrior/config/app_settings.dart';
55
import 'package:taskwarrior/drawer/filter_drawer.dart';
6+
import 'package:taskwarrior/drawer/nav_drawer.dart';
67
import 'package:taskwarrior/model/storage/storage_widget.dart';
7-
import 'package:taskwarrior/routes/pageroute.dart';
88
import 'package:taskwarrior/widgets/addTask.dart';
99
import 'package:taskwarrior/widgets/buildTasks.dart';
1010
import 'package:taskwarrior/widgets/pallete.dart';
@@ -35,8 +35,6 @@ class HomePage extends StatefulWidget {
3535
}
3636

3737
class _HomePageState extends State<HomePage> {
38-
static bool _darkmode =
39-
SchedulerBinding.instance.window.platformBrightness == Brightness.dark;
4038
@override
4139
Widget build(BuildContext context) {
4240
var storageWidget = StorageWidget.of(context);
@@ -81,10 +79,10 @@ class _HomePageState extends State<HomePage> {
8179
title: Text('Home Page', style: TextStyle(color: Colors.white)),
8280
actions: [
8381
IconButton(
84-
icon: (storageWidget.searchVisible)
85-
? const Icon(Icons.cancel, color: Colors.white)
86-
: const Icon(Icons.search, color: Colors.white),
87-
onPressed: storageWidget.toggleSearch,
82+
icon: (storageWidget.searchVisible)
83+
? const Icon(Icons.cancel, color: Colors.white)
84+
: const Icon(Icons.search, color: Colors.white),
85+
onPressed: storageWidget.toggleSearch,
8886
),
8987
// Builder(
9088
// builder: (context) => IconButton(
@@ -106,76 +104,9 @@ class _HomePageState extends State<HomePage> {
106104
),
107105
),
108106
),
109-
drawer: Drawer(
110-
backgroundColor: _darkmode?Colors.black:Colors.white,
111-
child: ListView(
112-
padding: EdgeInsets.zero,
113-
children: [
114-
ListTile(
115-
tileColor: _darkmode?Colors.black:Colors.white,
116-
textColor: _darkmode?Colors.white:Colors.black,
117-
contentPadding: EdgeInsets.only(top: 40, left: 10),
118-
title: const Text(
119-
'Menu',
120-
style: TextStyle(
121-
fontSize: 25,
122-
fontWeight: FontWeight.bold,
123-
),
124-
),
125-
onTap: () => Navigator.pop(context),
126-
),
127-
ListTile(
128-
tileColor: _darkmode?Colors.black:Colors.white,
129-
textColor: _darkmode?Colors.white:Colors.black,
130-
leading: Icon(Icons.person_rounded, color: _darkmode?Colors.white:Colors.black,),
131-
title: const Text('Profile'),
132-
onTap: () {
133-
// Update the state of the app
134-
// ...
135-
Navigator.pushNamed(context, PageRoutes.profile);
136-
// Then close the drawer
137-
// Navigator.pop(context);
138-
},
139-
),
140-
ListTile(
141-
tileColor: _darkmode?Colors.black:Colors.white,
142-
textColor: _darkmode?Colors.white:Colors.black,
143-
leading: Icon(Icons.refresh, color: _darkmode?Colors.white:Colors.black,),
144-
onTap: () {
145-
storageWidget.synchronize(context);
146-
Navigator.pop(context);
147-
},
148-
title: Text("Refresh"),
149-
),
150-
ListTile(
151-
tileColor: _darkmode?Colors.black:Colors.white,
152-
textColor: _darkmode?Colors.white:Colors.black,
153-
leading: _darkmode
154-
? const Icon(
155-
Icons.light_mode,
156-
color: Color.fromARGB(255, 216, 196, 15),
157-
size: 25,
158-
)
159-
: const Icon(
160-
Icons.dark_mode,
161-
color: Colors.black,
162-
size: 25,
163-
),
164-
title: Text("Switch Theme"),
165-
onTap: () {
166-
if (_darkmode) {
167-
_darkmode = false;
168-
} else {
169-
_darkmode = true;
170-
}
171-
setState(() {});
172-
Navigator.pop(context);
173-
},
174-
)
175-
],
176-
)),
107+
drawer: NavDrawer(storageWidget: storageWidget, notifyParent: refresh),
177108
body: Container(
178-
color: _darkmode ? Palette.kToDark.shade200 : Colors.white,
109+
color: AppSettings.isDarkMode ? Palette.kToDark.shade200 : Colors.white,
179110
child: Column(
180111
children: <Widget>[
181112
if (storageWidget.searchVisible)
@@ -191,7 +122,7 @@ class _HomePageState extends State<HomePage> {
191122
Expanded(
192123
child: Scrollbar(
193124
child: TasksBuilder(
194-
darkmode: _darkmode,
125+
// darkmode: AppSettings.isDarkMode,
195126
taskData: taskData,
196127
pendingFilter: pendingFilter,
197128
),
@@ -211,4 +142,8 @@ class _HomePageState extends State<HomePage> {
211142
resizeToAvoidBottomInset: false,
212143
);
213144
}
145+
146+
refresh() {
147+
setState(() {});
148+
}
214149
}

0 commit comments

Comments
 (0)