Added dining location menus from FD MealPlanner API

Dining locations that also exist on FD MealPlanner now have a "View Menu" button under the favorite/OnDemand/map buttons that take you to a new view that pulls the location's menu from FD MealPlanner. You can view all of the menu items that have actually been added to that site, and tap them for more details (which will be expanded on later). Searching the item list is supported, with more filtering options coming in the next update. Meal periods can be browsed using the clock button in the top right for locations that are open more than once per day.
Other changes:
- App renamed from "RIT Dining" to "TigerDine" to not get me in trouble for an App Store release
- Slightly changed the way that dining locations' short descriptions and current open times are displayed in the detail view
- Fixed the box truck icon used in the food truck view being squished
This commit is contained in:
2025-11-08 22:33:20 -05:00
parent 2c512180d9
commit c7639de06b
17 changed files with 785 additions and 198 deletions

View File

@@ -0,0 +1,90 @@
//
// FDMealPlannerTypes.swift
// RIT Dining
//
// Created by Campbell on 11/3/25.
//
import Foundation
/// Struct to parse the response from the FDMP search API. This API returns all of the dining locations that are have menus available and the required IDs needed to get those menus.
struct FDSearchResponseParser: Decodable {
/// The main response body containing the result count and the results themselves.
struct Data: Decodable {
/// The key information returned for each location in the search results. These values are required to pass along to the menu API.
struct Result: Decodable {
let locationId: Int
let accountId: Int
let tenantId: Int
let locationName: String
let locationCode: String
let locationDisplayName: String
let accountName: String
}
let result: [Result]
let totalCount: Int
}
let success: Bool
let errorMessage: String?
let data: Data
}
/// Struct to parse the response from the FDMP meal periods API. This API returns all potentail meal periods for a location based on its ID. This meal period ID is required to get the menu for that meal period from the meals API.
struct FDMealPeriodsParser: Decodable {
/// The response body, which is a list of responses that include a meal period and the ID that maps to it.
struct Data: Decodable {
let id: Int
let mealPeriodName: String
}
let success: Bool
let errorMessage: String?
let data: [Data]
}
/// Struct to parse the response from the FDMP meals API. This API contains the actual menu information for the specified location during the specified meal period. It doesn't contain every menu item, but it's the best source of menu information that I can access.
struct FDMealsParser: Decodable, Hashable {
/// The actual response body.
struct Result: Decodable, Hashable {
/// An individual item on the menu at this location and its information.
struct MenuRecipe: Decodable, Hashable {
let componentName: String
let componentId: Int
let componentTypeId: Int
let englishAlternateName: String
let category: String
let allergenName: String
let calories: String
let recipeProductDietaryName: String
let ingredientStatement: String
let sellingPrice: Double
let productMeasuringSize: Int
let productMeasuringSizeUnit: String
let itemsToOrder: Int
}
let menuId: Int
let menuForDate: String
let menuToDate: String
let accountId: Int
let accountName: String
let menuTypeName: String
let mealPeriodId: Int
let allMenuRecipes: [MenuRecipe]?
}
let responseStatus: String?
let result: [Result]
}
/// A single menu item, stripped down and reorganized to a format that actually makes sense for me to use in the rest of the app.
struct FDMenuItem: Hashable, Identifiable {
let id: Int
let name: String
let exactName: String
let category: String
let allergens: [String]
let calories: Int
let dietaryMarkers: [String]
let ingredients: String
let price: Double
let servingSize: Int
let servingSizeUnit: String
}

View File

@@ -0,0 +1,18 @@
//
// FoodTruckTypes.swift
// RIT Dining
//
// Created by Campbell on 11/3/25.
//
import Foundation
// A weekend food trucks even representing when it's happening and what food trucks will be there.
struct FoodTruckEvent: Hashable {
let date: Date
let openTime: Date
let closeTime: Date
let location: String
let trucks: [String]
}

View File

@@ -0,0 +1,138 @@
//
// TigerCenterTypes.swift
// RIT Dining
//
// Created by Campbell on 9/2/25.
//
import Foundation
// I'll be honest, I am NOT good at representing other people's JSON in my code. This kinda sucks but it gets the job done and can
// be improved later when I feel like it.
struct DiningLocationParser: Decodable {
// An individual "event", which is just an open period for the location.
struct Event: Decodable {
// Hour exceptions for the given event.
struct HoursException: Decodable {
let id: Int
let name: String
let startTime: String
let endTime: String
let startDate: String
let endDate: String
let open: Bool
}
let startTime: String
let endTime: String
let daysOfWeek: [String]
let exceptions: [HoursException]?
}
// An individual "menu", which can be either a daily special item or a visitng chef. Description needs to be optional because
// visiting chefs have descriptions but specials do not.
struct Menu: Decodable {
let name: String
let description: String?
let category: String
}
// Other basic information to read from a location's JSON that we'll need later.
let id: Int
let mdoId: Int
let name: String
let summary: String
let description: String
let mapsUrl: String
let events: [Event]
let menus: [Menu]
}
// Struct that probably doesn't need to exist but this made parsing the list of location responses easy.
struct DiningLocationsParser: Decodable {
let locations: [DiningLocationParser]
}
// Enum to represent the four possible states a given location can be in.
enum OpenStatus {
case open
case closed
case openingSoon
case closingSoon
}
// An individual open period for a location.
struct DiningTimes: Equatable, Hashable {
var openTime: Date
var closeTime: Date
}
// Enum to represent the five possible states a visiting chef can be in.
enum VisitingChefStatus {
case hereNow
case gone
case arrivingLater
case arrivingSoon
case leavingSoon
}
// A visiting chef present at a location.
struct VisitingChef: Equatable, Hashable {
let name: String
let description: String
var openTime: Date
var closeTime: Date
var status: VisitingChefStatus
}
// A daily special at a location.
struct DailySpecial: Equatable, Hashable {
let name: String
let type: String
}
// The IDs required to get the menu for a location from FD MealPlanner. Only present if the location appears in the map.
struct FDMPIds: Hashable {
let locationId: Int
let accountId: Int
}
// The basic information about a dining location needed to display it in the app after parsing is finished.
struct DiningLocation: Identifiable, Hashable {
let id: Int
let mdoId: Int
let fdmpIds: FDMPIds?
let name: String
let summary: String
let desc: String
let mapsUrl: String
let date: Date
let diningTimes: [DiningTimes]?
var open: OpenStatus
var visitingChefs: [VisitingChef]?
let dailySpecials: [DailySpecial]?
}
// Parser to read the occupancy data for a location.
struct DiningOccupancyParser: Decodable {
// Represents a per-hour occupancy rating.
struct HourlyOccupancy: Decodable {
let hour: Int
let today: Int
let today_max: Int
let one_week_ago: Int
let one_week_ago_max: Int
let average: Int
}
let count: Int
let location: String
let building: String
let mdo_id: Int
let max_occ: Int
let open_status: String
let intra_loc_hours: [HourlyOccupancy]
}
// Struct used to represent a day and its hours as strings. Type used for the hours of today and the next 6 days used in DetailView.
struct WeeklyHours: Hashable {
let day: String
let date: Date
let timeStrings: [String]
}