Skip to content

Commit e9f85b2

Browse files
authored
Merge pull request #80 from TaskarCenterAtUW/feature-login
Feature login
2 parents f3d9472 + a6cf24a commit e9f85b2

File tree

14 files changed

+844
-360
lines changed

14 files changed

+844
-360
lines changed

GoInfoGame/GoInfoGame.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@
168168
A4E711B02B59011000C9DE08 /* StepsInclineForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E711AF2B59011000C9DE08 /* StepsInclineForm.swift */; };
169169
B0CCB98C2B8626AE00AA73DE /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0CCB98B2B8626AE00AA73DE /* ProfileView.swift */; };
170170
B0CCB98E2B8626C600AA73DE /* ProfileViewVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0CCB98D2B8626C600AA73DE /* ProfileViewVM.swift */; };
171+
FA1992ED2BB1A78C003B4719 /* KeychainManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA1992EC2BB1A78C003B4719 /* KeychainManager.swift */; };
171172
FA5853C12B21F17F00301CDA /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA5853C02B21F17F00301CDA /* OnboardingView.swift */; };
172173
FA87A8102B68142F000A6BEA /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A80F2B68142F000A6BEA /* LoadingView.swift */; };
173174
FA87A8132B6AC019000A6BEA /* StepsRampTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A8112B6AC019000A6BEA /* StepsRampTests.swift */; };
174175
FA87A8152B6AC4E2000A6BEA /* BusStopLitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A8142B6AC4E2000A6BEA /* BusStopLitTests.swift */; };
175176
FA87A8172B6AC885000A6BEA /* StepsInclineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A8162B6AC885000A6BEA /* StepsInclineTests.swift */; };
176177
FA87A8192B6B01A4000A6BEA /* HandRailTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A8182B6B01A4000A6BEA /* HandRailTests.swift */; };
177178
FA87A81B2B6B042E000A6BEA /* SideWalkWidthTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A81A2B6B042E000A6BEA /* SideWalkWidthTests.swift */; };
179+
FA9FE2D82BAC75390036F618 /* OAuthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9FE2D72BAC75390036F618 /* OAuthViewController.swift */; };
178180
FABF3CF42B7419BB0080EAC9 /* LocationManagerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FABF3CF32B7419BB0080EAC9 /* LocationManagerDelegate.swift */; };
179181
FABF3CF82B822F120080EAC9 /* CustomSureAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = FABF3CF72B822F120080EAC9 /* CustomSureAlert.swift */; };
180182
FABF3CFD2B8607860080EAC9 /* MeasureWidthContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FABF3CFC2B8607860080EAC9 /* MeasureWidthContainer.swift */; };
@@ -436,13 +438,15 @@
436438
C96303080D26026265099E0E /* Pods-GoInfoGame.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame.release.xcconfig"; path = "Target Support Files/Pods-GoInfoGame/Pods-GoInfoGame.release.xcconfig"; sourceTree = "<group>"; };
437439
D76D8E22AC705A38AFEA78B1 /* Pods-GoInfoGame-GoInfoGameUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame-GoInfoGameUITests.debug.xcconfig"; path = "Target Support Files/Pods-GoInfoGame-GoInfoGameUITests/Pods-GoInfoGame-GoInfoGameUITests.debug.xcconfig"; sourceTree = "<group>"; };
438440
F008D431593E568E75C48C84 /* Pods-GoInfoGame.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame.debug.xcconfig"; path = "Target Support Files/Pods-GoInfoGame/Pods-GoInfoGame.debug.xcconfig"; sourceTree = "<group>"; };
441+
FA1992EC2BB1A78C003B4719 /* KeychainManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainManager.swift; sourceTree = "<group>"; };
439442
FA5853C02B21F17F00301CDA /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = "<group>"; };
440443
FA87A80F2B68142F000A6BEA /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = "<group>"; };
441444
FA87A8112B6AC019000A6BEA /* StepsRampTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsRampTests.swift; sourceTree = "<group>"; };
442445
FA87A8142B6AC4E2000A6BEA /* BusStopLitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BusStopLitTests.swift; sourceTree = "<group>"; };
443446
FA87A8162B6AC885000A6BEA /* StepsInclineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsInclineTests.swift; sourceTree = "<group>"; };
444447
FA87A8182B6B01A4000A6BEA /* HandRailTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandRailTests.swift; sourceTree = "<group>"; };
445448
FA87A81A2B6B042E000A6BEA /* SideWalkWidthTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideWalkWidthTests.swift; sourceTree = "<group>"; };
449+
FA9FE2D72BAC75390036F618 /* OAuthViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthViewController.swift; sourceTree = "<group>"; };
446450
FABF3CF32B7419BB0080EAC9 /* LocationManagerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManagerDelegate.swift; sourceTree = "<group>"; };
447451
FABF3CF72B822F120080EAC9 /* CustomSureAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSureAlert.swift; sourceTree = "<group>"; };
448452
FABF3CFC2B8607860080EAC9 /* MeasureWidthContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeasureWidthContainer.swift; sourceTree = "<group>"; };
@@ -552,6 +556,7 @@
552556
0536DD912B0BD58800B04C4B /* OAuthService.swift */,
553557
0536DD932B0BD59900B04C4B /* OAuthError.swift */,
554558
0536DD982B0BDBFE00B04C4B /* OAuthManager.swift */,
559+
FA9FE2D72BAC75390036F618 /* OAuthViewController.swift */,
555560
);
556561
path = OAuth;
557562
sourceTree = "<group>";
@@ -1168,6 +1173,7 @@
11681173
FAC9E60E2B04F9C800E2C608 /* OverpassRequestManager.swift */,
11691174
FAC9E6102B06811300E2C608 /* LocationManager.swift */,
11701175
FABF3CF32B7419BB0080EAC9 /* LocationManagerDelegate.swift */,
1176+
FA1992EC2BB1A78C003B4719 /* KeychainManager.swift */,
11711177
05CB71DD2B0FAEC200DED821 /* UI */,
11721178
05CB71DE2B0FAFAA00DED821 /* Bridges */,
11731179
058EADD92B10E02E0017E259 /* DataBase */,
@@ -1747,6 +1753,8 @@
17471753
97439F7A2B87447400DA43E1 /* CrossingKerbHeight.swift in Sources */,
17481754
971F9FE12B847358005397CC /* CrossingIsland.swift in Sources */,
17491755
970D5BD12B62B61300C20BE7 /* MapViewController.swift in Sources */,
1756+
FA9FE2D82BAC75390036F618 /* OAuthViewController.swift in Sources */,
1757+
FA1992ED2BB1A78C003B4719 /* KeychainManager.swift in Sources */,
17501758
0536DD972B0BD95100B04C4B /* URLSession+Extension.swift in Sources */,
17511759
973FC04C2B5A5F5F00878269 /* RadioItem.swift in Sources */,
17521760
A495DF2D2B6A190400478E44 /* CustomMapView.swift in Sources */,
@@ -2255,6 +2263,7 @@
22552263
DEVELOPMENT_TEAM = NPCMG529DV;
22562264
GENERATE_INFOPLIST_FILE = YES;
22572265
INFOPLIST_FILE = GoInfoGame/Info.plist;
2266+
INFOPLIST_KEY_NSCameraUsageDescription = "This app requires to access your camera to measure width of sidewalk";
22582267
INFOPLIST_KEY_NSFileProviderDomainUsageDescription = "";
22592268
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "We need your location";
22602269
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "We need your location";
@@ -2291,6 +2300,7 @@
22912300
DEVELOPMENT_TEAM = NPCMG529DV;
22922301
GENERATE_INFOPLIST_FILE = YES;
22932302
INFOPLIST_FILE = GoInfoGame/Info.plist;
2303+
INFOPLIST_KEY_NSCameraUsageDescription = "This app requires to access your camera to measure width of sidewalk";
22942304
INFOPLIST_KEY_NSFileProviderDomainUsageDescription = "";
22952305
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "We need your location";
22962306
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "We need your location";
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<device id="retina6_12" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
57
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<scenes>
@@ -11,15 +14,34 @@
1114
<objects>
1215
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
1316
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
17+
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
1518
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16-
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
19+
<subviews>
20+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="pedestrian_crossing" translatesAutoresizingMaskIntoConstraints="NO" id="Mv8-nM-gQ0">
21+
<rect key="frame" x="76" y="322" width="241" height="208"/>
22+
<constraints>
23+
<constraint firstAttribute="height" constant="208" id="JHI-5O-ChS"/>
24+
</constraints>
25+
</imageView>
26+
</subviews>
1727
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
28+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
29+
<constraints>
30+
<constraint firstItem="Mv8-nM-gQ0" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="7XI-7g-6QQ"/>
31+
<constraint firstItem="Mv8-nM-gQ0" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="NtR-pt-oLV"/>
32+
<constraint firstItem="Mv8-nM-gQ0" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="76" id="YqX-XD-GRe"/>
33+
</constraints>
1834
</view>
1935
</viewController>
2036
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
2137
</objects>
22-
<point key="canvasLocation" x="53" y="375"/>
38+
<point key="canvasLocation" x="52.671755725190835" y="374.64788732394368"/>
2339
</scene>
2440
</scenes>
41+
<resources>
42+
<image name="pedestrian_crossing" width="128" height="128"/>
43+
<systemColor name="systemBackgroundColor">
44+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
45+
</systemColor>
46+
</resources>
2547
</document>

