Unified detail views, model
This commit is contained in:
50
CHDataManagement/Views/Generic/DatePropertyView.swift
Normal file
50
CHDataManagement/Views/Generic/DatePropertyView.swift
Normal file
@ -0,0 +1,50 @@
|
||||
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)
|
||||
.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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user