diff --git a/android/app/build.gradle b/android/app/build.gradle index 620a6d8..3861e4f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -2,7 +2,7 @@ plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" - id("com.google.gms.google-services") + id "com.google.gms.google-services" } def localProperties = new Properties() @@ -46,7 +46,7 @@ android { applicationId "com.example.firebase_editor_gsoc" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion flutter.minSdkVersion + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/android/google-services.json b/android/app/google-services.json similarity index 100% rename from android/google-services.json rename to android/app/google-services.json diff --git a/android/settings.gradle b/android/settings.gradle index f2f86c8..3349c10 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -8,8 +8,8 @@ pluginManagement { } settings.ext.flutterSdkPath = flutterSdkPath() - includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") repositories { google() mavenCentral() @@ -20,7 +20,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "org.jetbrains.kotlin.android" version "1.9.24" apply false id 'com.google.gms.google-services' version '4.4.2' apply false } diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..40a15b7 --- /dev/null +++ b/firebase.json @@ -0,0 +1 @@ +{"flutter":{"platforms":{"android":{"default":{"projectId":"gsoc-24-3f4d1","appId":"1:211384953661:android:14233d29467afa30317354","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"gsoc-24-3f4d1","configurations":{"android":"1:211384953661:android:14233d29467afa30317354","ios":"1:211384953661:ios:007f4e6da5f618ea317354"}}}}}} \ No newline at end of file diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000..7fd1d8c --- /dev/null +++ b/lib/firebase_options.dart @@ -0,0 +1,69 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyAO1F8fTW1EG88fnnTTFRJiKXH4I-MHlbI', + appId: '1:211384953661:android:14233d29467afa30317354', + messagingSenderId: '211384953661', + projectId: 'gsoc-24-3f4d1', + storageBucket: 'gsoc-24-3f4d1.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyAfe7Be2vESlx3uSGQs_zZ12QWN-EdBgGs', + appId: '1:211384953661:ios:007f4e6da5f618ea317354', + messagingSenderId: '211384953661', + projectId: 'gsoc-24-3f4d1', + storageBucket: 'gsoc-24-3f4d1.appspot.com', + iosClientId: '211384953661-9hkosute6of7qapl18kjacl04m6f14ko.apps.googleusercontent.com', + iosBundleId: 'com.example.firebaseEditorGsoc', + ); +} diff --git a/lib/home_screen.dart b/lib/home_screen.dart index e11578b..8481d2f 100644 --- a/lib/home_screen.dart +++ b/lib/home_screen.dart @@ -1,57 +1,36 @@ - -import 'package:firebase_editor_gsoc/views/circle_widget.dart'; -import 'package:firebase_editor_gsoc/views/custom_drawer.dart'; -import 'package:firebase_editor_gsoc/views/define_schema.dart'; import 'package:flutter/material.dart'; -import 'user_profile.dart'; +import 'package:google_sign_in/google_sign_in.dart'; + class HomeScreen extends StatelessWidget { + final GoogleSignIn googleSignIn = GoogleSignIn(); + + void _handleSignOut(BuildContext context) async { + try { + await googleSignIn.signOut(); + // Navigate to the sign-in screen after signing out + Navigator.pop(context); + } catch (error) { + print('Error signing out: $error'); + // Handle sign-out error + } + } + @override Widget build(BuildContext context) { return Scaffold( - drawer: CustomDrawer(), appBar: AppBar( title: Text('Home'), - backgroundColor: Theme.of(context).appBarTheme.backgroundColor, + actions: [ + IconButton( + icon: Icon(Icons.exit_to_app), + onPressed: () => _handleSignOut(context), + ), + ], ), body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - - Icon(Icons.handyman), - Text("Under Developement", - style: Theme.of(context).textTheme.displayLarge?.copyWith( - color: Colors.grey, - fontSize: 30.0 - ) - ,) - // ElevatedButton( - // onPressed: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => UserProfile(), - // ), - // ); - // }, - // child: Text('Go to User Profile'), - // ), - // - // ElevatedButton( - // onPressed: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => DefineSchema(), - // ), - // ); - // }, - // child: Text('Go to Define Schema'), - // ), - ], - ), + child: Text('Welcome to Home Screen'), ), ); } -} +} \ No newline at end of file diff --git a/lib/views/sigin.dart b/lib/views/sigin.dart new file mode 100644 index 0000000..a5c70da --- /dev/null +++ b/lib/views/sigin.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:firebase_editor_gsoc/home_screen.dart'; + + + +class SignInScreen extends StatelessWidget { + final GoogleSignIn googleSignIn = GoogleSignIn(); + + void _handleSignIn(BuildContext context) async { + try { + print("IN SIGN IN METHOD"); + await googleSignIn.signIn(); + // Navigate to the next screen or perform other actions after successful sign-in + Navigator.push( + context, + MaterialPageRoute(builder: (context) => HomeScreen()), + ); + } catch (error) { + print('Error signing in with Google: $error'); + // Handle sign-in error + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Sign In'), + ), + body: Center( + child: ElevatedButton( + onPressed: () => _handleSignIn(context), + child: Text('Sign in with Google'), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/views/starter_screen_3.dart b/lib/views/starter_screen_3.dart index 8250f4c..746e83f 100644 --- a/lib/views/starter_screen_3.dart +++ b/lib/views/starter_screen_3.dart @@ -1,6 +1,7 @@ // lib/my_screen.dart import 'package:firebase_editor_gsoc/home_screen.dart'; +import 'package:firebase_editor_gsoc/views/sigin.dart'; import 'package:flutter/material.dart'; class StarterScreen3 extends StatelessWidget { @@ -61,7 +62,7 @@ class StarterScreen3 extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => HomeScreen(), + builder: (context) => SignInScreen(), ), ); }, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 82f2a45..9ae8802 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,12 @@ import FlutterMacOS import Foundation +import firebase_auth +import firebase_core import google_sign_in_ios func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 4da98ed..b4fc45e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "0816f12bbbd9e21f72ea8592b11bce4a628d4e5cb7a81ff9f1eee4f3dc23206e" + url: "https://pub.dev" + source: hosted + version: "1.3.37" async: dependency: transitive description: @@ -57,6 +65,54 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + sha256: "3af60a78e92567af3d9a5e25d3955f0f6a3f7a33b900724c1c4c336ff5e44200" + url: "https://pub.dev" + source: hosted + version: "5.1.0" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + sha256: "6941c07a1d129a8b834f85b6673d3455f24102b6338346596c26ef3be2c106ce" + url: "https://pub.dev" + source: hosted + version: "7.4.0" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + sha256: "5c3f6b45dc141cec858c050d6a6f07bdbfab45ab92a68b32be4b08805bdcadaa" + url: "https://pub.dev" + source: hosted + version: "5.12.2" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: fae4ab4317c2a7afb13d44ef1e3f9f28a630e10016bc5cfe761e8e6a0ed7816a + url: "https://pub.dev" + source: hosted + version: "3.1.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: "1003a5a03a61fc9a22ef49f37cbcb9e46c86313a7b2e7029b9390cf8c6fc32cb" + url: "https://pub.dev" + source: hosted + version: "5.1.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: "6643fe3dbd021e6ccfb751f7882b39df355708afbdeb4130fc50f9305a9d1a3d" + url: "https://pub.dev" + source: hosted + version: "2.17.2" flutter: dependency: "direct main" description: flutter @@ -80,6 +136,14 @@ packages: description: flutter source: sdk version: "0.0.0" + font_awesome_flutter: + dependency: transitive + description: + name: font_awesome_flutter + sha256: "275ff26905134bcb59417cf60ad979136f1f8257f2f449914b2c3e05bbb4cd6f" + url: "https://pub.dev" + source: hosted + version: "10.7.0" google_identity_services_web: dependency: transitive description: @@ -216,6 +280,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + sign_in_button: + dependency: "direct main" + description: + name: sign_in_button + sha256: "977b9b0415d2f3909e642275dfabba7919ba8e111324641b76cae6d1acbd183e" + url: "https://pub.dev" + source: hosted + version: "3.2.0" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 9ae0d4e..aa740f9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,6 +37,9 @@ dependencies: cupertino_icons: ^1.0.6 http: ^1.2.1 google_sign_in: ^6.2.1 + firebase_core: ^3.1.0 + firebase_auth: ^5.1.0 + sign_in_button: ^3.0.0 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..d141b74 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,12 @@ #include "generated_plugin_registrant.h" +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..29944d5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,8 @@ # list(APPEND FLUTTER_PLUGIN_LIST + firebase_auth + firebase_core ) list(APPEND FLUTTER_FFI_PLUGIN_LIST