Commit 0ebe904f by Daniel Dahan

development: BottomSheet respects persistent sizing

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