Manual Entry kinda works

This commit is contained in:
2026-03-20 02:30:15 -05:00
parent 2110c13ea1
commit 310d9faf33
9 changed files with 1029 additions and 88 deletions

View File

@@ -2,7 +2,12 @@ import SwiftUI
import LabWiseKit
struct ChemicalDetailView: View {
let chemical: Chemical
@State private var chemical: Chemical
@State private var showEdit = false
init(chemical: Chemical) {
self._chemical = State(initialValue: chemical)
}
var body: some View {
Form {
@@ -57,6 +62,9 @@ struct ChemicalDetailView: View {
if let barcode = chemical.barcode {
LabeledContent("Barcode", value: barcode)
}
if let contact = chemical.contact {
LabeledContent("Contact", value: contact)
}
}
if let comments = chemical.comments, !comments.isEmpty {
@@ -77,5 +85,30 @@ struct ChemicalDetailView: View {
}
.navigationTitle(chemical.chemicalName)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
showEdit = true
} label: {
Image(systemName: "pencil")
}
}
}
.sheet(isPresented: $showEdit) {
AddChemicalView(editing: chemical) { saved in
showEdit = false
if saved {
Task { await reloadChemical() }
}
}
}
}
// Reload from server so the detail view reflects the saved changes.
private func reloadChemical() async {
let updated = try? await ChemicalsClient().list()
if let match = updated?.first(where: { $0.id == chemical.id }) {
chemical = match
}
}
}