mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Added blur background support for iPhone and iPad. Slight API changes to avoid race conditions while sharing a presenter.
This commit is contained in:
@@ -39,6 +39,23 @@ class SlidingModalContainerView: UIView, Themable, NibLoadable {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private weak var blurView: UIVisualEffectView?
|
||||
var blurBackground: Bool = false {
|
||||
didSet {
|
||||
if blurBackground {
|
||||
let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
blurView.frame = self.dimmingView.bounds
|
||||
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
self.dimmingView.addSubview(blurView)
|
||||
self.blurView = blurView
|
||||
self.dimmingView.backgroundColor = .clear
|
||||
} else {
|
||||
self.blurView?.removeFromSuperview()
|
||||
self.dimmingView.backgroundColor = UIColor.black.withAlphaComponent(Constants.dimmingColorAlpha)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Outlets
|
||||
|
||||
@IBOutlet private weak var dimmingView: UIView!
|
||||
@@ -61,6 +78,9 @@ class SlidingModalContainerView: UIView, Themable, NibLoadable {
|
||||
return -(self.contentViewHeightConstraint.constant + bottomSafeAreaHeight)
|
||||
}
|
||||
|
||||
// used to avoid changing constraint during animations
|
||||
private var lastBounds: CGRect?
|
||||
|
||||
// MARK: Public
|
||||
|
||||
var contentViewFrame: CGRect {
|
||||
@@ -92,12 +112,26 @@ class SlidingModalContainerView: UIView, Themable, NibLoadable {
|
||||
super.layoutSubviews()
|
||||
|
||||
self.contentView.layer.cornerRadius = Constants.cornerRadius
|
||||
|
||||
guard lastBounds != nil else {
|
||||
lastBounds = bounds
|
||||
return
|
||||
}
|
||||
|
||||
if UIDevice.current.userInterfaceIdiom == .pad && lastBounds != bounds {
|
||||
lastBounds = bounds
|
||||
self.contentViewBottomConstraint.constant = (UIScreen.main.bounds.height + self.dismissContentViewBottomConstant) / 2
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func preparePresentAnimation() {
|
||||
self.contentViewBottomConstraint.constant = 0
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
self.contentViewBottomConstraint.constant = (UIScreen.main.bounds.height + self.dismissContentViewBottomConstant) / 2
|
||||
} else {
|
||||
self.contentViewBottomConstraint.constant = 0
|
||||
}
|
||||
}
|
||||
|
||||
func prepareDismissAnimation() {
|
||||
|
||||
Reference in New Issue
Block a user