Add the ability to take a photo and save that image into Firebase Store
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# NOTE: This podspec is NOT to be published. It is only used as a local source!
|
||||
#
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'Flutter'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'High-performance, high-fidelity mobile apps.'
|
||||
s.description = <<-DESC
|
||||
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
|
||||
DESC
|
||||
s.homepage = 'https://flutter.io'
|
||||
s.license = { :type => 'MIT' }
|
||||
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
|
||||
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.vendored_frameworks = 'Flutter.framework'
|
||||
end
|
||||
@@ -20,6 +20,9 @@ PODS:
|
||||
- Firebase/Firestore (6.0.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseFirestore (~> 1.3.0)
|
||||
- Firebase/Storage (6.0.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseStorage (~> 3.2.0)
|
||||
- firebase_auth (0.0.1):
|
||||
- Firebase/Auth (~> 6.0)
|
||||
- Firebase/Core
|
||||
@@ -27,6 +30,9 @@ PODS:
|
||||
- firebase_core (0.0.1):
|
||||
- Firebase/Core
|
||||
- Flutter
|
||||
- firebase_storage (0.0.1):
|
||||
- Firebase/Storage
|
||||
- Flutter
|
||||
- FirebaseAnalytics (6.0.0):
|
||||
- FirebaseCore (~> 6.0)
|
||||
- FirebaseInstanceID (~> 4.0)
|
||||
@@ -65,6 +71,10 @@ PODS:
|
||||
- FirebaseCore (~> 6.0)
|
||||
- GoogleUtilities/Environment (~> 6.0)
|
||||
- GoogleUtilities/UserDefaults (~> 6.0)
|
||||
- FirebaseStorage (3.2.1):
|
||||
- FirebaseAuthInterop (~> 1.0)
|
||||
- FirebaseCore (~> 6.0)
|
||||
- GTMSessionFetcher/Core (~> 1.1)
|
||||
- Flutter (1.0.0)
|
||||
- flutter_local_notifications (0.0.1):
|
||||
- Flutter
|
||||
@@ -124,6 +134,8 @@ PODS:
|
||||
- nanopb (~> 0.3)
|
||||
- gRPC-Core/Interface (1.19.0)
|
||||
- GTMSessionFetcher/Core (1.2.2)
|
||||
- image_picker (0.0.1):
|
||||
- Flutter
|
||||
- leveldb-library (1.20)
|
||||
- nanopb (0.3.901):
|
||||
- nanopb/decode (= 0.3.901)
|
||||
@@ -138,9 +150,11 @@ DEPENDENCIES:
|
||||
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
|
||||
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
|
||||
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
||||
- firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
|
||||
- Flutter (from `.symlinks/flutter/ios`)
|
||||
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
|
||||
- google_sign_in (from `.symlinks/plugins/google_sign_in/ios`)
|
||||
- image_picker (from `.symlinks/plugins/image_picker/ios`)
|
||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
||||
|
||||
SPEC REPOS:
|
||||
@@ -153,6 +167,7 @@ SPEC REPOS:
|
||||
- FirebaseCore
|
||||
- FirebaseFirestore
|
||||
- FirebaseInstanceID
|
||||
- FirebaseStorage
|
||||
- GoogleAppMeasurement
|
||||
- GoogleSignIn
|
||||
- GoogleToolboxForMac
|
||||
@@ -171,12 +186,16 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/firebase_auth/ios"
|
||||
firebase_core:
|
||||
:path: ".symlinks/plugins/firebase_core/ios"
|
||||
firebase_storage:
|
||||
:path: ".symlinks/plugins/firebase_storage/ios"
|
||||
Flutter:
|
||||
:path: ".symlinks/flutter/ios"
|
||||
flutter_local_notifications:
|
||||
:path: ".symlinks/plugins/flutter_local_notifications/ios"
|
||||
google_sign_in:
|
||||
:path: ".symlinks/plugins/google_sign_in/ios"
|
||||
image_picker:
|
||||
:path: ".symlinks/plugins/image_picker/ios"
|
||||
shared_preferences:
|
||||
:path: ".symlinks/plugins/shared_preferences/ios"
|
||||
|
||||
@@ -186,12 +205,14 @@ SPEC CHECKSUMS:
|
||||
Firebase: fa80b9d987ca014a1ba9357496ef2a0178b28b12
|
||||
firebase_auth: 7a2cc520766f90212b845a5b35316601707bfa25
|
||||
firebase_core: ce5006bb48508ee4e71e0f429a3f519bb8ee2961
|
||||
firebase_storage: d83bfc0e0e849b2f871a34c474466bf5014ff304
|
||||
FirebaseAnalytics: 1743c5f4de3687d0745709dfdc4b1dea1484f44c
|
||||
FirebaseAuth: efc72b0f6fe075d2a6de8d81a6d9de83ef2b47eb
|
||||
FirebaseAuthInterop: 0ffa57668be100582bb7643d4fcb7615496c41fc
|
||||
FirebaseCore: e38f025287b413255a53acc1945d048a112047f7
|
||||
FirebaseFirestore: 0537b2a960a4819fae2834e688e5daeb571c81d6
|
||||
FirebaseInstanceID: 0e0348a3c00a734fa376a070f5ad4533ad975cb5
|
||||
FirebaseStorage: 926d41552072b9fee67aa645760f05f87b7ce604
|
||||
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
||||
flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186
|
||||
google_sign_in: 27e70a98b529f0b076d4b19f231b81da28b1750b
|
||||
@@ -202,6 +223,7 @@ SPEC CHECKSUMS:
|
||||
"gRPC-C++": 98be881723177d8c4faf5fdffacb582c7b4971a2
|
||||
gRPC-Core: bd9472c8daa2e414b9f8038ba667bf56ce0e02b8
|
||||
GTMSessionFetcher: 61bb0f61a4cb560030f1222021178008a5727a23
|
||||
image_picker: e3eacd46b94694dde7cf2705955cece853aa1a8f
|
||||
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
|
||||
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
|
||||
Protobuf: 7a877b7f3e5964e3fce995e2eb323dbc6831bb5a
|
||||
|
||||
@@ -259,6 +259,7 @@
|
||||
"${BUILT_PRODUCTS_DIR}/flutter_local_notifications/flutter_local_notifications.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/gRPC-C++/grpcpp.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/leveldb-library/leveldb.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
|
||||
@@ -274,6 +275,7 @@
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_local_notifications.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpcpp.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Permiso para usar la camara</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
@@ -41,6 +43,10 @@
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Permiso para ver tus fotos</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Permiso para grabar audio</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
@@ -48,8 +54,6 @@
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<!-- TODO Replace this value: -->
|
||||
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
|
||||
<string>com.googleusercontent.apps.173215752753-sfdf5d19ospsuphvgaclfsie0vp873lb</string>
|
||||
</array>
|
||||
</dict>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class ExpensesRepository {
|
||||
final String userId;
|
||||
@@ -33,18 +38,45 @@ class ExpensesRepository {
|
||||
.delete();
|
||||
}
|
||||
|
||||
add(String categoryName, double value, DateTime date) {
|
||||
Firestore.instance
|
||||
add(String categoryName, double value, DateTime date, File selectedImage) async {
|
||||
var document = Firestore.instance
|
||||
.collection('users')
|
||||
.document(userId)
|
||||
.collection('expenses')
|
||||
.document()
|
||||
.setData({
|
||||
.document();
|
||||
|
||||
await document.setData({
|
||||
"category": categoryName,
|
||||
"value": value,
|
||||
"month": date.month,
|
||||
"day": date.day,
|
||||
"year": date.year,
|
||||
});
|
||||
|
||||
if (selectedImage != null) {
|
||||
var imageName = Uuid().v1();
|
||||
var imagePath = "/users/$userId/$imageName.jpg";
|
||||
final StorageReference storageReference = FirebaseStorage().ref().child(imagePath);
|
||||
|
||||
final StorageUploadTask uploadTask = storageReference.putFile(selectedImage);
|
||||
|
||||
final StreamSubscription<StorageTaskEvent> streamSubscription = uploadTask.events.listen((event) {
|
||||
// You can use this to notify yourself or your user in any kind of way.
|
||||
// For example: you could use the uploadTask.events stream in a StreamBuilder instead
|
||||
// to show your user what the current status is. In that case, you would not need to cancel any
|
||||
// subscription as StreamBuilder handles this automatically.
|
||||
|
||||
// Here, every StorageTaskEvent concerning the upload is printed to the logs.
|
||||
print('EVENT ${event.type}');
|
||||
});
|
||||
|
||||
// Cancel your subscription when done.
|
||||
await uploadTask.onComplete;
|
||||
streamSubscription.cancel();
|
||||
|
||||
document.setData({
|
||||
"imageUrl": (await storageReference.getDownloadURL()).toString(),
|
||||
}, merge: true,);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-17
@@ -1,6 +1,9 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:como_gasto/category_selection_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../expenses_repository.dart';
|
||||
@@ -25,6 +28,8 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
String dateStr = "hoy";
|
||||
DateTime date = DateTime.now();
|
||||
|
||||
File _selectedPicture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -64,11 +69,26 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
offset: Offset(0, h * (1 - _pageAnimation.value)),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
leading: BackButton(
|
||||
color: Colors.grey,
|
||||
onPressed: () {
|
||||
_controller.reverse();
|
||||
},
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0.0,
|
||||
title: GestureDetector(
|
||||
onTap: () {
|
||||
title: Text(
|
||||
"Category ($dateStr)",
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.calendar_today),
|
||||
color: Colors.grey,
|
||||
onPressed: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
@@ -83,22 +103,16 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
"Category ($dateStr)",
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
icon: Icon(Icons.camera_alt),
|
||||
color: Colors.grey,
|
||||
),
|
||||
onPressed: () {
|
||||
_controller.reverse();
|
||||
onPressed: () async {
|
||||
var image = await ImagePicker.pickImage(source: ImageSource.camera);
|
||||
|
||||
setState(() {
|
||||
_selectedPicture = image;
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
@@ -119,6 +133,11 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
_categorySelector(),
|
||||
if (_selectedPicture != null)
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: Image.file(_selectedPicture),
|
||||
),
|
||||
_currentValue(),
|
||||
_numpad(),
|
||||
SizedBox(
|
||||
@@ -303,7 +322,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
onPressed: () {
|
||||
var db = Provider.of<ExpensesRepository>(context);
|
||||
if (value > 0 && category != "") {
|
||||
db.add(category, value / 100.0, date);
|
||||
db.add(category, value / 100.0, date, _selectedPicture);
|
||||
|
||||
_controller.reverse();
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DayExpenseListTile extends StatelessWidget {
|
||||
@@ -46,6 +47,9 @@ class DayExpenseListTile extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: document['imageUrl'] == null
|
||||
? null
|
||||
: Image.network(document['imageUrl']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.0+1"
|
||||
firebase_storage:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: firebase_storage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.8"
|
||||
flare_dart:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -165,6 +172,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
image_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.1+11"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -303,6 +317,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
uuid:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: uuid
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
+4
-1
@@ -14,7 +14,7 @@ description: An app to help to track your expenses
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -22,6 +22,9 @@ dependencies:
|
||||
charts_flutter: ^0.6.0
|
||||
font_awesome_flutter: ^8.4.0
|
||||
cloud_firestore: ^0.11.0+2
|
||||
firebase_storage: ^3.0.8
|
||||
image_picker: ^0.6.1+11
|
||||
uuid:
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
||||
Reference in New Issue
Block a user