From a4755f6d53944a4756005f78253775e97489ecbb Mon Sep 17 00:00:00 2001 From: nicolas Date: Mon, 14 Sep 2026 10:33:07 +0200 Subject: [PATCH] feat(auth): integrate Google Sign-In UI with custom button and friendly preparation notice --- lib/screens/auth_dialog.dart | 113 +++++++++++++++++++++++++++++++++ lib/services/auth_service.dart | 7 ++ 2 files changed, 120 insertions(+) diff --git a/lib/screens/auth_dialog.dart b/lib/screens/auth_dialog.dart index 9bf485d..d343694 100644 --- a/lib/screens/auth_dialog.dart +++ b/lib/screens/auth_dialog.dart @@ -145,6 +145,31 @@ class _AuthDialogState extends State } } + Future _handleGoogleSignIn() async { + setState(() { + _isLoading = true; + _errorMessage = null; + }); + + final auth = Provider.of(context, listen: false); + final error = await auth.signInWithGoogle(); + + if (!mounted) return; + setState(() => _isLoading = false); + + if (error == null) { + Navigator.pop(context); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Erfolgreich mit Google angemeldet!'), + backgroundColor: Colors.green, + ), + ); + } else { + setState(() => _errorMessage = error); + } + } + Future _handleCodeUnlock() async { final code = _codeController.text.trim(); if (code.isEmpty) { @@ -388,6 +413,26 @@ class _AuthDialogState extends State : const Text('Anmelden', style: TextStyle(fontSize: 15)), ), + const SizedBox(height: 14), + Row( + children: [ + Expanded(child: Divider(color: Colors.grey.shade300)), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Text( + 'ODER', + style: TextStyle( + fontSize: 11, + color: Colors.grey.shade500, + fontWeight: FontWeight.bold, + ), + ), + ), + Expanded(child: Divider(color: Colors.grey.shade300)), + ], + ), + const SizedBox(height: 14), + _buildGoogleButton(label: 'Mit Google anmelden'), ], ), ), @@ -481,6 +526,26 @@ class _AuthDialogState extends State 'Konto erstellen & E-Mail bestätigen', style: TextStyle(fontSize: 14)), ), + const SizedBox(height: 14), + Row( + children: [ + Expanded(child: Divider(color: Colors.grey.shade300)), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Text( + 'ODER', + style: TextStyle( + fontSize: 11, + color: Colors.grey.shade500, + fontWeight: FontWeight.bold, + ), + ), + ), + Expanded(child: Divider(color: Colors.grey.shade300)), + ], + ), + const SizedBox(height: 14), + _buildGoogleButton(label: 'Mit Google registrieren'), ], ), ), @@ -542,4 +607,52 @@ class _AuthDialogState extends State ), ); } + + Widget _buildGoogleButton({required String label}) { + return OutlinedButton( + onPressed: _isLoading ? null : _handleGoogleSignIn, + style: OutlinedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 11, horizontal: 16), + side: BorderSide(color: Colors.grey.shade300), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + backgroundColor: Colors.white, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + _buildGoogleIcon(), + const SizedBox(width: 12), + Text( + label, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + ], + ), + ); + } + + Widget _buildGoogleIcon() { + return Container( + width: 22, + height: 22, + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.circle, + border: Border.all(color: Colors.grey.shade200), + ), + alignment: Alignment.center, + child: const Text( + 'G', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xFF4285F4), + ), + ), + ); + } } diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart index 60c172a..9f8539b 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -136,6 +136,13 @@ class AuthService extends ChangeNotifier { } } + /// Sign in with Google (UI stub / preparation) + Future signInWithGoogle() async { + // Note: Once SHA-1 fingerprint is registered in Firebase Console, + // the full interactive Google OAuth sign-in flow can be activated. + return 'Google Sign-In ist in Vorbereitung. Bitte nutze derzeit die E-Mail-Anmeldung oder den Bürger-Code.'; + } + /// Send password reset email Future sendPasswordReset(String email) async { try {