Initial commit for first version of project
This commit is contained in:
59
GasTankAR/Views/TankAR/MeasurementListView.swift
Normal file
59
GasTankAR/Views/TankAR/MeasurementListView.swift
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// MeasurementListView.swift
|
||||
// GasTankAR
|
||||
//
|
||||
// Created by Dennis Nemec on 28.08.26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// Von unten einschwebendes Sheet mit den angelegten Strecken. Ist keine vorhanden,
|
||||
/// wird zum Hinzufügen aufgefordert.
|
||||
struct MeasurementListView: View {
|
||||
let controller: ARSessionController
|
||||
/// Startet einen neuen Messvorgang (schließt das Sheet und lässt den Nutzer zwei Punkte wählen).
|
||||
let onAddStrecke: () -> Void
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
Group {
|
||||
if controller.measurements.isEmpty {
|
||||
ContentUnavailableView {
|
||||
Label("Keine Strecken", systemImage: "ruler")
|
||||
} description: {
|
||||
Text("Füge eine Strecke hinzu und wähle dafür zwei Punkte im Raum.")
|
||||
} actions: {
|
||||
Button("Strecke hinzufügen", systemImage: "plus", action: onAddStrecke)
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
} else {
|
||||
List {
|
||||
ForEach(controller.measurements) { measurement in
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(measurement.name)
|
||||
.font(.headline)
|
||||
Text(measurement.formattedDistance)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
Image(systemName: "ruler")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.onDelete { controller.deleteMeasurements(at: $0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Strecken")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
Button("Hinzufügen", systemImage: "plus", action: onAddStrecke)
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user