mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
Sellers Filtering
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterfire_ui/auth.dart';
|
||||
import 'package:firebase_database/firebase_database.dart';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
import 'home.dart';
|
||||
|
||||
final FirebaseAuth auth = FirebaseAuth.instance;
|
||||
|
||||
Future<void> addUser(String? name, String uid) async {
|
||||
final CollectionReference users =
|
||||
FirebaseFirestore.instance.collection('users');
|
||||
return await users
|
||||
.add({
|
||||
'name': name,
|
||||
'uid': uid,
|
||||
'swipes': 0,
|
||||
})
|
||||
.then((value) => print(""))
|
||||
.catchError((error) => print("ERROR ADDING DATA: $error"));
|
||||
}
|
||||
|
||||
class AuthGate extends StatelessWidget {
|
||||
const AuthGate({super.key});
|
||||
|
||||
@@ -33,7 +50,9 @@ class AuthGate extends StatelessWidget {
|
||||
subtitleBuilder: (context, action) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: action == AuthAction.signIn ? const Text('Welcome to RUSwipeShare, please sign in!') : const Text('Welcome to RUSwipeShare, please sign up!'),
|
||||
child: action == AuthAction.signIn
|
||||
? const Text('Welcome to RUSwipeShare, please sign in!')
|
||||
: const Text('Welcome to RUSwipeShare, please sign up!'),
|
||||
);
|
||||
},
|
||||
footerBuilder: (context, action) {
|
||||
@@ -48,6 +67,20 @@ class AuthGate extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
User? user = auth.currentUser;
|
||||
|
||||
if (user != null) {
|
||||
bool isNewUser =
|
||||
user.metadata.creationTime == user.metadata.lastSignInTime;
|
||||
|
||||
if (isNewUser) {
|
||||
final name = user.displayName;
|
||||
final uid = user.uid;
|
||||
|
||||
addUser(name, uid);
|
||||
}
|
||||
}
|
||||
|
||||
return const HomeScreen();
|
||||
},
|
||||
);
|
||||
|
Reference in New Issue
Block a user