Skip to content

Commit

Permalink
Added scroll background config
Browse files Browse the repository at this point in the history
  • Loading branch information
benedom committed Dec 28, 2024
1 parent f56f3f0 commit 6537b7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ You can also configure `AutoResizingSheet` by passing a `AutoResizingSheetConfig
| `scrollable` | `Bool`: Should the content be wrapped inside a scroll view. Defaults to `true`. |
| `showGrabber` | `Bool`: If the grabber should be shown. Defaults to `true`. |
| `extendableToFullSize` | `Bool`: If the sheet is extendable to full size using the grabber. Defaults to `true`, will be `false` if `showGrabber` is `false`. |
| `scrollBackground` | `UIColor`: If scrollable, defines the background color of the `ScrollView`. Defaults to `.clear`. |

Create a configuration like this:
```swift
let configuration = AutoResizingSheetConfiguration(
scrollable: true,
showGrabber: true,
extendableToFullSize: true
extendableToFullSize: true,
scrollBackground: .clear
)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public struct AutoResizingSheetConfiguration {
public var scrollable: Bool
public var showGrabber: Bool
public var extendableToFullSize: Bool
public var scrollBackground: UIColor

/// Creates a new instance of `AutoResizingSheetConfiguration`.
///
Expand All @@ -17,14 +18,18 @@ public struct AutoResizingSheetConfiguration {
/// Defaults to `true`.
/// - extendableToFullSize: If the sheet is extendable to full size using the grabber.
/// Defaults to `true`, will be `false` if `showGrabber` is `false`.
/// - scrollBackground: If scrollable, defines the background color of the `ScrollView`.
/// Defaults to `.clear`.
///
public init(
scrollable: Bool = true,
showGrabber: Bool = true,
extendableToFullSize: Bool = true
extendableToFullSize: Bool = true,
scrollBackground: UIColor = .clear
) {
self.scrollable = scrollable
self.showGrabber = showGrabber
self.scrollBackground = scrollBackground
if !showGrabber {
self.extendableToFullSize = false
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct AutoResizingSheetViewModifier<SheetContent: View>: ViewModifier {
updateDetents(newHeigh: newSize.height)
}
}
.background(Color(configuration.scrollBackground))
} else {
sheetContent()
.presentationDetents(detents, selection: $selectedDetent)
Expand Down

0 comments on commit 6537b7f

Please sign in to comment.