Skip to content

Commit

Permalink
Add Remove from Wishlist Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
codewith-usama committed Nov 19, 2023
1 parent 188055f commit 2f8d202
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions lib/views/wishlist_screen_view/wishlist_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,55 @@ class WishlistScreen extends StatelessWidget {
if (!snapshot.hasData)
return loadingIndicator();
else if (snapshot.data!.docs.isEmpty)
return "No items yet!".text.color(darkFontGrey).makeCentered();
else
return Container();
return "Wishlist is Empty".text.color(darkFontGrey).makeCentered();
else {
var data = snapshot.data!.docs;
return Column(
children: [
Expanded(
child: ListView.builder(
itemCount: data.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) => ListTile(
leading: Image.network(
"${data[index]['p_images'][0]}",
width: 80,
fit: BoxFit.cover,
),
title: "${data[index]['p_name']}"
.text
.fontFamily(semibold)
.size(16)
.make(),
subtitle: "${data[index]['p_price']}"
.numCurrency
.text
.fontFamily(semibold)
.size(16)
.color(redColor)
.make(),
trailing: IconButton(
onPressed: () => firestore
.collection(productsCollection)
.doc(data[index].id)
.set(
{
'p_wishlist':
FieldValue.arrayRemove([currentUser!.uid])
},
SetOptions(merge: true),
),
icon: const Icon(
Icons.favorite_outlined,
color: redColor,
),
),
),
),
),
],
);
}
},
),
);
Expand Down

0 comments on commit 2f8d202

Please sign in to comment.