mirror of
https://github.com/NinjaCheetah/RIT-Dining.git
synced 2026-03-05 05:25:29 -05:00
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:
@@ -59,15 +59,37 @@ struct MenuItemView: View {
|
||||
)
|
||||
}
|
||||
}
|
||||
Text("Allergens")
|
||||
.font(.headline)
|
||||
.padding(.top, 8)
|
||||
Text(menuItem.allergens.joined(separator: ", "))
|
||||
.foregroundStyle(.secondary)
|
||||
.textSelection(.enabled)
|
||||
.padding(.bottom, 8)
|
||||
.padding(.bottom, 12)
|
||||
if !menuItem.allergens.isEmpty {
|
||||
Text("Allergens")
|
||||
.font(.title3)
|
||||
.fontWeight(.semibold)
|
||||
Text(menuItem.allergens.joined(separator: ", "))
|
||||
.foregroundStyle(.secondary)
|
||||
.textSelection(.enabled)
|
||||
.padding(.bottom, 12)
|
||||
.onAppear {
|
||||
print(menuItem.allergens)
|
||||
}
|
||||
}
|
||||
VStack(alignment: .leading) {
|
||||
Text("Nutrition Facts")
|
||||
.font(.title3)
|
||||
.fontWeight(.semibold)
|
||||
ForEach(menuItem.nutritionalEntries, id: \.self) { entry in
|
||||
HStack(alignment: .top) {
|
||||
Text(entry.type)
|
||||
Spacer()
|
||||
Text("\(String(format: "%.1f", entry.amount))\(entry.unit)")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 12)
|
||||
Text("Ingredients")
|
||||
.font(.headline)
|
||||
.font(.title3)
|
||||
.fontWeight(.semibold)
|
||||
Text(menuItem.ingredients)
|
||||
.foregroundStyle(.secondary)
|
||||
.textSelection(.enabled)
|
||||
@@ -88,6 +110,7 @@ struct MenuItemView: View {
|
||||
category: "Baked Goods",
|
||||
allergens: ["Wheat", "Gluten", "Egg", "Milk", "Soy"],
|
||||
calories: 470,
|
||||
nutritionalEntries: [FDNutritionalEntry(type: "Example", amount: 0.0, unit: "g")],
|
||||
dietaryMarkers: ["Vegetarian"],
|
||||
ingredients: "Some ingredients that you'd expect to find inside of a chocolate chip muffin",
|
||||
price: 2.79,
|
||||
|
||||
@@ -67,6 +67,9 @@ struct MenuView: View {
|
||||
let searchedLocations = searchText.isEmpty || item.name.localizedCaseInsensitiveContains(searchText)
|
||||
return searchedLocations
|
||||
}
|
||||
newItems.sort { firstItem, secondItem in
|
||||
return firstItem.name.localizedCaseInsensitiveCompare(secondItem.name) == .orderedAscending
|
||||
}
|
||||
return newItems
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user