Skip to content

Commit 1ae7ba7

Browse files
committed
refactor: 코드 리뷰 반영
1 parent a3f03b7 commit 1ae7ba7

5 files changed

Lines changed: 31 additions & 43 deletions

File tree

Projects/DataSource/Sources/Common/Error/UserError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enum UserError: Error, CustomStringConvertible {
1111
case unknown(error: Error)
1212

1313

14-
public var description: String {
14+
var description: String {
1515
switch self {
1616
case .accessTokenLoadFailed:
1717
return "토큰 불러오기에 실패했습니다."

Projects/DataSource/Sources/Repository/UserDataRepository.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// Created by 이동현 on 7/20/25.
66
//
77

8-
import Foundation
98
import Domain
9+
import Foundation
1010

1111
final class UserDataRepository: UserDataRepositoryProtocol {
1212
private let keychainStorage: KeychainStorageProtocol
@@ -19,17 +19,17 @@ final class UserDataRepository: UserDataRepositoryProtocol {
1919

2020
// TODO: - accessToken fetch 로직 상의 후 결정
2121
func loadAccessToken() throws -> String {
22-
guard
23-
let token = keychainStorage.load(forKey: TokenType.accessToken.rawValue)
24-
else { throw UserError.accessTokenLoadFailed }
22+
guard let token = keychainStorage.load(forKey: TokenType.accessToken.rawValue) else {
23+
throw UserError.accessTokenLoadFailed
24+
}
2525

2626
return token
2727
}
2828

2929
func loadNickname() throws -> String {
30-
guard
31-
let nickname: String = userDefaultsStorage.load(forKey: UserDefaultsKey.nickname.rawValue)
32-
else { throw UserError.nicknameLoadFailed }
30+
guard let nickname: String = userDefaultsStorage.load(forKey: UserDefaultsKey.nickname.rawValue) else {
31+
throw UserError.nicknameLoadFailed
32+
}
3333

3434
return nickname
3535
}

Projects/Presentation/Sources/Common/Extension/NSObject+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public extension NSObject {
10+
extension NSObject {
1111
var className: String {
1212
return String(describing: type(of: self))
1313
}

Projects/Presentation/Sources/MyPage/View/Component/MypageTableViewCell.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import UIKit
1111
final class MypageTableViewCell: UITableViewCell {
1212
private enum Layout {
1313
static let titleLableLeadingSpacing: CGFloat = 20
14+
static let titleLableTrailingSpacing: CGFloat = 8
1415
static let chevronImageViewTrailingSpacing: CGFloat = 6
1516
static let chevronImageViewSize: CGFloat = 36
1617
}
@@ -51,7 +52,7 @@ final class MypageTableViewCell: UITableViewCell {
5152
titleLabel.snp.makeConstraints { make in
5253
make.verticalEdges.equalToSuperview()
5354
make.leading.equalToSuperview().offset(Layout.titleLableLeadingSpacing)
54-
make.trailing.equalTo(chevronImageView.snp.leading).offset(-8)
55+
make.trailing.equalTo(chevronImageView.snp.leading).offset(-Layout.titleLableTrailingSpacing)
5556
}
5657
}
5758
}

Projects/Presentation/Sources/MyPage/View/MypageView.swift

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
// Created by 이동현 on 7/17/25.
66
//
77
import Combine
8+
import SafariServices
89
import Shared
910
import SnapKit
1011
import UIKit
1112

1213
final class MypageView: BaseViewController<MypageViewModel> {
1314
private enum Layout {
14-
static let titleLabelHeight: CGFloat = 54
15-
static let settingButtonSize: CGFloat = 48
16-
static let settingButtonTrailingSpacing: CGFloat = 8
1715
static let profileImageViewSize: CGFloat = 80
1816
static let profileImageViewCornerRadius: CGFloat = profileImageViewSize / 2
1917
static let profileImageViewTopSpacing: CGFloat = 32
@@ -25,7 +23,7 @@ final class MypageView: BaseViewController<MypageViewModel> {
2523
}
2624

2725
private let titleLabel = UILabel()
28-
private let settingButton = UIButton()
26+
private let settingButton = UIBarButtonItem()
2927
private let profileImageView = UIImageView()
3028
private let nicknameLabel = UILabel()
3129
private let dividerView = UIView()
@@ -41,19 +39,16 @@ final class MypageView: BaseViewController<MypageViewModel> {
4139
fatalError("init(coder:) has not been implemented")
4240
}
4341

44-
override func viewDidLoad() {
45-
super.viewDidLoad()
46-
}
47-
4842
override func configureAttribute() {
4943
view.backgroundColor = .white
44+
navigationItem.rightBarButtonItem = settingButton
45+
title = "마이페이지"
5046

51-
titleLabel.text = "마이페이지"
52-
titleLabel.font = BitnagilFont(style: .title3, weight: .semiBold).font
53-
titleLabel.textAlignment = .center
54-
titleLabel.textColor = .black
55-
56-
settingButton.setImage(BitnagilIcon.settingIcon, for: .normal)
47+
settingButton.action = #selector(settingButtonTapped)
48+
settingButton.tintColor = .black
49+
settingButton.image = BitnagilIcon
50+
.settingIcon?
51+
.withRenderingMode(.alwaysTemplate)
5752

5853
profileImageView.layer.cornerRadius = Layout.profileImageViewCornerRadius
5954
profileImageView.layer.masksToBounds = true
@@ -73,26 +68,13 @@ final class MypageView: BaseViewController<MypageViewModel> {
7368

7469
override func configureLayout() {
7570
let safeArea = view.safeAreaLayoutGuide
76-
view.addSubview(titleLabel)
77-
view.addSubview(settingButton)
7871
view.addSubview(profileImageView)
7972
view.addSubview(nicknameLabel)
8073
view.addSubview(dividerView)
8174
view.addSubview(tableView)
8275

83-
titleLabel.snp.makeConstraints { make in
84-
make.horizontalEdges.top.equalTo(safeArea)
85-
make.height.equalTo(Layout.titleLabelHeight)
86-
}
87-
88-
settingButton.snp.makeConstraints { make in
89-
make.centerY.equalTo(titleLabel)
90-
make.trailing.equalToSuperview().inset(Layout.settingButtonTrailingSpacing)
91-
make.size.equalTo(Layout.settingButtonSize)
92-
}
93-
9476
profileImageView.snp.makeConstraints { make in
95-
make.top.equalTo(titleLabel.snp.bottom).offset(Layout.profileImageViewTopSpacing)
77+
make.top.equalTo(safeArea.snp.top).offset(Layout.profileImageViewTopSpacing)
9678
make.centerX.equalToSuperview()
9779
make.size.equalTo(Layout.profileImageViewSize)
9880
}
@@ -124,11 +106,16 @@ final class MypageView: BaseViewController<MypageViewModel> {
124106
.store(in: &cancellables)
125107

126108
viewModel.output.externalURLPublisher
127-
.sink { url in
128-
UIApplication.shared.open(url)
109+
.sink { [weak self] url in
110+
let safariView = SFSafariViewController(url: url)
111+
self?.present(safariView, animated: true)
129112
}
130113
.store(in: &cancellables)
131114
}
115+
116+
@objc private func settingButtonTapped() {
117+
// TODO: - 추후 설정 페이지 연결
118+
}
132119
}
133120

134121
extension MypageView: UITableViewDelegate {
@@ -145,9 +132,9 @@ extension MypageView: UITableViewDataSource {
145132
}
146133

147134
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
148-
guard
149-
let cell = tableView.dequeueReusableCell(withIdentifier: MypageTableViewCell.className) as? MypageTableViewCell
150-
else { return .init() }
135+
guard let cell = tableView.dequeueReusableCell(withIdentifier: MypageTableViewCell.className) as? MypageTableViewCell else {
136+
return .init()
137+
}
151138

152139
let title = MypageViewModel.MypageMenu
153140
.allCases[indexPath.row]

0 commit comments

Comments
 (0)