Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#44-homeViewUI
Browse files Browse the repository at this point in the history
  • Loading branch information
boyeon0119 authored Jan 12, 2024
2 parents def8aef + 324c441 commit 7498fc9
Show file tree
Hide file tree
Showing 20 changed files with 327 additions and 147 deletions.
20 changes: 20 additions & 0 deletions HMH_iOS/HMH_iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
0B000CED2B4D9DA800AEC582 /* ApprovePermisionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */; };
0B000CF12B4DA30F00AEC582 /* AppSelectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */; };
0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */; };
0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */; };
0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */; };
0B2C2D3B2B443BE90023CCFA /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D3A2B443BE90023CCFA /* Image.swift */; };
0B2C2D412B4572240023CCFA /* HMHSelectButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */; };
0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B50F9CA2B369813000C5046 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -61,6 +63,7 @@
17CF9FC92B4EE964000DD09C /* AppUsingProgressViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FC82B4EE964000DD09C /* AppUsingProgressViewCell.swift */; };
17CF9FCF2B4F1A91000DD09C /* MyGoalTimeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FCE2B4F1A91000DD09C /* MyGoalTimeCell.swift */; };
17CF9FD12B4F31C0000DD09C /* BlackHoleImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17CF9FD02B4F31C0000DD09C /* BlackHoleImageCell.swift */; };
363863BA2B50782E000FE5E7 /* CreateChallengeResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 363863B92B50782E000FE5E7 /* CreateChallengeResponseDTO.swift */; };
363863BD2B5129F2000FE5E7 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 363863BC2B5129F2000FE5E7 /* Lottie */; };
364923652B4F4FB800BF7ACA /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923642B4F4FB800BF7ACA /* Config.swift */; };
364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 364923672B4F513600BF7ACA /* BaseTargetType.swift */; };
Expand Down Expand Up @@ -179,6 +182,8 @@
0B000CEC2B4D9DA800AEC582 /* ApprovePermisionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApprovePermisionController.swift; sourceTree = "<group>"; };
0B000CF02B4DA30F00AEC582 /* AppSelectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSelectViewController.swift; sourceTree = "<group>"; };
0B00353F2B43D64D00DA140C /* HMHNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHNavigationBar.swift; sourceTree = "<group>"; };
0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManager.swift; sourceTree = "<group>"; };
0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultWrapper.swift; sourceTree = "<group>"; };
0B2C2D3A2B443BE90023CCFA /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = "<group>"; };
0B2C2D402B4572240023CCFA /* HMHSelectButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMHSelectButton.swift; sourceTree = "<group>"; };
0B50F9C72B369813000C5046 /* HMH_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMH_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -230,6 +235,7 @@
17CF9FC82B4EE964000DD09C /* AppUsingProgressViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUsingProgressViewCell.swift; sourceTree = "<group>"; };
17CF9FCE2B4F1A91000DD09C /* MyGoalTimeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyGoalTimeCell.swift; sourceTree = "<group>"; };
17CF9FD02B4F31C0000DD09C /* BlackHoleImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlackHoleImageCell.swift; sourceTree = "<group>"; };
363863B92B50782E000FE5E7 /* CreateChallengeResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateChallengeResponseDTO.swift; sourceTree = "<group>"; };
364923612B4F4E7D00BF7ACA /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
364923642B4F4FB800BF7ACA /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
364923672B4F513600BF7ACA /* BaseTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTargetType.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -343,6 +349,15 @@
path = ViewControllers;
sourceTree = "<group>";
};
0B17D3E92B5104B900CFA3B7 /* User */ = {
isa = PBXGroup;
children = (
0B17D3EA2B5104E000CFA3B7 /* UserManager.swift */,
0B17D3EC2B5108D200CFA3B7 /* UserDefaultWrapper.swift */,
);
path = User;
sourceTree = "<group>";
};
0B2C2D3C2B4559AE0023CCFA /* Onboarding */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -494,6 +509,7 @@
0B8A89982B369CF800688BA6 /* SupportingFiles */ = {
isa = PBXGroup;
children = (
0B17D3E92B5104B900CFA3B7 /* User */,
3666C8782B45F4D900564874 /* AppBlock */,
0B8A89992B369D0B00688BA6 /* Base */,
);
Expand Down Expand Up @@ -829,6 +845,7 @@
isa = PBXGroup;
children = (
3649239F2B505F2000BF7ACA /* CreateChallengeRequestDTO.swift */,
363863B92B50782E000FE5E7 /* CreateChallengeResponseDTO.swift */,
);
path = ChallengeModel;
sourceTree = "<group>";
Expand Down Expand Up @@ -1088,6 +1105,7 @@
0B8A89AF2B369E4300688BA6 /* HomeModel.swift in Sources */,
3666C89F2B485C8F00564874 /* DateCollectionViewCell.swift in Sources */,
3666C87A2B45F4F900564874 /* SelectedBlocker.swift in Sources */,
0B17D3ED2B5108D200CFA3B7 /* UserDefaultWrapper.swift in Sources */,
0BC0EBD42B494459003EF5D4 /* OnboardingSwipeView.swift in Sources */,
17314F9B2B4C485B0089A551 /* UserPointHeaderView.swift in Sources */,
364923862B4FDCBD00BF7ACA /* NetworkProvider.swift in Sources */,
Expand All @@ -1102,6 +1120,7 @@
174AF4942B447B5500450D07 /* MyPageViewController.swift in Sources */,
0BA193B42B4D089C007E3F9C /* TimeSurveyViewController.swift in Sources */,
36A3D9B82B3EBC3B007EA272 /* UILabel+.swift in Sources */,
0B17D3EB2B5104E000CFA3B7 /* UserManager.swift in Sources */,
0B50F9CB2B369813000C5046 /* AppDelegate.swift in Sources */,
0B7817522B4BE0280078E925 /* ProgressBarManager.swift in Sources */,
0B8A89C42B369FA000688BA6 /* F.swift in Sources */,
Expand Down Expand Up @@ -1165,6 +1184,7 @@
3666C89B2B48516500564874 /* ChallengeView.swift in Sources */,
364923682B4F513600BF7ACA /* BaseTargetType.swift in Sources */,
3666C88D2B471B1D00564874 /* UIImage+.swift in Sources */,
363863BA2B50782E000FE5E7 /* CreateChallengeResponseDTO.swift in Sources */,
3666C87C2B45F50F00564874 /* BlockingApplicationModel.swift in Sources */,
0B0035402B43D64D00DA140C /* HMHNavigationBar.swift in Sources */,
0BA193B22B4CE908007E3F9C /* SurveyView.swift in Sources */,
Expand Down
26 changes: 24 additions & 2 deletions HMH_iOS/HMH_iOS/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@
//

import UIKit
import AuthenticationServices

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func sceneDidBecomeActive(_ scene: UIScene) {
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: "000340.8d411a5d11d84e8da0c22ef43dce465a.1657" ?? "") { (credentialState, error) in
switch credentialState {
case .authorized:
print("authorized")
case .revoked:
print("revoked")
case .notFound:
print("notFound")
default:
break
}
}
}

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
Expand All @@ -24,7 +40,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
DispatchQueue.main.async{
showTabBarViewController()
if UserManager.shared.hasAccessToken {
//애플 로그인 토큰 리프레쉬 로직. 성공한다면 엑세스와 리프레시 토큰 업데이트 그러면서 이동
// 토큰 리프레시가 실패 한다. 로그인 컨트롤러로 바로 이동.
showTabBarViewController()
} else {
showLoginViewController()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// UserDefaultWrapper.swift
// HMH_iOS
//
// Created by Seonwoo Kim on 1/12/24.
//

import Foundation

@propertyWrapper
struct UserDefaultWrapper<T> {
var wrappedValue: T? {
get {
return UserDefaults.standard.object(forKey: self.key) as? T
}

set {
if newValue == nil {
UserDefaults.standard.removeObject(forKey: key)
} else { UserDefaults.standard.setValue(newValue, forKey: key) }
}
}

private let key: String

init(key: String) {
self.key = key
}
}
90 changes: 90 additions & 0 deletions HMH_iOS/HMH_iOS/Global/SupportingFiles/User/UserManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// UserManager.swift
// HMH_iOS
//
// Created by Seonwoo Kim on 1/12/24.
//

import Foundation

final class UserManager {
static let shared = UserManager()

@UserDefaultWrapper<String>(key: "accessToken") private(set) var accessToken
@UserDefaultWrapper<String>(key: "refreshToken") private(set) var refreshToken
@UserDefaultWrapper<String>(key: "AppleToken") private(set) var appleToken
@UserDefaultWrapper<String>(key: "userIdentifier") private(set) var appleUserIdentifier
@UserDefaultWrapper<String>(key: "familyName") private(set) var familyName
@UserDefaultWrapper<String>(key: "givenName") private(set) var givenName
@UserDefaultWrapper<String>(key: "fullName") private(set) var fullName
@UserDefaultWrapper<Int>(key: "userId") private(set) var userId

var hasAccessToken: Bool { return self.accessToken != nil }
var getAccessToken: String { return self.accessToken ?? "" }
var getRefreshToken: String { return self.refreshToken ?? "" }
var getAppleToken: String { return self.appleToken ?? "" }
var getUserIdentifier: String { return self.appleUserIdentifier ?? "" }
var getUserName: String { return self.familyName ?? "" }
var getGivenName: String { return self.givenName ?? "" }
var getFullName: String { return self.fullName ?? "" }
var getUserId: Int { return self.userId ?? 0}

var haveFullName: Bool {
if fullName == "" {
return false
} else if fullName == nil {
return false
} else {
return true
}
}

private init() {}
}

extension UserManager {
func updateToken(_ accessToken: String, _ refreshToken: String) {
self.accessToken = accessToken
self.refreshToken = refreshToken
}

func updateAppleToken(_ appleToken: String) {
self.appleToken = appleToken
}

func updateUserIdentifier(_ appleUserIdentifier: String) {
self.appleUserIdentifier = appleUserIdentifier
}

func updateUserName(_ givenName: String, _ familyName: String) {
self.givenName = givenName
self.familyName = familyName
self.fullName = familyName + givenName
}

func updateUserId(_ userId: Int) {
self.userId = userId
}

func setUserIdForApple(userId: String) {
self.appleUserIdentifier = appleUserIdentifier
}

func clearAll() {
self.accessToken = nil
self.refreshToken = nil
self.appleToken = nil
self.appleUserIdentifier = nil
self.familyName = nil
self.givenName = nil
self.fullName = nil
self.userId = nil
}

func clearData() {
self.accessToken = nil
self.refreshToken = nil
self.appleToken = nil
self.appleUserIdentifier = nil
}
}
4 changes: 4 additions & 0 deletions HMH_iOS/HMH_iOS/HMH_iOS.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
<key>com.apple.developer.family-controls</key>
<true/>
</dict>
Expand Down
5 changes: 5 additions & 0 deletions HMH_iOS/HMH_iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@
</array>
</dict>
</dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
1 change: 1 addition & 0 deletions HMH_iOS/HMH_iOS/Network/Base/AuthInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ final class AuthInterceptor: RequestInterceptor {
}

func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) {
print("retry")
}
}
1 change: 0 additions & 1 deletion HMH_iOS/HMH_iOS/Network/Base/BaseModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ struct BaseResponse<T: Decodable>: Decodable {
var message: String?
var data: T?
}

