IOS_Boss/IOS_study/Profile/ProfileView+ComUI.swift
2025-07-27 12:33:06 +08:00

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()
}
}