Skip to content

Commit

Permalink
[Feat/#118] 토큰 업데이트 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HELLOHIDI committed Nov 24, 2024
1 parent afcebd1 commit a27c137
Show file tree
Hide file tree
Showing 20 changed files with 293 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_baseline-apple.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ri_kakao-talk-fill.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Networks

typealias NavigationRoutableType = NavigationRoutable & ObservableObjectSettable

Expand All @@ -28,5 +29,5 @@ final class DIContainer: ObservableObject {

extension DIContainer {
static let `default` = DIContainer(service: HMHService())
static let stub = DIContainer(service: StubHMHSerivce())
static let stub = DIContainer(service: StubHMHService())
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ import KakaoSDKAuth

@main
struct NetworkTestApp: App {
let kakaoAPIKey = Config.appKey
init() {
// print(Networks.Config.baseURL)
KakaoSDK.initSDK(appKey: kakaoAPIKey)
}

@StateObject var container = DIContainer.default

var body: some Scene {
WindowGroup {
NetworkTestHomeView()
TokenTestHomeView()
.environmentObject(container)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct NetworkTestHomeView: View {
Spacer()
ServiceButton(
imageResource: .auth,
backgroundColor: .clear,
title: "Auth") {
container.navigationRouter.push(to: .auth)
}
Expand All @@ -61,6 +62,7 @@ struct NetworkTestHomeView: View {

ServiceButton(
imageResource: .challenge,
backgroundColor: .clear,
title: "Challenge") {
container.navigationRouter.push(to: .challenge)
}
Expand All @@ -77,6 +79,7 @@ struct NetworkTestHomeView: View {

ServiceButton(
imageResource: .point,
backgroundColor: .clear,
title: "Point") {
container.navigationRouter.push(to: .point)
}
Expand All @@ -86,6 +89,7 @@ struct NetworkTestHomeView: View {

ServiceButton(
imageResource: .user,
backgroundColor: .clear,
title: "User") {
container.navigationRouter.push(to: .user)
}
Expand All @@ -96,46 +100,13 @@ struct NetworkTestHomeView: View {
Spacer()
}
.padding(.horizontal, 30)
.navigationBarBackButtonHidden()
.setHMHNavigation()
.background(Color(asset: NetworksDemoAsset.blackground))
}
}
}

fileprivate struct ServiceButton : View {

let imageResource: ImageResource
let title: String
let action: () -> Void

fileprivate var body: some View {
Button {
action()
} label: {

VStack {
Image(imageResource)
.resizable()
.scaledToFit()
.frame(width: 75, height: 75)
Text(title)
.foregroundStyle(.white)
.bold()
.padding(.top, 7)

}
.frame(width: 145, height: 145)
.background(.clear)
.multilineTextAlignment(.center)
.shadow(radius: 2)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(.white), lineWidth: 1)
)

}
}
}

#Preview {
return NetworkTestHomeView()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// ServiceButton.swift
// NetworksDemo
//
// Created by 류희재 on 11/24/24.
// Copyright © 2024 HMH-iOS. All rights reserved.
//

import SwiftUI
import Core

struct ServiceButton : View {

let imageResource: ImageResource
let backgroundColor: Color
let title: String
let action: () -> Void

internal var body: some View {
Button {
action()
} label: {

VStack {
Image(imageResource)
.resizable()
.scaledToFit()
.frame(width: 75, height: 75)
Text(title)
.foregroundStyle(.white)
.bold()
.padding(.top, 7)

}
.frame(width: 145, height: 145)
.background(backgroundColor)
.multilineTextAlignment(.center)
.shadow(radius: 2)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(.white), lineWidth: 1)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class AuthServiceViewModel: ObservableObject {
self?.state.resultText[index] = "❌ 실패"
}
}) { [weak self] result in
UserManager.shared.accessToken = result.token.accessToken
UserManager.shared.refreshToken = result.token.refreshToken
self?.state.networkLoggingText = "\(result)"
self?.state.resultText[index] = "✅ 성공"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ChallengeServiceTestView.swift
// ChallengeServiceTestView.swift
// NetworksDemo
//
// Created by 류희재 on 11/23/24.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// TokenTestView.swift
// NetworksDemo
//
// Created by 류희재 on 11/24/24.
// Copyright © 2024 HMH-iOS. All rights reserved.
//

import SwiftUI
import Networks
import Core

//디버그(Debug) 모드와 릴리즈(Release) 모드에서 Xcode의 프리뷰(Preview) 활성화 여부 다름 So QA를 다시 debug로 변경

struct TokenTestHomeView: View {
@EnvironmentObject var container: DIContainer
private let cancelBag = CancelBag()

var body: some View {
NavigationStack(path: $container.navigationRouter.destinations) {
VStack(alignment: .center) {
Spacer()
.frame(height: 25)

Image(.main)
.resizable()
.frame(width: 86, height: 86)

Spacer()
.frame(height: 20)

Text("HMH-iOS\nNetwork Demo App")
.foregroundStyle(.white)
.frame(alignment: .center)
.font(.title)
.bold()
.multilineTextAlignment(.center)

Spacer()
.frame(height: 20)

Text("테스트를 하기 전, idToken부터 받으세요!")
.foregroundStyle(.gray)
.frame(alignment: .center)
.font(.body)
.bold()
.multilineTextAlignment(.center)

Spacer()
.frame(height: 60)

HStack {
Spacer()
ServiceButton(
imageResource: .kakaoLogo,
backgroundColor: .yellow,
title: "KAKAO") {
let oauthKakaoService = OAuthKakaoService()
oauthKakaoService.authorize()
.sink(receiveCompletion: { _ in

}, receiveValue: { token in
UserManager.shared.accessToken = token
container.navigationRouter.push(to: .home)
})
.store(in: cancelBag)

}

Spacer()
.frame(width: 25)

ServiceButton(
imageResource: .appleLogo,
backgroundColor: .white,
title: "APPLE") {
container.navigationRouter.push(to: .home)
}

Spacer()
}
Spacer()
}
.padding(.horizontal, 30)
.setHMHNavigation()
.background(Color(asset: NetworksDemoAsset.blackground))
}
}
}

#Preview {
return TokenTestHomeView()
.environmentObject(DIContainer.stub)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public enum NetworksDemoAsset {
public static let challenge = NetworksDemoImages(name: "Challenge")
public static let point = NetworksDemoImages(name: "Point")
public static let user = NetworksDemoImages(name: "User")
public static let appleLogo = NetworksDemoImages(name: "appleLogo")
public static let blackground = NetworksDemoColors(name: "blackground")
public static let bluePurpleButton = NetworksDemoColors(name: "blue purple_button")
public static let kakaoLogo = NetworksDemoImages(name: "kakaoLogo")
public static let main = NetworksDemoImages(name: "main")
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ public enum Config {
return dict
}()

static let baseURL: String = "http://3.36.221.133"

// static public let baseURL: String = {
// guard let key = Config.infoDictionary[Keys.Plist.baseURL] as? String else {
// fatalError("Base URL is not set in plist for this configuration.")
// }
// return key
// }()
static public let baseURL: String = {
guard let key = Config.infoDictionary[Keys.Plist.baseURL] as? String else {
fatalError("Base URL is not set in plist for this configuration.")
}
return key
}()

static public let appKey: String = {
guard let key = Config.infoDictionary[Keys.Plist.appKey] as? String else {
fatalError("Base URL is not set in plist for this configuration.")
fatalError("AppKey is not set in plist for this configuration.")
}
return key
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
//

import Foundation
import Networks


protocol HMHServiceType {
public protocol HMHServiceType {
var authService: AuthServiceType { get }
var challengeService: ChallengeServiceType { get }
var pointService: PointServiceType { get }
var userService: UserServiceType { get }
}

final class HMHService: HMHServiceType {
var authService: AuthServiceType = AuthService()
var challengeService: ChallengeServiceType = ChallengeService()
var pointService: PointServiceType = PointService()
var userService: UserServiceType = UserService()
final public class HMHService: HMHServiceType {
public init() {}
public var authService: AuthServiceType = AuthService()
public var challengeService: ChallengeServiceType = ChallengeService()
public var pointService: PointServiceType = PointService()
public var userService: UserServiceType = UserService()
}

final class StubHMHSerivce: HMHServiceType {
var authService: AuthServiceType = StubAuthService()
var challengeService: ChallengeServiceType = StubChallengeService()
var pointService: PointServiceType = StubPointService()
var userService: UserServiceType = StubUserService()
final public class StubHMHService: HMHServiceType {
public init() {}
public var authService: AuthServiceType = StubAuthService()
public var challengeService: ChallengeServiceType = StubChallengeService()
public var pointService: PointServiceType = StubPointService()
public var userService: UserServiceType = StubUserService()
}
Loading

0 comments on commit a27c137

Please sign in to comment.