Slide 17
Slide 17 text
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
*UFN *UFN
struct OperationScrollView: View {
@State var componentsOffset: CGFloat
var topPadding: CGFloat
@Namespace private var scrollView: Namespace.ID
private var scrollViewOpacity: CGFloat {
max(min((-componentsOffset-10) / topPadding, 0.8), 0)
}
var body: some View {
ScrollView {
LazyVGrid(columns: [GridItem(.flexible(minimum:
150, maximum: 300)), GridItem(.flexible(minimum: 150,
maximum: 300))], content: {
ForEach(0 ..< 20) { i in
Text("Item: \(i)")
.frame(maxWidth: .infinity)
.frame(height: 100)
.background(Color.blue)
}
})
.padding(.horizontal)
.reading(\.minY, in: .named(scrollView),
andAssignTo: $componentsOffset)
}
.safeAreaPadding(.top, topPadding)
.background(Color.black.opacity(scrollViewOpacity
))
.coordinateSpace(.named(scrollView))
}
}