Improvements to FD MealPlanner integration

- Detailed nutrition facts are now shown on the menu item view
- Fixed The College Grind not having a "View Menu" button (IDs were mapped incorrectly)
- Menu items are now sorted alphabetically
- "Allergens" section now hidden on the menu item view if the item contains no allergens
- Duplicate items will no longer be added to the menu item list, so no more issues with items randomly appearing and disappearing (thanks FD MealPlanner for having duplicates in the first place)
This commit is contained in:
2025-11-10 01:58:23 -05:00
parent c7639de06b
commit 85aa9e636d
6 changed files with 95 additions and 12 deletions

View File

@@ -20,6 +20,6 @@ let tCtoFDMPMap: [Int: (Int, Int)] = [
441: (11, 11), // Loaded Latke
38: (12, 12), // Midnight Oil
26: (14, 4), // RITZ
9041: (18, 17), // The College Grind
35: (18, 17), // The College Grind
24: (15, 14), // The Commons
]

View File

@@ -54,6 +54,32 @@ struct FDMealsParser: Decodable, Hashable {
let category: String
let allergenName: String
let calories: String
let carbohydrates: String
let carbohydratesUOM: String
let dietaryFiber: String
let dietaryFiberUOM: String
let fat: String
let fatUOM: String
let protein: String
let proteinUOM: String
let saturatedFat: String
let saturatedFatUOM: String
let transFattyAcid: String
let transFattyAcidUOM: String
let calcium: String
let calciumUOM: String
let cholesterol: String
let cholesterolUOM: String
let iron: String
let ironUOM: String
let sodium: String
let sodiumUOM: String
let vitaminA: String
let vitaminAUOM: String
let vitaminC: String
let vitaminCUOM: String
let totalSugars: String
let totalSugarsUOM: String
let recipeProductDietaryName: String
let ingredientStatement: String
let sellingPrice: Double
@@ -74,6 +100,13 @@ struct FDMealsParser: Decodable, Hashable {
let result: [Result]
}
/// A single nutritional entry, including the amount and the unit. Used over a tuple for hashable purposes.
struct FDNutritionalEntry: Hashable {
let type: String
let amount: Double
let unit: String
}
/// 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
@@ -82,6 +115,7 @@ struct FDMenuItem: Hashable, Identifiable {
let category: String
let allergens: [String]
let calories: Int
let nutritionalEntries: [FDNutritionalEntry]
let dietaryMarkers: [String]
let ingredients: String
let price: Double