mirror of
https://github.com/NinjaCheetah/RIT-Dining.git
synced 2025-12-02 01:21:35 -05:00
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
53 lines
2.2 KiB
Swift
53 lines
2.2 KiB
Swift
//
|
|
// FDMealPlannerParsers.swift
|
|
// RIT Dining
|
|
//
|
|
// Created by Campbell on 11/3/25.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
func parseFDMealPlannerMenu(menu: FDMealsParser) -> [FDMenuItem] {
|
|
var menuItems: [FDMenuItem] = []
|
|
if menu.result.isEmpty {
|
|
return menuItems
|
|
}
|
|
// We only need to operate on index 0, because the request code is designed to only get the menu for a single day so there
|
|
// will only be a single index to operate on.
|
|
if let allMenuRecipes = menu.result[0].allMenuRecipes {
|
|
for recipe in allMenuRecipes {
|
|
// englishAlternateName holds the proper name of the item, but it's blank for some items for some reason. If that's the
|
|
// case, then we should fall back on componentName, which is less user-friendly but works as a backup.
|
|
let realName = if recipe.englishAlternateName != "" {
|
|
recipe.englishAlternateName
|
|
} else {
|
|
recipe.componentName
|
|
}
|
|
let allergens = recipe.allergenName.components(separatedBy: ",")
|
|
// Get the list of dietary markers (Vegan, Vegetarian, Pork, Beef), and drop "Vegetarian" if "Vegan" is also included since
|
|
// that's kinda redundant.
|
|
var dietaryMarkers = recipe.recipeProductDietaryName != "" ? recipe.recipeProductDietaryName.components(separatedBy: ",").map { $0.trimmingCharacters(in: .whitespaces) } : []
|
|
if dietaryMarkers.contains("Vegan") {
|
|
dietaryMarkers.remove(at: dietaryMarkers.firstIndex(of: "Vegetarian")!)
|
|
}
|
|
let calories = Int(Double(recipe.calories)!.rounded())
|
|
|
|
let newItem = FDMenuItem(
|
|
id: recipe.componentId,
|
|
name: realName,
|
|
exactName: recipe.componentName,
|
|
category: recipe.category,
|
|
allergens: allergens,
|
|
calories: calories,
|
|
dietaryMarkers: dietaryMarkers,
|
|
ingredients: recipe.ingredientStatement,
|
|
price: recipe.sellingPrice,
|
|
servingSize: recipe.productMeasuringSize,
|
|
servingSizeUnit: recipe.productMeasuringSizeUnit
|
|
)
|
|
menuItems.append(newItem)
|
|
}
|
|
}
|
|
return menuItems
|
|
}
|