-
Notifications
You must be signed in to change notification settings - Fork 0
/
Homepage.swift
154 lines (88 loc) · 4.46 KB
/
Homepage.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//
// Homepage.swift
// iHW-WatchOS Watch App
//
// Created by Zachary Abrahamson on 1/3/23.
//
import SwiftUI
import UserNotifications
import Alamofire
import Foundation
func RelativeWidth(CurrentWidth: CGFloat) -> CGFloat {
let stepone = SGConvenience.deviceWidth / CurrentWidth
return SGConvenience.deviceWidth / stepone
}
struct HomeGrownButton: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding()
.frame(width: RelativeWidth(CurrentWidth: 120), height: RelativeWidth(CurrentWidth: 50))
.background(.red)
.foregroundColor(.white)
.clipShape(RoundedRectangle(cornerRadius: 15))
.scaleEffect(configuration.isPressed ? 1.2 : 1)
.animation(.easeInOut(duration: 0.4), value: configuration.isPressed)
.font(.system(size: 23, weight: .bold))
}
}
struct Homepage: View {
var body: some View {
VStack {
if #available(watchOS 9.0, *) {
NavigationStack {
ZStack {
VStack(spacing: 30) {
// making this into usmsselect because i honestly dont need sign in rn
NavigationLink(destination: USMSSelect()) {
Text("Schedule")
}
.buttonStyle(HomeGrownButton())
.padding(.bottom, 10.0)
NavigationLink(destination: About()) {
Text("About")
}
.buttonStyle(HomeGrownButton())
.padding(.bottom, 10.0)
}
}
.onAppear {
NotificationManager.instance.requestAuth()
}
}
} else {
NavigationView {
VStack(spacing: 30) {
// VStack {
// making this into usmsselect because i honestly dont need sign in rn
NavigationLink(destination: USMSSelect()) {
Text("Schedule")
}
.buttonStyle(HomeGrownButton())
.padding(.bottom, 10.0)
NavigationLink(destination: About()) {
Text("About")
}
.padding(.bottom, 10.0)
.buttonStyle(HomeGrownButton())
}
.onAppear {
NotificationManager.instance.requestAuth()
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
.onAppear() {
if let dtOutMS = UserDefaults.standard.string(forKey: "LastMSGet"), let dtOutUS = UserDefaults.standard.string(forKey: "LastUSGet") {
print(dtOutMS, "and", dtOutUS, "are the last requested dates of getting info for MS and US respectively.")
} else {
print("no saved info")
}
}
}
}
struct Homepage_Previews: PreviewProvider {
static var previews: some View {
Homepage().environmentObject(USINfo()).environmentObject(XMLInfo())
}
}