Skip to content

Commit f118e39

Browse files
committed
Minor Update
1 parent d1bee17 commit f118e39

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

iOS16-Live-Activities/ContentView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import ActivityKit
1010

1111
struct ContentView: View {
1212

13+
@State var startingEvent: Bool = false
1314
@State var showContactAction: Bool = false
1415
@State var driver: String = ""
1516
@State var showAlert: Bool = false
@@ -88,7 +89,7 @@ struct ContentView: View {
8889
Button(action: { startDeliveryPizza() }) {
8990
HStack {
9091
Spacer()
91-
Text("Start Ordering 👨🏻‍🍳").font(.headline)
92+
Text(startingEvent ? "Loading... 🍕" : "Start Ordering 👨🏻‍🍳").font(.headline)
9293
Spacer()
9394
}.frame(height: 45)
9495
}.tint(.blue)
@@ -119,6 +120,8 @@ struct ContentView: View {
119120

120121
// MARK: - Functions
121122
func startDeliveryPizza() {
123+
startingEvent = true
124+
122125
print(ActivityAuthorizationInfo().areActivitiesEnabled)
123126

124127
let pizzaDeliveryAttributes = PizzaDeliveryAttributes(numberOfPizzas: 1, totalAmount:"$99")
@@ -141,12 +144,14 @@ struct ContentView: View {
141144

142145
alertMsg = "Requested a pizza delivery Live Activity \(deliveryActivity.id)\n\nPush Token: \(pushTokenString)"
143146
showAlert = true
147+
startingEvent = false
144148
}
145149
}
146150
} catch (let error) {
147151
print("Error requesting pizza delivery Live Activity \(error.localizedDescription)")
148152
alertMsg = "Error requesting pizza delivery Live Activity \(error.localizedDescription)"
149153
showAlert = true
154+
startingEvent = false
150155
}
151156
}
152157
func updateDeliveryPizza() {
@@ -169,7 +174,7 @@ struct ContentView: View {
169174
await activity.end(dismissalPolicy: .immediate)
170175
}
171176

172-
print("Cancelled pizza delivery Live Activity")
177+
print("Cancelled all pizza delivery Live Activity")
173178

174179
showAlert = true
175180
alertMsg = "Cancelled pizza delivery Live Activity"

0 commit comments

Comments
 (0)