Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Fix/skip creation page (#212)
Browse files Browse the repository at this point in the history
* feat(cacheManagement): refacto to use cache pattern

* feat(cache) : refactore share management

* (feat/CM_loyaltycards)

* feat(cache) : added itemList cache management

* rebase develop

* fix(getit): remove duplicate register

* fix(lists) : Delete creation list page

Co-authored-by: PiotrFLEURY <piotr.fleury@gmail.com>
Co-authored-by: zohra <senouci12@hotmail.fr>
  • Loading branch information
3 people authored Aug 24, 2020
1 parent 0cf17e5 commit 3b4c6e1
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 139 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Password : User can now see the password he his typing
- Progress_bar : Progress bar value error
- openedListPage and new_list : change ui
- list Creation : User don't have to use the creation list page to create a list anymore

### Security

Expand Down
17 changes: 15 additions & 2 deletions lib/dao/wishlist_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ class WishlistDao {
Future<DocumentSnapshot> fetchShareLists(String userUuid) =>
Firestore.instance.collection("shared").document(userUuid).get();

addWishlist(String text, String wishlistUuid, String userUuid) async {
Future<void> addWishlist(String wishlistUuid, String userUuid) async {
String wishlistName;

await Firestore.instance
.collection("owners")
.document(userUuid)
.get()
.then((value) {
value.data.isNotEmpty
? wishlistName =
"Wishlist " + (value.data["lists"].length + 1).toString()
: wishlistName = "Wishlist 1";
});

//Create a wishlist
await Firestore.instance
.collection("wishlists")
.document(wishlistUuid)
.setData({
'itemCounts': "0",
'label': text,
'label': wishlistName,
'timestamp': new DateTime.now(),
});

Expand Down
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import 'package:MobileOne/pages/authentication-page.dart';
import 'package:MobileOne/localization/delegate.dart';
import 'package:MobileOne/localization/supported.dart';
import 'package:MobileOne/pages/Mainpage.dart';
import 'package:MobileOne/pages/create_list.dart';
import 'package:MobileOne/pages/forgotten_password.dart';
import 'package:MobileOne/pages/openedListPage.dart';
import 'package:MobileOne/pages/register-page.dart';
Expand Down Expand Up @@ -117,7 +116,6 @@ class MyApp extends StatelessWidget {
'/authentication': (context) => AuthenticationPage(),
'/registerPage': (context) => RegisterPage(),
'/forgottenPasswordPage': (context) => ForgottenPasswordPage(),
'/createList': (context) => CreateList(),
'/openedListPage': (context) => OpenedListPage(),
'/shareOne': (context) => ShareOne(),
'/shareTwo': (context) => ShareTwo(),
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/Mainpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:MobileOne/pages/list.dart';
import 'package:MobileOne/pages/profile.dart';
import 'package:MobileOne/providers/loyalty_cards_provider.dart';
import 'package:MobileOne/pages/share.dart';
import 'package:MobileOne/providers/wishlistsList_provider.dart';
import 'package:MobileOne/services/analytics_services.dart';
import 'package:MobileOne/services/color_service.dart';
import 'package:MobileOne/services/user_service.dart';
Expand Down Expand Up @@ -57,7 +58,7 @@ class MainPageState extends State<MainPage> {
super.initState();
_actions = [
scanLoyaltyCardsBareCode,
goToCreateListPage,
createList,
goToSharedPage,
_getImage,
];
Expand Down Expand Up @@ -176,8 +177,8 @@ class MainPageState extends State<MainPage> {
debugPrint("no action assigned");
}

goToCreateListPage() {
Navigator.of(context).pushNamed("/createList");
createList() async {
await GetIt.I.get<WishlistsListProvider>().addWishlist(context);
_analytics.sendAnalyticsEvent("add_wishlist");
}

Expand Down
99 changes: 0 additions & 99 deletions lib/pages/create_list.dart

This file was deleted.

8 changes: 4 additions & 4 deletions lib/pages/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ListsState extends State<Lists> {
children: <Widget>[
GestureDetector(
onTap: () {
openCreateListPage();
createList();
},
child: EmptyLists(
icon: Icons.add_shopping_cart,
Expand Down Expand Up @@ -186,7 +186,7 @@ class ListsState extends State<Lists> {
padding: const EdgeInsets.only(left: 8.0),
child: GestureDetector(
onTap: () {
openCreateListPage();
createList();
},
child: buildEmptyTemplate()),
);
Expand Down Expand Up @@ -264,8 +264,8 @@ class ListsState extends State<Lists> {
}
}

void openCreateListPage() {
Navigator.of(context).pushNamed('/createList');
void createList() async {
await GetIt.I.get<WishlistsListProvider>().addWishlist(context);
}

void openOpenedListPage(String uuid, bool isGuest) {
Expand Down
44 changes: 23 additions & 21 deletions lib/pages/openedListPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,29 +280,31 @@ class OpenedListPageState extends State<OpenedListPage> {
}

emptyList() {
return Center(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.2,
child: Image.asset(
"assets/images/square-logo.png",
height: 100,
width: 100,
return SingleChildScrollView(
child: Center(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.2,
child: Image.asset(
"assets/images/square-logo.png",
height: 100,
width: 100,
),
),
),
Container(
height: MediaQuery.of(context).size.height * 0.3,
child: Icon(Icons.add_shopping_cart, size: 100, color: WHITE),
),
Container(
height: MediaQuery.of(context).size.height * 0.3,
child: Text(
getString(context, "empty_items"),
style: TextStyle(color: WHITE, fontSize: 20),
Container(
height: MediaQuery.of(context).size.height * 0.3,
child: Icon(Icons.add_shopping_cart, size: 100, color: WHITE),
),
),
],
Container(
height: MediaQuery.of(context).size.height * 0.3,
child: Text(
getString(context, "empty_items"),
style: TextStyle(color: WHITE, fontSize: 20),
),
),
],
),
),
);
}
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/share.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:MobileOne/localization/localization.dart';
import 'package:MobileOne/providers/share_provider.dart';
import 'package:MobileOne/providers/wishlistsList_provider.dart';
import 'package:MobileOne/services/analytics_services.dart';
import 'package:MobileOne/services/color_service.dart';
import 'package:MobileOne/utility/arguments.dart';
Expand Down Expand Up @@ -87,7 +88,7 @@ class ShareState extends State<Share> {
height: MediaQuery.of(context).size.height * 0.17,
child: GestureDetector(
onTap: () {
openCreateListPage();
createList();
},
child: EmptyLists(
icon: Icons.add_shopping_cart,
Expand Down Expand Up @@ -164,7 +165,7 @@ class ShareState extends State<Share> {
Navigator.popUntil(context, ModalRoute.withName("/mainPage"));
}

void openCreateListPage() {
Navigator.of(context).pushNamed('/createList');
void createList() async {
await GetIt.I.get<WishlistsListProvider>().addWishlist(context);
}
}
5 changes: 2 additions & 3 deletions lib/providers/wishlistsList_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ class WishlistsListProvider with ChangeNotifier {
return guestLists ?? List();
}

addWishlist(String text) async {
await wishlistService.addWishlist(text);
addWishlist(BuildContext context) async {
await wishlistService.addWishlist(context);
notifyListeners();
}

deleteWishlist(String listUuid, String userUid) async {
await wishlistService.deleteWishlist(listUuid, userUid);

notifyListeners();
}

Expand Down
8 changes: 6 additions & 2 deletions lib/services/wishlist_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:MobileOne/data/wishlist_item.dart';
import 'package:MobileOne/services/analytics_services.dart';
import 'package:MobileOne/services/image_service.dart';
import 'package:MobileOne/services/user_service.dart';
import 'package:MobileOne/utility/arguments.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
Expand Down Expand Up @@ -72,9 +73,12 @@ class WishlistService {
return data;
}

addWishlist(String text) async {
addWishlist(BuildContext context) async {
final wishlistUuid = Uuid().v4();
await dao.addWishlist(text, wishlistUuid, userService.user.uid);
await dao.addWishlist(wishlistUuid, userService.user.uid).whenComplete(() =>
Navigator.of(context).pushNamed('/openedListPage',
arguments:
OpenedListArguments(listUuid: wishlistUuid, isGuest: false)));
_flush();
}

Expand Down

0 comments on commit 3b4c6e1

Please sign in to comment.