Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'bug/(#179)-recruitment_filter_bug' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
HongSJae committed Oct 8, 2023
2 parents 57308c5 + f63d6d0 commit 21705e0
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,31 @@ struct RecruitmentFilterSheet: View {

selectedOption()

techCodeList(techCodeList: viewModel.techCodeList)
VStack(alignment: .leading, spacing: 20) {
ForEach(viewModel.techCodeList, id: \.code) { code in
TechCodeListCell(
title: code.keyword,
isChecked: viewModel.selectedTechCode.contains(code)
) {
withAnimation(.easeIn(duration: 0.3)) {
if viewModel.selectedTechCode.contains(code) {
viewModel.selectedTechCode.removeAll { $0 == code }
} else {
viewModel.selectedTechCode.append(code)
}
}
}

if code != viewModel.techCodeList.last {
Divider()
.foregroundColor(.Sub.gray40)
}
}

Spacer()
}
.padding(.bottom, 70)
.frame(maxHeight: .infinity)
}
.background(Color.Sub.gray10)
}
Expand Down Expand Up @@ -74,6 +98,8 @@ struct RecruitmentFilterSheet: View {
.JOBISFont(.body(.body4), color: .Sub.gray90)

Text(
viewModel.selectedJobCode?.keyword ?? "" +
(viewModel.selectedTechCode.isEmpty ? "": " | ") +
viewModel.selectedTechCode.map { $0.keyword }
.joined(separator: " | ")
)
Expand Down Expand Up @@ -102,14 +128,14 @@ struct RecruitmentFilterSheet: View {
items: jobCodeList,
itemSpacing: 4
) { jobCode in
let action = {
viewModel.selectedJobCode = viewModel.selectedJobCode == jobCode ? nil : jobCode
}

if viewModel.selectedJobCode == jobCode {
SolidBtn(text: jobCode.keyword, size: .small) { action() }
SolidBtn(text: jobCode.keyword, size: .small) {
viewModel.selectedJobCode = nil
}
} else {
ShadowBtn(text: jobCode.keyword, size: .small) { action() }
ShadowBtn(text: jobCode.keyword, size: .small) {
viewModel.selectedJobCode = jobCode
}
}
}
.padding(.vertical, 10)
Expand All @@ -119,33 +145,4 @@ struct RecruitmentFilterSheet: View {
}
})
}

