53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
//
|
|
// LocationEditScreen.swift
|
|
// AutoCat
|
|
//
|
|
// Created by Selim Mustafaev on 27.07.2024.
|
|
// Copyright © 2024 Selim Mustafaev. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import AutoCatCore
|
|
|
|
struct LocationEditScreen: View {
|
|
|
|
enum Screen: String {
|
|
|
|
case locationPicker
|
|
}
|
|
|
|
@Environment(\.dismiss) var dismiss
|
|
|
|
@State var viewModel: LocationEditViewModel
|
|
|
|
init(event: VehicleEventDto, onUpdate: @escaping (VehicleEventDto) -> Void) {
|
|
|
|
self.viewModel = LocationEditViewModel(
|
|
event: event,
|
|
onUpdate: onUpdate
|
|
)
|
|
}
|
|
|
|
var body: some View {
|
|
List {
|
|
DatePicker("Date", selection: $viewModel.date)
|
|
.datePickerStyle(.compact)
|
|
NavigationLink(value: Screen.locationPicker) {
|
|
TextRowView(title: "Location", value: viewModel.event.location)
|
|
}
|
|
}
|
|
.navigationTitle("Edit event")
|
|
.toolbar {
|
|
ToolbarItem(placement: .primaryAction) {
|
|
Button("Done") {
|
|
viewModel.done()
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
.navigationDestination(for: Screen.self) { _ in
|
|
LocationPickerScreen(event: viewModel.event, onUpdate: viewModel.onEventUpdated)
|
|
}
|
|
}
|
|
}
|