Skip to content

Commit

Permalink
Fixed bug related to loading shopping list
Browse files Browse the repository at this point in the history
Fixed bug related to watchlist backend
Updated demo video
  • Loading branch information
mohammadkamal committed Feb 27, 2021
1 parent f24acf7 commit 1fb2fd5
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 63 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Bayya",
"request": "launch",
"type": "dart"
}
]
}
35 changes: 5 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
# Bayya

An e-commerce flutter application
An e-commerce flutter application.
The application features:
* Shopping Cart & Watchlist tracking
* User Login and registration support

## Demo
[![Demo](https://img.youtube.com/vi/Gj34dG4w6Mk/0.jpg)](https://www.youtube.com/watch?v=Gj34dG4w6Mk)

## Description
### Homepage
<p>Homepage currently contains list of dummy test cases for products.</p>
<img src="/docs/homepage_screenshot.png" width="250" />

### Application Sidebar
<p>Sidebar for the application contains shopping cart, watchlist, account management.</p>
<img src="/docs/application_sidebar.png" width="250" />

### Product page
<p>Product page currently contains some details about the products itself.</p>

Main product page | Click cart icon | Click watchlist icon
------------ | ------------- | ------------- | -------------
<img src="/docs/product_screenshot.png" width="250" /> | <img src="/docs/product_added_to_shopping_cart.png" width="250" /> | <img src="/docs/product_watchlisted.png" width="250" />

### Shopping Cart page
<p>This page tracks the products added by the user to shopping cart.</p>
<img src="/docs/shopping_cart.png" width="250" />

### Watchlist page
<p>This page tracks watchlisted products (or saved) by the user.</p>
<img src="/docs/watchlist.png" width="250" />

### Search page
<p>This page is used to search desired products by name instead looking through the whole catalog.</p>
<img src="/docs/search_page.png" width="250" />
[![Demo](https://img.youtube.com/vi/mIx5fLc2f2E/0.jpg)](https://www.youtube.com/watch?v=mIx5fLc2f2E)
20 changes: 10 additions & 10 deletions lib/Cart/ShoppingCartList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class ShoppingCartList extends StatelessWidget {
color: Colors.grey,
child: ListView(
padding: EdgeInsets.symmetric(vertical: 8.0),
children:
context.read<ShoppingCart>().shoppingItemQuantites.isNotEmpty
? context
.read<ShoppingCart>()
.shoppingItemQuantites
.keys
.map((e) {
return ShoppingCartItem(productId: e);
}).toList()
: [])),
children: Provider.of<ShoppingCart>(context)
.shoppingItemQuantites
.isNotEmpty
? Provider.of<ShoppingCart>(context)
.shoppingItemQuantites
.keys
.map((e) {
return ShoppingCartItem(productId: e);
}).toList()
: [])),
floatingActionButton: FloatingActionButton.extended(
onPressed: null,
label: Text(
Expand Down
4 changes: 2 additions & 2 deletions lib/Catalog/ShoppingList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class _ShoppingListState extends State<ShoppingList> {
Widget _productsList() {
return ListView(
padding: EdgeInsets.symmetric(vertical: 8.0),
children: context.read<Catalog>().productsCatalog.isNotEmpty
? context.read<Catalog>().productsCatalog.keys.map((e) {
children: Provider.of<Catalog>(context).productsCatalog.isNotEmpty
? Provider.of<Catalog>(context).productsCatalog.keys.map((e) {
return ShoppingListItem(productId: e);
}).toList()
: [LinearProgressIndicator()]);
Expand Down
2 changes: 1 addition & 1 deletion lib/SideDrawer/WatchlistCard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _WatchlistCardState extends State<WatchlistCard>
@override
Widget build(BuildContext context)
{
int _watchlistCount = Provider.of<Watchlist>(context).watchlistList.length;
int _watchlistCount = Provider.of<Watchlist>(context).watchlistMap.keys.length;
return ListTile(
title: Text('Watchlist'),
leading: Icon(Icons.favorite, color: Colors.red),
Expand Down
7 changes: 4 additions & 3 deletions lib/Watchlist/ViewWatchList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ class ViewWatchList extends StatelessWidget {
color: Colors.grey,
child: ListView(
padding: EdgeInsets.symmetric(vertical: 8.0),
children: Provider.of<Watchlist>(context).watchlistList.isNotEmpty
children: Provider.of<Watchlist>(context).watchlistMap.isNotEmpty
? Provider.of<Watchlist>(context)
.watchlistList
.map((String productId) {
.watchlistMap
.keys
.map((productId) {
return WatchlistItem(
productId: productId,
);
Expand Down
28 changes: 12 additions & 16 deletions lib/Watchlist/Watchlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,37 @@ class Watchlist extends ChangeNotifier {
CollectionReference watchlist =
FirebaseFirestore.instance.collection('watchlist');

List<String> _watchlistList = new List<String>();
UnmodifiableListView<String> get watchlistList =>
UnmodifiableListView(_watchlistList);
Map<String, bool> _watchlistMap = new Map<String, bool>();
UnmodifiableMapView<String, bool> get watchlistMap =>
UnmodifiableMapView(_watchlistMap);

void setWatchlisted(String key) {
_watchlistList.add(key);
_watchlistMap[key] = true;
update();
notifyListeners();
}

void unWatchlist(String key) {
_watchlistList.remove(key);
_watchlistMap.remove(key);
update();
notifyListeners();
}

bool getWatchlisted(String key) {
return _watchlistList.contains(key);
return _watchlistMap.containsKey(key);
}

void update() {
watchlist
.doc(FirebaseAuth.instance.currentUser.email)
.set({"watchArr": _watchlistList});
watchlist.doc(FirebaseAuth.instance.currentUser.email).set(_watchlistMap);
}

Future<void> fetchData() async {
await watchlist
DocumentSnapshot documentSnapshot = await watchlist
.doc(FirebaseAuth.instance.currentUser.email)
.get()
.then((value) {
List.from(value.data()["watchArr"]).forEach((element) {
_watchlistList.add(element);
});
.get();
documentSnapshot.data().forEach((key, value) {
_watchlistMap[key] = value;
notifyListeners();
});
notifyListeners();
}
}
2 changes: 1 addition & 1 deletion lib/Watchlist/WatchlistItem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _WatchlistItemState extends State<WatchlistItem> {
padding: const EdgeInsets.only(bottom: 4),
child: Text(
Provider.of<Catalog>(context)
.productsCatalog[widget.productId]
.productsCatalog[widget.productId].price
.toString() +
' EGP',
textAlign: TextAlign.left),
Expand Down

0 comments on commit 1fb2fd5

Please sign in to comment.