organize
This commit is contained in:
parent
42188066f5
commit
5c4dbce95e
|
@ -289,7 +289,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "Gas Man/Gas_Man.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 202503191221;
|
||||
CURRENT_PROJECT_VERSION = 202503191240;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Gas Man/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = Z734T5CD6B;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
|
@ -332,7 +332,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "Gas Man/Gas_Man.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 202503191221;
|
||||
CURRENT_PROJECT_VERSION = 202503191240;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Gas Man/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = Z734T5CD6B;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
//
|
||||
// ContentView.swift
|
||||
// Gas Man
|
||||
//
|
||||
// Created by Kameron Kenny on 3/17/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
//import CoreData
|
||||
//
|
||||
//struct ContentView: View {
|
||||
// @Environment(\.managedObjectContext) private var viewContext
|
||||
//
|
||||
// @FetchRequest(
|
||||
// sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
|
||||
// animation: .default)
|
||||
// private var items: FetchedResults<Item>
|
||||
//
|
||||
// var body: some View {
|
||||
// NavigationView {
|
||||
// List {
|
||||
// ForEach(items) { item in
|
||||
// NavigationLink {
|
||||
// Text("Item at \(item.timestamp!, formatter: itemFormatter)")
|
||||
// } label: {
|
||||
// Text(item.timestamp!, formatter: itemFormatter)
|
||||
// }
|
||||
// }
|
||||
// .onDelete(perform: deleteItems)
|
||||
// }
|
||||
// .toolbar {
|
||||
//#if os(iOS)
|
||||
// ToolbarItem(placement: .navigationBarTrailing) {
|
||||
// EditButton()
|
||||
// }
|
||||
//#endif
|
||||
// ToolbarItem {
|
||||
// Button(action: addItem) {
|
||||
// Label("Add Item", systemImage: "plus")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Text("Select an item")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private func addItem() {
|
||||
// withAnimation {
|
||||
// let newItem = Item(context: viewContext)
|
||||
// newItem.timestamp = Date()
|
||||
//
|
||||
// do {
|
||||
// try viewContext.save()
|
||||
// } catch {
|
||||
// // Replace this implementation with code to handle the error appropriately.
|
||||
// // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||
// let nsError = error as NSError
|
||||
// fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private func deleteItems(offsets: IndexSet) {
|
||||
// withAnimation {
|
||||
// offsets.map { items[$0] }.forEach(viewContext.delete)
|
||||
//
|
||||
// do {
|
||||
// try viewContext.save()
|
||||
// } catch {
|
||||
// // Replace this implementation with code to handle the error appropriately.
|
||||
// // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||
// let nsError = error as NSError
|
||||
// fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//private let itemFormatter: DateFormatter = {
|
||||
// let formatter = DateFormatter()
|
||||
// formatter.dateStyle = .short
|
||||
// formatter.timeStyle = .medium
|
||||
// return formatter
|
||||
//}()
|
||||
|
||||
//#Preview {
|
||||
// ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
|
||||
//}
|
|
@ -1,59 +0,0 @@
|
|||
//
|
||||
// VehicleListView.swift
|
||||
// Gas Man
|
||||
//
|
||||
// Created by Kameron Kenny on 3/18/25.
|
||||
//
|
||||
|
||||
|
||||
import SwiftUI
|
||||
import CoreData
|
||||
|
||||
struct VehicleListView: View {
|
||||
@Environment(\.managedObjectContext) private var viewContext
|
||||
@FetchRequest(
|
||||
sortDescriptors: [NSSortDescriptor(keyPath: \Vehicle.make, ascending: true)],
|
||||
animation: .default)
|
||||
private var vehicles: FetchedResults<Vehicle>
|
||||
|
||||
@State private var showingAddVehicle = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
ForEach(vehicles) { vehicle in
|
||||
NavigationLink(destination: VehicleDetailView(vehicle: vehicle)) {
|
||||
VehicleRowView(vehicle: vehicle)
|
||||
}
|
||||
}
|
||||
.onDelete(perform: deleteVehicles)
|
||||
}
|
||||
.navigationTitle("Vehicles")
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button(action: { showingAddVehicle = true }) {
|
||||
Label("Add Vehicle", systemImage: "plus")
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showingAddVehicle) {
|
||||
AddVehicleView().environment(\.managedObjectContext, viewContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func deleteVehicles(offsets: IndexSet) {
|
||||
withAnimation {
|
||||
offsets.map { vehicles[$0] }.forEach(viewContext.delete)
|
||||
do {
|
||||
try viewContext.save()
|
||||
} catch {
|
||||
let nsError = error as NSError
|
||||
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue