diff --git a/lib/pages/item_page.dart b/lib/pages/item_page.dart index 97f52a54..f9b22656 100644 --- a/lib/pages/item_page.dart +++ b/lib/pages/item_page.dart @@ -16,6 +16,8 @@ import 'package:get_it/get_it.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; +var valid; + class EditItemPage extends StatefulWidget { EditItemPage({ Key key, @@ -39,6 +41,7 @@ class EditItemPageState extends State { String label = ""; String quantity = ""; String unit = ""; + bool validated; var _itemsListProvider = GetIt.I.get(); diff --git a/lib/pages/openedListPage.dart b/lib/pages/openedListPage.dart index cd321456..b12a9464 100644 --- a/lib/pages/openedListPage.dart +++ b/lib/pages/openedListPage.dart @@ -14,6 +14,11 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import '../localization/localization.dart'; import 'package:MobileOne/utility/colors.dart'; +import 'package:flutter_animation_progress_bar/flutter_animation_progress_bar.dart'; + +var wishlist = []; +int nombrearticle; +int articlevalide; class OpenedListPage extends StatefulWidget { OpenedListPage({ @@ -25,12 +30,33 @@ class OpenedListPage extends StatefulWidget { } class OpenedListPageState extends State { + String valid; + ItemArguments arg; + String listUuid; + int progressPercentBar = 50; + bool isProgressBarVisible = true; final _myController = TextEditingController(); final _wishlistProvider = GetIt.I.get(); + getvalidated() async { + String validated; + await Firestore.instance + .collection("items") + .document(arg.listUuid) + .get() + .then((value) { + validated = value[arg.itemUuid]["isValidated"]; + }); + setState(() { + valid = validated; + }); + print("ICI"); + print(valid); + } + @override Widget build(BuildContext context) { - String listUuid = ModalRoute.of(context).settings.arguments; + listUuid = ModalRoute.of(context).settings.arguments; return MultiProvider( providers: [ ChangeNotifierProvider.value( @@ -76,6 +102,7 @@ class OpenedListPageState extends State { Widget content( Wishlist wishlistHead, DocumentSnapshot snapshot, ConnectionState state) { List wishlist = getSortedList(snapshot); + var pourcentage = 100 / wishlist.length; return Scaffold( floatingActionButton: FloatingActionButton( @@ -154,64 +181,77 @@ class OpenedListPageState extends State { ); } return SafeArea( - child: Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - child: new ListView.builder( - padding: EdgeInsets.only(top: 30), - itemCount: wishlist.length, - itemBuilder: (BuildContext ctxt, int index) { - return Container( - child: Dismissible( - confirmDismiss: (DismissDirection direction) async { - if (direction == DismissDirection.endToStart) { - return await buildDeleteShowDialog(context); - } else { - return true; - } - }, - background: Container( - color: GREEN, - child: Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.only(left: 8.0), - child: Icon( - Icons.check, - color: WHITE, - )), - ), - ), - secondaryBackground: Container( - color: RED, - child: Align( - alignment: Alignment.centerRight, - child: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Icon( - Icons.delete, - color: WHITE, - )), - ), - ), - key: UniqueKey(), - child: WidgetItem(wishlist[index], wishlistHead.uuid, - wishlist[index].uuid), - onDismissed: (direction) { - if (direction == DismissDirection.endToStart) { - deleteItemFromList( - listUuid: wishlistHead.uuid, - itemUuid: wishlist[index].uuid, - ); - } else { - validateItem( - listUuid: wishlistHead.uuid, - item: wishlist[index], - ); - } - }), - ); - }), + child: Column( + children: [ + Visibility( + visible: true, + child: FAProgressBar( + // currentValue: pourcentage.toInt() * (articlevalide), + currentValue: 100, + displayText: '%', + ), + ), + Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height - 150, + child: new ListView.builder( + itemCount: wishlist.length, + itemBuilder: (BuildContext ctxt, int index) { + return Container( + child: Dismissible( + confirmDismiss: + (DismissDirection direction) async { + if (direction == DismissDirection.endToStart) { + return await buildDeleteShowDialog(context); + } else { + return true; + } + }, + background: Container( + color: GREEN, + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Icon( + Icons.check, + color: WHITE, + )), + ), + ), + secondaryBackground: Container( + color: RED, + child: Align( + alignment: Alignment.centerRight, + child: Padding( + padding: + const EdgeInsets.only(right: 8.0), + child: Icon( + Icons.delete, + color: WHITE, + )), + ), + ), + key: UniqueKey(), + child: WidgetItem(wishlist[index], + wishlistHead.uuid, wishlist[index].uuid), + onDismissed: (direction) { + if (direction == DismissDirection.endToStart) { + deleteItemFromList( + listUuid: wishlistHead.uuid, + itemUuid: wishlist[index].uuid, + ); + } else { + validateItem( + listUuid: wishlistHead.uuid, + item: wishlist[index], + ); + } + }), + ); + }), + ), + ], ), ); }, diff --git a/lib/providers/itemsList_provider.dart b/lib/providers/itemsList_provider.dart index 9ff1bbbd..cee6d408 100644 --- a/lib/providers/itemsList_provider.dart +++ b/lib/providers/itemsList_provider.dart @@ -7,6 +7,18 @@ class ItemsListProvider with ChangeNotifier { return Firestore.instance.collection('items').document(listUuid).get(); } + getValidateItem(String listUuid) async { + var listItemsCount; + Firestore.instance + .collection('items') + .document(listUuid) + .get() + .then((value) { + listItemsCount = value["isValidated"]; + }); + notifyListeners(); + } + addItemTolist({ @required String name, @required int count, diff --git a/lib/widgets/widget_item.dart b/lib/widgets/widget_item.dart index 67a24081..96c7d564 100644 --- a/lib/widgets/widget_item.dart +++ b/lib/widgets/widget_item.dart @@ -1,6 +1,7 @@ import 'package:MobileOne/data/wishlist_item.dart'; import 'package:MobileOne/localization/localization.dart'; import 'package:MobileOne/providers/itemsList_provider.dart'; +import 'package:MobileOne/pages/openedListPage.dart'; import 'package:MobileOne/utility/arguments.dart'; import 'package:MobileOne/utility/colors.dart'; import 'package:flutter/material.dart'; @@ -46,6 +47,8 @@ class WidgetItemState extends State { } Builder buildValidatedItem(String completeName) { + print("est le nombdre d'article ici ? "); + print(nombrearticle); return Builder( builder: (context) { return Padding( @@ -71,18 +74,18 @@ class WidgetItemState extends State { Flexible( flex: 1, child: IconButton( - padding: EdgeInsets.only(right: 12.0), - icon: Icon( - Icons.check_circle, - color: GREEN, - ), - onPressed: () => + padding: EdgeInsets.only(right: 12.0), + icon: Icon( + Icons.check_circle, + color: GREEN, + ), + onPressed: () { GetIt.I.get().validateItem( listUuid: _listUuid, itemUuid: _itemlist.uuid, isValidated: false, - ), - ), + ); + }), ), Flexible(flex: 1, child: Image(image: _itemImage)) ]), diff --git a/pubspec.yaml b/pubspec.yaml index fa89f8f9..b81c45a0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,6 +47,7 @@ dependencies: gallery_saver: ^2.0.1 flutter_svg: ^0.18.0 firebase_storage: ^3.1.6 + flutter_animation_progress_bar: ^1.0.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.