scroll stick

This commit is contained in:
Daniel Arantes Loverde
2026-02-12 15:05:09 -03:00
parent 38fc71718b
commit b027a10c8d
5 changed files with 1044 additions and 13 deletions

View File

@@ -83,8 +83,21 @@ struct HomeView: View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(featuredStoresCards) { store in
FeaturedStoreCard(store: store)
.frame(width: 190)
NavigationLink {
StoreDetailView(
storeId: store.id,
storeName: store.name,
storeCoverURL: store.coverURL,
storeLogoURL: store.logoURL,
storeCategory: store.category,
storeRating: store.rating,
storeDistance: store.distance
)
} label: {
FeaturedStoreCard(store: store)
.frame(width: 190)
}
.buttonStyle(.plain)
}
}
.padding(.horizontal, 20)
@@ -138,7 +151,20 @@ struct HomeView: View {
} else {
VStack(spacing: 16) {
ForEach(nearbyStoreCards) { store in
FeaturedStoreCard(store: store)
NavigationLink {
StoreDetailView(
storeId: store.id,
storeName: store.name,
storeCoverURL: store.coverURL,
storeLogoURL: store.logoURL,
storeCategory: store.category,
storeRating: store.rating,
storeDistance: store.distance
)
} label: {
FeaturedStoreCard(store: store)
}
.buttonStyle(.plain)
}
}
.padding(.horizontal, 20)
@@ -296,7 +322,9 @@ struct HomeView: View {
}
private func mapStoreToCard(_ store: StoreSummary) -> FeaturedStoreCardModel {
FeaturedStoreCardModel(
let coverURL = resolveStoreMediaURL(store.cover)
let logoURL = resolveStoreMediaURL(store.logo)
return FeaturedStoreCardModel(
id: store.id,
name: store.name,
rating: store.rating ?? 0,
@@ -306,16 +334,15 @@ struct HomeView: View {
promoText: nil,
isFavorite: appState.favorites.storeIds.contains(store.id),
iconName: "storefront",
imageURL: resolveStoreImageURL(logo: store.logo, cover: store.cover)
imageURL: coverURL ?? logoURL,
logoURL: logoURL,
coverURL: coverURL
)
}
private func resolveStoreImageURL(logo: String?, cover: String?) -> String? {
let preferred = [logo, cover]
.compactMap { $0?.trimmingCharacters(in: .whitespacesAndNewlines) }
.first { $0.isEmpty == false }
guard let raw = preferred else { return nil }
private func resolveStoreMediaURL(_ raw: String?) -> String? {
guard let raw = raw?.trimmingCharacters(in: .whitespacesAndNewlines),
raw.isEmpty == false else { return nil }
if raw.lowercased().hasPrefix("http://") || raw.lowercased().hasPrefix("https://") {
return raw