@@ -15,178 +15,174 @@ class HomePage extends StatelessWidget {
1515
1616 @override
1717 Widget build (BuildContext context) {
18- final deviceSize = MediaQuery .of (context).size;
18+ final _deviceSize = MediaQuery .of (context).size;
1919
2020 return Scaffold (
2121 body: SafeArea (
22- child: SizedBox (
23- width: deviceSize.width,
24- height: deviceSize.height,
25- child: Column (
26- crossAxisAlignment: CrossAxisAlignment .stretch,
27- children: [
28- Padding (
29- padding: const EdgeInsets .only (
30- top: 8.0 ,
31- bottom: 8.0 ,
32- left: 16.0 ,
33- ),
34- child: Row (
35- mainAxisAlignment: MainAxisAlignment .spaceBetween,
36- children: [
37- Text (
38- appName,
39- style: GoogleFonts .pollerOne (
40- textStyle: const TextStyle (
41- fontSize: 24.0 ,
42- fontWeight: FontWeight .w600,
43- overflow: TextOverflow .clip,
44- ),
22+ child: Column (
23+ crossAxisAlignment: CrossAxisAlignment .stretch,
24+ children: [
25+ Padding (
26+ padding: const EdgeInsets .only (
27+ top: 8.0 ,
28+ bottom: 8.0 ,
29+ left: 16.0 ,
30+ ),
31+ child: Row (
32+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
33+ mainAxisSize: MainAxisSize .max,
34+ children: [
35+ Text (
36+ appName,
37+ style: GoogleFonts .rowdies (
38+ textStyle: const TextStyle (
39+ fontSize: 24.0 ,
40+ fontWeight: FontWeight .w500,
41+ overflow: TextOverflow .clip,
4542 ),
4643 ),
47- IconButton (
48- onPressed: () {
49- Navigator .push (
50- context,
51- MaterialPageRoute (
52- builder: (_) {
53- return const SettingsPage ();
54- },
55- ),
56- );
57- },
58- icon: const Icon (
59- Icons .settings,
60- size: 28.0 ,
61- ),
62- padding: const EdgeInsets .all (0.0 ),
44+ ),
45+ IconButton (
46+ onPressed: () {
47+ Navigator .push (
48+ context,
49+ MaterialPageRoute (
50+ builder: (_) {
51+ return const SettingsPage ();
52+ },
53+ ),
54+ );
55+ },
56+ icon: const Icon (
57+ Icons .settings,
58+ size: 28.0 ,
6359 ),
64- ],
65- ),
60+ padding: const EdgeInsets .all (0.0 ),
61+ ),
62+ ],
6663 ),
67- const SizedBox (height: 8.0 ),
68- Expanded (
69- child: Padding (
70- padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
71- child: StreamBuilder <List <GroceryList ?>>(
72- stream: groceryProvider.onGroceryListItems (),
73- builder: (ctx, snapshot) {
74- var items = snapshot.data;
75- if (items == null ) {
76- return const Center (
77- child: CircularProgressIndicator (),
78- );
79- }
80- if (items.isEmpty) {
64+ ),
65+ const SizedBox (height: 8.0 ),
66+ Expanded (
67+ child: Padding (
68+ padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
69+ child: StreamBuilder <List <GroceryList ?>>(
70+ stream: groceryProvider.onGroceryListItems (),
71+ builder: (ctx, snapshot) {
72+ var items = snapshot.data;
73+ if (items == null ) {
74+ return const Center (
75+ child: CircularProgressIndicator (),
76+ );
77+ }
78+ if (items.isEmpty) {
79+ return Column (
80+ mainAxisSize: MainAxisSize .min,
81+ mainAxisAlignment: MainAxisAlignment .center,
82+ children: [
83+ SvgPicture .asset (
84+ "assets/empty_cart.svg" ,
85+ width: _deviceSize.width * 0.75 ,
86+ ),
87+ const SizedBox (height: 20.0 ),
88+ Text (
89+ "No lists." ,
90+ style: GoogleFonts .montserrat (
91+ color: Colors .grey,
92+ fontSize: 20.0 ,
93+ ),
94+ )
95+ ],
96+ );
97+ }
98+ return ListView .builder (
99+ shrinkWrap: true ,
100+ physics: const BouncingScrollPhysics (),
101+ itemBuilder: (ctx, i) {
102+ var item = items[i]! ;
81103 return Column (
82104 mainAxisSize: MainAxisSize .min,
83- mainAxisAlignment: MainAxisAlignment .center,
84105 children: [
85- SvgPicture .asset (
86- "assets/empty_cart.svg" ,
87- width: deviceSize.width * 0.75 ,
88- ),
89- const SizedBox (height: 20.0 ),
90- Text (
91- "No lists." ,
92- style: GoogleFonts .montserrat (
93- color: Colors .grey,
94- fontSize: 20.0 ,
106+ GestureDetector (
107+ child: GroceryListCard (
108+ title: item.title.v ?? '' ,
109+ description: item.description.v ?? '' ,
110+ addedAt: item.addedAt.v ?? '' ,
111+ color: i % 2 == 0
112+ ? Colors .redAccent.withOpacity (0.75 )
113+ : Colors .green.withOpacity (0.75 ),
114+ onViewBtn: () {
115+ Navigator .of (context).push (
116+ MaterialPageRoute (
117+ builder: (_) {
118+ return ListDetailsPage (
119+ initialItem: item,
120+ );
121+ },
122+ ),
123+ );
124+ },
125+ onEditBtn: () {
126+ Navigator .of (context).push (
127+ MaterialPageRoute (
128+ builder: (_) {
129+ return AddEditListPage (
130+ initialItem: item,
131+ );
132+ },
133+ ),
134+ );
135+ },
136+ onDeleteBtn: () async {
137+ if (await showDialog (
138+ context: context,
139+ barrierDismissible: false ,
140+ builder: (ctx) {
141+ return AlertDialog (
142+ title: const Text ("Delete List?" ),
143+ content: SingleChildScrollView (
144+ child: ListBody (
145+ children: const [
146+ Text (
147+ "Tap YES to confirm item deletion." ),
148+ ],
149+ ),
150+ ),
151+ actions: [
152+ TextButton (
153+ onPressed: () {
154+ Navigator .pop (ctx, true );
155+ },
156+ child: const Text ('YES' ),
157+ ),
158+ TextButton (
159+ onPressed: () {
160+ Navigator .pop (ctx, false );
161+ },
162+ child: const Text ('NO' ),
163+ ),
164+ ],
165+ );
166+ }) ??
167+ false ) {
168+ await groceryProvider
169+ .deleteGroceryListItem (item.id.v);
170+ }
171+ },
95172 ),
96- )
173+ ),
174+ if (i != (items.length - 1 ))
175+ const SizedBox (height: 8.0 ),
97176 ],
98177 );
99- }
100- return ListView .builder (
101- shrinkWrap: true ,
102- physics: const BouncingScrollPhysics (),
103- itemBuilder: (ctx, i) {
104- var item = items[i]! ;
105- return Column (
106- mainAxisSize: MainAxisSize .min,
107- children: [
108- GestureDetector (
109- child: GroceryListCard (
110- title: item.title.v ?? '' ,
111- description: item.description.v ?? '' ,
112- addedAt: item.addedAt.v ?? '' ,
113- color: i % 2 == 0
114- ? Colors .redAccent.withOpacity (0.75 )
115- : Colors .green.withOpacity (0.75 ),
116- onViewBtn: () {
117- Navigator .of (context).push (
118- MaterialPageRoute (
119- builder: (_) {
120- return ListDetailsPage (
121- initialItem: item,
122- );
123- },
124- ),
125- );
126- },
127- onEditBtn: () {
128- Navigator .of (context).push (
129- MaterialPageRoute (
130- builder: (_) {
131- return AddEditListPage (
132- initialItem: item,
133- );
134- },
135- ),
136- );
137- },
138- onDeleteBtn: () async {
139- if (await showDialog (
140- context: context,
141- barrierDismissible: false ,
142- builder: (ctx) {
143- return AlertDialog (
144- title:
145- const Text ("Delete List?" ),
146- content: SingleChildScrollView (
147- child: ListBody (
148- children: const [
149- Text (
150- "Tap YES to confirm item deletion." ),
151- ],
152- ),
153- ),
154- actions: [
155- TextButton (
156- onPressed: () {
157- Navigator .pop (ctx, true );
158- },
159- child: const Text ('YES' ),
160- ),
161- TextButton (
162- onPressed: () {
163- Navigator .pop (ctx, false );
164- },
165- child: const Text ('NO' ),
166- ),
167- ],
168- );
169- }) ??
170- false ) {
171- await groceryProvider
172- .deleteGroceryListItem (item.id.v);
173- }
174- },
175- ),
176- ),
177- if (i != (items.length - 1 ))
178- const SizedBox (height: 8.0 ),
179- ],
180- );
181- },
182- itemCount: items.length,
183- );
184- },
185- ),
178+ },
179+ itemCount: items.length,
180+ );
181+ },
186182 ),
187183 ),
188- ] ,
189- ) ,
184+ ) ,
185+ ] ,
190186 ),
191187 ),
192188 floatingActionButton: FloatingActionButton (
0 commit comments