Skip to content

Commit bfabbb1

Browse files
committed
fix: 마이페이지 네비게이션 수정
1 parent c269e92 commit bfabbb1

2 files changed

Lines changed: 45 additions & 24 deletions

File tree

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ extension UIViewController {
1414
case withBackButton(title: String) // 백버튼 + 타이틀 (없으면 빈 String)
1515
case withTitle(title: String) // 오로지 타이틀만
1616
case withProgressBar(step: Int) // 백버튼 + progress
17+
case withRightButton(
18+
title: String,
19+
rightButtonImage: UIImage,
20+
rightButtonAction: UIAction,
21+
rightButtonTintColor: UIColor? = nil,
22+
withBackButton: Bool = false) // 커스텀 우측 버튼
1723
}
1824

1925
func configureCustomNavigationBar(navigationBarStyle: NavigationBarStyle, backgroundColor: UIColor? = .white) {
@@ -31,6 +37,7 @@ extension UIViewController {
3137
private func customNavigationBar(navigationBarStyle: NavigationBarStyle) -> UIView {
3238
let navigationBar = UIView()
3339
let customBackButton = UIButton()
40+
let customRightButton = UIButton()
3441
let titleLabel = UILabel()
3542
let progressView = UIImageView()
3643

@@ -46,6 +53,7 @@ extension UIViewController {
4653
titleLabel.textColor = BitnagilColor.gray10
4754

4855
progressView.isHidden = true
56+
customRightButton.isHidden = true
4957

5058
switch navigationBarStyle {
5159
case .withBackButton(let title):
@@ -59,10 +67,23 @@ extension UIViewController {
5967
titleLabel.isHidden = true
6068
progressView.image = progressImage(step: step)
6169
progressView.isHidden = false
70+
case .withRightButton(
71+
title: let title,
72+
rightButtonImage: let rightButtonImage,
73+
rightButtonAction: let action,
74+
rightButtonTintColor: let tintColor,
75+
withBackButton: let withBackButton):
76+
77+
customBackButton.isHidden = !withBackButton
78+
customRightButton.isHidden = false
79+
customRightButton.addAction(action, for: .touchUpInside)
80+
titleLabel.text = title
81+
customRightButton.setImage(rightButtonImage, for: .normal)
82+
customRightButton.tintColor = tintColor
6283
}
6384

6485
navigationBar.backgroundColor = .systemBackground
65-
[customBackButton, titleLabel, progressView].forEach {
86+
[customBackButton, titleLabel, progressView, customRightButton].forEach {
6687
navigationBar.addSubview($0)
6788
}
6889

@@ -72,6 +93,12 @@ extension UIViewController {
7293
make.size.equalTo(48)
7394
}
7495

96+
customRightButton.snp.makeConstraints { make in
97+
make.top.equalToSuperview()
98+
make.trailing.equalToSuperview()
99+
make.size.equalTo(48)
100+
}
101+
75102
titleLabel.snp.makeConstraints { make in
76103
make.center.equalToSuperview()
77104
}

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

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class MypageView: BaseViewController<MypageViewModel> {
1414
private enum Layout {
1515
static let profileImageViewSize: CGFloat = 80
1616
static let profileImageViewCornerRadius: CGFloat = profileImageViewSize / 2
17-
static let profileImageViewTopSpacing: CGFloat = 32
17+
static let profileImageViewTopSpacing: CGFloat = 74
1818
static let nicknameLabelHeight: CGFloat = 24
1919
static let nicknameLabelTopSpacing: CGFloat = 12
2020
static let divideLineHeight: CGFloat = 6
@@ -41,27 +41,12 @@ final class MypageView: BaseViewController<MypageViewModel> {
4141

4242
override func viewWillAppear(_ animated: Bool) {
4343
super.viewWillAppear(animated)
44-
45-
navigationController?.setNavigationBarHidden(false, animated: animated)
46-
47-
let appearance = UINavigationBarAppearance()
48-
appearance.configureWithOpaqueBackground()
49-
appearance.backgroundColor = .white
50-
appearance.shadowColor = .clear
51-
52-
navigationController?.navigationBar.standardAppearance = appearance
53-
navigationController?.navigationBar.scrollEdgeAppearance = appearance
54-
navigationController?.navigationBar.compactAppearance = appearance
44+
navigationController?.navigationBar.isHidden = true
5545
}
5646

5747
override func configureAttribute() {
5848
view.backgroundColor = .white
59-
navigationItem.rightBarButtonItem = settingButton
60-
title = "마이페이지"
6149

62-
settingButton.action = #selector(settingButtonTapped)
63-
settingButton.target = self
64-
settingButton.image = BitnagilIcon.settingIcon?.withRenderingMode(.alwaysOriginal)
6550
profileImageView.image = BitnagilGraphic.profileGraphic
6651

6752
nicknameLabel.font = BitnagilFont(style: .title3, weight: .semiBold).font
@@ -75,6 +60,21 @@ final class MypageView: BaseViewController<MypageViewModel> {
7560
tableView.delegate = self
7661
tableView.separatorStyle = .none
7762
tableView.bounces = false
63+
64+
let settingButtonImage = BitnagilIcon.settingIcon
65+
let settingButtonAction = UIAction { [weak self] _ in
66+
guard let settingViewModel = Shared.DIContainer.shared.resolve(type: SettingViewModel.self) else { return }
67+
let settingView = SettingView(viewModel: settingViewModel)
68+
self?.navigationController?.pushViewController(settingView, animated: true)
69+
}
70+
71+
configureCustomNavigationBar(navigationBarStyle:
72+
.withRightButton(
73+
title: "마이페이지",
74+
rightButtonImage: settingButtonImage ?? .init(),
75+
rightButtonAction: settingButtonAction,
76+
rightButtonTintColor: BitnagilColor.gray70,
77+
withBackButton: false))
7878
}
7979

8080
override func configureLayout() {
@@ -125,12 +125,6 @@ final class MypageView: BaseViewController<MypageViewModel> {
125125
}
126126
.store(in: &cancellables)
127127
}
128-
129-
@objc private func settingButtonTapped() {
130-
guard let settingViewModel = Shared.DIContainer.shared.resolve(type: SettingViewModel.self) else { return }
131-
let settingView = SettingView(viewModel: settingViewModel)
132-
navigationController?.pushViewController(settingView, animated: true)
133-
}
134128
}
135129

136130
extension MypageView: UITableViewDelegate {

0 commit comments

Comments
 (0)