Skip to content

Commit

Permalink
Add use hearts for favorites setting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexphanna committed Oct 3, 2024
1 parent 274ff07 commit 0f981aa
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
Binary file not shown.
4 changes: 3 additions & 1 deletion RU-Eating/Models/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class Settings {
var systemColorScheme: Bool?
var colorScheme: Bool?
var lastDiningHall: String
var useHearts: Bool

init(filterIngredients: Bool = false, restrictions: [String] = [], hideRestricted: Bool = false, carbonFootprints: Bool = true, hideZeros: Bool = false, hideNils: Bool = false, extraPercents: Bool = true, fdaDailyValues: Bool = false, systemColorScheme: Bool? = nil, colorScheme: Bool? = nil, lastDiningHall: String = "Busch") {
init(filterIngredients: Bool = false, restrictions: [String] = [], hideRestricted: Bool = false, carbonFootprints: Bool = true, hideZeros: Bool = false, hideNils: Bool = false, extraPercents: Bool = true, fdaDailyValues: Bool = false, systemColorScheme: Bool? = nil, colorScheme: Bool? = nil, lastDiningHall: String = "Busch", useHearts: Bool = false) {
self.filterIngredients = filterIngredients
self.hideRestricted = hideRestricted
self.restrictions = restrictions
Expand All @@ -39,6 +40,7 @@ class Settings {
self.systemColorScheme = systemColorScheme
self.colorScheme = colorScheme
self.lastDiningHall = lastDiningHall
self.useHearts = useHearts
}

func favorite(item: Item) {
Expand Down
20 changes: 16 additions & 4 deletions RU-Eating/Views/ItemNavigationLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ struct ItemNavigationLink : View {
Text(viewModel.item.name)
} icon: {
if viewModel.item.isFavorite {
Image(systemName: "star.fill")
.foregroundStyle(.yellow)
if settings.useHearts {
Image(systemName: "heart.fill")
.foregroundStyle(.pink)
}
else {
Image(systemName: "star.fill")
.foregroundStyle(.yellow)
}
}
else if (settings.filterIngredients && viewModel.containsRestrictions) {
Image(systemName: "exclamationmark.triangle.fill")
Expand Down Expand Up @@ -62,9 +68,15 @@ struct ItemNavigationLink : View {
}
.swipeActions {
Button(action: { settings.favorite(item: viewModel.item) }) {
Image(systemName: viewModel.item.isFavorite ? "star.slash.fill" : "star.fill")
if settings.useHearts {
Image(systemName: viewModel.item.isFavorite ? "heart.slash.fill" : "heart.fill")
.tint(.pink)
}
else {
Image(systemName: viewModel.item.isFavorite ? "star.slash.fill" : "star.fill")
.tint(.yellow)
}
}
.tint(.yellow)
}
}
}
10 changes: 8 additions & 2 deletions RU-Eating/Views/ItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ struct ItemView: View {
ToolbarItem(placement: .topBarTrailing) {
// toggle was changing background color, so I use button
Button(action: { settings.favorite(item: viewModel.item) }) {
Image(systemName: viewModel.item.isFavorite ? "star.fill" : "star")
.foregroundStyle(.yellow)
if settings.useHearts {
Image(systemName: viewModel.item.isFavorite ? "heart.fill" : "heart")
.foregroundStyle(.pink)
}
else {
Image(systemName: viewModel.item.isFavorite ? "star.fill" : "star")
.foregroundStyle(.yellow)
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions RU-Eating/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ struct SettingsView : View {
}
}
}
Toggle(isOn: $viewModel.settings.useHearts) {
Text("Use Hearts for Favorites")
}
Toggle(isOn: $viewModel.settings.carbonFootprints) {
Text("Carbon Footprints")
}
Expand Down

0 comments on commit 0f981aa

Please sign in to comment.