Missing Field Handling

This commit is contained in:
2026-05-01 13:54:05 -05:00
parent 5a6491fa51
commit 09447be473
9 changed files with 252 additions and 105 deletions

View File

@@ -9,14 +9,23 @@ struct ChemicalRowView: View {
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(chemical.chemicalName)
Text(chemical.displayName)
.font(.headline)
Spacer()
PhysicalStateBadge(state: chemical.physicalState)
if let state = chemical.physicalState, !state.isEmpty {
PhysicalStateBadge(state: state)
}
}
HStack(spacing: 6) {
if let cas = chemical.casNumber, !cas.isEmpty {
Text("CAS: \(cas)")
.font(.caption)
.foregroundStyle(.secondary)
}
if chemical.isMissingKeyInfo {
MissingInfoBadge()
}
}
Text("CAS: \(chemical.casNumber)")
.font(.caption)
.foregroundStyle(.secondary)
if let pct = chemical.percentageFull {
PercentageBar(value: pct / 100)
.frame(height: 4)
@@ -52,6 +61,25 @@ struct PhysicalStateBadge: View {
}
}
// MARK: - Missing info badge
/// Mirrors the web "Missing info" pill amber, with a warning glyph.
struct MissingInfoBadge: View {
var body: some View {
HStack(spacing: 3) {
Image(systemName: "exclamationmark.triangle.fill")
.font(.caption2)
Text("Missing info")
.font(.caption2.weight(.semibold))
}
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(Color.orange.opacity(0.15))
.foregroundStyle(Color.orange)
.clipShape(Capsule())
}
}
// MARK: - Percentage bar
struct PercentageBar: View {