Created [signIn] methos
This commit is contained in:
parent
5bf61cabfc
commit
459d5139bf
2 changed files with 27 additions and 73 deletions
|
|
@ -1,10 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import './models/event_model.dart';
|
||||
import './models/task_model.dart';
|
||||
import './models/user_model.dart';
|
||||
import './resources/firestore_provider.dart';
|
||||
|
||||
class App extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
|
|
@ -19,71 +14,3 @@ class App extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* class App extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final fire = FirestoreProvider();
|
||||
return MaterialApp(
|
||||
title: 'Do more',
|
||||
//home: Text('Start'),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('DO>'),
|
||||
),
|
||||
body: 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,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} */
|
||||
|
|
|
|||
|
|
@ -1 +1,28 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
class GoogleSignInProvider {
|
||||
final GoogleSignIn _googleSignIn;
|
||||
final FirebaseAuth _auth;
|
||||
|
||||
GoogleSignInProvider([GoogleSignIn googleSignIn, FirebaseAuth firebaseAuth])
|
||||
: _googleSignIn = googleSignIn ?? GoogleSignIn(),
|
||||
_auth = firebaseAuth ?? FirebaseAuth.instance;
|
||||
|
||||
Future<FirebaseUser> signIn() async {
|
||||
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser.authentication;
|
||||
|
||||
final AuthCredential credential = GoogleAuthProvider.getCredential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
|
||||
final FirebaseUser user = await _auth.signInWithCredential(credential);
|
||||
print("signed in " + user.displayName);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue