Skip to content

Commit 1af2bb7

Browse files
committed
Add blur on container
1 parent 2397f22 commit 1af2bb7

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

BottomSheetDemo/Sources/User Interface/Screens/Root/RootViewController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ final class RootViewController: UIViewController {
5353
let viewController = ResizeViewController(initialHeight: 300)
5454
presentBottomSheetInsideNavigationController(
5555
viewController: viewController,
56-
configuration: .default
56+
configuration: BottomSheetConfiguration(
57+
cornerRadius: 10,
58+
pullBarConfiguration: .visible(.init(height: 50)),
59+
shadowConfiguration: .init(backgroundColor: UIColor.black.withAlphaComponent(0.6), blur: .light)
60+
)
5761
)
5862
}
5963
}

Sources/BottomSheet/Core/BottomSheetConfiguration.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ public struct BottomSheetConfiguration {
2626

2727
public struct ShadowConfiguration {
2828
public let backgroundColor: UIColor
29+
public let blur: UIBlurEffect.Style?
2930

30-
public init(backgroundColor: UIColor) {
31+
public init(backgroundColor: UIColor, blur: UIBlurEffect.Style? = nil) {
3132
self.backgroundColor = backgroundColor
33+
self.blur = blur
3234
}
3335

3436
public static let `default` = ShadowConfiguration(backgroundColor: UIColor.black.withAlphaComponent(0.6))

Sources/BottomSheet/Core/Presentation/BottomSheetPresentationController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ public final class BottomSheetPresentationController: UIPresentationController {
284284
}
285285

286286
private func addShadow(containerView: UIView) {
287-
let shadingView = UIView()
287+
var shadingView = UIView()
288+
if let blur = configuration.shadowConfiguration.blur {
289+
shadingView = UIVisualEffectView.init(effect: UIBlurEffect.init(style: blur))
290+
}
291+
288292
shadingView.backgroundColor = configuration.shadowConfiguration.backgroundColor
289293
containerView.addSubview(shadingView)
290294
shadingView.frame = containerView.bounds

0 commit comments

Comments
 (0)