@@ -27,6 +27,9 @@ struct Carousel<Content: View>: View {
27
27
/// The content shown in the Carousel.
28
28
let content : ( _: CGSize , _: ( ( ) -> Void ) ? ) -> Content
29
29
30
+ /// The amount to offset the scroll indicator.
31
+ let scrollIndicatorOffset = 10.0
32
+
30
33
/// This number is used to compute the final width that allows for a partially visible cell.
31
34
var cellBaseWidth = 120.0
32
35
@@ -55,7 +58,6 @@ struct Carousel<Content: View>: View {
55
58
ScrollViewReader { scrollViewProxy in
56
59
ScrollView ( . horizontal) {
57
60
makeCommonScrollViewContent ( scrollViewProxy)
58
- . padding ( . bottom, 10 )
59
61
}
60
62
}
61
63
. onAppear {
@@ -66,15 +68,14 @@ struct Carousel<Content: View>: View {
66
68
}
67
69
}
68
70
// When a GeometryReader is within a List, height must be specified.
69
- . frame ( height: cellSize. height)
71
+ . frame ( height: cellSize. height + scrollIndicatorOffset )
70
72
}
71
73
72
74
@available ( iOS 18 . 0 , * )
73
75
var iOS18Implementation : some View {
74
76
ScrollViewReader { scrollViewProxy in
75
77
ScrollView ( . horizontal) {
76
78
makeCommonScrollViewContent ( scrollViewProxy)
77
- . padding ( . bottom, 10 )
78
79
}
79
80
}
80
81
. onScrollGeometryChange ( for: CGFloat . self) { geometry in
@@ -94,6 +95,9 @@ struct Carousel<Content: View>: View {
94
95
. id ( contentIdentifier)
95
96
. frame ( width: cellSize. width, height: cellSize. height)
96
97
. clipped ( )
98
+ // Pad the content such that the scroll indicator appears beneath it
99
+ // so that the content is not covered.
100
+ . padding ( . bottom, scrollIndicatorOffset)
97
101
}
98
102
}
99
103
}
0 commit comments