-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericPresetView.swift
49 lines (45 loc) · 1.6 KB
/
GenericPresetView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// GenericPresetView.swift
// Lucify (iOS)
//
// Created by Patrick Elfert on 27.05.22.
//
import Combine
import SwiftUI
struct GenericPresetView: View {
@ObservedObject var genericPreset: GenericTechniqueViewModel
@State var anyCancallable: AnyCancellable = AnyCancellable {}
@Binding var allAlarms: [LDAlarm]
var body: some View {
List {
Section {
ForEach($genericPreset.wbtbAlarms) {
$alarm in
DatePicker(selection: $alarm.date, displayedComponents: [.hourAndMinute]) {
Image(systemName: "moon.stars.fill").foregroundColor(Primary)
Text("WBTB")
}.datePickerStyle(.graphical)
}
}
Section {
ForEach($genericPreset.morningAlarms) {
$alarm in
DatePicker(selection: $alarm.date, displayedComponents: [.hourAndMinute]) {
Image(systemName: "sun.and.horizon.fill").foregroundColor(Primary)
Text("Morning")
}.datePickerStyle(.graphical)
}
}
}.listStyle(.automatic)
.onAppear {
anyCancallable = genericPreset.$allAlarms.assign(to: \.allAlarms, on: self)
}.onDisappear {
anyCancallable.cancel()
}
}
}
struct GenericPresetView_Previews: PreviewProvider {
static var previews: some View {
GenericPresetView(genericPreset: GenericTechniqueViewModel(type: .SSILD), allAlarms: .constant([]))
}
}