Skip to content

Commit

Permalink
[Chore] #80 - 반복되는 숫자 상수화
Browse files Browse the repository at this point in the history
  • Loading branch information
JinUng41 committed Jan 12, 2025
1 parent 01bec7c commit e4e3c34
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,38 @@ private extension InfoPageViewController {
.receive(on: RunLoop.main)
.sink { [weak self] isNewsBadgeShown, isNoticeBadgeShown in
if isNewsBadgeShown {
self?.rootView.segmentedControl.showBadge(at: 2)
self?.rootView.segmentedControl.showBadge(at: Constants.newsIndexNumber)
}

if isNoticeBadgeShown {
self?.rootView.segmentedControl.showBadge(at: 3)
self?.rootView.segmentedControl.showBadge(at: Constants.noticeIndexNumber)
}
}
.store(in: cancelBag)

output.hideNewsBadge
.receive(on: RunLoop.main)
.sink { [weak self] _ in
self?.rootView.segmentedControl.hideBadge(at: 2)
self?.rootView.segmentedControl.hideBadge(at: Constants.newsIndexNumber)
}
.store(in: cancelBag)

output.hideNoticeBadge
.receive(on: RunLoop.main)
.sink { [weak self] _ in
self?.rootView.segmentedControl.hideBadge(at: 3)
self?.rootView.segmentedControl.hideBadge(at: Constants.noticeIndexNumber)
}
.store(in: cancelBag)
}
}

private extension InfoPageViewController {

// MARK: - Constants

enum Constants {
static let newsIndexNumber = 2
static let noticeIndexNumber = 3
}

}
16 changes: 12 additions & 4 deletions Wable-iOS/Presentation/Info/Page/ViewModel/InfoPageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension InfoPageViewModel: ViewModelType {
.eraseToAnyPublisher()

let hideNewsBadge = input.currentIndex
.filter { $0 == 2 }
.filter { $0 == Constants.newsIndexNumber }
.combineLatest(infoCount)
.map { $1 }
.filter { $0.newsCount > existingNewsCount }
Expand All @@ -67,7 +67,7 @@ extension InfoPageViewModel: ViewModelType {
.eraseToAnyPublisher()

let hideNoticeBadge = input.currentIndex
.filter { $0 == 3 }
.filter { $0 == Constants.noticeIndexNumber }
.combineLatest(infoCount)
.map { $1 }
.filter { $0.noticeCount > existingNoticeCount }
Expand Down Expand Up @@ -104,9 +104,10 @@ extension InfoPageViewModel: ViewModelType {
}
}

// MARK: - UserDefaultsKey

extension InfoPageViewModel {

// MARK: - UserDefaultsKey

enum UserDefaultsKeys: UserDefaultsKey {
case newsCount
case noticeCount
Expand All @@ -118,4 +119,11 @@ extension InfoPageViewModel {
}
}
}

// MARK: - Constants

enum Constants {
static let newsIndexNumber = 2
static let noticeIndexNumber = 3
}
}

0 comments on commit e4e3c34

Please sign in to comment.