I’ve read this also caused drag gesture issues, which were fixed with simultaneousGestures
Are there any other fixes?
That's my simplified code
Код: Выделить всё
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 12) {
ForEach(0...2, id:\.self) { _ in
mostScannedItem(img: .moltoMagnum, name: "Molto Magnum", calories: 123)
.onTapGesture {
showProductSheet = true
}.scrollTargetLayout()
}
}.padding(.bottom)
.scrollTargetBehavior(.viewAligned)
Код: Выделить всё
@ViewBuilder
func mostScannedItem(img: ImageResource, name: String, calories: Int) -> some View {
ZStack(alignment: .leading) {
VStack(alignment: .leading) {
Text(name)
.fontWeight(.medium)
Text("\(calories) kcal")
.foregroundStyle(.colorTextTertiary)
.font(.footnote)
}.padding()
.padding(.leading, 40)
.background(.colorGray)
.clipShape(.rect(cornerRadius: 16))
Image(img)
.resizable()
.frame(width: 42.5, height: 100)
.aspectRatio(contentMode: .fit)
.shadow(radius: 2)
.padding(.leading, 8)
}.contentShape(.rect)
.shadow(radius: 2, x: 1, y: 1)
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... uttons-now