99 lines
3.0 KiB
Swift
99 lines
3.0 KiB
Swift
//
|
|
// FuelLogDetailView.swift
|
|
// Gas Man
|
|
//
|
|
// Created by Kameron Kenny on 3/17/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
private let dateFormatter: DateFormatter = {
|
|
let formatter = DateFormatter()
|
|
formatter.dateStyle = .short
|
|
formatter.timeStyle = .short
|
|
return formatter
|
|
}()
|
|
|
|
struct FuelLogDetailView: View {
|
|
var fuelLog: FuelLog
|
|
|
|
var body: some View {
|
|
Form {
|
|
// Vehicle header section
|
|
if let vehicle = fuelLog.vehicle {
|
|
Section {
|
|
Text("\(vehicle.year) \(vehicle.model ?? "")")
|
|
.font(.headline)
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
}
|
|
}
|
|
|
|
Section(header: Text("")) {
|
|
HStack {
|
|
Text("Date:")
|
|
Spacer()
|
|
Text(fuelLog.date ?? Date(), formatter: dateFormatter)
|
|
}
|
|
HStack {
|
|
Text("Odometer:")
|
|
Spacer()
|
|
Text("\(fuelLog.odometer, specifier: "%.0f") miles")
|
|
}
|
|
}
|
|
Section(header: Text("Fuel Information")) {
|
|
HStack {
|
|
Text("Fuel Volume:")
|
|
Spacer()
|
|
Text("\(fuelLog.fuelVolume, specifier: "%.3f") gallons")
|
|
}
|
|
HStack {
|
|
Text("Cost:")
|
|
Spacer()
|
|
Text("$\(fuelLog.cost, specifier: "%.2f")")
|
|
}
|
|
HStack {
|
|
Text("Price per Gallon:")
|
|
Spacer()
|
|
Text("$\(fuelLog.pricePerGalon, specifier: "%.3f")")
|
|
}
|
|
}
|
|
// New Tank Status Section
|
|
Section(header: Text("Tank Status")) {
|
|
HStack {
|
|
Text("Tank:")
|
|
Spacer()
|
|
if fuelLog.fullTank {
|
|
Image(systemName: "checkmark.circle.fill")
|
|
.foregroundColor(.green)
|
|
Text("Full")
|
|
} else {
|
|
Image(systemName: "xmark.circle.fill")
|
|
.foregroundColor(.red)
|
|
Text("Not Full")
|
|
}
|
|
}
|
|
}
|
|
Section(header: Text("Location")) {
|
|
HStack {
|
|
Text("Coordinates:")
|
|
Spacer()
|
|
Text(fuelLog.locationCoordinates ?? "N/A")
|
|
}
|
|
HStack {
|
|
Text("Location Name:")
|
|
Spacer()
|
|
Text(fuelLog.locationName ?? "N/A")
|
|
}
|
|
}
|
|
Section(header: Text("Fuel Details")) {
|
|
HStack {
|
|
Text("Octane:")
|
|
Spacer()
|
|
Text("\(fuelLog.octane)")
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Fuel Log Detail")
|
|
}
|
|
}
|