-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeView.swift
71 lines (66 loc) · 2.4 KB
/
HomeView.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// HomeView.swift
// Lucify (iOS)
//
// Created by Patrick Elfert on 19.06.22.
//
import SwiftUI
struct HomeView: View {
@Environment(\.scenePhase) var scenePhase
@State var selectedTechnique: Technique = .MILD
@State private var isPresented: Bool = false
@State private var allAlarms: [LDAlarm] = []
@State private var alarmsActive = false
@ObservedObject var alarmManager: AlarmManager = .init()
func onTechniqueClicked(type: Technique) {
selectedTechnique = type
isPresented = true
}
var body: some View {
ZStack {
VStack {
ScrollView(showsIndicators: false) {
/* HStack {
Text("Your Progress")
.font(Font.largeTitle.weight(.bold))
.padding(.top)
.padding(.leading)
Spacer()
}
HStack {
StatisticCardView(title: "Lucid Dreams", count: 20)
StatisticCardView(title: "Normal Dreams", count: 20)
} */
HStack {
Text("Start dreaming")
.font(Font.largeTitle.weight(.bold))
.padding(.top)
.padding(.leading)
Spacer()
}
ForEach(Technique.allCases, id: \.rawValue) {
technique in
TechniqueCardView(type: technique, description: technique.description, onClick: onTechniqueClicked)
}
Spacer()
}
}
.background(PrimaryDark).cornerRadius(radius: 17, corners: [.topLeft, .topRight])
.sheet(isPresented: $alarmsActive) {
AlarmView().environmentObject(alarmManager).onAppear {
isPresented = false
}.environment(\.scenePhase, scenePhase)
}.sheet(isPresented: $isPresented) {
TechniqueSheetView(selectedTechnique: $selectedTechnique) {
alarms in alarmManager.setAlarms(alarms: alarms)
alarmsActive = true
}
}
}
}
}
struct HomeView_Previews: PreviewProvider {
static var previews: some View {
HomeView().environmentObject(AlarmManager())
}
}