mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-22 03:18:44 -04:00
homescreen fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutterfire_ui/auth.dart';
|
import 'package:flutterfire_ui/auth.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'home.dart';
|
import 'home.dart';
|
||||||
|
|
||||||
class AuthGate extends StatelessWidget {
|
class AuthGate extends StatelessWidget {
|
||||||
@@ -9,14 +9,17 @@ class AuthGate extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
String webId = dotenv.env['GOOGLEWEBSDK']!;
|
||||||
return StreamBuilder<User?>(
|
return StreamBuilder<User?>(
|
||||||
stream: FirebaseAuth.instance.authStateChanges(),
|
stream: FirebaseAuth.instance.authStateChanges(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return SignInScreen(
|
return SignInScreen(
|
||||||
providerConfigs: const [
|
providerConfigs: [
|
||||||
EmailProviderConfiguration(),
|
const EmailProviderConfiguration(),
|
||||||
GoogleProviderConfiguration(),
|
GoogleProviderConfiguration(
|
||||||
|
clientId: webId,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
headerBuilder: (context, constraints, shrinkOffset) {
|
headerBuilder: (context, constraints, shrinkOffset) {
|
||||||
return Padding(
|
return Padding(
|
||||||
|
@@ -4,60 +4,29 @@ import 'package:flutterfire_ui/auth.dart';
|
|||||||
|
|
||||||
import 'home.dart';
|
import 'home.dart';
|
||||||
|
|
||||||
class AuthGate extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
const AuthGate({super.key});
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamBuilder<User?>(
|
return Scaffold(
|
||||||
stream: FirebaseAuth.instance.authStateChanges(),
|
appBar: AppBar(
|
||||||
builder: (context, snapshot) {
|
title: const Text('FlutterFire UI'),
|
||||||
if (!snapshot.hasData) {
|
),
|
||||||
return SignInScreen(
|
body: Center(
|
||||||
providerConfigs: const [
|
child: Column(
|
||||||
EmailProviderConfiguration(),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
GoogleProviderConfiguration(),
|
children: [
|
||||||
],
|
const Text('You are logged in!'),
|
||||||
headerBuilder: (context, constraints, shrinkOffset) {
|
ElevatedButton(
|
||||||
return Padding(
|
onPressed: () {
|
||||||
padding: const EdgeInsets.all(20),
|
FirebaseAuth.instance.signOut();
|
||||||
child: AspectRatio(
|
},
|
||||||
aspectRatio: 1,
|
child: const Text('Sign out'),
|
||||||
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