diff --git a/.vscode/settings.json b/.vscode/settings.json index 3ebdbc0..fe1640e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "CodeGPT.apiKey": "CodeGPT Plus Beta" + "CodeGPT.apiKey": "CodeGPT Plus Beta", + "dart.flutterSdkPath": "D:\\pooja\\fluttersdk\\flutter_3.16.9\\flutter" } \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 54842fa..3b66bba 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') @@ -68,4 +68,6 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.facebook.android:facebook-login:latest.release' + } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 970b96b..9fc0f9d 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,11 @@ + package="com.example.regroup" + xmlns:tools="http://schemas.android.com/tools" + > + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..b304a14 --- /dev/null +++ b/android/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + + ReGroup123 + 8076081959097016 + fb8076081959097016 + ca5a1805872edbec0d3a0a0b02229ba5 + \ No newline at end of file diff --git a/lib/Login/View/loginscreen.dart b/lib/Login/View/loginscreen.dart index 9b83556..106b500 100644 --- a/lib/Login/View/loginscreen.dart +++ b/lib/Login/View/loginscreen.dart @@ -1,4 +1,3 @@ -import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -14,6 +13,7 @@ import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; import 'package:show_fps/show_fps.dart'; +import 'package:flutter_facebook_auth/flutter_facebook_auth.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @@ -23,11 +23,69 @@ class LoginScreen extends StatefulWidget { } class _LoginScreenState extends State { + Map? _userData; + AccessToken? _accessToken; + bool _checking = true; final TextEditingController _email = TextEditingController(); RxBool isObscured = true.obs; final TextEditingController _password = TextEditingController(); // final GlobalKey _form = GlobalKey(); + @override + void initState() { + // TODO: implement initState + // _checkIfisLoggedIn(); + + super.initState(); + } + + _checkIfisLoggedIn() async { + final accessToken = await FacebookAuth.instance.accessToken; + + setState(() { + _checking = false; + }); + + if (accessToken != null) { + print("/////////////////////////////////////////check"); + print("worked"); + print(accessToken.toJson()); + final userData = await FacebookAuth.instance.getUserData(); + _accessToken = accessToken; + setState(() { + _userData = userData; + }); + } else { + print("/////////////////////////////////////////check"); + + print("not worked"); + _login(); + } + } + _login() async { + final LoginResult result = await FacebookAuth.instance.login(); + + if (result.status == LoginStatus.success) { + _accessToken = result.accessToken; + + final userData = await FacebookAuth.instance.getUserData(); + _userData = userData; + } else { + print(result.status); + print(result.message); + } + setState(() { + _checking = false; + }); + } + + _logout() async { + await FacebookAuth.instance.logOut(); + _accessToken = null; + _userData = null; + setState(() {}); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -242,28 +300,44 @@ class _LoginScreenState extends State { 'assets/images/png/login3.png'))), ), const Spacer(), - Container( - width: 55, - height: 55, - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.71, -0.70), - end: const Alignment(-0.71, 0.7), - colors: [ - Colors.white - .withOpacity(0.07999999821186066), - Colors.white - .withOpacity(0.12999999523162842) - ], - ), - shape: const OvalBorder( - side: BorderSide( - width: 0.50, - color: Color(0xFF434A53)), - ), - image: const DecorationImage( - image: AssetImage( - 'assets/images/png/login4.png'))), + GestureDetector( + onTap: () async { + _checkIfisLoggedIn(); + + /* FacebookAuth.instance.login( + permissions: ['public_profile', 'email'], + ).then((value) { + FacebookAuth.instance.getUserData().then((userData) { + setState(() { + /* _isLoggedIn = true; + _userObj = userData; */ + }); + }); + }); */ + }, + child: Container( + width: 55, + height: 55, + decoration: ShapeDecoration( + gradient: LinearGradient( + begin: const Alignment(0.71, -0.70), + end: const Alignment(-0.71, 0.7), + colors: [ + Colors.white + .withOpacity(0.07999999821186066), + Colors.white + .withOpacity(0.12999999523162842) + ], + ), + shape: const OvalBorder( + side: BorderSide( + width: 0.50, + color: Color(0xFF434A53)), + ), + image: const DecorationImage( + image: AssetImage( + 'assets/images/png/login4.png'))), + ), ), ], ), diff --git a/lib/main.dart b/lib/main.dart index 41732c0..0b4cc70 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,8 +18,13 @@ Future main() async { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, - ]).then((value) => runApp(StatsFl( - align: Alignment.center, width: 200, height: 100, child: const MyApp()))); + ]).then( + (value) =>runApp(MyApp()) /* runApp(StatsFl( + align: Alignment.center, + width: 200, + height: 100, + child: const MyApp())), */ + ); } class MyApp extends StatefulWidget { diff --git a/pubspec.lock b/pubspec.lock index 4e96466..9dac0de 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -230,6 +230,30 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_facebook_auth: + dependency: "direct main" + description: + name: flutter_facebook_auth + sha256: fd1a6749dafbd5923585038671b63abdcedd4fe5923eb42fc154247dc5622519 + url: "https://pub.dev" + source: hosted + version: "6.0.4" + flutter_facebook_auth_platform_interface: + dependency: transitive + description: + name: flutter_facebook_auth_platform_interface + sha256: "86630c4dbba1c20fba26ea9e59ad0d48f5ff59e7373cacd36f916160186f9ce9" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_facebook_auth_web: + dependency: transitive + description: + name: flutter_facebook_auth_web + sha256: "0e2960e9e23f2538e29b406495e18b047fbf233abfaed8d2b99acda17a2f7479" + url: "https://pub.dev" + source: hosted + version: "5.0.1" flutter_lints: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index a6fe0b6..f78c8fe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,7 @@ dependencies: glassmorphism_ui: ^0.3.0 show_fps: ^1.0.6 statsfl: ^2.3.0 + flutter_facebook_auth: ^6.0.4