Skip to content

Commit

Permalink
Merge pull request #47 from sanghyeok-kim/feature/#46-empty-timer-nam…
Browse files Browse the repository at this point in the history
…e-placeholder

타이머 편집시 이름이 설정되지 않았을 경우에 대한 placeholder 표시
  • Loading branch information
sanghyeok-kim authored Aug 9, 2023
2 parents b3e0c74 + 044073d commit 9bb9684
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class TimerEditingReactor: Reactor {
case setTimePickerViewIsHidden(Bool)
case editTimer(Timer)
case updateSelectedRingtone(Ringtone)
case setTimerNamePlaceholder(String)
}

struct State {
Expand All @@ -32,6 +33,7 @@ final class TimerEditingReactor: Reactor {
var isCompleteButtonEnable: Bool = false
var isTimePickerViewHidden: Bool = false
var shouldExitScene: Bool = false
var timerNamePlaceholder: String?
}

let initialState: State
Expand Down Expand Up @@ -81,7 +83,11 @@ final class TimerEditingReactor: Reactor {
case .viewDidLoad:
let initialTimer = currentState.initialTimer
let isTimePickerViewHidden = !initialTimer.type.shouldSetTime
return .just(.setTimePickerViewIsHidden(isTimePickerViewHidden))
let placeholder = initialTimer.name.isEmpty ? initialTimer.type.placeholder : initialTimer.name
return .concat(
.just(.setTimePickerViewIsHidden(isTimePickerViewHidden)),
.just(.setTimerNamePlaceholder(placeholder))
)

case .ringtoneButtonDidTap:
return showRingtoneSelectScene(selectedRingtoneRelay: selectedRingtoneRelay)
Expand All @@ -107,6 +113,9 @@ final class TimerEditingReactor: Reactor {
initialTimer: state.initialTimer,
newTimer: newState.editedTimer
)

case .setTimerNamePlaceholder(let placeholder):
newState.timerNamePlaceholder = placeholder
}
return newState
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ private extension TimerEditingViewController {
.map { LocalizableString.ringtoneName(ringtone: $0 ?? .default1).localized }
.bind(to: ringtoneButton.rx.configurationTitle)
.disposed(by: disposeBag)

reactor.state.map { $0.timerNamePlaceholder }
.distinctUntilChanged()
.bind(to: nameTextField.rx.placeholder)
.disposed(by: disposeBag)
}
}

Expand All @@ -189,7 +194,6 @@ private extension TimerEditingViewController {

func configureUI(with timer: Timer) {
title = LocalizableString.settingTimer(timerType: timer.type).localized
nameTextField.placeholder = timer.name
nameTextField.text = timer.name
timePickerView.selectRows(by: timer.time, animated: true)
}
Expand Down

0 comments on commit 9bb9684

Please sign in to comment.