Commit b7a1d22a by Daniel Dahan

development: updated CollectionViewCard and BottomSheetController

parent 6e0141ee
...@@ -431,7 +431,7 @@ open class BottomSheetController: RootController { ...@@ -431,7 +431,7 @@ open class BottomSheetController: RootController {
isUserInteractionEnabled = false isUserInteractionEnabled = false
delegate?.bottomSheetController?(bottomSheetController: self, willOpen: .right) delegate?.bottomSheetControllerWillOpen?(bottomSheetController: self)
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.y / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.y / velocity)))),
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
...@@ -446,7 +446,7 @@ open class BottomSheetController: RootController { ...@@ -446,7 +446,7 @@ open class BottomSheetController: RootController {
return return
} }
s.delegate?.bottomSheetController?(bottomSheetController: s, didOpen: .right) s.delegate?.bottomSheetControllerDidOpen?(bottomSheetController: s)
} }
} }
...@@ -467,7 +467,7 @@ open class BottomSheetController: RootController { ...@@ -467,7 +467,7 @@ open class BottomSheetController: RootController {
isUserInteractionEnabled = true isUserInteractionEnabled = true
delegate?.bottomSheetController?(bottomSheetController: self, willClose: .left) delegate?.bottomSheetControllerWillClose?(bottomSheetController: self)
UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.y / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.y / velocity)))),
animations: { [weak self, v = v] in animations: { [weak self, v = v] in
...@@ -484,7 +484,7 @@ open class BottomSheetController: RootController { ...@@ -484,7 +484,7 @@ open class BottomSheetController: RootController {
s.hideView(container: v) s.hideView(container: v)
s.delegate?.bottomSheetController?(bottomSheetController: s, didClose: .left) s.delegate?.bottomSheetControllerDidClose?(bottomSheetController: s)
} }
} }
...@@ -700,7 +700,7 @@ extension BottomSheetController: UIGestureRecognizerDelegate { ...@@ -700,7 +700,7 @@ extension BottomSheetController: UIGestureRecognizerDelegate {
return return
} }
delegate?.bottomSheetController?(bottomSheetController: self, didTapAt: recognizer.location(in: view), position: .left) delegate?.bottomSheetController?(bottomSheetController: self, didTapAt: recognizer.location(in: view))
guard isBottomViewEnabled && isBottomViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) else { guard isBottomViewEnabled && isBottomViewOpened && !isPointContainedWithinView(container: v, point: recognizer.location(in: v)) else {
return return
......
...@@ -46,8 +46,8 @@ open class CollectionViewCard: Card { ...@@ -46,8 +46,8 @@ open class CollectionViewCard: Card {
/// A reference to the dataSourceItems. /// A reference to the dataSourceItems.
open var dataSourceItems = [DataSourceItem]() open var dataSourceItems = [DataSourceItem]()
/// An index of IndexPath to MenuItem. /// An index of IndexPath to DataSourceItem.
open var indexForDataSourceItems = [IndexPath: Any]() open var dataSourceItemsIndexPaths = [IndexPath: Any]()
/// A reference to the collectionView. /// A reference to the collectionView.
@IBInspectable @IBInspectable
...@@ -96,9 +96,9 @@ extension CollectionViewCard { ...@@ -96,9 +96,9 @@ extension CollectionViewCard {
extension CollectionViewCard: CollectionViewDelegate { extension CollectionViewCard: CollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let card = indexForDataSourceItems[indexPath] as? Card else { // guard let card = dataSourceItemsIndexPaths[indexPath] as? Card else {
return // return
} // }
} }
} }
...@@ -121,7 +121,7 @@ extension CollectionViewCard: CollectionViewDataSource { ...@@ -121,7 +121,7 @@ extension CollectionViewCard: CollectionViewDataSource {
return cell return cell
} }
indexForDataSourceItems[indexPath] = card dataSourceItemsIndexPaths[indexPath] = card
if .vertical == self.collectionView.scrollDirection { if .vertical == self.collectionView.scrollDirection {
card.width = cell.width card.width = cell.width
......
...@@ -294,7 +294,7 @@ extension Menu { ...@@ -294,7 +294,7 @@ extension Menu {
extension Menu: CollectionViewDelegate { extension Menu: CollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let menuItem = collectionViewCard.indexForDataSourceItems[indexPath] as? MenuItem else { guard let menuItem = collectionViewCard.dataSourceItemsIndexPaths[indexPath] as? MenuItem else {
return return
} }
...@@ -321,7 +321,7 @@ extension Menu: CollectionViewDataSource { ...@@ -321,7 +321,7 @@ extension Menu: CollectionViewDataSource {
return cell return cell
} }
collectionViewCard.indexForDataSourceItems[indexPath] = menuItem collectionViewCard.dataSourceItemsIndexPaths[indexPath] = menuItem
cell.menuItem = menuItem cell.menuItem = menuItem
cell.menuItem?.width = cell.width cell.menuItem?.width = cell.width
......
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