Commit afb96ee8 by Orkhan Alikhanov

Added option for disabling snackbar layout edge inset calculation

parent ad7a9aee
...@@ -110,6 +110,13 @@ open class SnackbarController: TransitionController { ...@@ -110,6 +110,13 @@ open class SnackbarController: TransitionController {
layoutSubviews() layoutSubviews()
} }
} }
/**
A boolean that controls if layoutEdgeInsets of snackbar is adjusted
automatically.
*/
@IBInspectable
open var automaticallyAdjustSnackbarLayoutEdgeInsets = true
/** /**
Animates to a SnackbarStatus. Animates to a SnackbarStatus.
...@@ -179,17 +186,20 @@ open class SnackbarController: TransitionController { ...@@ -179,17 +186,20 @@ open class SnackbarController: TransitionController {
snackbar.frame.origin.x = snackbarEdgeInsets.left snackbar.frame.origin.x = snackbarEdgeInsets.left
snackbar.frame.size.width = view.bounds.width - snackbarEdgeInsets.left - snackbarEdgeInsets.right snackbar.frame.size.width = view.bounds.width - snackbarEdgeInsets.left - snackbarEdgeInsets.right
snackbar.frame.size.height = snackbar.heightPreset.rawValue snackbar.frame.size.height = snackbar.heightPreset.rawValue
snackbar.layoutEdgeInsets = .zero
if .bottom == snackbarAlignment {
snackbar.frame.size.height += bottomLayoutGuide.length
snackbar.layoutEdgeInsets.bottom += bottomLayoutGuide.length
} else {
snackbar.frame.size.height += topLayoutGuide.length
snackbar.layoutEdgeInsets.top += topLayoutGuide.length
}
rootViewController.view.frame = view.bounds if automaticallyAdjustSnackbarLayoutEdgeInsets {
layoutSnackbar(status: snackbar.status) snackbar.layoutEdgeInsets = .zero
if .bottom == snackbarAlignment {
snackbar.frame.size.height += bottomLayoutGuide.length
snackbar.layoutEdgeInsets.bottom += bottomLayoutGuide.length
} else {
snackbar.frame.size.height += topLayoutGuide.length
snackbar.layoutEdgeInsets.top += topLayoutGuide.length
}
rootViewController.view.frame = view.bounds
layoutSnackbar(status: snackbar.status)
}
} }
open override func prepare() { open override func prepare() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment