Skip to content

Commit

Permalink
Merge pull request #227 from teamterning/Refactor/#168
Browse files Browse the repository at this point in the history
[Fix] #168 - ์นด์นด์˜ค ๋กœ๊ทธ์ธ์—์„œ ์นด์นด์˜ค ์•ฑ์ด ์ž‘๋™ ์•ˆ๋˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • Loading branch information
thingineeer authored Dec 5, 2024
2 parents 19bb55a + f195dbd commit f8e5e93
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 25 deletions.
4 changes: 4 additions & 0 deletions Terning-iOS/Terning-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,7 @@
};
71E3C3DE2C22BAF50026C4DD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B8F503372C749309000D2A22 /* Config.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand All @@ -1746,6 +1747,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UIUserInterfaceStyle = Light;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1770,6 +1772,7 @@
};
71E3C3DF2C22BAF50026C4DD /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B8F503372C749309000D2A22 /* Config.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand All @@ -1786,6 +1789,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UIUserInterfaceStyle = Light;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
18 changes: 14 additions & 4 deletions Terning-iOS/Terning-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>CFBundleDisplayName</key>
<string>terning</string>
<key>CFBundleShortVersionString</key>
<string>1.0.4</string>
<key>CFBundleVersion</key>
<string>2024.1119.2145</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -23,13 +25,19 @@
</array>
<key>KAKAO_NATIVE_APP_KEY</key>
<string>$(KAKAO_NATIVE_APP_KEY)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
<string>kakaotalk</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UIAppFonts</key>
<array>
<string>Pretendard-Light.otf</string>
Expand All @@ -54,5 +62,7 @@
</array>
</dict>
</dict>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
</dict>
</plist>
19 changes: 19 additions & 0 deletions Terning-iOS/Terning-iOS/Resource/Utils/setImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import SwiftUI
import Kingfisher

public extension UIImageView {
Expand Down Expand Up @@ -52,3 +53,21 @@ public extension UIImageView {
)
}
}

struct RemoteImageView: View {
let urlString: String

var body: some View {
KFImage(URL(string: urlString))
.placeholder {
Image("img_placeholder") // ๋กœ๋“œ ์ค‘์— ํ‘œ์‹œํ•  placeholder
.resizable()
.scaledToFit()
}
.resizable()
.fade(duration: 0.5)
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.scaledToFit()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,26 @@ import Moya
final class AuthInterceptor: RequestInterceptor {

static let shared = AuthInterceptor()

private var retryCount = 0
private let maxRetryCount = 3


private init() {}

func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result<URLRequest, Error>) -> Void) {
var urlRequest = urlRequest

guard urlRequest.url?.absoluteString.hasPrefix(Config.baseURL) == true,
let accessToken = UserManager.shared.accessToken,
let refreshToken = UserManager.shared.refreshToken
let accessToken = UserManager.shared.accessToken
else {
completion(.success(urlRequest))
return
}

urlRequest.setValue(accessToken, forHTTPHeaderField: "accessToken")
urlRequest.setValue(refreshToken, forHTTPHeaderField: "refreshToken")
var urlRequest = urlRequest
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
print("adator ์ ์šฉ \(urlRequest.headers)")
completion(.success(urlRequest))
}

func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -> Void) {
print("retry ์ง„์ž…")
guard retryCount < maxRetryCount,
let response = request.task?.response as? HTTPURLResponse,
guard let response = request.task?.response as? HTTPURLResponse,
response.statusCode == 401,
let pathComponents = request.request?.url?.pathComponents,
!pathComponents.contains("getNewToken")
Expand All @@ -54,7 +47,6 @@ final class AuthInterceptor: RequestInterceptor {
switch result {
case .success:
print("Retry-ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ ์„ฑ๊ณต")
self.retryCount += 1
completion(.retry)
case .failure(let error):
// ์„ธ์…˜ ๋งŒ๋ฃŒ -> ๋กœ๊ทธ์ธ ํ™”๋ฉด์œผ๋กœ ์ „ํ™˜
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Moya

struct Providers {
static let calendarProvider = MoyaProvider<CalendarTargetType>(withAuth: true)
static let authProvider = MoyaProvider<AuthTargetType>(withAuth: true)
static let authProvider = MoyaProvider<AuthTargetType>(withAuth: false)
static let homeProvider = MoyaProvider<HomeTargetType>(withAuth: true)
static let myPageProvider = MoyaProvider<MyPageTargetType>(withAuth: true)
static let scrapsProvider = MoyaProvider<ScrapsTargetType>(withAuth: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension AnnouncementsTargetType: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension CalendarTargetType: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extension FiltersTargetType: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension HomeTargetType: TargetType {
}

var headers: [String: String]? {
return ["Content-Type": "application/json", "Authorization": "Bearer \(Config.accessToken)"]
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extension MyPageTargetType: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension ScrapsTargetType: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension SearchTargetType: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
Expand Down

0 comments on commit f8e5e93

Please sign in to comment.