From 186092cd8cda83a9ba97a6996f0115abe3747a34 Mon Sep 17 00:00:00 2001 From: Kirill Prokofyev Date: Thu, 3 Apr 2025 15:42:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D1=85=D0=BE=D0=B4=D0=BE=D0=B2,=20=D1=82=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=BC=D0=B8=D0=BD=D0=BE=D1=80=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=B8=20(=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EatHub/Modules/Details/DetailsView.swift | 3 +- EatHub/EatHub/Modules/Home/HomeView.swift | 2 + .../Cell/HorizontalItemView.swift | 74 ++++++++++++------- .../HorizontalListSection.swift | 5 +- .../Cell/VerticalItemView.swift | 4 +- 5 files changed, 58 insertions(+), 30 deletions(-) diff --git a/EatHub/EatHub/Modules/Details/DetailsView.swift b/EatHub/EatHub/Modules/Details/DetailsView.swift index edafba2..4c3dd22 100644 --- a/EatHub/EatHub/Modules/Details/DetailsView.swift +++ b/EatHub/EatHub/Modules/Details/DetailsView.swift @@ -41,6 +41,7 @@ struct DetailsView: View { ingredientsSection instructionsSection } + .ignoreTabBar() .background(Color.Custom.backgroundPrimary) } .ignoresSafeArea(edges: .top) @@ -55,7 +56,7 @@ struct DetailsView: View { } } .navigationBarHidden(true) - .background(Color(.systemBackground)) + .background(Color.Custom.backgroundPrimary) .onAppear { viewModel.fetchMeal() } diff --git a/EatHub/EatHub/Modules/Home/HomeView.swift b/EatHub/EatHub/Modules/Home/HomeView.swift index 151437d..1343c37 100644 --- a/EatHub/EatHub/Modules/Home/HomeView.swift +++ b/EatHub/EatHub/Modules/Home/HomeView.swift @@ -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) diff --git a/EatHub/EatHub/UIComponents/HorizontalListSection/Cell/HorizontalItemView.swift b/EatHub/EatHub/UIComponents/HorizontalListSection/Cell/HorizontalItemView.swift index 179720f..bb0b0f1 100644 --- a/EatHub/EatHub/UIComponents/HorizontalListSection/Cell/HorizontalItemView.swift +++ b/EatHub/EatHub/UIComponents/HorizontalListSection/Cell/HorizontalItemView.swift @@ -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()) } } diff --git a/EatHub/EatHub/UIComponents/HorizontalListSection/HorizontalListSection.swift b/EatHub/EatHub/UIComponents/HorizontalListSection/HorizontalListSection.swift index dcb36d4..439fd8a 100644 --- a/EatHub/EatHub/UIComponents/HorizontalListSection/HorizontalListSection.swift +++ b/EatHub/EatHub/UIComponents/HorizontalListSection/HorizontalListSection.swift @@ -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) diff --git a/EatHub/EatHub/UIComponents/VerticalListSection/Cell/VerticalItemView.swift b/EatHub/EatHub/UIComponents/VerticalListSection/Cell/VerticalItemView.swift index 16410d1..8b8deeb 100644 --- a/EatHub/EatHub/UIComponents/VerticalListSection/Cell/VerticalItemView.swift +++ b/EatHub/EatHub/UIComponents/VerticalListSection/Cell/VerticalItemView.swift @@ -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 {