diff --git a/lib/authGate.dart b/lib/authGate.dart index bedaf60..ac6b887 100644 --- a/lib/authGate.dart +++ b/lib/authGate.dart @@ -1,7 +1,7 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutterfire_ui/auth.dart'; - +import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'home.dart'; class AuthGate extends StatelessWidget { @@ -9,14 +9,17 @@ class AuthGate extends StatelessWidget { @override Widget build(BuildContext context) { + String webId = dotenv.env['GOOGLEWEBSDK']!; return StreamBuilder( stream: FirebaseAuth.instance.authStateChanges(), builder: (context, snapshot) { if (!snapshot.hasData) { return SignInScreen( - providerConfigs: const [ - EmailProviderConfiguration(), - GoogleProviderConfiguration(), + providerConfigs: [ + const EmailProviderConfiguration(), + GoogleProviderConfiguration( + clientId: webId, + ) ], headerBuilder: (context, constraints, shrinkOffset) { return Padding( diff --git a/lib/home.dart b/lib/home.dart index bedaf60..25510b2 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -4,60 +4,29 @@ import 'package:flutterfire_ui/auth.dart'; import 'home.dart'; -class AuthGate extends StatelessWidget { - const AuthGate({super.key}); +class HomeScreen extends StatelessWidget { + const HomeScreen({super.key}); @override Widget build(BuildContext context) { - return StreamBuilder( - 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(); - }, - ); + return Scaffold( + appBar: AppBar( + title: const Text('FlutterFire UI'), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('You are logged in!'), + ElevatedButton( + onPressed: () { + FirebaseAuth.instance.signOut(); + }, + child: const Text('Sign out'), + ), + ], + ), + ), + ); } } \ No newline at end of file