Files
RIT-Dining/TigerDine/Views/Fragments/LoadingView.swift
NinjaCheetah 42b3c35f68 Added deep links for widgets
- Widgets will now open the appropriate DetailView in the app when you tap on them.
  - ...except when they don't. This is still a little buggy. It works correctly when the app is already alive in the background but only works about 75% of the time when the app isn't running yet.
- Unified the loading view into a shared view used in all places requiring loading
2026-01-24 15:11:45 -05:00

65 lines
1.7 KiB
Swift

//
// LoadingView.swift
// TigerDine
//
// Created by Campbell on 1/24/26.
//
import SwiftUI
enum LoadingType {
case normal
case truck
}
struct LoadingView: View {
@Binding var loadFailed: Bool
@State var loadingType: LoadingType = .normal
@State private var rotationDegrees: Double = 0
private var animation: Animation {
.linear
.speed(0.1)
.repeatForever(autoreverses: false)
}
private var loadingSymbol: String {
switch loadingType {
case .normal:
return "fork.knife.circle"
case .truck:
return "truck.box"
}
}
var body: some View {
VStack {
if loadFailed {
Image(systemName: "wifi.exclamationmark.circle")
.resizable()
.frame(width: 75, height: 75)
.foregroundStyle(.accent)
Text("An error occurred while loading data. Please check your network connection and try again.")
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
} else {
Image(systemName: loadingSymbol)
.resizable()
.scaledToFit()
.frame(width: 75, height: 75)
.foregroundStyle(.accent)
.rotationEffect(.degrees(rotationDegrees))
.onAppear {
withAnimation(animation) {
rotationDegrees = 360.0
}
}
Text("Loading...")
.foregroundStyle(.secondary)
}
}
.padding()
}
}