61 lines
2.4 KiB
Swift
61 lines
2.4 KiB
Swift
import SwiftUI
|
|
|
|
struct LeadSigningDocumentListView: View {
|
|
let documents: [LeadDocument]
|
|
let currentID: String?
|
|
let signedIDs: Set<String>
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("DOKUMENTE").font(.caption).foregroundStyle(.secondary)
|
|
.padding(.horizontal, 6)
|
|
VStack(spacing: 0) {
|
|
ForEach(Array(documents.enumerated()), id: \.element.id) { index, document in
|
|
LeadSigningDocumentRow(
|
|
title: document.title.replacingOccurrences(of: ".pdf", with: ""),
|
|
number: index + 1,
|
|
isCurrent: document.id == currentID && document.status != .signed && !signedIDs.contains(document.id),
|
|
isSigned: document.status == .signed || signedIDs.contains(document.id)
|
|
)
|
|
if document.id != documents.last?.id {
|
|
Divider().padding(.leading, 44)
|
|
}
|
|
}
|
|
}
|
|
.background(Color(uiColor: .secondarySystemGroupedBackground), in: .rect(cornerRadius: 12))
|
|
.clipShape(.rect(cornerRadius: 12))
|
|
}
|
|
.padding(12)
|
|
}
|
|
}
|
|
|
|
struct LeadSigningDocumentRow: View {
|
|
let title: String
|
|
let number: Int
|
|
let isCurrent: Bool
|
|
let isSigned: Bool
|
|
|
|
var body: some View {
|
|
HStack(spacing: 12) {
|
|
if isSigned {
|
|
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green).frame(width: 20)
|
|
} else {
|
|
Text(number.formatted()).foregroundStyle(isCurrent ? Color.accentColor : .secondary)
|
|
.frame(width: 20)
|
|
}
|
|
VStack(alignment: .leading, spacing: 3) {
|
|
Text(title).fontWeight(isCurrent ? .semibold : .regular).lineLimit(2)
|
|
Text(isSigned ? "Unterschrieben" : isCurrent ? "Jetzt unterschreiben" : "Ausstehend")
|
|
.font(.caption)
|
|
.foregroundStyle(isSigned ? Color.green : isCurrent ? Color.accentColor : .secondary)
|
|
}
|
|
Spacer(minLength: 0)
|
|
}
|
|
.padding(12)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.background(isCurrent ? Color.accentColor.opacity(0.10) : .clear)
|
|
.accessibilityElement(children: .combine)
|
|
.accessibilityAddTraits(isCurrent ? .isSelected : [])
|
|
}
|
|
}
|