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