Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion EatHub/EatHub/Modules/Details/DetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct DetailsView: View {
ingredientsSection
instructionsSection
}
.ignoreTabBar()
.background(Color.Custom.backgroundPrimary)
}
.ignoresSafeArea(edges: .top)
Expand All @@ -55,7 +56,7 @@ struct DetailsView: View {
}
}
.navigationBarHidden(true)
.background(Color(.systemBackground))
.background(Color.Custom.backgroundPrimary)
.onAppear {
viewModel.fetchMeal()
}
Expand Down
2 changes: 2 additions & 0 deletions EatHub/EatHub/Modules/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ struct HomeView: View {
VStack(alignment: .leading, spacing: 16) {
Text("Popular")
.font(Font.Custom.headline)
.shadow(color: Color.black.opacity(0.3), radius: 5, x: 0, y: 2)
.padding(.horizontal, .large)
HorizontalListSection(meals: viewModel.horizontalMeals)
Text("Recent")
.font(Font.Custom.headline)
.shadow(color: Color.black.opacity(0.3), radius: 5, x: 0, y: 2)
.padding(.horizontal, .large)
VerticalListSection(meals: viewModel.verticalMeals)
.padding(.horizontal, .large)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,66 @@
import SwiftUI

struct HorizontalItemView: View {
private enum Constants {
static let itemWidth: CGFloat = 100
static let itemHeight: CGFloat = 180
static let gradientHeight: CGFloat = 60
static let cornerRadius: CGFloat = 16
static let shadowRadius: CGFloat = 4
static let shadowX: CGFloat = 0
static let shadowY: CGFloat = 2
static let horizontalPadding: CGFloat = 4
static let textBottomPadding: CGFloat = 8
}

let meal: Meal

var body: some View {
ZStack(alignment: .bottom) {
if let url = URL(string: meal.thumbnail ?? "") {
CachedAsyncImage(url: url) { image in
image
.resizable()
.scaledToFill()
} placeholder: {
Group {
if let url = URL(string: meal.thumbnail ?? "") {
CachedAsyncImage(url: url) { image in
image
.resizable()
.scaledToFill()
} placeholder: {
Color.Custom.backgroundSecondary
.skeletonable(true)
}
} else {
Color.Custom.backgroundSecondary
.skeletonable(true)
}
.frame(width: 100, height: 180)
.clipped()
.cornerRadius(5)
}
.frame(width: Constants.itemWidth, height: Constants.itemHeight)
.clipped()

ZStack(alignment: .bottom) {
LinearGradient(
gradient: Gradient(colors: [Color.black.opacity(0.9), Color.clear]),
startPoint: .bottom,
endPoint: .top
)
.frame(height: 60)
.frame(maxWidth: .infinity)

LinearGradient(
gradient: Gradient(colors: [Color.black.opacity(0.9), Color.clear]),
startPoint: .bottom,
endPoint: .top
)
.frame(height: Constants.gradientHeight)
.frame(maxWidth: .infinity)
.overlay(
Text(meal.name)
.font(Font.Custom.caption)
.foregroundColor(.white)
.lineLimit(4)
.lineLimit(2)
.multilineTextAlignment(.center)
.truncationMode(.tail)
.padding(.horizontal, 4)
.padding(.bottom, 8)
}
.frame(width: 100, height: 60)
.padding(.horizontal, Constants.horizontalPadding)
.padding(.bottom, Constants.textBottomPadding),
alignment: .bottom
)
}
.frame(width: 100, height: 180)
.cornerRadius(11)
.shadow(color: Color.black.opacity(0.1), radius: 4, x: 0, y: 2)
.frame(width: Constants.itemWidth, height: Constants.itemHeight)
.cornerRadius(Constants.cornerRadius)
.shadow(
color: Color.black.opacity(0.1),
radius: Constants.shadowRadius,
x: Constants.shadowX,
y: Constants.shadowY
)
.contentShape(Rectangle())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ struct HorizontalListSection: View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(meals, id: \.id) { meal in
HorizontalItemView(meal: meal)
NavigationLink(value: meal) {
HorizontalItemView(meal: meal)
}
.buttonStyle(PlainButtonStyle())
}
}
.padding(.horizontal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ struct VerticalItemView: View {
}
.padding(.bottom, Constants.spacing)
.background(Color.Custom.backgroundAccent)
.clipped()
.shadow(color: Color.black.opacity(0.3), radius: 4, x: 0, y: 2)
.cornerRadius(Constants.cellCornerRadius, corners: .allCorners)
.contentShape(Rectangle())
.clipped()
}

private var infoSection: some View {
Expand Down