79 lines
2.1 KiB
Swift
79 lines
2.1 KiB
Swift
//
|
|
// MainView.swift
|
|
// AutoCat2SUI
|
|
//
|
|
// Created by Selim Mustafaev on 24.07.2022.
|
|
//
|
|
|
|
import SwiftUI
|
|
import AutoCatCore
|
|
|
|
struct MainView: View {
|
|
|
|
@FetchRequest(entity: CDVehicle.entity(), sortDescriptors: []) var vehicles: FetchedResults<CDVehicle>
|
|
|
|
@State private var selectedFilter: Filter?
|
|
@State private var checkSheetPresented = false
|
|
|
|
private var historyFilters: [Filter] = [
|
|
.allLocal,
|
|
.unrecognized,
|
|
.outdated
|
|
]
|
|
|
|
private var remoteFilters: [Filter] = [
|
|
.allRemote
|
|
]
|
|
|
|
var body: some View {
|
|
NavigationSplitView {
|
|
List(selection: $selectedFilter) {
|
|
Section("History") {
|
|
ForEach(historyFilters) { filter in
|
|
NavigationLink(value: filter) {
|
|
Label(filter.name, systemImage: filter.iconName)
|
|
.badge(vehicles.count)
|
|
}
|
|
}
|
|
}
|
|
|
|
Section("Remote") {
|
|
ForEach(remoteFilters) { filter in
|
|
NavigationLink(value: filter) {
|
|
Label(filter.name, systemImage: filter.iconName)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.toolbar {
|
|
ToolbarItemGroup(placement: .primaryAction) {
|
|
Spacer()
|
|
Button {
|
|
checkSheetPresented = true
|
|
} label: {
|
|
Image(systemName: "plus")
|
|
}
|
|
.sheet(isPresented: $checkSheetPresented) {
|
|
CheckNumber()
|
|
}
|
|
|
|
}
|
|
}
|
|
.navigationDestination(for: Filter.self) { filter in
|
|
VehiclesListView(vehicles: [], selection: nil)
|
|
}
|
|
} content: {
|
|
Text("Content")
|
|
} detail: {
|
|
Text("Detail")
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
struct MainView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
MainView()
|
|
}
|
|
}
|