Skip to content

Commit 21db344

Browse files
authored
[Feat-T3-104] 마이페이지 UI 구현 (#22)
* Feat: 이미지 asset 추가 (#T3-104) - BitnagilIcon에 이미지 추가 * Feat: NSObject extension 추가 (#T3-104) - {class이름}.className을 통해 클래스의 이름을 스트링으로 사용할 수 있도록 구현 * Feat: UserDataRepository 구현 (#T3-104) - 유저 정보 (닉네임, accessToken)을 가져올 수 있는 repository 구현 - UserDataRepository 의존성 등록 * Feat: 마이페이지 화면 구현 (#T3-104) - 마이페이지 화면 구현 - 의존성 등록 - TabBar에서 Myapge 클래스 삭제 * refactor: 코드 리뷰 반영
1 parent 211de3a commit 21db344

19 files changed

Lines changed: 456 additions & 8 deletions

File tree

Projects/DataSource/Sources/Common/DataSourceDependencyAssembler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ public struct DataSourceDependencyAssembler: DependencyAssemblerProtocol {
3737
DIContainer.shared.register(type: OnboardingRepositoryProtocol.self) { _ in
3838
return OnboardingRepository(networkService: networkService, keychainStorage: keychainStorage)
3939
}
40+
41+
DIContainer.shared.register(type: UserDataRepositoryProtocol.self) { _ in
42+
return UserDataRepository(keychainStorage: keychainStorage, userDefaultsStorage: userDefaultsStorage)
43+
}
4044
}
4145
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// UserError.swift
3+
// DataSource
4+
//
5+
// Created by 이동현 on 7/20/25.
6+
//
7+
8+
enum UserError: Error, CustomStringConvertible {
9+
case accessTokenLoadFailed
10+
case nicknameLoadFailed
11+
case unknown(error: Error)
12+
13+
14+
var description: String {
15+
switch self {
16+
case .accessTokenLoadFailed:
17+
return "토큰 불러오기에 실패했습니다."
18+
case .nicknameLoadFailed:
19+
return "닉네임 불러오기에 실패했습니다."
20+
case .unknown(let error):
21+
return "알 수 없는 에러가 발생했습니다. \(error.localizedDescription)"
22+
}
23+
}
24+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// UserDataRepository.swift
3+
// DataSource
4+
//
5+
// Created by 이동현 on 7/20/25.
6+
//
7+
8+
import Domain
9+
import Foundation
10+
11+
final class UserDataRepository: UserDataRepositoryProtocol {
12+
private let keychainStorage: KeychainStorageProtocol
13+
private let userDefaultsStorage: UserDefaultsStorageProtocol
14+
15+
init(keychainStorage: KeychainStorageProtocol, userDefaultsStorage: UserDefaultsStorageProtocol) {
16+
self.keychainStorage = keychainStorage
17+
self.userDefaultsStorage = userDefaultsStorage
18+
}
19+
20+
// TODO: - accessToken fetch 로직 상의 후 결정
21+
func loadAccessToken() throws -> String {
22+
guard let token = keychainStorage.load(forKey: TokenType.accessToken.rawValue) else {
23+
throw UserError.accessTokenLoadFailed
24+
}
25+
26+
return token
27+
}
28+
29+
func loadNickname() throws -> String {
30+
guard let nickname: String = userDefaultsStorage.load(forKey: UserDefaultsKey.nickname.rawValue) else {
31+
throw UserError.nicknameLoadFailed
32+
}
33+
34+
return nickname
35+
}
36+
}
37+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// UserDataRepositoryProtocol.swift
3+
// DataSource
4+
//
5+
// Created by 이동현 on 7/20/25.
6+
//
7+
8+
/// 유저의 이름, 토큰 등 유저 정보와 관련된 데이터를 가져오는 Repository
9+
public protocol UserDataRepositoryProtocol {
10+
/// 저장한 accessToken을 가져옵니다.
11+
/// - Returns: accessToken
12+
func loadAccessToken() throws -> String
13+
14+
/// 저장한 닉네임을 가져옵니다.
15+
/// - Returns: 유저 닉네임
16+
func loadNickname() throws -> String
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "chevron_right_icon@1x.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"filename" : "chevron_right_icon@2x.png",
10+
"idiom" : "universal",
11+
"scale" : "2x"
12+
},
13+
{
14+
"filename" : "chevron_right_icon@3x.png",
15+
"idiom" : "universal",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"author" : "xcode",
21+
"version" : 1
22+
}
23+
}
181 Bytes
Loading
261 Bytes
Loading
306 Bytes
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "setting_icon@1x.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"filename" : "setting_icon@2x.png",
10+
"idiom" : "universal",
11+
"scale" : "2x"
12+
},
13+
{
14+
"filename" : "setting_icon@3x.png",
15+
"idiom" : "universal",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"author" : "xcode",
21+
"version" : 1
22+
}
23+
}
724 Bytes
Loading

0 commit comments

Comments
 (0)