Skip to content

Commit

Permalink
Login functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
usamaaelgendy committed Dec 15, 2020
1 parent bdf6694 commit f5c2355
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 121 deletions.
11 changes: 5 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
41D5C69C43A2B5863930BE3E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDD9CA5DB35781A84D3FDE35 /* Pods_Runner.framework */; };
50D6FE8B2578A11E0026BE75 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 50D6FE8A2578A11E0026BE75 /* GoogleService-Info.plist */; };
505A10C325883A3800BAFD24 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 505A10C225883A3700BAFD24 /* GoogleService-Info.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
Expand All @@ -36,7 +36,7 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3C0C012B6DF132F0985C1738 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
50D6FE8A2578A11E0026BE75 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
505A10C225883A3700BAFD24 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -96,7 +96,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
50D6FE8A2578A11E0026BE75 /* GoogleService-Info.plist */,
505A10C225883A3700BAFD24 /* GoogleService-Info.plist */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
Expand All @@ -116,7 +116,6 @@
3C0C012B6DF132F0985C1738 /* Pods-Runner.release.xcconfig */,
BFB2D1346197580CDEB8A23B /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -194,7 +193,7 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
50D6FE8B2578A11E0026BE75 /* GoogleService-Info.plist in Resources */,
505A10C325883A3800BAFD24 /* GoogleService-Info.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
Expand Down
13 changes: 8 additions & 5 deletions ios/Runner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
Expand All @@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-26" y="-44"/>
</scene>
</scenes>
</document>
4 changes: 2 additions & 2 deletions ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.154365471254-s2sp2qvfgr9mu0vic26mfopau23cmhkk</string>
<key>ANDROID_CLIENT_ID</key>
<string>154365471254-fltdsv7tbpt1p2hghs8grv8952f3dmgr.apps.googleusercontent.com</string>
<string>154365471254-g2do4io6dgd255qh5g9pa4u8pingmev7.apps.googleusercontent.com</string>
<key>API_KEY</key>
<string>AIzaSyCzqOfUYwS0lJJWdISWrgDlNPVo_B8q1tI</string>
<key>GCM_SENDER_ID</key>
Expand All @@ -31,6 +31,6 @@
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:154365471254:ios:0b587f59ed812806c62337</string>
<string>1:154365471254:ios:8c5a29a8ed3b6151c62337</string>
</dict>
</plist>
17 changes: 2 additions & 15 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,15 @@
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<string>E-Commerce</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- TODO Replace this value: -->
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
<string>com.googleusercontent.apps.154365471254-s2sp2qvfgr9mu0vic26mfopau23cmhkk</string>
<string>fb234291428113052</string>
</array>
</dict>
</array>
<!-- End of the Google Sign-in Section -->



<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb234291428113052</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>234291428113052</string>
<key>FacebookDisplayName</key>
Expand Down
30 changes: 26 additions & 4 deletions lib/core/view_model/auth_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:ecommerce_app/view/home_view.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_facebook_login/flutter_facebook_login.dart';
import 'package:get/get.dart';
import 'package:google_sign_in/google_sign_in.dart';
Expand All @@ -7,10 +9,18 @@ class AuthViewModel extends GetxController {
GoogleSignIn _googleSignIn = GoogleSignIn(scopes: ['email']);
FirebaseAuth _auth = FirebaseAuth.instance;
FacebookLogin _facebookLogin = FacebookLogin();

String email, password, name;

Rx<User> _user = Rx<User>();

String get user => _user.value?.email;

@override
void onInit() {
// TODO: implement onInit
super.onInit();
_user.bindStream(_auth.authStateChanges());
}

@override
Expand All @@ -36,10 +46,7 @@ class AuthViewModel extends GetxController {
accessToken: googleSignInAuthentication.accessToken,
);

UserCredential userCredential =
await _auth.signInWithCredential(credential);

print(userCredential.user);
await _auth.signInWithCredential(credential);
}

void facebookSignInMethod() async {
Expand All @@ -53,4 +60,19 @@ class AuthViewModel extends GetxController {
await _auth.signInWithCredential(faceCredential);
}
}

void signInWithEmailAndPassword() async {
try {
await _auth.signInWithEmailAndPassword(email: email, password: password);
Get.offAll(HomeView());
} catch (e) {
print(e.message);
Get.snackbar(
'Error login account',
e.message,
colorText: Colors.black,
snackPosition: SnackPosition.BOTTOM,
);
}
}
}
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:ecommerce_app/helper/binding.dart';
import 'package:ecommerce_app/view/auth/login_screen.dart';
import 'package:ecommerce_app/view/control_view.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
Expand All @@ -16,7 +16,7 @@ class MyApp extends StatelessWidget {
return GetMaterialApp(
initialBinding: Binding(),
home: Scaffold(
body: LoginScreen(),
body: ControlView(),
),
);
}
Expand Down
Loading

0 comments on commit f5c2355

Please sign in to comment.