51 lines
1.2 KiB
Swift
51 lines
1.2 KiB
Swift
import SwiftUI
|
|
|
|
struct DatePropertyView: View {
|
|
|
|
let title: String
|
|
|
|
@Binding
|
|
var value: Date
|
|
|
|
let footer: String
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
Text(title)
|
|
.font(.headline)
|
|
DatePicker("", selection: $value, displayedComponents: [.date, .hourAndMinute])
|
|
.datePickerStyle(.compact)
|
|
Text(footer)
|
|
.foregroundStyle(.secondary)
|
|
.padding(.bottom)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct OptionalDatePropertyView: View {
|
|
|
|
let title: LocalizedStringKey
|
|
|
|
@Binding
|
|
var isEnabled: Bool
|
|
|
|
@Binding
|
|
var date: Date
|
|
|
|
let footer: LocalizedStringKey
|
|
|
|
var body: some View {
|
|
GenericPropertyView(title: title, footer: footer) {
|
|
HStack(alignment: .firstTextBaseline) {
|
|
Toggle("", isOn: $isEnabled)
|
|
.toggleStyle(.switch)
|
|
DatePicker("", selection: $date, displayedComponents: .date)
|
|
.datePickerStyle(.compact)
|
|
.padding(.bottom)
|
|
.disabled(!isEnabled)
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
}
|