diff --git a/nirvana-ios.xcodeproj/project.pbxproj b/nirvana-ios.xcodeproj/project.pbxproj
index 5814e74..dd5035e 100644
--- a/nirvana-ios.xcodeproj/project.pbxproj
+++ b/nirvana-ios.xcodeproj/project.pbxproj
@@ -32,6 +32,7 @@
89288ECB27675B9F00E962C4 /* OnboardingTemplateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89288ECA27675B9F00E962C4 /* OnboardingTemplateView.swift */; };
89D99D2E2766FD6B00237814 /* Liquid in Frameworks */ = {isa = PBXBuildFile; productRef = 89D99D2D2766FD6B00237814 /* Liquid */; };
89F1386D2767EB19006680ED /* SignInView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89F1386C2767EB19006680ED /* SignInView.swift */; };
+ 89F138702767F55F006680ED /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = 89F1386F2767F55F006680ED /* GoogleSignIn */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -69,6 +70,7 @@
89288EC7276756DF00E962C4 /* FirebaseDatabase in Frameworks */,
89288EC9276756DF00E962C4 /* FirebaseStorage in Frameworks */,
89D99D2E2766FD6B00237814 /* Liquid in Frameworks */,
+ 89F138702767F55F006680ED /* GoogleSignIn in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -229,6 +231,7 @@
89288EC4276756DF00E962C4 /* FirebaseAuth */,
89288EC6276756DF00E962C4 /* FirebaseDatabase */,
89288EC8276756DF00E962C4 /* FirebaseStorage */,
+ 89F1386F2767F55F006680ED /* GoogleSignIn */,
);
productName = "nirvana-ios";
productReference = 891A15DD27653A7000B26659 /* nirvana-ios.app */;
@@ -261,6 +264,7 @@
packageReferences = (
89D99D2C2766FD6B00237814 /* XCRemoteSwiftPackageReference "liquid" */,
89288EC1276756DF00E962C4 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
+ 89F1386E2767F55F006680ED /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */,
);
productRefGroup = 891A15DE27653A7000B26659 /* Products */;
projectDirPath = "";
@@ -532,6 +536,14 @@
minimumVersion = 0.0.2;
};
};
+ 89F1386E2767F55F006680ED /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */ = {
+ isa = XCRemoteSwiftPackageReference;
+ repositoryURL = "https://github.com/google/GoogleSignIn-iOS.git";
+ requirement = {
+ kind = upToNextMajorVersion;
+ minimumVersion = 6.0.0;
+ };
+ };
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
@@ -560,6 +572,11 @@
package = 89D99D2C2766FD6B00237814 /* XCRemoteSwiftPackageReference "liquid" */;
productName = Liquid;
};
+ 89F1386F2767F55F006680ED /* GoogleSignIn */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = 89F1386E2767F55F006680ED /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */;
+ productName = GoogleSignIn;
+ };
/* End XCSwiftPackageProductDependency section */
};
rootObject = 891A15D527653A7000B26659 /* Project object */;
diff --git a/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index 526812f..50781f1 100644
--- a/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -10,6 +10,15 @@
"version": "0.20200225.4"
}
},
+ {
+ "package": "AppAuth",
+ "repositoryURL": "https://github.com/openid/AppAuth-iOS.git",
+ "state": {
+ "branch": null,
+ "revision": "01131d68346c8ae552961c768d583c715fbe1410",
+ "version": "1.4.0"
+ }
+ },
{
"package": "BoringSSL-GRPC",
"repositoryURL": "https://github.com/firebase/boringssl-SwiftPM.git",
@@ -46,6 +55,15 @@
"version": "9.1.2"
}
},
+ {
+ "package": "GoogleSignIn",
+ "repositoryURL": "https://github.com/google/GoogleSignIn-iOS.git",
+ "state": {
+ "branch": null,
+ "revision": "27bc94f5e1bd1f3b12ba5abb2230dd77dd143f1e",
+ "version": "6.0.2"
+ }
+ },
{
"package": "GoogleUtilities",
"repositoryURL": "https://github.com/google/GoogleUtilities.git",
@@ -73,6 +91,15 @@
"version": "1.7.0"
}
},
+ {
+ "package": "GTMAppAuth",
+ "repositoryURL": "https://github.com/google/GTMAppAuth.git",
+ "state": {
+ "branch": null,
+ "revision": "40f4103fb52109032c05599a0c39ad43edbdf80a",
+ "version": "1.2.2"
+ }
+ },
{
"package": "leveldb",
"repositoryURL": "https://github.com/firebase/leveldb.git",
diff --git a/nirvana-ios/Assets.xcassets/icons/Contents.json b/nirvana-ios/Assets.xcassets/icons/Contents.json
new file mode 100644
index 0000000..73c0059
--- /dev/null
+++ b/nirvana-ios/Assets.xcassets/icons/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/nirvana-ios/Assets.xcassets/icons/google.imageset/Contents.json b/nirvana-ios/Assets.xcassets/icons/google.imageset/Contents.json
new file mode 100644
index 0000000..f96e471
--- /dev/null
+++ b/nirvana-ios/Assets.xcassets/icons/google.imageset/Contents.json
@@ -0,0 +1,21 @@
+{
+ "images" : [
+ {
+ "filename" : "google.svg",
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/nirvana-ios/Assets.xcassets/icons/google.imageset/google.svg b/nirvana-ios/Assets.xcassets/icons/google.imageset/google.svg
new file mode 100644
index 0000000..d5616b3
--- /dev/null
+++ b/nirvana-ios/Assets.xcassets/icons/google.imageset/google.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/nirvana-ios/Info.plist b/nirvana-ios/Info.plist
index ed7a5a9..69e7e18 100644
--- a/nirvana-ios/Info.plist
+++ b/nirvana-ios/Info.plist
@@ -2,6 +2,17 @@
+ CFBundleURLTypes
+
+
+ CFBundleTypeRole
+ Editor
+ CFBundleURLSchemes
+
+ com.googleusercontent.apps.93806270104-62r53m53imapfocl1sck8bn4ho910ndh
+
+
+
UIAppFonts
Satisfy-Regular.ttf
diff --git a/nirvana-ios/Views/SignInview/SignInView.swift b/nirvana-ios/Views/SignInview/SignInView.swift
index 178af8e..9ae9e9b 100644
--- a/nirvana-ios/Views/SignInview/SignInView.swift
+++ b/nirvana-ios/Views/SignInview/SignInView.swift
@@ -6,38 +6,101 @@
//
import SwiftUI
+import Firebase
+import AuthenticationServices
+import GoogleSignIn
struct SignInView: View {
var body: some View {
OnboardingTemplateView(hdrText: "Let's get started", imgName: "undraw_enter_uhqk", bottomActArea:
AnyView(
VStack(alignment: .center) {
- NavigationLink(destination: HomeView()) {
- Text("Sign Up")
- .bold()
- .foregroundColor(NirvanaColor.white)
- .frame(maxWidth: .infinity)
- .padding(.vertical, 20)
- .background(NirvanaColor.teal)
- .clipShape(Capsule())
- .shadow(radius:10)
- }
-
- Button(
- action: {
- print("link to website learn more clicked")
- },
- label: {
- Text("Learn More")
+// SignInWithAppleButton(.signIn,
+// onRequest: { request in
+// print("siginin in ")
+// }, onCompletion: {result in
+// print("signed in")
+// })
+// .frame(height:50)
+// .clipShape(Capsule())
+// .shadow(radius:20)
+
+ Button {
+ self.handleLogin()
+ } label: {
+ HStack {
+ Image("google")
+ .resizable()
+ .renderingMode(.template)
+ .aspectRatio(contentMode: .fit)
+ .frame(width: 28, height: 28)
+ .foregroundColor(NirvanaColor.white)
+
+ Text("Continue with Google")
+ .foregroundColor(NirvanaColor.white)
.bold()
- })
-
- //learn more button to usenirvana.com
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 20)
+ .background(NirvanaColor.teal)
+ .clipShape(Capsule())
+ .shadow(radius:10)
+ }
+
+
+ Text("By continuing, you are agreeing to our Terms of Service.")
+ .font(.callout.bold())
+ .foregroundColor(.gray)
+ .multilineTextAlignment(.center)
+
}
.padding(.top, 20)
)
)
}
+
+ func handleLogin(){
+ //Google sign in
+ guard let clientID = FirebaseApp.app()?.options.clientID else { return }
+
+ // create google sign in configuration object
+ let config = GIDConfiguration(clientID: clientID)
+
+ GIDSignIn.sharedInstance.signIn(with: config, presenting: getRootViewController())
+ {[self] user, err in
+
+ if let error = err {
+ print(err)
+ return
+ }
+
+ guard
+ let authentication = user?.authentication,
+ let idToken = authentication.idToken
+ else {
+ return
+ }
+
+ let credential = GoogleAuthProvider.credential(withIDToken: idToken,
+ accessToken: authentication.accessToken)
+
+ Auth.auth().signIn(with: credential) { result, error in
+ if let error = error {
+ print(error.localizedDescription)
+ }
+
+ guard let user = result?.user else {
+ return
+ }
+
+ print(user.displayName ?? "Success!")
+ print(user.photoURL)
+ // User is signed in
+ // ...
+ }
+ }
+ }
+
}
struct SignInView_Previews: PreviewProvider {
@@ -45,3 +108,15 @@ struct SignInView_Previews: PreviewProvider {
SignInView()
}
}
+
+extension View {
+ func getRootViewController() -> UIViewController {
+ guard let screen = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return .init() }
+
+ guard let root = screen.windows.first?.rootViewController else {
+ return .init()
+ }
+
+ return root
+ }
+}
diff --git a/nirvana-ios/Views/Templates/OnboardingTemplateView.swift b/nirvana-ios/Views/Templates/OnboardingTemplateView.swift
index 27cca4f..b91271a 100644
--- a/nirvana-ios/Views/Templates/OnboardingTemplateView.swift
+++ b/nirvana-ios/Views/Templates/OnboardingTemplateView.swift
@@ -43,6 +43,8 @@ struct OnboardingTemplateView: View {
HeaderView()
VStack {
+ self.onboardingHeaderText
+
self.onboardingImageView
self.onboardingActionTextView
@@ -51,7 +53,7 @@ struct OnboardingTemplateView: View {
self.bottomActionArea
}
- .padding(screenWidth * 0.1)
+ .padding(.horizontal, screenWidth * 0.1)
Spacer()
} //outermost vstack
@@ -60,6 +62,19 @@ struct OnboardingTemplateView: View {
.navigationBarTitleDisplayMode(.inline)
}
+ private var onboardingHeaderText: some View {
+ ZStack {
+ if (self.headerText != nil) {
+ Text(self.headerText!)
+ .font(.title)
+ .fontWeight(.medium)
+ .foregroundColor(NirvanaColor.teal)
+ .multilineTextAlignment(.center)
+ }
+ }
+ .padding()
+ }
+
private var onboardingImageView: some View {
Image(self.imageName ?? "")
.renderingMode(.original)
@@ -98,7 +113,7 @@ struct OnboardingTemplateView: View {
struct OnboardingTemplateView_Previews: PreviewProvider {
static var previews: some View {
- OnboardingTemplateView(imgName: "undraw_friendship_mni7", mainLeadingActText: "Your", mainHighlightedActText: "minimalist", mainTrailingActText: "social media.", subActText: "Tired of the rat race on the test of th4e best oadf the best?", bottomActArea: AnyView(
+ OnboardingTemplateView(hdrText: "let's get started", imgName: "undraw_friendship_mni7", mainLeadingActText: "Your", mainHighlightedActText: "minimalist", mainTrailingActText: "social media.", subActText: "Tired of the rat race on the test of th4e best oadf the best?", bottomActArea: AnyView(
VStack(alignment: .center) {
NavigationLink(destination: HomeView()) {
Text("Start Your Detox")
diff --git a/nirvana-ios/Views/WelcomeView/WelcomeView.swift b/nirvana-ios/Views/WelcomeView/WelcomeView.swift
index c207663..8921e2b 100644
--- a/nirvana-ios/Views/WelcomeView/WelcomeView.swift
+++ b/nirvana-ios/Views/WelcomeView/WelcomeView.swift
@@ -14,7 +14,7 @@ struct WelcomeView: View {
var body: some View {
OnboardingTemplateView(imgName: "undraw_friendship_mni7", mainLeadingActText: "Your", mainHighlightedActText: "minimalist", mainTrailingActText: "social media.", subActText: "Tired of the rat race on insta, snap, tik-tok, \"meta\"?", bottomActArea: AnyView(
VStack(alignment: .center) {
- NavigationLink(destination: HomeView()) {
+ NavigationLink(destination: SignInView()) {
Text("Start Your Detox")
.bold()
.foregroundColor(NirvanaColor.white)
diff --git a/nirvana-ios/nirvana_iosApp.swift b/nirvana-ios/nirvana_iosApp.swift
index ced16b1..361603f 100644
--- a/nirvana-ios/nirvana_iosApp.swift
+++ b/nirvana-ios/nirvana_iosApp.swift
@@ -7,17 +7,27 @@
import SwiftUI
import Firebase
+import GoogleSignIn
@main
struct nirvana_iosApp: App {
-
- init() {
- FirebaseApp.configure()
- }
-
+ @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
+
+class AppDelegate: NSObject, UIApplicationDelegate{
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:
+ [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
+ FirebaseApp.configure()
+
+ return true
+ }
+
+ func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
+ return GIDSignIn.sharedInstance.handle(url)
+ }
+}