Skip to content

Commit a2ac8ad

Browse files
committed
Refactor: 추천 루틴 감정 구슬 등록하기 버튼 수정된 디자인 반영 (#T3-167)
1 parent 6fc1d80 commit a2ac8ad

3 files changed

Lines changed: 107 additions & 77 deletions

File tree

Projects/Presentation/Sources/RecommendedRoutine/View/Component/RegisterEmotionButton.swift

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//
2+
// RegisterEmotionButtonView.swift
3+
// Presentation
4+
//
5+
// Created by 최정인 on 8/15/25.
6+
//
7+
8+
import SnapKit
9+
import UIKit
10+
11+
protocol RegisterEmotionButtonViewDelegate: AnyObject {
12+
func registerEmotionButtonViewDidTapRegisterButton(_ sender: RegisterEmotionButtonView)
13+
}
14+
15+
final class RegisterEmotionButtonView: UIView {
16+
private enum Layout {
17+
static let cornerRadius: CGFloat = 12
18+
static let emotionOrbImageViewLeadingSpacing: CGFloat = 13
19+
static let emotionOrbImageViewSize: CGFloat = 34
20+
static let registerEmotionLabelLeadingSpacing: CGFloat = 5
21+
static let registerEmotionButtonCornerRadius: CGFloat = 8
22+
static let registerEmotionButtonTrailingSpacing: CGFloat = 19
23+
static let registerEmotionButtonWidth: CGFloat = 74
24+
static let registerEmotionButtonHeight: CGFloat = 38
25+
}
26+
27+
private let emotionOrbImageView = UIImageView()
28+
private let registerEmotionLabel = UILabel()
29+
private let registerEmotionButton = UIButton()
30+
weak var delegate: RegisterEmotionButtonViewDelegate?
31+
32+
init() {
33+
super.init(frame: .zero)
34+
configureAttribute()
35+
configureLayout()
36+
}
37+
38+
required init?(coder: NSCoder) {
39+
fatalError("init(coder:) has not been implemented")
40+
}
41+
42+
private func configureAttribute() {
43+
emotionOrbImageView.image = BitnagilGraphic.defaultEmotionGraphic
44+
emotionOrbImageView.contentMode = .scaleAspectFit
45+
46+
registerEmotionLabel.text = "내 기분에 맞는 루틴 추천받기"
47+
registerEmotionLabel.font = BitnagilFont(style: .body2, weight: .semiBold).font
48+
registerEmotionLabel.textColor = .white
49+
50+
var buttonConfiguration = UIButton.Configuration.filled()
51+
buttonConfiguration.baseBackgroundColor = BitnagilColor.orange500
52+
buttonConfiguration.background.cornerRadius = Layout.registerEmotionButtonCornerRadius
53+
buttonConfiguration.attributedTitle = AttributedString(
54+
"추천받기",
55+
attributes: .init([.font: BitnagilFont(style: .caption1, weight: .semiBold).font]))
56+
buttonConfiguration.baseForegroundColor = .white
57+
registerEmotionButton.configuration = buttonConfiguration
58+
registerEmotionButton.addAction(
59+
UIAction { [weak self] _ in
60+
guard let self else { return }
61+
self.delegate?.registerEmotionButtonViewDidTapRegisterButton(self)
62+
},
63+
for: .touchUpInside)
64+
}
65+
66+
private func configureLayout() {
67+
backgroundColor = BitnagilColor.gray10
68+
layer.masksToBounds = true
69+
layer.cornerRadius = Layout.cornerRadius
70+
71+
[emotionOrbImageView, registerEmotionLabel, registerEmotionButton].forEach {
72+
addSubview($0)
73+
}
74+
75+
emotionOrbImageView.snp.makeConstraints { make in
76+
make.leading.equalToSuperview().offset(Layout.emotionOrbImageViewLeadingSpacing)
77+
make.centerY.equalToSuperview()
78+
make.size.equalTo(Layout.emotionOrbImageViewSize)
79+
}
80+
81+
registerEmotionLabel.snp.makeConstraints { make in
82+
make.leading.equalTo(emotionOrbImageView.snp.trailing).offset(Layout.registerEmotionLabelLeadingSpacing)
83+
make.centerY.equalToSuperview()
84+
}
85+
86+
registerEmotionButton.snp.makeConstraints { make in
87+
make.trailing.equalToSuperview().inset(Layout.registerEmotionButtonTrailingSpacing)
88+
make.centerY.equalToSuperview()
89+
make.width.equalTo(Layout.registerEmotionButtonWidth)
90+
make.height.equalTo(Layout.registerEmotionButtonHeight)
91+
}
92+
}
93+
}

Projects/Presentation/Sources/RecommendedRoutine/View/RecommendedRoutineView.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import SnapKit
1212
import UIKit
1313

1414
final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewModel> {
15-
1615
private enum Layout {
1716
static let horizontalMargin: CGFloat = 20
1817
static let bottomSheetHeight: CGFloat = 226
@@ -26,7 +25,7 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
2625
static let recommendedRoutineScrollViewBottomSpacing: CGFloat = 10
2726
static let recommendedRoutineStackViewBottomSpacing: CGFloat = 50
2827
static let routineCardHeight: CGFloat = 80
29-
static let registerEmotionButtonHeight: CGFloat = 52
28+
static let registerEmotionButtonHeight: CGFloat = 66
3029
static let floatingButtonBottomSpacing: CGFloat = 19
3130
static let floatingButtonSize: CGFloat = 52
3231
static let floatingMenuBottomSpacing: CGFloat = 15
@@ -44,7 +43,7 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
4443
private let recommendedRoutineScrollView = UIScrollView()
4544
private let recommendedRoutineStackView = UIStackView()
4645
private var recommendedRoutineCards: [Int: RecommendedRoutineCardView] = [:]
47-
private let registerEmotionButton = RegisterEmotionButton()
46+
private let registerEmotionButton = RegisterEmotionButtonView()
4847

4948
private var isExistEmotion: Bool = false
5049
private var isShowingFloatingMenu: Bool = false
@@ -91,14 +90,7 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
9190
recommendedRoutineStackView.axis = .vertical
9291
recommendedRoutineStackView.spacing = Layout.recommendedRoutineStackViewSpacing
9392

94-
registerEmotionButton.addAction(UIAction { _ in
95-
guard let emotionRegisterViewModel = DIContainer.shared.resolve(type: EmotionRegisterViewModel.self) else {
96-
fatalError("emotionRegisterViewModel 의존성이 등록되지 않았습니다.")
97-
}
98-
let emotionRegisterView = EmotionRegisterView(viewModel: emotionRegisterViewModel)
99-
emotionRegisterView.hidesBottomBarWhenPushed = true
100-
self.navigationController?.pushViewController(emotionRegisterView, animated: true)
101-
}, for: .touchUpInside)
93+
registerEmotionButton.delegate = self
10294

10395
floatingButton.addAction(UIAction { [weak self] _ in
10496
self?.toggleFloatingButton()
@@ -331,3 +323,14 @@ extension RecommendedRoutineView: FloatingMenuViewDelegate {
331323
self.navigationController?.pushViewController(routineCreationView, animated: true)
332324
}
333325
}
326+
327+
extension RecommendedRoutineView: RegisterEmotionButtonViewDelegate {
328+
func registerEmotionButtonViewDidTapRegisterButton(_ sender: RegisterEmotionButtonView) {
329+
guard let emotionRegisterViewModel = DIContainer.shared.resolve(type: EmotionRegisterViewModel.self)
330+
else { fatalError("emotionRegisterViewModel 의존성이 등록되지 않았습니다.") }
331+
332+
let emotionRegisterView = EmotionRegisterView(viewModel: emotionRegisterViewModel)
333+
emotionRegisterView.hidesBottomBarWhenPushed = true
334+
self.navigationController?.pushViewController(emotionRegisterView, animated: true)
335+
}
336+
}

0 commit comments

Comments
 (0)