Skip to content

Commit

Permalink
Merge pull request #112 from DSM-PICK/feature/#111-weekend_meal_status
Browse files Browse the repository at this point in the history
feat :: [#111] 주말 급식 신청 상태 조회 디자인 수정
  • Loading branch information
cyj513 authored Oct 31, 2024
2 parents 583d81f + 1b8d0bc commit bcae8a2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 51 deletions.
10 changes: 8 additions & 2 deletions Projects/Data/Sources/DTO/WeekendMeal/WeekendMealPeriodDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ public struct WeekendMealPeriodDTO: Decodable {

extension WeekendMealPeriodDTO {
func toDomain() -> WeekendMealPeriodEntity {
var weekendMealPeriod: String {
guard let start, let end else { return "" }
let startDate = start.toDate(type: .fullDate).toString(type: .monthAndDayKor)
let endDate = end.toDate(type: .fullDate).toString(type: .monthAndDayKor)
return "(\(startDate) ~ \(endDate))"
}

return .init(
status: status,
start: start,
end: end
period: weekendMealPeriod
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ import Core

public struct WeekendMealPeriodEntity {
public let status: Bool
public let start: String?
public let end: String?
public let period: String

public init(
status: Bool,
start: String?,
end: String?
) {
public init(status: Bool, period: String) {
self.status = status
self.start = start
self.end = end
self.period = period
}

}
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 bcae8a2

Please sign in to comment.