IOS_Boss/IOS_study/PLJobView.swift
2025-07-01 11:41:38 +08:00

254 lines
9.3 KiB
Swift
Raw Permalink 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.

//
// PLJobView.swift
// IOS_study
//
// Created by CC-star on 2025/6/13.
//
import SwiftUI
struct PLJobView: View {
@Environment(PLJobViewModel.self) var vm
@State var showActiveDialog = false
@State var showRemoveDialog = false
@State var showRemoveAlert = false
@Binding var naviPath : NavigationPath
var job: PLJob { vm.job }
var isActive:Bool{ vm.job.isActive }
var titleAD: String { isActive ? "" : "[已下线]" }
@Environment(HUD.self) var hud
var body: some View {
List {
//
VStack(alignment: .leading,spacing: kStackSpacing) {
//
HStack {
VStack(alignment: .leading) {
HStack {
Text(job.business)
.labelBG2()
if job.updatedAt.daysFromNow <= 7 { Text("新到").labelWA() }
Text("3人想去")
.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()
}
Text("\(job.updatedAt.toStr)发布").secondary()
}
//
HStack(spacing: kStackSpacing){
HStack {
HStack(spacing: kIconSpacing) {
//icon
Image("station").iconStyle()
Text("\(job.province)-\(job.city)").semib()
Button {
if let url = URL(string: "https://maps.google.com/?q=\(job.province)\(job.city)"){
UIApplication.shared.open(url)
}
} label: {
Text("导航")
}.btnStyle()
}
HStack(spacing: kIconSpacing) {
Image("want").iconStyle()
Text("\(job.wantNum)")
}
HStack {
Button("编辑") {
vm.draftJob = job
naviPath.append(Navi1.PLJobToEdit)
}.buttonStyle(.borderless).accent()
Button(isActive ? "下线" : "上线") {
showActiveDialog = true
}.buttonStyle(.borderless).accent()
.confirmationDialog(isActive ? "确定下线吗" : "确定上线吗", isPresented: $showActiveDialog, titleVisibility: .visible) {
Button("确定") {
toggleJobStatus()
}
Button("再想想", role: .cancel) { }
}
Button("删除") {
showRemoveDialog = true
}.buttonStyle(.borderless).accent()
.confirmationDialog("确定删除吗", isPresented: $showRemoveDialog, titleVisibility: .visible) {
Button("确定", role: .destructive) {
showRemoveAlert = true
}
Button("再想想", role: .cancel) { }
}.alert("删除之后不可恢复", isPresented: $showRemoveAlert) {
Button("确定", role: .destructive) { removeJob() }
Button("取消", role: .cancel) { }
}
}
}
}
}.textStyle2().cellStyle()
//
Button {
} label: {
HStack(spacing: kIconSpacing){
Image("company").iconStyle()
Text(job.companyName).size16semib().oneLineStyleMiddle()
Spacer()
Group {
Text("更多工作")
Image(systemName: "chevron.right")
}.secondary()
}
}.textStyle().cellStyle().buttonStyle(.borderless)
//
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()
//
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()
listBottomEView()
}.listStyle().navigationTitle("长期兼职").navigationBarTitleDisplayMode(.inline).navigationBarBackButtonHidden()
//
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
if !naviPath.isEmpty {//
naviPath.removeLast()//
}
} label: {
Image(systemName: "chevron.left").secondary().padding(.horizontal,6)
}.btnStyle()
}
}
}
}
//#Preview {
// PLJobView(naviPath: .constant(NavigationPath()))
//}