Compare commits
No commits in common. "953a064de6a92af130328544896f73d5e417c9e6" and "078719ef2ba41df16fb5885fd5d03f77cb9f816e" have entirely different histories.
953a064de6
...
078719ef2b
@ -1,66 +0,0 @@
|
|||||||
//
|
|
||||||
// AddEntryView.swift
|
|
||||||
// gastrack
|
|
||||||
//
|
|
||||||
// Created by Pradyun Setti on 23/02/2025.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct AddEntryView: View {
|
|
||||||
@State private var t1: String = ""
|
|
||||||
@State private var t2: String = ""
|
|
||||||
|
|
||||||
@State private var Odometer = ""
|
|
||||||
@State private var CostPerLitre = ""
|
|
||||||
@State private var Litres = ""
|
|
||||||
@State private var TotalCost = ""
|
|
||||||
@State private var FuelType = ""
|
|
||||||
@State private var Location = ""
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
NavigationView {
|
|
||||||
Form {
|
|
||||||
HStack() {
|
|
||||||
Text("Last: \(72398)")
|
|
||||||
Divider()
|
|
||||||
TextField("Odometer", text: $Odometer)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HStack {
|
|
||||||
TextField("Cost/L", text: $CostPerLitre)
|
|
||||||
Divider()
|
|
||||||
TextField("Litres", text: $Litres)
|
|
||||||
Divider()
|
|
||||||
TextField("Total Cost", text: $TotalCost)
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField("Fuel Type", text: $FuelType)
|
|
||||||
TextField("Location", text: $Location)
|
|
||||||
}
|
|
||||||
.navigationTitle("New Entry")
|
|
||||||
.toolbar {
|
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
|
||||||
Button("Cancel") {}
|
|
||||||
}
|
|
||||||
ToolbarItem(placement: .confirmationAction) {
|
|
||||||
Button("Confirm") {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Preview {
|
|
||||||
NavigationView {
|
|
||||||
Text("s")
|
|
||||||
.sheet(isPresented: Binding(get: {true}, set: {_ in})) {
|
|
||||||
AddEntryView()
|
|
||||||
.presentationDetents([.medium])
|
|
||||||
.presentationCornerRadius(20)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,8 +11,6 @@ import SwiftData
|
|||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@Environment(\.modelContext) private var modelContext
|
@Environment(\.modelContext) private var modelContext
|
||||||
@Query private var entries: [Entry]
|
@Query private var entries: [Entry]
|
||||||
|
|
||||||
@State private var addEntry = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
@ -21,20 +19,11 @@ struct ContentView: View {
|
|||||||
Text("Entry: \(e.odo)")
|
Text("Entry: \(e.odo)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(isPresented: $addEntry) {
|
|
||||||
AddEntryView()
|
|
||||||
.presentationDetents([.medium])
|
|
||||||
.presentationCornerRadius(20)
|
|
||||||
}
|
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .bottomBar) {
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
Text("")
|
EditButton()
|
||||||
}
|
}
|
||||||
ToolbarItem(placement: .status) {
|
ToolbarItem {
|
||||||
Text("Placeholder")
|
|
||||||
.frame(alignment: .center)
|
|
||||||
}
|
|
||||||
ToolbarItem(placement: .bottomBar) {
|
|
||||||
Button(action: addItem) {
|
Button(action: addItem) {
|
||||||
Label("Add Item", systemImage: "plus")
|
Label("Add Item", systemImage: "plus")
|
||||||
}
|
}
|
||||||
@ -46,12 +35,11 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func addItem() {
|
private func addItem() {
|
||||||
addEntry.toggle()
|
withAnimation {
|
||||||
// withAnimation {
|
let newItem = Entry(odo: 75239, cost: 92.19, quantity: 36.34, fuelType: "91")
|
||||||
// let newItem = Entry(odo: 75239, cost: 92.19, quantity: 36.34, fuelType: "91")
|
modelContext.insert(newItem)
|
||||||
// modelContext.insert(newItem)
|
try? modelContext.save()
|
||||||
// try? modelContext.save()
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func deleteItems(offsets: IndexSet) {
|
private func deleteItems(offsets: IndexSet) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user