Код: Выделить всё
struct UserEvaluationDetailView2: View {
var body: some View {
ZStack{
ConstantsEval.Black.ignoresSafeArea()
VStack(spacing:10) {
VStack(spacing:0){
HStack(spacing:0){
Text("Evaluation Date")
.font(Font.custom("Agency FB", size: 16))
.foregroundColor(ConstantsEval.LightWhite)
.frame(width: 80, height: 35) .padding(.vertical)
.padding(.leading,10)
.background(ConstantsEval.BG1)
ScrollView(.horizontal,showsIndicators: false){
HStack{
ForEach(bleTeamMeta.fetchedData){ item in
Text(item.desc)
.font(Font.custom("Agency FB", size: 15))
.multilineTextAlignment(.center)
.lineLimit(1)
.foregroundColor(ConstantsEval.White)
.frame(width: 80, height: 35)
}
}.padding(.vertical).background(ConstantsEval.BG1)
}
Text("Action")
.font(Font.custom("Agency FB", size: 15)).italic()
.foregroundColor(ConstantsEval.LightWhite)
.frame(width: 40).frame(height: 35) // Centered alignment
.padding(.vertical) // Consistent padding
.background(ConstantsEval.BG1) // Gray background for the header
}.background(ConstantsEval.BG1)
ScrollView{
LazyVStack(alignment: .leading, pinnedViews: [.sectionHeaders]) {
HStack(spacing:0){
HStack{
VStack(alignment:.leading,spacing:12){
ForEach(userMeasurements.indices, id: \.self) { index in
let row = userMeasurements[index]
let eval_date: String = row["row_name"]["evaluation_date"].stringValue
Text(Helper.shared.formatDateString(eval_date))
.textCase(.uppercase)
.font(Font.custom("Agency FB", size: 16))
.foregroundColor(ConstantsEval.White)
.frame(width: 80,height: 35,alignment: .leading)
.padding(.leading,10)
}
}
}
HStack{
ScrollView(.horizontal,showsIndicators: false){
VStack(alignment:.center,spacing:12){
ForEach(userMeasurements.indices, id: \.self) { index in
let row = userMeasurements[index]
let eval_date: String = row["row_name"]["evaluation_date"].stringValue
HStack{
ForEach(bleTeamMeta.fetchedData) { item in
let eval: String? = row[item.id].stringValue
let eval_int: Int = row[item.id].intValue
let eval_double: Double = abs(row[item.id].doubleValue)
if eval != "" {
HStack(spacing: 2){
if eval_int < 0{
Image(systemName: "arrow.down")
.font(Font.custom("Agency FB", size: 15))
.multilineTextAlignment(.trailing)
.foregroundColor(.red)
}
else{
Image(systemName: "arrow.up")
.font(Font.custom("Agency FB", size: 15))
.multilineTextAlignment(.trailing)
.foregroundColor(.green)
}
Text("\(String(format: "%.2f", eval_double))" )
.font(Font.custom("Agency FB", size: 15))
.multilineTextAlignment(.center)
.foregroundColor(ConstantsEval.White)
}.frame(width: 80, height: 35)
} else{
Text(" - ")
.font(Font.custom("Agency FB", size: 16))
.multilineTextAlignment(.center)
.foregroundColor(ConstantsEval.White)
.frame(width: 80, height: 35)
}
}
}
}
}
}
}
HStack{
VStack(alignment:.leading,spacing:12){
ForEach(userMeasurements.indices, id: \.self) { index in
Image("edit")
.frame(width: 40)
.frame(height: 35)
}
}
}
}
}
}.frame(maxWidth: .infinity).padding(.bottom,10).background(ConstantsEval.BG2)
}
}.cornerRadius(8)
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... in-swiftui