Skip to content

Commit

Permalink
feat :: [#111] 주말급식 신청 상태 조회 디자인 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
cyj513 committed Oct 31, 2024
1 parent df6bd62 commit 1b8d0bc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ public class WeekendMealApplyView: BaseView {

public var applyState = BehaviorRelay<Bool>(value: false)

private let applyDate = Date()
private let calendar = Calendar.current
private lazy var nextMonth = calendar.date(byAdding: .month, value: 1, to: applyDate)

private lazy var currnetMonthWeekendMealApplyLabel = PiCKLabel(
text: "\(nextMonth?.toString(type: .month) ?? "Error") 주말 급식 신청",
textColor: .modeBlack,
font: .body1
)
Expand All @@ -34,17 +29,18 @@ public class WeekendMealApplyView: BaseView {
$0.distribution = .fillEqually
}

public func setApplyText(
public func setup(
status: Bool,
month: Int?
month: Int
) {
if status == true {
self.currnetMonthWeekendMealApplyLabel.text = "\(month ?? 0)월 주말 급식 신청"
self.buttonStackView.isHidden = false
self.currnetMonthWeekendMealApplyLabel.text = "\(month)월 주말 급식 신청"
} else {
self.currnetMonthWeekendMealApplyLabel.text = "지금은 신청 기간이 아닙니다."
self.buttonStackView.isHidden = true
let statusText = "\(status ? "신청" : "미신청")"
self.currnetMonthWeekendMealApplyLabel.text = "주말 급식 신청 상태는 \(statusText)입니다."
self.currnetMonthWeekendMealApplyLabel.changePointColor(targetString: "\(statusText)", color: .main500)
}
self.buttonStackView.isHidden = !status
}
public func setStatus(
status: Bool
Expand All @@ -70,20 +66,21 @@ public class WeekendMealApplyView: BaseView {
}
public override func bind() {
applyState.asObservable()
.subscribe(onNext: { data in
self.applyButton.isSelected = data
self.notApplyButton.isSelected = !data
}).disposed(by: disposeBag)

applyButton.rx.tap
.bind(onNext: { [self] in
.withUnretained(self)
.bind { owner, data in
owner.applyButton.isSelected = data
owner.notApplyButton.isSelected = !data
}.disposed(by: disposeBag)

applyButton.buttonTap
.bind { [self] in
clickRadioButton(button: applyButton)
}).disposed(by: disposeBag)
}.disposed(by: disposeBag)

notApplyButton.buttonTap
.bind(onNext: { [self] in
.bind { [self] in
clickRadioButton(button: notApplyButton)
}).disposed(by: disposeBag)
}.disposed(by: disposeBag)
}
public override func layout() {
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public class WeekendMealApplyViewController: BaseViewController<WeekendMealApply
.asObservable()
.withUnretained(self)
.bind { owner, data in
owner.weekendMealApplyView.setApplyText(
owner.weekendMealApplyView.setup(
status: data.status,
month: data.month
month: data.month ?? 0
)
owner.saveButton.isHidden = !data.status
}.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public class WeekendMealApplyViewModel: BaseViewModel, Stepper {
return WeekendMealType(rawValue: $0.status) ?? .ok
}
}
.bind {
self.weekendMealStatusRelay.accept($0)
}
.bind(to: weekendMealStatusRelay)
.disposed(by: disposeBag)

input.viewWillAppear
Expand All @@ -66,14 +64,14 @@ public class WeekendMealApplyViewModel: BaseViewModel, Stepper {
.bind(to: weekendMealApplicationPeriod)
.disposed(by: disposeBag)

input.applyStatus
.bind {
self.weekendMealStatusRelay.accept($0)
}
.disposed(by: disposeBag)
// input.applyStatus
// .bind {
// self.weekendMealStatusRelay.accept($0)
// }
// .disposed(by: disposeBag)

input.clickApplyButton
.withLatestFrom(self.weekendMealStatusRelay)
.withLatestFrom(input.applyStatus)
.flatMap { status in
self.weekendMealApplyUseCase.execute(status: status)
.catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ public class WeekendMealPeriodHeaderView: BaseView {
)

public func setup(
startPeriodText: String?,
endPeriodText: String?
period: String
) {
let startPeriod = startPeriodText?.toDate(type: .fullDate).toString(type: .monthAndDayKor) ?? ""
let endPeriod = endPeriodText?.toDate(type: .fullDate).toString(type: .monthAndDayKor) ?? ""

let period = "\(startPeriod)~\(endPeriod)"

self.announcementLabel.text = "지금은 주말 급식 신청 기간입니다 (\(period))"
self.announcementLabel.text = "지금은 주말 급식 신청 기간입니다 \(period)"
self.announcementLabel.changePointColor(targetString: "주말 급식 신청 기간", color: .main900)
}

Expand Down

0 comments on commit 1b8d0bc

Please sign in to comment.