diff --git a/assets/images/Google.png b/assets/images/Google.png new file mode 100644 index 0000000..001e1a2 Binary files /dev/null and b/assets/images/Google.png differ diff --git a/lib/ui/login/view/LoginView.dart b/lib/ui/login/view/LoginView.dart index ae86c56..fedb7e7 100644 --- a/lib/ui/login/view/LoginView.dart +++ b/lib/ui/login/view/LoginView.dart @@ -1,9 +1,7 @@ -import 'package:aranduapp/core/log/Log.dart'; import 'package:aranduapp/ui/home/view/HomeView.dart'; import 'package:aranduapp/ui/shared/TextAndLink.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:aranduapp/ui/login/viewModel/LoginViewModel.dart'; @@ -15,6 +13,7 @@ import 'package:aranduapp/ui/shared/TextEmail.dart'; import 'package:aranduapp/ui/shared/ErrorPopUp.dart'; import 'package:aranduapp/ui/shared/TextPassword.dart'; import 'package:aranduapp/ui/shared/OrDivider.dart'; +import 'package:url_launcher/url_launcher.dart'; class Login extends StatelessWidget { const Login({super.key}); @@ -37,6 +36,40 @@ class _Login extends StatefulWidget { } } +class GoogleLoginButton extends StatelessWidget { + const GoogleLoginButton({super.key}); + + Future _launchGoogleSignIn() async { + final Uri url = Uri.parse('http://localhost/auth/google'); + if (!await launchUrl(url, mode: LaunchMode.externalApplication)) { + throw Exception('Não foi possível abrir a URL: $url'); + } + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: _launchGoogleSignIn, + child: Container( + width: 50, + height: 50, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all(color: Theme.of(context).colorScheme.outline), + color: Colors.transparent, + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Image.asset( + 'assets/images/Google.png', + fit: BoxFit.cover, + ), + ), + ), + ); + } +} + class _LoginState extends State<_Login> { late Future _future; @@ -116,10 +149,10 @@ class _LoginState extends State<_Login> { const SizedBox(height: 80), _loginButtonSection(), const OrDivider(), - _loggingInWithOther(), + const GoogleLoginButton(), TextAndLink( - text: 'É novo pro aqui?', - link: 'Cria a sua conta', + text: 'Não tem uma conta?', + link: 'Registre-se', action: () { Navigator.of(context).push( MaterialPageRoute( @@ -154,7 +187,7 @@ class _LoginState extends State<_Login> { onTap: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => RecoverAccount(), + builder: (context) => RecoverAccount(), ), ); }, @@ -201,24 +234,4 @@ class _LoginState extends State<_Login> { )), ); } - - Widget _loggingInWithOther() { - return GestureDetector( - onTap: () => Log.d(""), - child: Container( - width: 50, - height: 50, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: Theme.of(context).colorScheme.outline), - color: Colors.transparent, - ), - child: Icon( - FontAwesomeIcons.google, - size: 20, - color: Theme.of(context).colorScheme.primary, - ), - ), - ); - } } diff --git a/pubspec.yaml b/pubspec.yaml index 1593fb4..1d2bbf9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,6 +44,8 @@ dependencies: dio: ^5.7.0 font_awesome_flutter: ^10.8.0 flutter_secure_storage: ^9.2.2 + url_launcher: ^6.2.1 + dev_dependencies: flutter_test: @@ -71,6 +73,7 @@ flutter: - assets/images/Component1.png - assets/images/Component2.png - assets/images/Component3.png + - assets/images/Google.png # To add assets to your application, add an assets section, like this: # assets: