Test for the firebase storage provider
This commit is contained in:
parent
19d7dad3d1
commit
ac5f4906d1
4 changed files with 45 additions and 85 deletions
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
|
|
||||||
333667AF222371A60086B018 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 333667AE222371A60086B018 /* GoogleService-Info.plist */; };
|
333667AF222371A60086B018 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 333667AE222371A60086B018 /* GoogleService-Info.plist */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||||
|
|
@ -42,7 +41,6 @@
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||||
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
|
|
||||||
333667AE222371A60086B018 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
333667AE222371A60086B018 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||||
|
|
@ -78,7 +76,6 @@
|
||||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
|
|
||||||
3B80C3931E831B6300D905FE /* App.framework */,
|
3B80C3931E831B6300D905FE /* App.framework */,
|
||||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||||
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||||
|
|
@ -216,7 +213,6 @@
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||||
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
|
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
|
||||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||||
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
|
|
||||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||||
333667AF222371A60086B018 /* GoogleService-Info.plist in Resources */,
|
333667AF222371A60086B018 /* GoogleService-Info.plist in Resources */,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,6 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'src/App.dart';
|
import 'src/App.dart';
|
||||||
|
|
||||||
main() => runApp(App());
|
main() async {
|
||||||
|
runApp(App());
|
||||||
|
}
|
||||||
|
|
|
||||||
121
lib/src/App.dart
121
lib/src/App.dart
|
|
@ -1,14 +1,21 @@
|
||||||
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import './models/event_model.dart';
|
|
||||||
import './models/summary_model.dart';
|
|
||||||
import './models/task_model.dart';
|
|
||||||
import './models/user_model.dart';
|
|
||||||
import './resources/google_sign_in_provider.dart';
|
import './resources/google_sign_in_provider.dart';
|
||||||
|
import 'package:firebase_storage/firebase_storage.dart';
|
||||||
|
import './resources/firebase_storage_provider.dart';
|
||||||
|
|
||||||
|
class App extends StatefulWidget {
|
||||||
|
AppState createState() => AppState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppState extends State<App> {
|
||||||
|
File image;
|
||||||
|
FirebaseStorageProvider provider = FirebaseStorageProvider();
|
||||||
|
StorageUploadTask task;
|
||||||
|
|
||||||
class App extends StatelessWidget {
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final gLogin = GoogleSignInProvider();
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Do more',
|
title: 'Do more',
|
||||||
//home: Text('Start'),
|
//home: Text('Start'),
|
||||||
|
|
@ -20,84 +27,38 @@ class App extends StatelessWidget {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text('Tasks'),
|
Text('Tasks'),
|
||||||
MaterialButton(
|
MaterialButton(
|
||||||
child: Text('Google Sign In'),
|
child: Text('Upload Picture'),
|
||||||
onPressed: gLogin.signIn,
|
onPressed: uploadPicture,
|
||||||
),
|
|
||||||
MaterialButton(
|
|
||||||
child: Text('Google Current User'),
|
|
||||||
onPressed: gLogin.getCurrentUser,
|
|
||||||
),
|
|
||||||
MaterialButton(
|
|
||||||
child: Text('Google Sign out'),
|
|
||||||
onPressed: gLogin.signOut,
|
|
||||||
),
|
|
||||||
StreamBuilder(
|
|
||||||
stream: gLogin.onAuthStateChange,
|
|
||||||
builder:
|
|
||||||
(BuildContext context, AsyncSnapshot<FirebaseUser> snapshot) {
|
|
||||||
if (!snapshot.hasData) {
|
|
||||||
return Text('no user');
|
|
||||||
}
|
|
||||||
return Text(snapshot.data.displayName);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
buildImage(),
|
||||||
|
buildFromTask(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
/* StreamBuilder(
|
|
||||||
stream: fire.getEvent('vBOvtmTeC8iPg8L4Hixh', '-LZReccofbHpw9UfOTMk'),
|
|
||||||
builder:
|
|
||||||
(BuildContext context, AsyncSnapshot<EventModel> userSnapshot) {
|
|
||||||
if (!userSnapshot.hasData) {
|
|
||||||
return Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final children = <Widget>[
|
|
||||||
MaterialButton(
|
|
||||||
onPressed: () {
|
|
||||||
final task = TaskModel(
|
|
||||||
ownerUsername: 'mariano159357',
|
|
||||||
text: 'I dont know what to put',
|
|
||||||
priority: 2,
|
|
||||||
done: false,
|
|
||||||
event: 'Math',
|
|
||||||
);
|
|
||||||
|
|
||||||
final event = EventModel(
|
|
||||||
name: 'Langs and trans',
|
|
||||||
tasks: <String>[],
|
|
||||||
highPriority: 0,
|
|
||||||
mediumPriority: 0,
|
|
||||||
lowPriority: 0,
|
|
||||||
media: <String>[],
|
|
||||||
when: <bool>[],
|
|
||||||
pendigTasks: 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
fire.updateEvent(
|
|
||||||
'vBOvtmTeC8iPg8L4Hixh',
|
|
||||||
'-LZReccofbHpw9UfOTMk',
|
|
||||||
name: 'Custom Task',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text('Add task'),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
//children.add(Text(userSnapshot.data.text));
|
|
||||||
|
|
||||||
//userSnapshot.data.forEach((EventModel task) {
|
|
||||||
// children.add(Text(task.name));
|
|
||||||
//});
|
|
||||||
|
|
||||||
children.add(Text(userSnapshot.data.name));
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: children,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
), */
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> uploadPicture() async {
|
||||||
|
final imageTaken = await ImagePicker.pickImage(source: ImageSource.camera);
|
||||||
|
setState(() {
|
||||||
|
image = imageTaken;
|
||||||
|
});
|
||||||
|
task = provider.uploadFile(imageTaken);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildImage() {
|
||||||
|
if (image == null) {
|
||||||
|
return Text('No image yet');
|
||||||
|
}
|
||||||
|
return Image.file(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildFromTask() {
|
||||||
|
if (task == null) {
|
||||||
|
return Text('No task yet');
|
||||||
|
} else if (task.isComplete) {
|
||||||
|
return Icon(Icons.check);
|
||||||
|
}
|
||||||
|
return CircularProgressIndicator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:firebase_storage/firebase_storage.dart';
|
import 'package:firebase_storage/firebase_storage.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
export 'package:firebase_storage/firebase_storage.dart' show StorageUploadTask;
|
||||||
|
|
||||||
class FirebaseStorageProvider {
|
class FirebaseStorageProvider {
|
||||||
final StorageReference _storage;
|
final StorageReference _storage;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue