Skip to content
Merged
5 changes: 5 additions & 0 deletions Common/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ let package = Package(
name: "SharedUI",
targets: ["SharedUI"]
),
.library(
name: "SharedDomain",
targets: ["SharedDomain"]
),
],
targets: [
.target(
Expand All @@ -50,6 +54,7 @@ let package = Package(
name: "SharedUI",
dependencies: ["DesignSystem"]
),
.target(name: "SharedDomain"),

.plugin(
name: "ColorGenerator",
Expand Down
28 changes: 28 additions & 0 deletions Common/Sources/DesignSystem/HambugCommonAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ public struct AlertButton {
self.title = title
self.action = action
}

public init(
_ type: AlertButtonType,
action: @escaping @MainActor () -> Void
) {
self.title = type.title
self.action = action
}

public enum AlertButtonType {
case ok
case cancel
case save
case accountDelete

var title: String {
switch self {
case .ok:
return "확인"
case .cancel:
return "취소"
case .save:
return "저장"
case .accountDelete:
return "탈퇴"
}
}
}
}

#Preview {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"images" : [
{
"filename" : "기본 프로필 이미지.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "placeholder_profile.png",
"idiom" : "universal",
"scale" : "2x"
},
Expand Down
4 changes: 3 additions & 1 deletion Common/Sources/Managers/AppStateManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ public final class AppStateManager {
state = .main
}

// 로그아웃 (선택사항 - 나중에 구현 예정이지만 미리 추가)
// 로그아웃
public func logout() {
do {
try tokenStorage.clear()
UserDefaultsManager.shared.clearAll()
// TODO: - push key 추가시 삭제 해야할듯 ?
state = .login
} catch {
print("⚠️ Failed to logout: \(error)")
Expand Down
1 change: 0 additions & 1 deletion Common/Sources/Managers/AppStorageKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
public extension String {
struct Storage {
static let hasSeenOnboarding = "hasSeenOnboarding"
static let userResponse = "userResponse"
static let currentUserId = "currentUserId"
}
}
Expand Down
10 changes: 10 additions & 0 deletions Common/Sources/Managers/UserDefaultsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ public final class UserDefaultsManager {

@UDDefaultWrapper(key: .Storage.currentUserId, defaultValue: nil)
public var currentUserId: Int64?

func clearAll() {
let keys: [String] = [
.Storage.currentUserId,

]
keys.forEach {
UserDefaults.standard.removeObject(forKey: $0)
}
}
}
35 changes: 35 additions & 0 deletions Common/Sources/SharedDomain/User.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// User.swift
// Common
//
// Created by 강동영 on 1/12/26.
//


public struct User {
public let userId: Int64
public let nickname: String
public var profileImageURL: String
public let loginType: String
public let role: String
public let isRegister: Bool?
public let kakao: Bool

public init(
userId: Int64 = 0,
nickname: String = "",
profileImageURL: String = "",
loginType: String = "",
role: String = "",
isRegister: Bool? = false,
kakao: Bool = false
) {
self.userId = userId
self.nickname = nickname
self.profileImageURL = profileImageURL
self.loginType = loginType
self.role = role
self.isRegister = isRegister
self.kakao = kakao
}
}
6 changes: 3 additions & 3 deletions Common/Sources/Util/ImageProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public enum ImageProcessor {
// MARK: - Constants

/// 최대 파일 크기: 10MB
public static let maxFileSize: Int = 10 * 1024 * 1024
public static let maxFileSize: Int = 2 * 1024 * 1024

/// 최대 해상도: 1920px
public static let maxDimension: CGFloat = 1920
/// 최대 해상도: 1280px
public static let maxDimension: CGFloat = 1280

/// 기본 압축 품질
public static let compressionQuality: CGFloat = 0.85
Expand Down
12 changes: 12 additions & 0 deletions Common/Sources/Util/NSNotification.Name+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// NSNotification.Name+.swift
// Common
//
// Created by 강동영 on 1/12/26.
//

import Foundation.NSNotification

public extension NSNotification.Name {
static let userDidLogout = NSNotification.Name("userDidLogout")
}
9 changes: 0 additions & 9 deletions DI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ enum Config: String, CaseIterable {
case app = "App"
case intro = "Intro"
case login = "Login"
case myPage = "MyPage"

var name: String {
switch self {
Expand Down Expand Up @@ -42,7 +41,6 @@ let package = Package(
.package(name: "Infrastructure", path: "../Infrastructure"),
.package(name: "Intro", path: "../Intro"),
.package(name: "Login", path: "../Login"),
.package(name: "MyPage", path: "../MyPage"),
],
targets: [
.target(name: Config.interface.name),
Expand Down Expand Up @@ -70,13 +68,6 @@ let package = Package(
.target(config: .app),
.product(name: "Login", package: "Login"),
]
),
.target(
name: Config.myPage.name,
dependencies: [
.target(config: .app),
.product(name: "MyPage", package: "MyPage"),
]
)
]
)
Expand Down
9 changes: 7 additions & 2 deletions Hambug/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ struct ContentView: View {
.tag(1)


Text("MyPage")
.tag(2)
NavigationStack {
MyPageView(
viewModel: mypageDIContainer.makeMyPageViewModel()
)
}
.tag(2)
}
.toolbar(.hidden, for: .tabBar)
}
.ignoresSafeArea(.keyboard)
}
}

Expand Down
1 change: 1 addition & 0 deletions Hambug/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import LoginDI
import AppDI
import IntroDI
import NetworkImpl
import Util

struct RootView: View {
@Environment(AppStateManager.self) var appStateManager
Expand Down
1 change: 1 addition & 0 deletions Infrastructure/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let package = Package(
dependencies: [
.target(name: Config.networkInterface),
.product(name: "DataSources", package: "Common"),
.product(name: "Util", package: "Common"),
"Alamofire",
]
),
Expand Down
5 changes: 1 addition & 4 deletions Infrastructure/Sources/NetworkImpl/AuthInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import DataSources
import NetworkInterface

import Util
import Alamofire

// MARK: - Auth Interceptor
Expand Down Expand Up @@ -142,6 +142,3 @@ public final class AuthInterceptor: RequestInterceptor {

}

public extension NSNotification.Name {
static let userDidLogout = NSNotification.Name("userDidLogout")
}
8 changes: 7 additions & 1 deletion Infrastructure/Sources/NetworkImpl/NetworkServiceImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ public final class NetworkServiceImpl: NetworkServiceInterface {
responseType: T.Type
) -> AnyPublisher<T, NetworkError> {
do {
let urlRequest = try endpoint.createURLRequest()

#if DEBUG
logger?.requestLogger(request: urlRequest)
#endif

guard let url = endpoint.createURL() else {
throw NetworkError.invalidURL
}

return session.upload(
multipartFormData: { multipartFormData in
// 1. JSON body의 텍스트 필드 추가 (title, content, category)
Expand Down
13 changes: 13 additions & 0 deletions MyPage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PackageDescription
enum Config: String, CaseIterable {
static let name: String = "MyPage"

case di = "DI"
case data = "Data"
case domain = "Domain"
case presentation = "Presentation"
Expand Down Expand Up @@ -33,10 +34,22 @@ let package = Package(
.package(name: "Infrastructure", path: "../Infrastructure")
],
targets: [
.target(
name: Config.di.name,
dependencies: [
.target(config: .domain),
.target(config: .data),
.target(config: .presentation),
.product(name: "NetworkInterface", package: "Infrastructure"),
.product(name: "NetworkImpl", package: "Infrastructure")
],
path: Config.di.path
),
.target(
name: Config.data.name,
dependencies: [
.target(config: .domain),
.product(name: "SharedDomain", package: "Common"),
.product(name: "NetworkInterface", package: "Infrastructure"),
.product(name: "NetworkImpl", package: "Infrastructure")
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import DIKit
import AppDI
import NetworkInterface
import NetworkImpl
import MyPageDomain
import MyPageData
Expand All @@ -18,7 +19,7 @@ struct MyPageAssembly: Assembly {

container.register(MyPageRepository.self) { resolver in
MyPageRepositoryImpl(
networkService: NetworkServiceImpl()
networkService: resolver.resolve(NetworkServiceInterface.self)
)
}

Expand Down Expand Up @@ -46,7 +47,7 @@ public final class MyPageDIContainer {
// MARK: - Initialization
public init(appContainer: AppDIContainer? = nil) {
let parent = appContainer ?? AppDIContainer.shared
self.container = GenericDIContainer(parent: parent.baseContainer)
self.container = AppDIContainer.shared.baseContainer
MyPageAssembly().assemble(container: container)
}

Expand Down
2 changes: 0 additions & 2 deletions MyPage/Sources/Data/MyPage.swift

This file was deleted.

Loading
Loading