mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-31 11:54:30 +01:00
Implement FirebaseAuthView for Google and GitHub Sign-In
This commit adds the `FirebaseAuthView` class, a Flutter widget that serves as the UI for user authentication using Google and GitHub. The class uses the `AuthService` to handle the actual sign-in logic. Features: - Added an OutlinedButton for Google Sign-In, styled with Google's colors and logo. - Added an OutlinedButton for GitHub Sign-In, styled with GitHub's colors and logo. - Integrated the `AuthService` methods for Google and GitHub sign-in.
This commit is contained in:
71
frontend/lib/views/auth/firebase_auth_view.dart
Normal file
71
frontend/lib/views/auth/firebase_auth_view.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:auto_gpt_flutter_client/services/auth_service.dart';
|
||||
|
||||
class FirebaseAuthView extends StatelessWidget {
|
||||
// TODO: This should be initialized in the main.dart instead of here
|
||||
final AuthService _authService = AuthService();
|
||||
|
||||
FirebaseAuthView({super.key}); // Initialize the auth service
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
OutlinedButton(
|
||||
onPressed: () async {
|
||||
final user = await _authService.signInWithGoogle();
|
||||
if (user != null) {
|
||||
print(
|
||||
"Successfully signed in with Google: ${user.user?.displayName}");
|
||||
}
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.blue,
|
||||
side: const BorderSide(color: Colors.blue, width: 2),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset('assets/google_logo.svg.png', width: 24),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Sign in with Google',
|
||||
style: TextStyle(fontWeight: FontWeight.w300)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
OutlinedButton(
|
||||
onPressed: () async {
|
||||
final user = await _authService.signInWithGitHub();
|
||||
if (user != null) {
|
||||
print(
|
||||
"Successfully signed in with GitHub: ${user.user?.displayName}");
|
||||
}
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.black,
|
||||
side: const BorderSide(color: Colors.black, width: 2),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset('assets/github_logo.svg.png', width: 24),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Sign in with GitHub',
|
||||
style: TextStyle(fontWeight: FontWeight.w300)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user