Skip to content

Commit

Permalink
✨ :: [#1072] 토스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
KangTaeHoon committed Aug 12, 2024
1 parent 7dbb9e4 commit d6fcce2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private extension FruitDrawViewController {
output.canDraw
.skip(1)
.bind(with: self) { owner, canDraw in
owner.drawOrConfirmButton.isEnabled = canDraw
owner.drawOrConfirmButton.isEnabled = true
owner.drawOrConfirmButton.setTitle(canDraw ? "음표 열매 뽑기" : "오늘 뽑기 완료", for: .normal)
owner.drawOrConfirmButton.backgroundColor = canDraw ?
DesignSystemAsset.PrimaryColorV2.point.color :
Expand All @@ -222,6 +222,12 @@ private extension FruitDrawViewController {
}
.disposed(by: disposeBag)

output.showToast
.bind(with: self) { owner, message in
owner.showToast(text: message, options: [.tabBar])
}
.disposed(by: disposeBag)

output.occurredError
.bind(with: self) { owner, message in
owner.showBottomSheet(
Expand Down Expand Up @@ -259,11 +265,16 @@ private extension FruitDrawViewController {

drawOrConfirmButton.rx.tap
.withLatestFrom(output.canDraw)
.withLatestFrom(output.fruitSource) { ($0, $1) }
.filter { $0.0 }
.filter { [output] canDraw in
guard canDraw else {
output.showToast.onNext("오늘은 더 이상 뽑을 수 없어요.")
return false
}
return true
}
.throttle(.seconds(2), latest: false, scheduler: MainScheduler.instance)
.bind(with: self) { owner, source in
let (_, fruit) = source
.withLatestFrom(output.fruitSource)
.bind(with: self) { owner, fruit in
let drawCompleted: Bool = fruit.quantity > 0

if drawCompleted {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class FruitDrawViewModel: ViewModelType {
imageURL: ""
))
let showRewardNote: PublishSubject<FruitEntity> = PublishSubject()
let showToast: PublishSubject<String> = PublishSubject()
let occurredError: PublishSubject<String> = PublishSubject()
}

Expand Down

0 comments on commit d6fcce2

Please sign in to comment.