5 changes: 0 additions & 5 deletions HMH_iOS/HMH_iOS/Network/Base/BaseTargetType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import Foundation
import Moya



protocol BaseTargetType: TargetType {}

typealias Parameters = [String: String]
Expand All @@ -32,7 +30,4 @@ extension BaseTargetType {
return Data()
}

var validationType: ValidationType {
return .successCodes
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

import Foundation

class CreateChallengeRequestDTO: Request {

struct CreateChallengeRequestDTO: Codable {
let period, goalTime: Int
let apps: [App]
}

struct App: Codable {
let appCode: String
let appGoalTime: Int
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// CreateChallengeResponseDTO.swift
// HMH_iOS
//
// Created by 지희의 MAC on 1/12/24.
//

import Foundation

struct CreateChallengeResponseDTO: Codable {
let challengeID: Int

enum CodingKeys: String, CodingKey {
case challengeID = "challengeId"

}
}
6 changes: 3 additions & 3 deletions HMH_iOS/HMH_iOS/Network/Foundation/APIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ struct APIConstants{
static let contentType = "Content-Type"
static let applicationJSON = "application/json"
static let auth = "Authorization"
static let accessToken = "" // TO-DO: AccessToken
static let appleAccessToken = ""
static let accessToken = "Bearer " // TO-DO: AccessToken
static let appleAccessToken = ""
static let OS = "OS"
static let iOS = "iOS"
}

extension APIConstants{
static let hasSocialTokenHeader = [contentType: applicationJSON,
auth : accessToken]
auth : appleAccessToken]
static let hasTokenHeader = [contentType: applicationJSON,
OS: iOS,
auth : accessToken]
Expand Down
1 change: 1 addition & 0 deletions HMH_iOS/HMH_iOS/Network/Foundation/NetworkHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ struct NetworkHelper {
default: return .networkFail
}
}

}
Loading

0 comments on commit 7498fc9

Please sign in to comment.