@ViewBuilder
func techCodeList(techCodeList: [CodeEntity]) -> some View {
VStack(alignment: .leading, spacing: 20) {
ForEach(techCodeList, id: \.self) { code in
TechCodeListCell(
title: code.keyword,
isChecked: viewModel.selectedTechCode.contains(code)
) {
withAnimation(.easeIn(duration: 0.3)) {
if viewModel.selectedTechCode.contains(code) {
viewModel.selectedTechCode.removeAll { $0 == code }
} else {
viewModel.selectedTechCode.append(code)
}
}
}

if code != techCodeList.last {
Divider()
.foregroundColor(.Sub.gray40)
}
}

Spacer()
}
.padding(.bottom, 70)
.frame(maxHeight: .infinity)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@ import DesignSystem
import Kingfisher

struct RecruitmentListCell: View {
@Binding var recruitmentEntitys: [RecruitmentEntity]
let index: Int
@State private var isBookmarked: Bool = false
let recruitmentEntity: RecruitmentEntity
let bookmark: () -> Void

private let recruitmentDetailFactory: any RecruitmentDetailFactory

init(
recruitmentEntitys: Binding<[RecruitmentEntity]>,
index: Int,
recruitmentEntity: RecruitmentEntity,
recruitmentDetailFactory: any RecruitmentDetailFactory,
bookmark: @escaping () -> Void
) {
_recruitmentEntitys = recruitmentEntitys
self.index = index
self.recruitmentEntity = recruitmentEntity
self.bookmark = bookmark
self.recruitmentDetailFactory = recruitmentDetailFactory
}

var body: some View {
let recruitmentEntity = recruitmentEntitys[index]
NavigationLink {
recruitmentDetailFactory.makeView(
id: "\(recruitmentEntity.recruitID)", isDetail: false
Expand All @@ -36,7 +33,7 @@ struct RecruitmentListCell: View {
.cornerRadius(15)
.padding(8)

VStack(alignment: .leading, spacing: 0) {
VStack(alignment: .leading, spacing: 4) {
Text(recruitmentEntity.jobCodeList)
.multilineTextAlignment(.leading)
.JOBISFont(.body(.body2), color: .Sub.gray90)
Expand All @@ -45,28 +42,26 @@ struct RecruitmentListCell: View {
.JOBISFont(.etc(.caption), color: .Sub.gray60)

Spacer()

Text("실습 수당 \(recruitmentEntity.trainPay.intComma())만원")
.JOBISFont(.etc(.caption), color: .Sub.gray70)
}
.padding(.leading, 8)
.padding(.vertical, 14)
.padding(.top, 14)

Spacer()

VStack {
JOBISIcon(recruitmentEntity.bookmarked ? .bookmarkOn : .bookmarkOff)
JOBISIcon(self.isBookmarked ? .bookmarkOn : .bookmarkOff)
.frame(width: 12, height: 16)
.padding(5)
.onTapGesture {
recruitmentEntitys[index].bookmarked.toggle()
isBookmarked.toggle()
bookmark()
}

Spacer()

JOBISIcon(recruitmentEntity.military ? .militaryExceptionOn : .militaryExceptionOff)
.frame(width: 20, height: 20)
.opacity(recruitmentEntity.military ? 1 : 0)
}
.padding(.vertical, 14)
.padding(.trailing, 20)
Expand All @@ -75,6 +70,9 @@ struct RecruitmentListCell: View {
.background(Color.Sub.gray10)
.cornerRadius(15)
.shadow(color: .black, opacity: 0.1, blur: 4)
.onAppear {
self.isBookmarked = self.recruitmentEntity.bookmarked
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,34 @@ struct RecruitmentView: View {
LazyVStack {
searchBar()

if !viewModel.recruitmentList.recruitments.isEmpty {
ForEach(0..<viewModel.recruitmentList.recruitments.count, id: \.self) { index in
let recruitments = viewModel.recruitmentList.recruitments
if !recruitments.isEmpty {
ForEach(0..<recruitments.count, id: \.self) { index in
Button {
viewModel.isNavigateRecruitmentDetail.toggle()
} label: {
RecruitmentListCell(
recruitmentEntitys: $viewModel.recruitmentList.recruitments,
index: index,
recruitmentEntity: recruitments[index],
recruitmentDetailFactory: recruitmentDetailFactory
) {
viewModel.bookmark(id: viewModel.recruitmentList.recruitments[index].recruitID)
viewModel.recruitmentList.recruitments[index].bookmarked.toggle()
viewModel.bookmark(id: recruitments[index].recruitID)
}
}
.onAppear {
viewModel.appendRecruitmentList(list: viewModel.recruitmentList.recruitments[index])
viewModel.appendRecruitmentList(list: recruitments[index])
}
}
} else {
ProgressView().progressViewStyle(.circular)
Group {
if viewModel.isLoading {
ProgressView().progressViewStyle(.circular)
} else {
Text("모집의뢰서가 없어요. ❌")
.JOBISFont(.heading(.heading6), color: .Sub.gray90)
}
}
.padding(.vertical, 100)
}
}
.padding(.horizontal, 24)
Expand Down Expand Up @@ -96,7 +105,7 @@ struct RecruitmentView: View {

Spacer()

if !viewModel.selectedTechCode.isEmpty {
if !viewModel.selectedTechCode.isEmpty || viewModel.selectedJobCode != nil {
Text("필터 적용됨")
.JOBISFont(.etc(.caption), color: .Sub.gray60)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class RecruitmentViewModel: BaseViewModel {
@Published var recruitmentList: RecruitmentListEntity = .init(recruitments: [])
@Published var selectedJobCode: CodeEntity? {
didSet {
fetchCodeList(codeType: .tech, code: selectedJobCode?.code)
fetchCodeList(codeType: .tech)
}
}
@Published var selectedTechCode: [CodeEntity] = []
Expand Down Expand Up @@ -103,7 +103,7 @@ final class RecruitmentViewModel: BaseViewModel {
fetchCodeList(codeType: .tech)
}

private func fetchCodeList(codeType: CodeType, code: Int? = nil) {
private func fetchCodeList(codeType: CodeType) {
var keyword: String? {
switch codeType {
case .tech:
Expand All @@ -115,7 +115,7 @@ final class RecruitmentViewModel: BaseViewModel {
}

var parentCode: String? {
if let code {
if let code = selectedJobCode?.code, codeType == .tech {
return String(code)
} else {
return nil
Expand Down

0 comments on commit 21705e0

Please sign in to comment.