Skip to content

Commit 305e6c0

Browse files
committed
Refactor: 추천 루틴 난이도 설정 화면 디자인 반영 (#T3-167)
1 parent d777e54 commit 305e6c0

8 files changed

Lines changed: 38 additions & 65 deletions

File tree

Projects/Presentation/Sources/Common/Component/RoutineCardView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ final class RoutineCardView: UIView {
4242
titleLabel.font = BitnagilFont(style: .body1, weight: .semiBold).font
4343
titleLabel.textColor = BitnagilColor.gray10
4444

45-
plusButton.setImage(BitnagilIcon.plusIcon, for: .normal)
45+
let plusImage = BitnagilIcon.plusIcon?.resizeAspectFit(to: CGSize(width: 24, height: 24))
46+
plusButton.setImage(plusImage, for: .normal)
4647
plusButton.tintColor = BitnagilColor.gray10
4748

4849
grayLine.backgroundColor = BitnagilColor.gray97

Projects/Presentation/Sources/Common/Component/SelectableItemCell.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by 최정인 on 7/24/25.
66
//
77

8+
import SnapKit
89
import UIKit
910

1011
final class SelectableItemCell: UITableViewCell {
@@ -28,7 +29,7 @@ final class SelectableItemCell: UITableViewCell {
2829

2930
private func configureAttribute() {
3031
titleLabel.font = BitnagilFont(style: .body1, weight: .regular).font
31-
titleLabel.textColor = .black
32+
titleLabel.textColor = BitnagilColor.gray10
3233

3334
let checkImage = BitnagilIcon.checkIcon?
3435
.resizeAspectFit(to: CGSize(width: Layout.checkIconSize, height: Layout.checkIconSize))?
@@ -54,7 +55,24 @@ final class SelectableItemCell: UITableViewCell {
5455
}
5556

5657
func configureCell(item: SelectableItem, isSelected: Bool) {
57-
titleLabel.text = item.title
5858
checkIcon.isHidden = !isSelected
59+
60+
guard let displayName = item.displayName else {
61+
titleLabel.text = item.description
62+
return
63+
}
64+
let attributedString = NSMutableAttributedString(string: item.description)
65+
attributedString.addAttribute(
66+
.font,
67+
value: BitnagilFont(style: .body1, weight: .regular).font,
68+
range: NSRange(location: 0, length: item.description.count))
69+
70+
if let range = item.description.range(of: displayName) {
71+
let nsRange = NSRange(range, in: item.description)
72+
attributedString.addAttributes([
73+
.font: BitnagilFont(style: .body1, weight: .semiBold).font
74+
], range: nsRange)
75+
}
76+
titleLabel.attributedText = attributedString
5977
}
6078
}

Projects/Presentation/Sources/Common/Protocol/SelectableItem.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
protocol SelectableItem {
99
var id: Int { get }
10-
var title: String { get }
10+
var displayName: String? { get }
11+
var description: String { get }
1112
}

Projects/Presentation/Sources/Home/Model/RoutineSortType.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

Projects/Presentation/Sources/Home/View/HomeView.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,6 @@ extension HomeView: RoutineViewDelegate {
573573
}
574574
}
575575

576-
// MARK: SelectableItemTableViewDelegate
577-
extension HomeView: SelectableItemTableViewDelegate {
578-
func selectableItemTableView<T: SelectableItem & CaseIterable & Equatable>(_ sender: SelectableItemTableView<T>, didSelectItem: T?) {
579-
guard let sortType = didSelectItem as? RoutineSortType?
580-
else { return }
581-
582-
viewModel.action(input: .selectRoutineSortType(routineSortType: sortType))
583-
}
584-
}
585-
586576
// MARK: WeekViewDelegate
587577
extension HomeView: WeekViewDelegate {
588578
func weekView(_ sender: WeekView, didSelectDate date: Date) {

Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ final class HomeViewModel: ViewModel {
2121
case deleteAllRoutine
2222
case updateRoutineCompletion(updatedRoutine: Routine)
2323
case refreshSelectedDateRoutine
24-
case selectRoutineSortType(routineSortType: RoutineSortType?)
2524
}
2625

2726
struct Output {
@@ -44,7 +43,6 @@ final class HomeViewModel: ViewModel {
4443
private let selectedRoutineSubject = CurrentValueSubject<MainRoutine?, Never>(nil)
4544
private let deleteRoutineResultSubject = PassthroughSubject<Bool, Never>()
4645
private let updateRoutineCompletionResultSubject = PassthroughSubject<Bool, Never>()
47-
private let routineSortTypeSubject = CurrentValueSubject<RoutineSortType?, Never>(nil)
4846

4947
private let calendar = Calendar.current
5048
private let today = Date()
@@ -104,9 +102,6 @@ final class HomeViewModel: ViewModel {
104102

105103
case .refreshSelectedDateRoutine:
106104
fetchDailyRoutine(for: selectedDateSubject.value)
107-
108-
case .selectRoutineSortType(let routineSortType):
109-
sortRoutine(routineSortType: routineSortType)
110105
}
111106
}
112107

@@ -309,19 +304,4 @@ final class HomeViewModel: ViewModel {
309304
}
310305
}
311306
}
312-
313-
private func sortRoutine(routineSortType: RoutineSortType?) {
314-
let dailyRoutines = routinesSubject.value
315-
var sortedRoutines: [MainRoutine]
316-
switch routineSortType {
317-
case .complete:
318-
sortedRoutines = dailyRoutines.sorted(by: { $0.isDone && !$1.isDone})
319-
case .incomplete:
320-
sortedRoutines = dailyRoutines.sorted(by: { !$0.isDone && $1.isDone})
321-
case nil:
322-
let dateKey = selectedDateSubject.value.convertToString(dateType: .yearMonthDate)
323-
sortedRoutines = self.routines[dateKey] ?? []
324-
}
325-
routinesSubject.send(sortedRoutines)
326-
}
327307
}

Projects/Presentation/Sources/RecommendedRoutine/Model/RoutineLevelType.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ extension RoutineLevelType: SelectableItem {
1616
}
1717
}
1818

19-
var title: String {
19+
var displayName: String? {
2020
switch self {
21-
case .easy: "가볍게 할 수 있어요"
22-
case .normal: "조금 신경써서 할 수 있어요"
23-
case .hard: "의지를 다 잡고 할 수 있어요"
21+
case .easy: "난이도 하"
22+
case .normal: "난이도 중"
23+
case .hard: "난이도 상"
24+
}
25+
}
26+
27+
var description: String {
28+
switch self {
29+
case .easy: "\(self.displayName ?? "") | 가볍게 할 수 있어요"
30+
case .normal: "\(self.displayName ?? "") | 조금 신경써서 할 수 있어요"
31+
case .hard: "\(self.displayName ?? "") | 의지를 다 잡고 할 수 있어요"
2432
}
2533
}
2634
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final class RoutineLevelButton: UIButton {
4141
stackView.axis = .horizontal
4242
stackView.spacing = Layout.stackViewSpacing
4343

44-
buttonLabel.text = level?.title ?? "난이도 선택"
44+
buttonLabel.text = level?.displayName ?? "난이도 선택"
4545
buttonLabel.font = BitnagilFont(style: .body2, weight: .medium).font
4646
buttonLabel.textColor = BitnagilColor.gray40
4747

@@ -73,7 +73,7 @@ final class RoutineLevelButton: UIButton {
7373
}
7474

7575
private func updateButtonLabel() {
76-
buttonLabel.text = level?.title ?? "난이도 선택"
76+
buttonLabel.text = level?.displayName ?? "난이도 선택"
7777
}
7878

7979
func updateButton(level: RoutineLevelType?) {

0 commit comments

Comments
 (0)