Latest 1.01
Homepage https://github.com/yungdai/UIExpandableCVCellKit/
License Apache License, Version 2.0 Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Platforms ios 12.2
Authors

A Framework to add a Apple Appstore like animation to expand the cell to fullscreen when selecting a UICollectionViewCell

Installation

  1. Install cocoapods
  2. add pod ‘UIExpandableCVCellKit’ to your Podfile
  3. run pod install from the command line your project directory with the Podfile

Setup

UICollectionViewController:

  • Have your UICollectionView extend the ExpandableCVProtocol

  • Add this line to your viewDidAppear(_ animated:) delegate function:
    collectionView.isScrollEnabled = (isCellOpen) ? false : true

    This will ensure when you swap between apps, that the scrolling is set to the correct setting when you swap between apps

  • in collectionView(_ collectionView:, cellForItemAt indexPath:) dequeue your cell and then create the ExpandedCellViewModel and pass it to the cell using the ExpandableCVCellProtocol.configure(with: ExpandedCellViewMode) function, this will help the cell configure itself with all the settings it needs to function

  • in collectionView(_ collectionView:, didSelectItemAt indexPath:) impliment animateCellOpen(indexPath:) inside that delegate function to allow the cell to open properly. This is a manadatory implimentation.

UICollectionViewCell:

  • Have your UICollectionViewCell extend ExpandablerCVCellProtocol

  • Add setupPanGesture(selector: Selector) to your init(frame:) and init(coder:) initializers with your own gesturing funciton. I usually call mine cellGestured(), inside that @objc function I add the default cellGesturedLogic() function. You can of course override and write your own gesturing logic if required.

  • Optionally you may impliment the following functions to add or write your own code to animate the cells open, close, or snap back:

    • func openCellHandler() -> (handler: Handler?, completion: Handler?, isAnimated: Bool)
    • func closeCellHandler() -> (handler: Handler?, completion: Handler?, isAnimated: Bool)
    • func snapBackCellHandler() -> (handler: Handler?, completion: Handler?, isAnimated: Bool)

    Example of how to the openCellHanlder() or any of the other optional handler functions:

    func openCellHandler() -> (handler: Handler?, completion: Handler?, isAnimated: Bool) {
    
        let animations = {
            // your code that you would like animated into this block or any code you would like handled
        }
    
        let completion = {
            // any code you would like to run after the animations/handler
        }
    
        return (handler: animations, completion: completion, isAnimated: true)
    }

Optional

If you want to hide and show the status bar when showing and hiding the expandable collectionViewCell do the following:

  1. In your UICollectionView class

    Add:

    override var prefersStatusBarHidden: Bool {
    return statusBarShoudlBeHidden
    }

    override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
    return .slide
    }

    You can choose another type of animation, if you like

  2. Optionally you can use func animateStatusBar(duration: TimeInterval) to hide or show the status bar when required. You should however set the setting for statusBarShouldBeHidden before you run this function.

For an example project please see https://github.com/yungdai/AppStoreAnimationDemo

Latest podspec

{
    "name": "UIExpandableCVCellKit",
    "version": "1.01",
    "swift_versions": "5.0",
    "summary": "Recreate the Apple Appstore cell expansion experience!",
    "description": "Recreate the Apple Appstore cell experience when you tap on a cell.  Have the cell open up and maximize to full screen!",
    "homepage": "https://github.com/yungdai/UIExpandableCVCellKit/",
    "license": {
        "type": "Apache License, Version 2.0",
        "text": "    Licensed under the Apache License, Version 2.0 (the "License");n    you may not use this file except in compliance with the License.n    You may obtain a copy of the License atnn    http://www.apache.org/licenses/LICENSE-2.0nn    Unless required by applicable law or agreed to in writing, softwaren    distributed under the License is distributed on an "AS IS" BASIS,n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n    See the License for the specific language governing permissions andn    limitations under the License.n"
    },
    "authors": {
        "Yung Dai": "[email protected]"
    },
    "source": {
        "git": "https://github.com/yungdai/UIExpandableCVCellKit.git",
        "tag": "1.01"
    },
    "platforms": {
        "ios": "12.2"
    },
    "source_files": "UIExpandableCVCellKit/*.{swift,h,m}",
    "swift_version": "5.0"
}

Pin It on Pinterest

Share This