GoInfoGame/GoInfoGame/Info.plist

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>NSCameraUsageDescription</key>
6-
<string>This app requires to access your camera to measure width of sidewalk</string>
75
<key>CFBundleURLTypes</key>
86
<array>
97
<dict>
108
<key>CFBundleTypeRole</key>
119
<string>Editor</string>
1210
<key>CFBundleURLName</key>
13-
<string>com.taskar.GoInfoGame</string>
11+
<string>com.vindago.goinfogame</string>
1412
<key>CFBundleURLSchemes</key>
1513
<array>
1614
<string>goinfogame</string>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// KeychainManager.swift
3+
// GoInfoGame
4+
//
5+
// Created by Achyut Kumar M on 25/03/24.
6+
//
7+
8+
9+
import SwiftUI
10+
import Security
11+
12+
struct KeychainManager {
13+
14+
static func save(key: String, data: String) -> Bool {
15+
guard let data = data.data(using: .utf8) else { return false }
16+
17+
let query: [String: Any] = [
18+
kSecClass as String: kSecClassGenericPassword,
19+
kSecAttrService as String: key,
20+
kSecValueData as String: data
21+
]
22+
23+
SecItemDelete(query as CFDictionary)
24+
25+
let status = SecItemAdd(query as CFDictionary, nil)
26+
return status == errSecSuccess
27+
}
28+
29+
static func load(key: String) -> String? {
30+
let query: [String: Any] = [
31+
kSecClass as String: kSecClassGenericPassword,
32+
kSecAttrService as String: key,
33+
kSecMatchLimit as String: kSecMatchLimitOne,
34+
kSecReturnData as String: kCFBooleanTrue!
35+
]
36+
37+
var dataTypeRef: AnyObject?
38+
let status = SecItemCopyMatching(query as CFDictionary, &dataTypeRef)
39+
40+
guard status == errSecSuccess,
41+
let data = dataTypeRef as? Data,
42+
let result = String(data: data, encoding: .utf8) else {
43+
return nil
44+
}
45+
46+
return result
47+
}
48+
49+
static func delete(key: String) -> Bool {
50+
let query: [String: Any] = [
51+
kSecClass as String: kSecClassGenericPassword,
52+
kSecAttrService as String: key
53+
]
54+
55+
let status = SecItemDelete(query as CFDictionary)
56+
return status == errSecSuccess
57+
}
58+
}

