IOS_Boss/IOS_study/Jobs/PLJobsView+.swift
2025-07-27 12:33:06 +08:00

119 lines
3.7 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// PLJobsView+.swift
// IOS_study
//
// Created by CC-star on 2025/7/10.
//
import SwiftUI
extension PLJobsView {
//
var filterBtn: some View {
Button {
showOrderView = false
showFilterView.toggle()//
} label: {
HStack(spacing: 3) {
Text("筛选")
if vm.filter.totalCount > 0 {
Text("\(vm.filter.totalCount)").badgeStyle()
}
arrowIcon(showFilterView)
}.tc2().size15()
}.disabled(vm.isFcJobs)
}
var plFilterView: some View {
VStack(spacing: 14) {
VStack(alignment: .leading) {
Text("行业").labelStyleOF()
LazyVGrid(columns: [GridItem(.adaptive(minimum: 80))]) {
ForEach(kBusinessArr,id: \.self) { business in
Button {
if vm.filter.business == business {
vm.filter.business = nil
} else {
vm.filter.business = business
}
} label: {
Text(business).frame(maxWidth: .infinity)
}.selectBtnStyle(vm.filter.business == business)
}
}
}
VStack(alignment: .leading) {
Text("城市").labelStyleOF()
LazyVGrid(columns: [GridItem(.adaptive(minimum: 70))]) {
ForEach(kCityArr,id: \.self) { city in
Button {
if vm.filter.city == city {
vm.filter.city = nil
} else {
vm.filter.city = city
}
} label: {
Text(city).frame(maxWidth: .infinity)
}.selectBtnStyle(vm.filter.city == city)
}
}
}
HStack {
Button {
vm.filter = PLFilter()
} label: {
Text("清空").appleStyleS()
}.buttonStyle(.bordered)
Button {
showFilterView = false
getJobsByOF()
} label: {
Text("筛选").appleStyleS()
}.tint(.aTC).buttonStyle(.borderedProminent)
}.padding(.top, 9)
}.size14().padding().bg()
}
//
var orderBtn: some View {
Button {
showFilterView = false
showOrderView.toggle()//
} label: {
HStack(spacing: 3) {
Text(vm.order.rawValue)
arrowIcon(showOrderView)
}.tc2().size15()
}.disabled(vm.isFcJobs)
}
//
var plOrderView: some View {
VStack(spacing: 14) {
ForEach(PLOrder.allCases.indices, id: \.self) { index in
let order = PLOrder.allCases[index]
HStack {
Text(order.rawValue).foregroundStyle(vm.order == order ? .accent : .aTC)
Spacer()
if vm.order == order { Image(systemName: "checkmark.circle.fill").accent() }
}.contentShape(Rectangle())//
.onTapGesture {
vm.order = order
showOrderView = false
getJobsByOF()
}
if order != PLOrder.allCases.last { exDivider() }
}
}.size15().padding().bg()
}
func getJobsByOF() {//
vm.isOF.toggle()
if vm.filter == lastPLFilter && vm.order == lastPLOrder { return }//\
lastPLFilter = vm.filter
lastPLOrder = vm.order
Task {
await vm.getJobs(isResFresh: true)//
}
}
}