Skip to content

Commit

Permalink
Merge pull request #317 from OMZigak/feat/#312-add-promise
Browse files Browse the repository at this point in the history
[feat] 약속 추가 플로우 변경된 기능 명세 반영하기
  • Loading branch information
JinUng41 authored Aug 22, 2024
2 parents f19d3b8 + e0c7d53 commit 61b8c50
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 53 deletions.
4 changes: 2 additions & 2 deletions KkuMulKum/Source/AddPromise/View/AddPromiseCompleteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ final class AddPromiseCompleteView: BaseView {
}

progressView.snp.makeConstraints {
$0.top.equalTo(safeArea).offset(-2)
$0.top.equalTo(safeArea).offset(-1)
$0.horizontalEdges.equalToSuperview()
$0.height.equalTo(Screen.height(3))
$0.height.equalTo(Screen.height(4))
}

completionImageView.snp.makeConstraints {
Expand Down
4 changes: 2 additions & 2 deletions KkuMulKum/Source/AddPromise/View/AddPromiseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ final class AddPromiseView: BaseView {
let safeArea = safeAreaLayoutGuide

progressView.snp.makeConstraints {
$0.top.equalTo(safeArea).offset(-2)
$0.top.equalTo(safeArea).offset(-1)
$0.horizontalEdges.equalToSuperview()
$0.height.equalTo(Screen.height(3))
$0.height.equalTo(Screen.height(4))
}

descriptionStackView.snp.makeConstraints {
Expand Down
38 changes: 35 additions & 3 deletions KkuMulKum/Source/AddPromise/View/SelectMemberView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,36 @@ final class SelectMemberView: BaseView {
)
}

let confirmButton = CustomButton(title: "다음")
private let emptyImageView = UIImageView().then {
$0.contentMode = .scaleAspectFill
$0.image = .imgEmptyTardy.withRenderingMode(.alwaysOriginal)
}

private let emptyLabel = UILabel().then {
$0.setText(
"약속에 함께할 꾸물이들이 없어요!\n모임에 친구들을 초대해보세요",
style: .body05,
color: .gray3
)
$0.textAlignment = .center
}

let emptyContentView = UIStackView(axis: .vertical).then {
$0.spacing = 32
$0.alignment = .center
$0.isHidden = true
}

let confirmButton = CustomButton(title: "다음", isEnabled: true)

override func setupView() {
descriptionStackView.addArrangedSubviews(pageNumberLabel, titleLabel)
emptyContentView.addArrangedSubviews(emptyImageView, emptyLabel)
addSubviews(
progressView,
descriptionStackView,
memberListView,
emptyContentView,
confirmButton
)
}
Expand All @@ -62,9 +84,9 @@ final class SelectMemberView: BaseView {
let safeArea = safeAreaLayoutGuide

progressView.snp.makeConstraints {
$0.top.equalTo(safeArea).offset(-2)
$0.top.equalTo(safeArea).offset(-1)
$0.horizontalEdges.equalToSuperview()
$0.height.equalTo(Screen.height(3))
$0.height.equalTo(Screen.height(4))
}

descriptionStackView.snp.makeConstraints {
Expand All @@ -78,6 +100,16 @@ final class SelectMemberView: BaseView {
$0.bottom.equalToSuperview().offset(-167)
}

emptyImageView.snp.makeConstraints {
$0.width.equalTo(Screen.width(112))
$0.height.equalTo(Screen.height(122))
}

emptyContentView.snp.makeConstraints {
$0.top.equalTo(descriptionStackView.snp.bottom).offset(130)
$0.horizontalEdges.equalToSuperview().inset(84)
}

confirmButton.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(20)
$0.height.equalTo(Screen.height(CustomButton.defaultHeight))
Expand Down
4 changes: 2 additions & 2 deletions KkuMulKum/Source/AddPromise/View/SelectPenaltyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ final class SelectPenaltyView: BaseView {
let safeArea = safeAreaLayoutGuide

progressView.snp.makeConstraints {
$0.top.equalTo(safeArea).offset(-2)
$0.top.equalTo(safeArea).offset(-1)
$0.horizontalEdges.equalToSuperview()
$0.height.equalTo(Screen.height(3))
$0.height.equalTo(Screen.height(4))
}

descriptionStackView.snp.makeConstraints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ private extension SelectMemberViewController {
}
.disposed(by: disposeBag)

output.isEnabledConfirmButton
output.memberList
.map { $0.isEmpty }
.drive(with: self) { owner, flag in
owner.rootView.confirmButton.isEnabled = flag
owner.rootView.memberListView.isHidden = flag
owner.rootView.emptyContentView.isHidden = !flag
}
.disposed(by: disposeBag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ extension AddPromiseViewModel: ViewModelType {
let adjustedDate = Observable.combineLatest(input.date, input.time)
.map { date, time -> Date in
let calendar = Calendar.current
var combinedComponents = DateComponents()

guard let tempDate = calendar.date(byAdding: .minute, value: -1, to: Date()) else {
return Date()
Expand Down
12 changes: 2 additions & 10 deletions KkuMulKum/Source/AddPromise/ViewModel/SelectMemberViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ extension SelectMemberViewModel: ViewModelType {

struct Output {
let memberList: Driver<[Member]>
let isEnabledConfirmButton: Driver<Bool>
}

func transform(input: Input, disposeBag: DisposeBag) -> Output {
Expand Down Expand Up @@ -75,13 +74,8 @@ extension SelectMemberViewModel: ViewModelType {
}
.disposed(by: disposeBag)

let isEnabledConfirmButton = selectedMemberListRelay
.map { !$0.isEmpty }
.asDriver(onErrorJustReturn: false)

let output = Output(
memberList: memberListRelay.asDriver(onErrorJustReturn: []),
isEnabledConfirmButton: isEnabledConfirmButton
memberList: memberListRelay.asDriver(onErrorJustReturn: [])
)

return output
Expand All @@ -92,9 +86,7 @@ private extension SelectMemberViewModel {
func fetchMeetingMembers() {
Task {
do {
guard let responseBody = try await service.fetchMeetingMemberListExcludeLoginUser(
with: meetingID
),
guard let responseBody = try await service.fetchMeetingMemberListExcludeLoginUser(with: meetingID),
responseBody.success
else {
memberListRelay.accept([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ final class MeetingInfoViewController: BaseViewController {
setupNavigationBarBackButton()
}

override func setupAction() {
rootView.createPromiseButtonDidTap
.subscribe(with: self) { owner, _ in
owner.navigateToAddPromise()
}
.disposed(by: disposeBag)
}

override func setupDelegate() {
rootView.promiseListView.delegate = self
}
Expand Down Expand Up @@ -144,22 +152,6 @@ private extension MeetingInfoViewController {
)
}
.disposed(by: disposeBag)

output.isPossbleToCreatePromise
.drive(with: self) { owner, flag in
guard flag else {
let toast = Toast()
toast.show(
message: "모임에 구성원이 없어서 약속을 만들 수 없어요.",
view: owner.view,
position: .bottom,
inset: 100
)
return
}
owner.navigateToAddPromise()
}
.disposed(by: disposeBag)
}

func navigateToAddPromise() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ extension MeetingInfoViewModel: ViewModelType {
let memberCount: Driver<Int>
let members: Driver<[Member]>
let promises: Driver<[MeetingPromise]>
let isPossbleToCreatePromise: Driver<Bool>
}

func transform(input: Input, disposeBag: DisposeBag) -> Output {
Expand Down Expand Up @@ -74,25 +73,12 @@ extension MeetingInfoViewModel: ViewModelType {
return model.promises
}
.asDriver(onErrorJustReturn: [])

let isPossibleToCreatePromise = input.createPromiseButtonDidTap
.map { [weak self] _ in
guard let count = self?.meetingMemberModelRelay.value?.memberCount,
count > 1
else {
return false
}
return true
}
.asDriver(onErrorJustReturn: false)


let output = Output(
info: info,
memberCount: memberCount,
members: members,
promises: promises,
isPossbleToCreatePromise: isPossibleToCreatePromise
promises: promises
)

return output
Expand Down

0 comments on commit 61b8c50

Please sign in to comment.