mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
Authentication with Firebase v0.1
This commit is contained in:
63
lib/authGate.dart
Normal file
63
lib/authGate.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterfire_ui/auth.dart';
|
||||
|
||||
import 'home.dart';
|
||||
|
||||
class AuthGate extends StatelessWidget {
|
||||
const AuthGate({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder<User?>(
|
||||
stream: FirebaseAuth.instance.authStateChanges(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return SignInScreen(
|
||||
providerConfigs: const [
|
||||
EmailProviderConfiguration(),
|
||||
GoogleProviderConfiguration(),
|
||||
],
|
||||
headerBuilder: (context, constraints, shrinkOffset) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Image.asset('flutterfire_300x.png'),
|
||||
),
|
||||
);
|
||||
},
|
||||
subtitleBuilder: (context, action) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: action == AuthAction.signIn
|
||||
? const Text('Welcome to FlutterFire, please sign in!')
|
||||
: const Text('Welcome to Flutterfire, please sign up!'),
|
||||
);
|
||||
},
|
||||
footerBuilder: (context, action) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.only(top: 16),
|
||||
child: Text(
|
||||
'By signing in, you agree to our terms and conditions.',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
},
|
||||
sideBuilder: (context, shrinkOffset) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Image.asset('flutterfire_300x.png'),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return const HomeScreen();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user