99 lines
3.9 KiB
Swift
99 lines
3.9 KiB
Swift
//
|
|
// ProfileView+ComUI.swift
|
|
// IOS_study
|
|
//
|
|
// Created by CC-star on 2025/7/18.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Kingfisher
|
|
|
|
extension ProfileView {
|
|
var myCompanyView: some View {
|
|
VStack(alignment: .leading, spacing: 14) {
|
|
HStack {
|
|
// MARK: - 公司头部信息
|
|
Text("我的公司").headline().tc()
|
|
if user.cIsUploaded {
|
|
Button {
|
|
ProfileVM.draftUser = user
|
|
naviPath.append(Navi5.EditCompany)
|
|
} label: { Text("编辑") }.btnStyle()
|
|
} else {
|
|
Button {
|
|
ProfileVM.draftUser = DBUser()
|
|
naviPath.append(Navi5.AddCompany)
|
|
} label: { Text("去添加") }.btnStyle()
|
|
}
|
|
}
|
|
|
|
if user.cIsUploaded {//上传了公司信息
|
|
VStack(alignment: .leading, spacing: 9) {
|
|
HStack {
|
|
if user.cLogoURLStr.isEmpty {
|
|
Text("🏬").font(.system(size: 40))
|
|
} else {
|
|
Button {
|
|
showLogo = true
|
|
} label: {
|
|
KFImage(URL(string: user.cLogoURLStr))
|
|
.placeholder { ProgressView() }.loadDiskFileSynchronously().fade(duration: 0.15)
|
|
.onSuccess { result in
|
|
let image = result.image
|
|
logoAspectRatio = image.size.width / image.size.height
|
|
}
|
|
.onFailure { error in
|
|
print("图片加载失败:\(error)")
|
|
}
|
|
.resizable().scaledToFit().thumbFrameS(aspectRatio: logoAspectRatio).radius(6)
|
|
}.buttonStyle(.borderless)
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
Text(user.cName).subTStyle()//公司名字
|
|
Text(user.cProvince + "-" + user.cCity)
|
|
}
|
|
}
|
|
}.textStyle()
|
|
|
|
// MARK: - 公司简介
|
|
if !user.cAboutUS.isEmpty {
|
|
VStack(alignment: .leading, spacing: 9) {
|
|
Text("公司简介").subTStyle()
|
|
if sizeClass == .compact {
|
|
ZStack(alignment: .bottomTrailing) {
|
|
Text(user.cAboutUS).allowMulti().lineLimit((user.cAboutUS.count < 88 || isExpand) ? nil : 4)
|
|
if user.cAboutUS.count > 88 {
|
|
Text(isExpand ? "收起" : "展开").size14().accent().padding([.leading, .top], 3).bg()
|
|
.onTapGesture { isExpand.toggle() }
|
|
}
|
|
}
|
|
} else {
|
|
Text(user.cAboutUS).allowMulti()
|
|
}
|
|
}.size15().tc2().lineSpacing(6)
|
|
}
|
|
// MARK: - 公司相关图片
|
|
if !user.cImageURLStrs.isEmpty {
|
|
ScrollView(.horizontal) {
|
|
HStack {
|
|
ForEach(user.cImageURLStrs.indices, id: \.self) { i in
|
|
if i < user.cImageURLStrs.count {
|
|
NavigationLink {
|
|
CompanyGalleryORView(imageURLStrs: user.cImageURLStrs, currentPage: i)
|
|
} label: {
|
|
KFImage(URL(string: user.cImageURLStrs[i]))
|
|
.placeholder { ProgressView() }.loadDiskFileSynchronously().fade(duration: 0.15)
|
|
.resizable().scaledToFill().thumbFrame().radius(6)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}.scrollIndicators(.hidden)
|
|
}
|
|
}
|
|
}.push(to: .leading).cellStyle()
|
|
}
|
|
}
|