-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMildPresetView.swift
47 lines (43 loc) · 1.56 KB
/
MildPresetView.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
//
// MildPresetView.swift
// Lucify (iOS)
//
// Created by Patrick Elfert on 27.05.22.
//
import Combine
import SwiftUI
struct MildPresetView: View {
@Binding var allAlarms: [LDAlarm]
@ObservedObject var mildPreset = MildViewModel()
@State var anyCancallable: AnyCancellable = AnyCancellable {}
var body: some View {
List {
Toggle("Combine MILD with WBTB", isOn: $mildPreset.isWbtbEnabled.animation()).tint(Primary)
if mildPreset.isWbtbEnabled {
DatePicker(selection: $mildPreset.wbtbAlarms[0].date, displayedComponents: [.hourAndMinute]) {
Image(systemName: "moon.stars.fill").foregroundColor(Primary)
Text("WBTB")
}.datePickerStyle(.graphical)
}
Section {
ForEach($mildPreset.morningAlarms) {
$alarm in
DatePicker(selection: $alarm.date, displayedComponents: [.hourAndMinute]) {
Image(systemName: "sun.and.horizon.fill").foregroundColor(Primary)
Text("Morning")
}.datePickerStyle(.graphical)
}
}
}
.onAppear {
anyCancallable = mildPreset.$allAlarms.assign(to: \.allAlarms, on: self)
}.onDisappear {
anyCancallable.cancel()
}.listStyle(.insetGrouped)
}
}
struct MildPresetView_Previews: PreviewProvider {
static var previews: some View {
MildPresetView(allAlarms: .constant([])).environment(\.colorScheme, .dark)
}
}