Commit 0ebe904f by Daniel Dahan

development: BottomSheet respects persistent sizing

parent 07222ba0
...@@ -37,8 +37,8 @@ public enum BottomSheetFABButtonPosition: Int { ...@@ -37,8 +37,8 @@ public enum BottomSheetFABButtonPosition: Int {
case center case center
} }
@objc(BottomSheetLayoutStyle) @objc(BottomSheetStyle)
public enum BottomSheetLayoutStyle: Int { public enum BottomSheetStyle: Int {
case modal case modal
case persistent case persistent
} }
...@@ -51,6 +51,7 @@ open class BottomSheet: View { ...@@ -51,6 +51,7 @@ open class BottomSheet: View {
open var fabButton: FABButton? { open var fabButton: FABButton? {
didSet { didSet {
fabButtonWasSet?(fabButton) fabButtonWasSet?(fabButton)
fabButton?.zPosition = 6000
layoutSubviews() layoutSubviews()
} }
} }
...@@ -358,15 +359,17 @@ open class BottomSheetController: RootController { ...@@ -358,15 +359,17 @@ open class BottomSheetController: RootController {
open fileprivate(set) var bottomSheetHeight: CGFloat = 0 open fileprivate(set) var bottomSheetHeight: CGFloat = 0
/// Determines the layout style for the bottomSheet. /// Determines the layout style for the bottomSheet.
open var bottomSheetStyle = BottomSheetLayoutStyle.modal { open var bottomSheetStyle = BottomSheetStyle.modal {
didSet { didSet {
switch bottomSheetStyle { switch bottomSheetStyle {
case .modal: case .modal:
depthPreset = .depth1 depthPreset = .depth1
isBottomPanGestureEnabled = true
isBottomTapGestureEnabled = true
case .persistent: case .persistent:
depthPreset = .none depthPreset = .none
layoutSubviews() isBottomPanGestureEnabled = false
isBottomSheetEnabled = false isBottomTapGestureEnabled = false
} }
} }
} }
...@@ -406,6 +409,7 @@ open class BottomSheetController: RootController { ...@@ -406,6 +409,7 @@ open class BottomSheetController: RootController {
super.layoutSubviews() super.layoutSubviews()
bottomSheet.width = view.bounds.width bottomSheet.width = view.bounds.width
bottomSheet.height = bottomSheetHeight bottomSheet.height = bottomSheetHeight
bottomSheetThreshold = view.bounds.height - bottomSheetHeight / 2 bottomSheetThreshold = view.bounds.height - bottomSheetHeight / 2
if .persistent == bottomSheetStyle { if .persistent == bottomSheetStyle {
...@@ -459,8 +463,8 @@ open class BottomSheetController: RootController { ...@@ -459,8 +463,8 @@ open class BottomSheetController: RootController {
} }
v.bounds.size.height = height v.bounds.size.height = height
v.position.y = -height / 2 v.position.y = s.view.bounds.height - height / 2
s.rootViewController.view.alpha = 1 // s.rootViewController.view.alpha = 1
}) { [weak self, v = bottomSheet] _ in }) { [weak self, v = bottomSheet] _ in
guard let s = self else { guard let s = self else {
return return
...@@ -472,30 +476,30 @@ open class BottomSheetController: RootController { ...@@ -472,30 +476,30 @@ open class BottomSheetController: RootController {
} }
} else { } else {
UIView.animate(withDuration: duration, UIView.animate(withDuration: duration,
animations: { [weak self, v = bottomSheet] in animations: { [weak self, v = bottomSheet, h = bottomSheetHeight] in
guard let s = self else { guard let s = self else {
return return
} }
v.bounds.size.height = height v.bounds.size.height = h
v.position.y = height / 2 v.position.y = s.view.bounds.height - h / 2
s.rootViewController.view.alpha = 0.5 // s.rootViewController.view.alpha = 0.5
}) { [weak self, v = bottomSheet] _ in }) { [weak self, v = bottomSheet] _ in
guard let s = self else { guard let s = self else {
return return
} }
v.isShadowPathAutoSizing = true v.isShadowPathAutoSizing = true
s.layoutSubviews() // s.layoutSubviews()
s.showView(container: v) s.showView(container: v)
} }
} }
} else { } else {
bottomSheet.bounds.size.height = height bottomSheet.bounds.size.height = bottomSheetHeight
if isHidden { if isHidden {
hideView(container: bottomSheet) hideView(container: bottomSheet)
bottomSheet.position.y = -bottomSheet.bounds.height / 2 bottomSheet.position.y = view.bounds.height - bottomSheetHeight / 2
rootViewController.view.alpha = 1 rootViewController.view.alpha = 1
} else { } else {
bottomSheet.isShadowPathAutoSizing = false bottomSheet.isShadowPathAutoSizing = false
......
...@@ -60,6 +60,8 @@ open class CollectionViewCard: Card { ...@@ -60,6 +60,8 @@ open class CollectionViewCard: Card {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
pulseAnimation = .none
prepareCollectionView() prepareCollectionView()
prepareContentView() prepareContentView()
} }
...@@ -112,6 +114,7 @@ extension CollectionViewCard: CollectionViewDataSource { ...@@ -112,6 +114,7 @@ extension CollectionViewCard: CollectionViewDataSource {
@objc @objc
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CardCollectionViewCell", for: indexPath) as! CardCollectionViewCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CardCollectionViewCell", for: indexPath) as! CardCollectionViewCell
cell.pulseAnimation = .none
guard let card = dataSourceItems[indexPath.item].data as? Card else { guard let card = dataSourceItems[indexPath.item].data as? Card else {
return cell return cell
......
...@@ -37,6 +37,17 @@ public enum ToolbarAlignment: Int { ...@@ -37,6 +37,17 @@ public enum ToolbarAlignment: Int {
} }
open class ImageCard: Card { open class ImageCard: Card {
/**
A Display value to indicate whether or not to
display the imageView to the full view
bounds.
*/
open var imageViewDisplay = Display.partial {
didSet {
layoutSubviews()
}
}
/// A preset wrapper around imageViewEdgeInsets. /// A preset wrapper around imageViewEdgeInsets.
open var imageViewEdgeInsetsPreset = EdgeInsetsPreset.none { open var imageViewEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet { didSet {
......
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