Skip to content

Commit 2f8d202

Browse files
Add Remove from Wishlist Screen
1 parent 188055f commit 2f8d202

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

lib/views/wishlist_screen_view/wishlist_screen.dart

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,55 @@ class WishlistScreen extends StatelessWidget {
2121
if (!snapshot.hasData)
2222
return loadingIndicator();
2323
else if (snapshot.data!.docs.isEmpty)
24-
return "No items yet!".text.color(darkFontGrey).makeCentered();
25-
else
26-
return Container();
24+
return "Wishlist is Empty".text.color(darkFontGrey).makeCentered();
25+
else {
26+
var data = snapshot.data!.docs;
27+
return Column(
28+
children: [
29+
Expanded(
30+
child: ListView.builder(
31+
itemCount: data.length,
32+
shrinkWrap: true,
33+
itemBuilder: (BuildContext context, int index) => ListTile(
34+
leading: Image.network(
35+
"${data[index]['p_images'][0]}",
36+
width: 80,
37+
fit: BoxFit.cover,
38+
),
39+
title: "${data[index]['p_name']}"
40+
.text
41+
.fontFamily(semibold)
42+
.size(16)
43+
.make(),
44+
subtitle: "${data[index]['p_price']}"
45+
.numCurrency
46+
.text
47+
.fontFamily(semibold)
48+
.size(16)
49+
.color(redColor)
50+
.make(),
51+
trailing: IconButton(
52+
onPressed: () => firestore
53+
.collection(productsCollection)
54+
.doc(data[index].id)
55+
.set(
56+
{
57+
'p_wishlist':
58+
FieldValue.arrayRemove([currentUser!.uid])
59+
},
60+
SetOptions(merge: true),
61+
),
62+
icon: const Icon(
63+
Icons.favorite_outlined,
64+
color: redColor,
65+
),
66+
),
67+
),
68+
),
69+
),
70+
],
71+
);
72+
}
2773
},
2874
),
2975
);

0 commit comments

Comments
 (0)