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

Commit

Permalink
first commit (#133)
Browse files Browse the repository at this point in the history
Co-authored-by: zohra <senouci12@hotmail.fr>
  • Loading branch information
nathanvandeperre97 and zohra051 committed Aug 6, 2020
1 parent 59628a4 commit 68be9e0
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 67 deletions.
3 changes: 3 additions & 0 deletions lib/pages/item_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -39,6 +41,7 @@ class EditItemPageState extends State<EditItemPage> {
String label = "";
String quantity = "";
String unit = "";
bool validated;

var _itemsListProvider = GetIt.I.get<ItemsListProvider>();

Expand Down
158 changes: 99 additions & 59 deletions lib/pages/openedListPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -25,12 +30,33 @@ class OpenedListPage extends StatefulWidget {
}

class OpenedListPageState extends State<OpenedListPage> {
String valid;
ItemArguments arg;
String listUuid;
int progressPercentBar = 50;
bool isProgressBarVisible = true;
final _myController = TextEditingController();
final _wishlistProvider = GetIt.I.get<WishlistHeadProvider>();

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(
Expand Down Expand Up @@ -76,6 +102,7 @@ class OpenedListPageState extends State<OpenedListPage> {
Widget content(
Wishlist wishlistHead, DocumentSnapshot snapshot, ConnectionState state) {
List<WishlistItem> wishlist = getSortedList(snapshot);
var pourcentage = 100 / wishlist.length;

return Scaffold(
floatingActionButton: FloatingActionButton(
Expand Down Expand Up @@ -154,64 +181,77 @@ class OpenedListPageState extends State<OpenedListPage> {
);
}
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: <Widget>[
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],
);
}
}),
);
}),
),
],
),
);
},
Expand Down
12 changes: 12 additions & 0 deletions lib/providers/itemsList_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 11 additions & 8 deletions lib/widgets/widget_item.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -46,6 +47,8 @@ class WidgetItemState extends State<WidgetItem> {
}

Builder buildValidatedItem(String completeName) {
print("est le nombdre d'article ici ? ");
print(nombrearticle);
return Builder(
builder: (context) {
return Padding(
Expand All @@ -71,18 +74,18 @@ class WidgetItemState extends State<WidgetItem> {
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<ItemsListProvider>().validateItem(
listUuid: _listUuid,
itemUuid: _itemlist.uuid,
isValidated: false,
),
),
);
}),
),
Flexible(flex: 1, child: Image(image: _itemImage))
]),
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 68be9e0

Please sign in to comment.