diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5b5b9b0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+AutoCat2.xcodeproj/xcuserdata/
+.DS_Store
diff --git a/AutoCat2.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist b/AutoCat2.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
index 65d954e..6d7bf61 100644
--- a/AutoCat2.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/AutoCat2.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -7,12 +7,12 @@
AutoCat2 (iOS).xcscheme_^#shared#^_
orderHint
- 1
+ 0
AutoCat2 (macOS).xcscheme_^#shared#^_
orderHint
- 0
+ 1
AutoCatCore.xcscheme_^#shared#^_
diff --git a/Shared/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents b/Shared/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents
index 4709899..5a90e77 100644
--- a/Shared/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents
+++ b/Shared/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents
@@ -1,9 +1,23 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
\ No newline at end of file
diff --git a/Shared/Models/Vehicle.swift b/Shared/Models/Vehicle.swift
index c45d429..b6b9f89 100644
--- a/Shared/Models/Vehicle.swift
+++ b/Shared/Models/Vehicle.swift
@@ -1,7 +1,16 @@
import Foundation
import CoreData
-@objc(Vehicle)
-public class Vehicle: NSManagedObject {
- @NSManaged public var number: String?
+extension Vehicle {
+ public var unrecognized: Bool {
+ return self.brand == nil
+ }
+
+ public var outdated: Bool {
+ if let current = self.currentNumber {
+ return current != self.number
+ } else {
+ return false
+ }
+ }
}
diff --git a/Shared/Persistence.swift b/Shared/Persistence.swift
index 526f5e1..395345d 100644
--- a/Shared/Persistence.swift
+++ b/Shared/Persistence.swift
@@ -13,10 +13,10 @@ struct PersistenceController {
static var preview: PersistenceController = {
let result = PersistenceController(inMemory: true)
let viewContext = result.container.viewContext
- for _ in 0..<10 {
- let newItem = Item(context: viewContext)
- newItem.timestamp = Date()
- }
+// for _ in 0..<10 {
+// let newItem = Item(context: viewContext)
+// newItem.timestamp = Date()
+// }
do {
try viewContext.save()
} catch {
diff --git a/Shared/Views/CheckView.swift b/Shared/Views/CheckView.swift
index b0736b9..50db450 100644
--- a/Shared/Views/CheckView.swift
+++ b/Shared/Views/CheckView.swift
@@ -2,16 +2,27 @@ import SwiftUI
struct CheckView: View {
@State private var number: String = ""
+ @FetchRequest(entity: Vehicle.entity(), sortDescriptors: []) var vehicles: FetchedResults
var body: some View {
- VStack(alignment: .center, spacing: 16) {
- TextField("", text: $number)
- Button("Check") {
-
+ NavigationView {
+ VStack(alignment: .center, spacing: 16) {
+ TextField("A123AA777", text: $number)
+ Button("Check") {
+
+ }
+ List(vehicles) { vehicle in
+ Text(vehicle.number ?? "")
+ }
}
-// List(["one", "two", "three"]) { item in
-// Text(item)
-// }
+ .toolbar {
+ ToolbarItem(placement: .primaryAction) {
+ Button("New") {}
+ }
+ }
+ #if os(iOS)
+ .navigationBarTitle("Title", displayMode: .inline)
+ #endif
}
}
}
@@ -19,5 +30,6 @@ struct CheckView: View {
struct CheckView_Previews: PreviewProvider {
static var previews: some View {
CheckView()
+ .preferredColorScheme(.dark)
}
}
diff --git a/Shared/Views/MainViewBig.swift b/Shared/Views/MainViewBig.swift
index 6e5e2b6..9fa2721 100644
--- a/Shared/Views/MainViewBig.swift
+++ b/Shared/Views/MainViewBig.swift
@@ -2,7 +2,64 @@ import SwiftUI
struct MainViewBig: View {
var body: some View {
- Text("Main view big")
+ NavigationView {
+ SidebarView()
+ Text("Master")
+ Text("Detail")
+ }
+ }
+}
+
+struct SidebarView: View {
+ @State var selection: String?
+
+ @FetchRequest(entity: Vehicle.entity(), sortDescriptors: []) var vehicles: FetchedResults
+
+ var body: some View {
+ List(selection: $selection) {
+ Section("History") {
+ NavigationLink(destination: VehiclesListView()) {
+ Label("All", systemImage: "car.2")
+ .badge(vehicles.count)
+ }
+ NavigationLink(destination: VehiclesListView()) {
+ Label("Unreconized", systemImage: "eye.slash")
+ .badge(vehicles.filter(\.unrecognized).count)
+ }
+ NavigationLink(destination: VehiclesListView()) {
+ Label("Outdated", systemImage: "wind")
+ .badge(vehicles.filter(\.outdated).count)
+ }
+ }
+ .collapsible(false)
+
+ Section("Other") {
+ Label("Recordings", systemImage: "waveform.path")
+ Label("Search", systemImage: "magnifyingglass")
+ }
+ .collapsible(false)
+ }
+ .frame(minWidth: 180)
+// .toolbar {
+// ToolbarItem(placement: .primaryAction) {
+// Button("xxx") {
+//
+// }
+// }
+// }
+ }
+}
+
+struct VehiclesListView: View {
+ var body: some View {
+ Text("Vehicles list")
+ .toolbar {
+ ToolbarItem(placement: .primaryAction) {
+ Button("xxx") {
+
+ }
+ }
+ }
}
}
diff --git a/Shared/Views/MainViewSmall.swift b/Shared/Views/MainViewSmall.swift
index be42872..0facd81 100644
--- a/Shared/Views/MainViewSmall.swift
+++ b/Shared/Views/MainViewSmall.swift
@@ -25,6 +25,9 @@ struct MainViewSmall: View {
Text("Settings")
}
}
+ #if os(iOS)
+ .navigationBarHidden(true)
+ #endif
Text("detail")
}
}