GoInfoGame/GoInfoGame/Network/URLSession+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension URLSession: NetworkRequest {
2121
} else if let data = data {
2222
completion(.success(data))
2323
} else {
24-
let unknownError = NSError(domain: "com.taskar.GoInfoGame", code: 0, userInfo: nil)
24+
let unknownError = NSError(domain: "com.vindago.goinfogame", code: 0, userInfo: nil)
2525
completion(.failure(unknownError))
2626
}
2727
}

GoInfoGame/GoInfoGame/SceneDelegate.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
4747
// to restore the scene back to its current state.
4848
}
4949

50+
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
51+
print("Open contexts called")
52+
// gaurd and get the first URL
53+
guard let url = URLContexts.first?.url else { return }
54+
55+
NotificationCenter.default.post(name: .init("HandleOAuthRedirect"), object: url)
56+
57+
58+
}
5059

5160
}
5261

GoInfoGame/GoInfoGame/UI/Login/LoginViewController.swift

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,50 @@
88
import UIKit
99
import SwiftUI
1010

11-
class LoginViewController: UIViewController {
12-
13-
override func viewDidLoad() {
14-
super.viewDidLoad()
15-
16-
// Do any additional setup after loading the view.
17-
}
18-
19-
@IBAction func loginMethod(_ sender: Any?) {
20-
21-
if OAuthManager.shared.isAuthorized() {
22-
// User is already authorized, fetch user details or perform other actions
23-
OAuthManager.shared.getUserDetails { userDetails in
24-
// Handle user details or perform other actions
25-
}
26-
} else {
27-
// User is not authorized, request access from the user
28-
OAuthManager.shared.requestAccessFromUser(withVC: self) { [weak self] result in
29-
self?.handleAuthorizationResult(result)
30-
}
31-
}
32-
33-
34-
}
35-
36-
// Handle the result of the authorization request
37-
private func handleAuthorizationResult(_ result: Result<Void, Error>) {
38-
switch result {
39-
case .success:
40-
// Authorization successful, fetch user details or perform other actions
41-
OAuthManager.shared.getUserDetails { userDetails in
42-
// Handle user details or perform other actions
43-
}
44-
case .failure(let error):
45-
// Authorization failed, handle the error
46-
print("Authorization failed with error: \(error.localizedDescription)")
47-
}
48-
}
49-
50-
@IBAction func skipButtonTapped(_ sender: Any) {
51-
@AppStorage("isOnboarding") var isOnboarding: Bool = true
52-
let contentView = isOnboarding ? AnyView( OnboardingView()) : AnyView(MapView())
53-
let childView = UIHostingController(rootView: contentView)
54-
self.navigationController?.pushViewController(childView, animated: false)
55-
}
56-
57-
@IBAction func viewQuestsTapped(_ sender: Any) {
58-
let childView = UIHostingController(rootView: QuestsListUIView())
59-
self.navigationController?.pushViewController(childView, animated: false)
60-
61-
}
62-
}
11+
//class LoginViewController: UIViewController {
12+
//
13+
// override func viewDidLoad() {
14+
// super.viewDidLoad()
15+
//
16+
// // Do any additional setup after loading the view.
17+
// }
18+
//
19+
// @IBAction func loginMethod(_ sender: Any?) {
20+
//
21+
//
22+
// // User is not authorized, request access from the user
23+
// OAuthManager.shared.requestAccessFromUser(withVC: self) { [weak self] result in
24+
// self?.handleAuthorizationResult(result)
25+
// }
26+
//
27+
//
28+
//
29+
// }
30+
//
31+
// // Handle the result of the authorization request
32+
// private func handleAuthorizationResult(_ result: Result<Void, Error>) {
33+
// switch result {
34+
// case .success:
35+
// // Authorization successful, fetch user details or perform other actions
36+
// OAuthManager.shared.getUserDetails { userDetails in
37+
// // Handle user details or perform other actions
38+
// }
39+
// case .failure(let error):
40+
// // Authorization failed, handle the error
41+
// print("Authorization failed with error: \(error.localizedDescription)")
42+
// }
43+
// }
44+
//
45+
// @IBAction func skipButtonTapped(_ sender: Any) {
46+
// @AppStorage("isOnboarding") var isOnboarding: Bool = true
47+
// let contentView = isOnboarding ? AnyView( OnboardingView()) : AnyView(MapView())
48+
// let childView = UIHostingController(rootView: contentView)
49+
// self.navigationController?.pushViewController(childView, animated: false)
50+
// }
51+
//
52+
// @IBAction func viewQuestsTapped(_ sender: Any) {
53+
// let childView = UIHostingController(rootView: QuestsListUIView())
54+
// self.navigationController?.pushViewController(childView, animated: false)
55+
//
56+
// }
57+
//}

0 commit comments

Comments
 (0)