// // ContentView.swift // RIT Dining // // Created by Campbell on 8/31/25. // import SwiftUI struct Location: Hashable { let name: String let summary: String let desc: String let mapsUrl: String let todaysHours: [String] let isOpen: openStatus } struct LocationList: View { let diningLocations: [Location] var body: some View { ForEach(diningLocations, id: \.self) { location in NavigationLink(destination: DetailView(location: location)) { VStack(alignment: .leading) { Text(location.name) switch location.isOpen { case .open: Text("Open") .foregroundStyle(.green) case .closed: Text("Closed") .foregroundStyle(.red) case .openingSoon: Text("Opening Soon") .foregroundStyle(.orange) case .closingSoon: Text("Closing Soon") .foregroundStyle(.orange) } ForEach(location.todaysHours, id: \.self) { hours in Text(hours) .foregroundStyle(.secondary) } } } } } } struct ContentView: View { @State private var isLoading = true @State private var rotationDegrees: Double = 0 @State private var diningLocations: [Location] = [] @State private var lastRefreshed: Date? @State private var searchText: String = "" @State private var openLocationsOnly: Bool = false private var animation: Animation { .linear .speed(0.1) .repeatForever(autoreverses: false) } // Asynchronously fetch the data for all of the locations and parse their data to display it. private func getDiningData() { var newDiningLocations: [Location] = [] getDiningLocation { result in DispatchQueue.global().async { switch result { case .success(let locations): for i in 0..