Skip to content

Commit 6537b7f

Browse files
committed
Added scroll background config
1 parent f56f3f0 commit 6537b7f

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,15 @@ You can also configure `AutoResizingSheet` by passing a `AutoResizingSheetConfig
120120
| `scrollable` | `Bool`: Should the content be wrapped inside a scroll view. Defaults to `true`. |
121121
| `showGrabber` | `Bool`: If the grabber should be shown. Defaults to `true`. |
122122
| `extendableToFullSize` | `Bool`: If the sheet is extendable to full size using the grabber. Defaults to `true`, will be `false` if `showGrabber` is `false`. |
123+
| `scrollBackground` | `UIColor`: If scrollable, defines the background color of the `ScrollView`. Defaults to `.clear`. |
123124

124125
Create a configuration like this:
125126
```swift
126127
let configuration = AutoResizingSheetConfiguration(
127128
scrollable: true,
128129
showGrabber: true,
129-
extendableToFullSize: true
130+
extendableToFullSize: true,
131+
scrollBackground: .clear
130132
)
131133
```
132134

Sources/AutoResizingSheet/Models/AutoResizingSheetConfiguration.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public struct AutoResizingSheetConfiguration {
55
public var scrollable: Bool
66
public var showGrabber: Bool
77
public var extendableToFullSize: Bool
8+
public var scrollBackground: UIColor
89

910
/// Creates a new instance of `AutoResizingSheetConfiguration`.
1011
///
@@ -17,14 +18,18 @@ public struct AutoResizingSheetConfiguration {
1718
/// Defaults to `true`.
1819
/// - extendableToFullSize: If the sheet is extendable to full size using the grabber.
1920
/// Defaults to `true`, will be `false` if `showGrabber` is `false`.
21+
/// - scrollBackground: If scrollable, defines the background color of the `ScrollView`.
22+
/// Defaults to `.clear`.
2023
///
2124
public init(
2225
scrollable: Bool = true,
2326
showGrabber: Bool = true,
24-
extendableToFullSize: Bool = true
27+
extendableToFullSize: Bool = true,
28+
scrollBackground: UIColor = .clear
2529
) {
2630
self.scrollable = scrollable
2731
self.showGrabber = showGrabber
32+
self.scrollBackground = scrollBackground
2833
if !showGrabber {
2934
self.extendableToFullSize = false
3035
} else {

Sources/AutoResizingSheet/ViewModifiers/AutoResizingSheetViewModifier.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct AutoResizingSheetViewModifier<SheetContent: View>: ViewModifier {
3636
updateDetents(newHeigh: newSize.height)
3737
}
3838
}
39+
.background(Color(configuration.scrollBackground))
3940
} else {
4041
sheetContent()
4142
.presentationDetents(detents, selection: $selectedDetent)

0 commit comments

Comments
 (0)