mirror of
https://github.com/mdanics/fluttergram.git
synced 2025-05-20 15:36:32 +08:00
fixed #45 - feed now loads after username selection
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'main.dart'; //for currentuser & google signin instance
|
||||
import 'models/user.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class EditProfilePage extends StatelessWidget {
|
||||
TextEditingController nameController = new TextEditingController();
|
||||
@ -123,6 +124,11 @@ class EditProfilePage extends StatelessWidget {
|
||||
await auth.signOut();
|
||||
await googleSignIn.signOut();
|
||||
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.clear();
|
||||
|
||||
currentUserModel = null;
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
@ -33,9 +33,8 @@ Future<Null> _ensureLoggedIn(BuildContext context) async {
|
||||
user = await googleSignIn.signInSilently();
|
||||
}
|
||||
if (user == null) {
|
||||
await googleSignIn.signIn().then((_) {
|
||||
tryCreateUserRecord(context);
|
||||
});
|
||||
await googleSignIn.signIn();
|
||||
await tryCreateUserRecord(context);
|
||||
}
|
||||
|
||||
if (await auth.currentUser() == null) {
|
||||
@ -58,9 +57,8 @@ Future<Null> _silentLogin(BuildContext context) async {
|
||||
GoogleSignInAccount user = googleSignIn.currentUser;
|
||||
|
||||
if (user == null) {
|
||||
user = await googleSignIn.signInSilently().then((_) {
|
||||
tryCreateUserRecord(context);
|
||||
});
|
||||
user = await googleSignIn.signInSilently();
|
||||
await tryCreateUserRecord(context);
|
||||
}
|
||||
|
||||
if (await auth.currentUser() == null && user != null) {
|
||||
@ -105,7 +103,7 @@ Future<Null> _setUpNotifications() async {
|
||||
}
|
||||
}
|
||||
|
||||
tryCreateUserRecord(BuildContext context) async {
|
||||
Future<void> tryCreateUserRecord(BuildContext context) async {
|
||||
GoogleSignInAccount user = googleSignIn.currentUser;
|
||||
if (user == null) {
|
||||
return null;
|
||||
@ -116,7 +114,6 @@ tryCreateUserRecord(BuildContext context) async {
|
||||
|
||||
String userName = await Navigator.push(
|
||||
context,
|
||||
// We'll create the SelectionScreen in the next step!
|
||||
new MaterialPageRoute(
|
||||
builder: (context) => new Center(
|
||||
child: new Scaffold(
|
||||
@ -154,6 +151,7 @@ tryCreateUserRecord(BuildContext context) async {
|
||||
}
|
||||
|
||||
currentUserModel = new User.fromDocument(userRecord);
|
||||
return null;
|
||||
}
|
||||
|
||||
class Fluttergram extends StatelessWidget {
|
||||
@ -233,7 +231,7 @@ class _HomePageState extends State<HomePage> {
|
||||
setUpNotifications();
|
||||
}
|
||||
|
||||
return googleSignIn.currentUser == null
|
||||
return (googleSignIn.currentUser == null || currentUserModel == null)
|
||||
? buildLoginPage()
|
||||
: new Scaffold(
|
||||
body: new PageView(
|
||||
|
Reference in New Issue
Block a user