236 lines
8.6 KiB
Swift
236 lines
8.6 KiB
Swift
//
|
||
// PLJobsView+JobUI.swift
|
||
// IOS_study
|
||
//
|
||
// Created by CC-star on 2025/7/24.
|
||
//
|
||
|
||
import SwiftUI
|
||
|
||
extension PLJobView {
|
||
// MARK: - 头部视图
|
||
var tilteView: some View {
|
||
VStack(alignment: .leading,spacing: kStackSpacing) {
|
||
//第一层
|
||
HStack {
|
||
VStack(alignment: .leading) {
|
||
HStack {
|
||
Text(job.business)
|
||
.labelBG2()
|
||
if job.updatedAt.daysFromNow <= 7 { Text("新到").labelWA() }
|
||
if job.wantWorkNum > 0 {
|
||
Text("\(job.wantWorkNum)").size13s()
|
||
}
|
||
}
|
||
Text(job.title + titleAD).tc().size18b()
|
||
}
|
||
Spacer()
|
||
Text("\(job.hourlyWage)").accent().headline()
|
||
}.padding(.bottom,-2)
|
||
//第二层
|
||
HStack{
|
||
Text(job.placeName)
|
||
if job.tax == "不报税" {
|
||
Text(job.tax).accentBorder()
|
||
} else if job.tax == "报税" {
|
||
Text(job.tax).redBorder()
|
||
} else {
|
||
Text(job.tax).grayBorder()
|
||
}
|
||
|
||
Text("\(job.updatedAt.toStr)发布").secondary()
|
||
}
|
||
//第三层
|
||
HStack(spacing: kStackSpacing){
|
||
HStack {
|
||
HStack(spacing: kIconSpacing) {
|
||
//icon
|
||
Image("station").iconStyle()
|
||
Text("\(job.province)-\(job.city)").semib()
|
||
//导航按钮:一键智能导航
|
||
Button {
|
||
let destination = LocationHelper.shared.buildSmartAddress(job: job)
|
||
LocationHelper.shared.navigateToDestination(destination: destination) { errorMessage in
|
||
if let message = errorMessage {
|
||
hud.show(message)
|
||
}
|
||
}
|
||
} label: {
|
||
Text("导航")
|
||
}.btnStyle()
|
||
}
|
||
HStack(spacing: kIconSpacing) {
|
||
Image("want").iconStyle()
|
||
Text("招\(job.wantNum)人")
|
||
}
|
||
|
||
if canEdit && job.userID == AuthManager.shared.getUserID(){
|
||
HStack {
|
||
Button("编辑") {
|
||
vm.draftJob = job
|
||
naviPath.append(Navi5.PLJobToEdit)
|
||
}.buttonStyle(.borderless).accent().disabled(isIng)
|
||
|
||
Button { showActiveDialog = true } label: {
|
||
if vm.isToggling { ProgressView().controlSize(.small) } else { Text(isActive ? "下线" : "上线") }
|
||
}.buttonStyle(.borderless).accent().disabled(isIng)
|
||
.confirmationDialog(isActive ? "确定下线吗" : "确定上线吗", isPresented: $showActiveDialog, titleVisibility: .visible) {
|
||
Button("确定") {
|
||
Task { await toggleJobStatus() }
|
||
}
|
||
Button("再想想", role: .cancel) { }
|
||
}
|
||
Button { showRemoveDialog = true } label: {
|
||
if vm.isRemoving { ProgressView().controlSize(.small) } else { Text("删除") }
|
||
}.buttonStyle(.borderless).accent().disabled(isIng)
|
||
.confirmationDialog("确定删除吗", isPresented: $showRemoveDialog, titleVisibility: .visible) {
|
||
Button("确定", role: .destructive) {
|
||
showRemoveAlert = true
|
||
}
|
||
Button("再想想", role: .cancel) { }
|
||
}.alert("删除之后不可恢复", isPresented: $showRemoveAlert) {
|
||
Button("确定", role: .destructive) { Task { await removeJob() } }
|
||
Button("取消", role: .cancel) { }
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}.textStyle2().cellStyle()
|
||
}
|
||
// MARK: - 公司视图
|
||
var companyView: some View {
|
||
Button {
|
||
//todo
|
||
} label: {
|
||
HStack(spacing: kIconSpacing){
|
||
Image("company").iconStyle()
|
||
Text(job.companyName).size16semib().oneLineStyleMiddle()
|
||
Spacer()
|
||
Group {
|
||
Text("更多工作")
|
||
Image(systemName: "chevron.right")
|
||
}.secondary()
|
||
}
|
||
}.textStyle().cellStyle().buttonStyle(.borderless)
|
||
}
|
||
// MARK: - 工作详情
|
||
var detailView: some View {
|
||
VStack(alignment: .leading,spacing:kStackSpacingS) {
|
||
//公司时间
|
||
VStack(alignment: .leading,spacing: kStackSpacingS) {
|
||
HStack(spacing: kIconSpacing) {
|
||
Image("time").iconStyle()
|
||
Text("工作时间").subTStyle()
|
||
}
|
||
|
||
HStack(spacing: 2) {
|
||
Text("\(job.startHour)")
|
||
Text(":").conlonStyle()
|
||
Text(job.startMin == 0 ? "00" : "\(job.startMin)")
|
||
Text("-").conlonStyle()
|
||
Text("\(job.endHour)")
|
||
Text(":").conlonStyle()
|
||
Text(job.endMin == 0 ? "00" : "\(job.endMin)")
|
||
}
|
||
|
||
if job.has2 {
|
||
HStack(spacing: 2) {
|
||
Text("\(job.startHour2)")
|
||
Text(":").conlonStyle()
|
||
Text(job.startMin2 == 0 ? "00" : "\(job.startMin2)")
|
||
Text("-").conlonStyle()
|
||
Text("\(job.endHour2)")
|
||
Text(":").conlonStyle()
|
||
Text(job.endMin2 == 0 ? "00" : "\(job.endMin2)")
|
||
}
|
||
|
||
}
|
||
|
||
// Text("\(job.startHour)-\(job.endHour)").labelBG()
|
||
// if job.has2 {
|
||
// Text("\(job.startHour2)-\(job.endHour2)").labelBG()
|
||
// }
|
||
}
|
||
|
||
// Divider()
|
||
exDivider()
|
||
if !job.workContent.isEmpty {
|
||
//工作内容
|
||
VStack(alignment: .leading,spacing: kStackSpacingS) {
|
||
HStack(spacing: kIconSpacing) {
|
||
Image("content").iconStyle()
|
||
Text("工作内容").subTStyle()
|
||
}
|
||
Text(job.workContent).allowMulti()
|
||
}
|
||
exDivider()
|
||
}
|
||
//工作要求
|
||
VStack(alignment: .leading,spacing: kStackSpacingS) {
|
||
HStack(spacing: kIconSpacing) {
|
||
Image("need").iconStyle()
|
||
Text("工作要求").subTStyle()
|
||
}
|
||
HStack {
|
||
Text(job.needExp).labelWAL()
|
||
Text(job.needEdu).labelWAL()
|
||
}
|
||
HStack {
|
||
Text(job.needLan).labelWAL()
|
||
Text(job.needFrame).labelWAL()
|
||
}
|
||
if !job.otherNeed.isEmpty {
|
||
Text(job.otherNeed).allowMulti()
|
||
}
|
||
}
|
||
|
||
//公式福利
|
||
exDivider()
|
||
VStack(alignment: .leading,spacing: kStackSpacingS) {
|
||
HStack(spacing: kIconSpacing) {
|
||
Image("benefit").iconStyle()
|
||
Text("公式福利").subTStyle()
|
||
}
|
||
HStack {
|
||
if job.noOverTime {
|
||
Text("不加班").labelWAL()
|
||
}
|
||
if job.moveFee {
|
||
Text("交通费").labelWAL()
|
||
}
|
||
}
|
||
//更多福利
|
||
if !job.otherBenefit.isEmpty {
|
||
Text(job.otherBenefit).allowMulti()
|
||
}
|
||
}
|
||
}.textStyle2().cellStyle()
|
||
}
|
||
// MARK: - 应聘电话
|
||
var contactView: some View {
|
||
VStack(alignment: .leading,spacing:kStackSpacingS){
|
||
Text("应聘方式(\(job.contactType))").subTStyleL()
|
||
HStack {
|
||
Text("\(job.contact)").size20b().tc().allowMulti()
|
||
Spacer()
|
||
Button("复制"){
|
||
UIPasteboard.general.string = job.contact
|
||
hud.show("复制成功")
|
||
//todo弹窗提示
|
||
}.btnStyle().padding(6)
|
||
|
||
|
||
// Button {
|
||
// UIPasteboard.general.string = "0423-1230-1241"
|
||
// //todo弹窗提示
|
||
// }
|
||
// } label: {
|
||
// Text("复制")
|
||
// }.btnStyle().padding(6)
|
||
}
|
||
Text("若问起,请说是在测试软件上看到的").size14().purple()
|
||
}.cellStyle()
|
||
}
|
||
}
|