75 lines
2.1 KiB
Swift
75 lines
2.1 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 {
|
|
Section(header: Text("Basic Information")) {
|
|
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")")
|
|
}
|
|
}
|
|
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")
|
|
}
|
|
}
|