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 authored Aug 5, 2020
1 parent f0be8df commit 0afd772
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add page for a big loyalty card
- Add loyalty cards deletion
- Add password changing
- Add item picked picture

### Changed

Expand Down
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.android.support:multidex:1.0.3' // use latest version
implementation 'com.firebaseui:firebase-ui-storage:3.1.3'

}
55 changes: 44 additions & 11 deletions lib/pages/item_page.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import 'dart:convert';

import 'package:path/path.dart' as path;
import 'dart:io';
import 'package:MobileOne/localization/localization.dart';
import 'package:MobileOne/providers/itemsList_provider.dart';
import 'package:MobileOne/utility/arguments.dart';
import 'package:MobileOne/utility/colors.dart';
import 'package:MobileOne/widgets/bubble_button.dart';
import 'package:barcode_scan/barcode_scan.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get_it/get_it.dart';
import 'package:http/http.dart' as http;
import 'package:MobileOne/utility/colors.dart' as CustomColors;
import 'package:image_picker/image_picker.dart';

class EditItemPage extends StatefulWidget {
EditItemPage({
Expand Down Expand Up @@ -42,6 +44,8 @@ class EditItemPageState extends State<EditItemPage> {

ItemArguments _args;
var _itemImage;
File pickedImage;
final _picker = ImagePicker();

Future<void> getItems() async {
String labelValue;
Expand Down Expand Up @@ -119,7 +123,17 @@ class EditItemPageState extends State<EditItemPage> {
height: 24,
),
onPressed: () => scanAnItem(),
)
),
IconButton(
icon: Icon(
Icons.camera,
color: Colors.lime[600],
size: 24,
),
onPressed: () {
pickImage();
},
),
],
),
body: SafeArea(
Expand Down Expand Up @@ -155,11 +169,31 @@ class EditItemPageState extends State<EditItemPage> {
);
}

Future<void> pickImage() async {
await _picker.getImage(source: ImageSource.camera).then((image) {
pickedImage = File(image.path);
});
uploadFile(_args.listUuid);
setState(() {
_itemImage = FileImage(pickedImage);
});
}

Future<void> uploadFile(String listUuid) async {
StorageReference storageReference = FirebaseStorage.instance
.ref()
.child('mobileone/$listUuid/${path.basename(pickedImage.path)}');
StorageUploadTask uploadTask = storageReference.putFile(pickedImage);
await uploadTask.onComplete;
storageReference.getDownloadURL().then((fileURL) {
imageLink = fileURL;
});
}

Text buildErrorMessage() {
return Text(
alert,
style: TextStyle(
color: CustomColors.RED, fontWeight: FontWeight.bold, fontSize: 12),
style: TextStyle(color: RED, fontWeight: FontWeight.bold, fontSize: 12),
);
}

Expand All @@ -176,8 +210,7 @@ class EditItemPageState extends State<EditItemPage> {
},
child: Text(
_args.buttonName,
style: TextStyle(
color: CustomColors.WHITE, fontWeight: FontWeight.bold),
style: TextStyle(color: WHITE, fontWeight: FontWeight.bold),
),
color: Colors.lime[600],
),
Expand All @@ -201,7 +234,7 @@ class EditItemPageState extends State<EditItemPage> {
}
}

_onValidate() {
_onValidate() async {
if (itemNameController == null ||
itemCountController == null ||
_type == null ||
Expand Down Expand Up @@ -237,7 +270,7 @@ class EditItemPageState extends State<EditItemPage> {
child: DropdownButtonFormField<String>(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: CustomColors.TRANSPARENT),
borderSide: BorderSide(color: TRANSPARENT),
),
filled: true,
fillColor: Colors.grey[300],
Expand Down Expand Up @@ -299,7 +332,7 @@ class EditItemPageState extends State<EditItemPage> {
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: CustomColors.TRANSPARENT),
borderSide: BorderSide(color: TRANSPARENT),
),
filled: true,
fillColor: Colors.grey[300],
Expand Down Expand Up @@ -336,7 +369,7 @@ class EditItemPageState extends State<EditItemPage> {
decoration: InputDecoration(
hintText: getString(context, 'item_name'),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: CustomColors.TRANSPARENT),
borderSide: BorderSide(color: TRANSPARENT),
),
filled: true,
fillColor: Colors.grey[300],
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
image_picker: ^0.6.5
gallery_saver: ^2.0.1
flutter_svg: ^0.17.4
firebase_storage: ^3.1.6

# 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 0afd772

Please sign in to comment.