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
98 lines
3.5 KiB
Swift
98 lines
3.5 KiB
Swift
//
|
|
// MenuItemView.swift
|
|
// RIT Dining
|
|
//
|
|
// Created by Campbell on 11/6/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct MenuItemView: View {
|
|
@State var menuItem: FDMenuItem
|
|
|
|
private var infoString: String {
|
|
// Calories SHOULD always be available, so start there.
|
|
var str = "\(menuItem.calories) Cal • "
|
|
// Price might be $0.00, so don't display it if that's the case because that's obviously wrong. RIT Dining would never give
|
|
// us free food!
|
|
if menuItem.price == 0.0 {
|
|
str += "Price Unavailable"
|
|
} else {
|
|
str += "$\(String(format: "%.2f", menuItem.price))"
|
|
}
|
|
// Same with the price, the serving size might be 0 which is also wrong so don't display that.
|
|
if menuItem.servingSize != 0 {
|
|
str += " • \(menuItem.servingSize) \(menuItem.servingSizeUnit)"
|
|
}
|
|
return str
|
|
}
|
|
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading) {
|
|
Text(menuItem.name)
|
|
.font(.title)
|
|
.fontWeight(.bold)
|
|
Text(menuItem.category)
|
|
.font(.title2)
|
|
.fontWeight(.semibold)
|
|
.foregroundStyle(.secondary)
|
|
Text(infoString)
|
|
.font(.title3)
|
|
.foregroundStyle(.secondary)
|
|
HStack {
|
|
ForEach(menuItem.dietaryMarkers, id: \.self) { dietaryMarker in
|
|
Text(dietaryMarker)
|
|
.foregroundStyle(Color.white)
|
|
.font(.caption)
|
|
.padding(5)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill({
|
|
switch dietaryMarker {
|
|
case "Vegan", "Vegetarian":
|
|
return Color.green
|
|
default:
|
|
return Color.orange
|
|
}
|
|
}())
|
|
)
|
|
}
|
|
}
|
|
Text("Allergens")
|
|
.font(.headline)
|
|
.padding(.top, 8)
|
|
Text(menuItem.allergens.joined(separator: ", "))
|
|
.foregroundStyle(.secondary)
|
|
.textSelection(.enabled)
|
|
.padding(.bottom, 8)
|
|
Text("Ingredients")
|
|
.font(.headline)
|
|
Text(menuItem.ingredients)
|
|
.foregroundStyle(.secondary)
|
|
.textSelection(.enabled)
|
|
}
|
|
.padding(.horizontal, 8)
|
|
}
|
|
.navigationTitle("Details")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
MenuItemView(
|
|
menuItem: FDMenuItem(
|
|
id: 0,
|
|
name: "Chocolate Chip Muffin",
|
|
exactName: "Muffin Chocolate Chip Thaw and Serve A; Case; 72 Ounce; 12",
|
|
category: "Baked Goods",
|
|
allergens: ["Wheat", "Gluten", "Egg", "Milk", "Soy"],
|
|
calories: 470,
|
|
dietaryMarkers: ["Vegetarian"],
|
|
ingredients: "Some ingredients that you'd expect to find inside of a chocolate chip muffin",
|
|
price: 2.79,
|
|
servingSize: 1,
|
|
servingSizeUnit: "Each")
|
|
)
|
|
}
|