@@ -214,11 +214,7 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType
214214 return indexPath
215215 }
216216
217- open func dismiss( ) {
218- dismiss ( nil )
219- }
220-
221- open func dismiss( _ completion: ( ( ) -> ( ) ) ? ) {
217+ open func dismiss( _ completion: ( ( ) -> ( ) ) ? = nil ) {
222218 disableActions = true
223219 presentingViewController? . dismiss ( animated: true ) { [ weak self] in
224220 self ? . disableActions = false
@@ -252,19 +248,19 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType
252248 if let headerSpec = headerSpec, let _ = headerData {
253249 switch headerSpec {
254250 case . cellClass:
255- collectionView. register ( HeaderViewType . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . Header. rawValue)
251+ collectionView. register ( HeaderViewType . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . Header. rawValue)
256252 case . nibFile( let nibName, let bundle, _) :
257- collectionView. register ( UINib ( nibName: nibName, bundle: bundle) , forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . Header. rawValue)
253+ collectionView. register ( UINib ( nibName: nibName, bundle: bundle) , forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . Header. rawValue)
258254 }
259255 }
260256
261257 // register section header
262258 if let headerSpec = sectionHeaderSpec {
263259 switch headerSpec {
264260 case . cellClass:
265- collectionView. register ( SectionHeaderViewType . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . SectionHeader. rawValue)
261+ collectionView. register ( SectionHeaderViewType . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . SectionHeader. rawValue)
266262 case . nibFile( let nibName, let bundle, _) :
267- collectionView. register ( UINib ( nibName: nibName, bundle: bundle) , forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . SectionHeader. rawValue)
263+ collectionView. register ( UINib ( nibName: nibName, bundle: bundle) , forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: ReusableViewIds . SectionHeader. rawValue)
268264 }
269265 }
270266
@@ -282,8 +278,6 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType
282278 }
283279 }
284280
285- setUpContentInsetForHeight ( view. frame. height)
286-
287281 // set up collection view initial position taking into account top content inset
288282 collectionView. frame = view. bounds
289283 collectionView. frame. origin. y += contentHeight + ( settings. cancelView. showCancel ? settings. cancelView. height : 0 )
@@ -295,6 +289,11 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType
295289 view. addSubview ( cancelView!)
296290 }
297291 }
292+
293+ open override func viewWillLayoutSubviews( ) {
294+ super. viewWillLayoutSubviews ( )
295+ setUpContentInsetForHeight ( view. frame. height)
296+ }
298297
299298 open override func viewWillAppear( _ animated: Bool ) {
300299 super. viewWillAppear ( animated)
@@ -661,12 +660,11 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType
661660 }
662661
663662 fileprivate func setUpContentInsetForHeight( _ height: CGFloat ) {
664- if initialContentInset == nil {
665- initialContentInset = collectionView. contentInset
666- }
663+
664+ initialContentInset = initialContentInset ?? collectionView. contentInset
667665 var leftInset = initialContentInset. left
668666 var rightInset = initialContentInset. right
669- var bottomInset = settings. cancelView. showCancel ? settings. cancelView. height : initialContentInset. bottom
667+ var bottomInset = settings. cancelView. showCancel ? initialContentInset . bottom + settings. cancelView. height : initialContentInset. bottom
670668 var topInset = height - contentHeight - safeAreaInsets. bottom
671669
672670 if settings. cancelView. showCancel {
@@ -682,7 +680,7 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType
682680
683681 collectionView. contentInset = UIEdgeInsets ( top: topInset, left: leftInset, bottom: bottomInset, right: rightInset)
684682 if !settings. behavior. useDynamics {
685- collectionView. contentOffset. y = - height + contentHeight + safeAreaInsets . bottom
683+ collectionView. contentOffset. y = - height + contentHeight + bottomInset
686684 }
687685 }
688686
@@ -778,10 +776,6 @@ open class DynamicsActionController<ActionViewType: UICollectionViewCell, Action
778776
779777 // MARK: - Overrides
780778
781- open override func dismiss( ) {
782- dismiss ( nil )
783- }
784-
785779 open override func dismiss( _ completion: ( ( ) -> ( ) ) ? ) {
786780 animator. addBehavior ( gravityBehavior)
787781
0 commit comments