<NME> README.md
<BEF> <a href="https://www.ramotion.com/agency/app-development/?utm_source=gthb&utm_medium=repo&utm_campaign=folding-cell"><img src="https://github.com/Ramotion/folding-cell/blob/master/header.png"></a>

<a href="https://github.com/Ramotion/folding-cell">
<img align="left" src="https://github.com/Ramotion/folding-cell/blob/master/Screenshots/foldingCell.gif" width="480" height="360" /></a>

<p><h1 align="left">FOLDING CELL</h1></p>

<h4>Expanding content cell with animation inspired by folding paper card material design.</h4>


___



<p><h6>We specialize in the designing and coding of custom UI for Mobile Apps and Websites.</h6>
<a href="https://www.ramotion.com/agency/app-development/?utm_source=gthb&utm_medium=repo&utm_campaign=folding-cell">
<img src="https://github.com/ramotion/gliding-collection/raw/master/contact_our_team@2x.png" width="187" height="34"></a>
</p>
<p><h6>Stay tuned for the latest updates:</h6>
<a href="https://goo.gl/rPFpid" >
<img src="https://i.imgur.com/ziSqeSo.png/" width="156" height="28"></a></p>

</br>

[![CocoaPods](https://img.shields.io/cocoapods/p/FoldingCell.svg)](https://cocoapods.org/pods/FoldingCell)
[![CocoaPods](https://img.shields.io/cocoapods/v/FoldingCell.svg)](http://cocoapods.org/pods/FoldingCell)
[![Twitter](https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat)](http://twitter.com/Ramotion)
[![Travis](https://img.shields.io/travis/Ramotion/folding-cell.svg)](https://travis-ci.org/Ramotion/folding-cell)
[![codebeat badge](https://codebeat.co/badges/6f67da5d-c416-4bac-9fb7-c2dc938feedc)](https://codebeat.co/projects/github-com-ramotion-folding-cell)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift 4.0](https://img.shields.io/badge/Swift-5.0-green.svg?style=flat)](https://developer.apple.com/swift/)
[![Analytics](https://ga-beacon.appspot.com/UA-84973210-1/ramotion/folding-cell)](https://github.com/igrigorik/ga-beacon)
[![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/Ramotion)

## Requirements

- iOS 8.0+
- Xcode 10.2

## Installation

Just add the FoldingCell.swift file to your project.

or use [CocoaPods](https://cocoapods.org) with Podfile:
```
pod 'FoldingCell'
```
or [Carthage](https://github.com/Carthage/Carthage) users can simply add Mantle to their `Cartfile`:
```
github "Ramotion/folding-cell"
```
or [Swift Package Manager](https://swift.org/package-manager/) by adding:
```
dependencies: [
.package(url: "https://github.com/Ramotion/folding-cell.git", from: "5.0.2")
]
```
to `Package.swift`

or just drag and drop FoldingCell.swift file to your project

## Solution
![Solution](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/Solution.png)
## Usage

1) Create a new cell inheriting from `FoldingCell`

2) Add a UIView to your cell in your storyboard or nib file, inheriting from `RotatedView`.
Connect the outlet from this view to the cell property `foregroundView`.
Add constraints from this view to the superview, as in this picture:

![1.1](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.1.png)

(constants of constraints may be different). Connect the outlet from this top constraint to the cell property `foregroundViewTop`
. (This view will be shown when the cell is in its normal state).

3) Add other UIViews to your cell, connect the outlet from this view to the cell
property `containerView`. Add constraints from this view to the superview like in the picture:

![1.2](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.2.png)

(constants of constraints may be different). Connect the outlet from this top constraint to the cell property `containerViewTop`.
(This view will be shown when the cell is opened)

Your result should be something like this picture:

![1.3](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.3.png)


4) Set ``` @IBInspectable var itemCount: NSInteger ``` property is a count of folding (it IBInspectable you can set in storyboard). range 2 or greater. Default value is 2

Ok, we've finished configuring the cell.

5) Adding code to your UITableViewController

5.1) Add constants:
``` swift
fileprivate struct C {
  struct CellHeight {
    static let close: CGFloat = *** // equal or greater foregroundView height
    static let open: CGFloat = *** // equal or greater containerView height
  }
}
```
5.2) Add property for calculate cells height

``` swift
     var cellHeights = (0..<CELLCOUNT).map { _ in C.CellHeight.close }
```

5.3) Override method:
``` swift
    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return cellHeights[indexPath.row]
    }
```

5.4) Added code to method:
``` swift
    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        guard case let cell as FoldingCell = tableView.cellForRowAtIndexPath(indexPath) else {
          return
        }

        var duration = 0.0
        if cellIsCollapsed {
            cellHeights[indexPath.row] = Const.openCellHeight
            cell.unfold(true, animated: true, completion: nil)
            duration = 0.5
        } else {
```

## Licence

Adaptive tab bar is released under the MIT license.
See [LICENSE](./LICENSE) for details.


## About
The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)]
See our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.

[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/ramotion/foolding-cell)
[![Twitter Follow](https://img.shields.io/twitter/follow/ramotion.svg?style=social)](https://twitter.com/ramotion)

        if case let cell as FoldingCell = cell {
            if cellHeights![indexPath.row] == C.cellHeights.close {
                foldingCell.selectedAnimation(false, animated: false, completion:nil)
            } else {
                foldingCell.selectedAnimation(true, animated: false, completion: nil)
            }
        }
    }
```

6) Add this code to your new cell class
``` swift
    override func animationDuration(itemIndex:NSInteger, type:AnimationType)-> NSTimeInterval {

        // durations count equal it itemCount
        let durations = [0.33, 0.26, 0.26] // timing animation for each view
        return durations[itemIndex]
    }
```

## if don't use storyboard and xib files

Create foregroundView and containerView from code (steps 2 - 3) look example:
[Folding-cell-programmatically](https://github.com/ober01/Folding-cell-programmatically)

## 🗂 Check this library on other language:
<a href="https://github.com/Ramotion/folding-cell-android">
<img src="https://github.com/ramotion/navigation-stack/raw/master/Android_Java@2x.png" width="178" height="81"></a>


## 📄 License

Folding cell is released under the MIT license.
See [LICENSE](./LICENSE) for details.

This library is a part of a <a href="https://github.com/Ramotion/swift-ui-animation-components-and-libraries"><b>selection of our best UI open-source projects.</b></a>

If you use the open-source library in your project, please make sure to credit and backlink to https://www.ramotion.com/

## 📱 Get the Showroom App for iOS to give it a try
Try this UI component and more like this in our iOS app. Contact us if interested.

<a href="https://itunes.apple.com/app/apple-store/id1182360240?pt=550053&ct=folding-cell&mt=8" >
<img src="https://github.com/ramotion/gliding-collection/raw/master/app_store@2x.png" width="117" height="34"></a>

<a href="https://www.ramotion.com/agency/app-development/?utm_source=gthb&utm_medium=repo&utm_campaign=folding-cell">
<img src="https://github.com/ramotion/gliding-collection/raw/master/contact_our_team@2x.png" width="187" height="34"></a>

<MSG> Update README.md
<DFF> @@ -131,11 +131,14 @@ Ok, we've finished configuring the cell.
 ```
 
 ## Licence
-
Adaptive tab bar is released under the MIT license.
See [LICENSE](./LICENSE) for details.
+
+Adaptive tab bar is released under the MIT license.
+See [LICENSE](./LICENSE) for details.
 
 
 ## About
-The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)]
See our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.
+The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)
+See our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.
 
 [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/ramotion/foolding-cell)
 [![Twitter Follow](https://img.shields.io/twitter/follow/ramotion.svg?style=social)](https://twitter.com/ramotion)

{'commit': "diff --git a/README.md b/README.md\nindex 1e60fce..b45b6cf 100644\n--- a/README.md\n+++ b/README.md\n@@ -131,11 +131,14 @@ Ok, we've finished configuring the cell.\n ```\n \n ## Licence\n-\rAdaptive tab bar is released under the MIT license.\rSee [LICENSE](./LICENSE) for details.\n+\n+Adaptive tab bar is released under the MIT license.\n+See [LICENSE](./LICENSE) for details.\n \n \n ## About\n-The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)]\rSee our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.\n+The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)\n+See our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.\n \n [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/ramotion/foolding-cell)\n [![Twitter Follow](https://img.shields.io/twitter/follow/ramotion.svg?style=social)](https://twitter.com/ramotion)\n", 'commit_subject': 'Update README.md', 'repo_name': 'Ramotion/folding-cell', 'committer': {'name': 'Juri Vasylenko', 'email': '880b7de2ac3743535b3f1eb12f46780a10b417e4@ramotion.com', 'time_sec': '1454314747', 'tz_offset': '180', 'date': {'seconds': '1454314747'}}, 'commit_tree': '939815fd8e58223dbe9ed17454a524b89e4b8195', 'commit_message': 'Update README.md', 'language_name': 'Ruby', 'license': 'mit', 'hunks': "@@ -131,11 +131,14 @@ Ok, we've finished configuring the cell.\n ```\n \n ## Licence\n-\rAdaptive tab bar is released under the MIT license.\rSee [LICENSE](./LICENSE) for details.\n+\n+Adaptive tab bar is released under the MIT license.\n+See [LICENSE](./LICENSE) for details.\n \n \n ## About\n-The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)]\rSee our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.\n+The project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)\n+See our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.\n \n [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/ramotion/foolding-cell)\n [![Twitter Follow](https://img.shields.io/twitter/follow/ramotion.svg?style=social)](https://twitter.com/ramotion)\n", 'addition_count': 5, 'deletion_count': 2, 'src_file': 'a/README.md', 'tgt_file': 'b/README.md', 'file_extension': '.md', 'before_file': '<a href="https://www.ramotion.com/agency/app-development/?utm_source=gthb&utm_medium=repo&utm_campaign=folding-cell"><img src="https://github.com/Ramotion/folding-cell/blob/master/header.png"></a>\n\n<a href="https://github.com/Ramotion/folding-cell">\n<img align="left" src="https://github.com/Ramotion/folding-cell/blob/master/Screenshots/foldingCell.gif" width="480" height="360" /></a>\n\n<p><h1 align="left">FOLDING CELL</h1></p>\n\n<h4>Expanding content cell with animation inspired by folding paper card material design.</h4>\n\n\n___\n\n\n\n<p><h6>We specialize in the designing and coding of custom UI for Mobile Apps and Websites.</h6>\n<a href="https://www.ramotion.com/agency/app-development/?utm_source=gthb&utm_medium=repo&utm_campaign=folding-cell">\n<img src="https://github.com/ramotion/gliding-collection/raw/master/contact_our_team@2x.png" width="187" height="34"></a>\n</p>\n<p><h6>Stay tuned for the latest updates:</h6>\n<a href="https://goo.gl/rPFpid" >\n<img src="https://i.imgur.com/ziSqeSo.png/" width="156" height="28"></a></p>\n\n</br>\n\n[![CocoaPods](https://img.shields.io/cocoapods/p/FoldingCell.svg)](https://cocoapods.org/pods/FoldingCell)\n[![CocoaPods](https://img.shields.io/cocoapods/v/FoldingCell.svg)](http://cocoapods.org/pods/FoldingCell)\n[![Twitter](https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat)](http://twitter.com/Ramotion)\n[![Travis](https://img.shields.io/travis/Ramotion/folding-cell.svg)](https://travis-ci.org/Ramotion/folding-cell)\n[![codebeat badge](https://codebeat.co/badges/6f67da5d-c416-4bac-9fb7-c2dc938feedc)](https://codebeat.co/projects/github-com-ramotion-folding-cell)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift 4.0](https://img.shields.io/badge/Swift-5.0-green.svg?style=flat)](https://developer.apple.com/swift/)\n[![Analytics](https://ga-beacon.appspot.com/UA-84973210-1/ramotion/folding-cell)](https://github.com/igrigorik/ga-beacon)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/Ramotion)\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 10.2\n\n## Installation\n\nJust add the FoldingCell.swift file to your project.\n\nor use [CocoaPods](https://cocoapods.org) with Podfile:\n```\npod \'FoldingCell\'\n```\nor [Carthage](https://github.com/Carthage/Carthage) users can simply add Mantle to their `Cartfile`:\n```\ngithub "Ramotion/folding-cell"\n```\nor [Swift Package Manager](https://swift.org/package-manager/) by adding:\n```\ndependencies: [\n.package(url: "https://github.com/Ramotion/folding-cell.git", from: "5.0.2")\n]\n```\nto `Package.swift`\n\nor just drag and drop FoldingCell.swift file to your project\n\n## Solution\n![Solution](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/Solution.png)\n## Usage\n\n1) Create a new cell inheriting from `FoldingCell`\n\n2) Add a UIView to your cell in your storyboard or nib file, inheriting from `RotatedView`.\nConnect the outlet from this view to the cell property `foregroundView`.\nAdd constraints from this view to the superview, as in this picture:\n\n![1.1](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.1.png)\n\n(constants of constraints may be different). Connect the outlet from this top constraint to the cell property `foregroundViewTop`\n. (This view will be shown when the cell is in its normal state).\n\n3) Add other UIViews to your cell, connect the outlet from this view to the cell\nproperty `containerView`. Add constraints from this view to the superview like in the picture:\n\n![1.2](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.2.png)\n\n(constants of constraints may be different). Connect the outlet from this top constraint to the cell property `containerViewTop`.\n(This view will be shown when the cell is opened)\n\nYour result should be something like this picture:\n\n![1.3](https://raw.githubusercontent.com/Ramotion/folding-cell/master/Tutorial-resources/1.3.png)\n\n\n4) Set ``` @IBInspectable var itemCount: NSInteger ``` property is a count of folding (it IBInspectable you can set in storyboard). range 2 or greater. Default value is 2\n\nOk, we\'ve finished configuring the cell.\n\n5) Adding code to your UITableViewController\n\n5.1) Add constants:\n``` swift\nfileprivate struct C {\n  struct CellHeight {\n    static let close: CGFloat = *** // equal or greater foregroundView height\n    static let open: CGFloat = *** // equal or greater containerView height\n  }\n}\n```\n5.2) Add property for calculate cells height\n\n``` swift\n     var cellHeights = (0..<CELLCOUNT).map { _ in C.CellHeight.close }\n```\n\n5.3) Override method:\n``` swift\n    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {\n        return cellHeights[indexPath.row]\n    }\n```\n\n5.4) Added code to method:\n``` swift\n    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {\n        guard case let cell as FoldingCell = tableView.cellForRowAtIndexPath(indexPath) else {\n          return\n        }\n\n        var duration = 0.0\n        if cellIsCollapsed {\n            cellHeights[indexPath.row] = Const.openCellHeight\n            cell.unfold(true, animated: true, completion: nil)\n            duration = 0.5\n        } else {\n```\n\n## Licence\n\rAdaptive tab bar is released under the MIT license.\rSee [LICENSE](./LICENSE) for details.\n\n\n## About\nThe project maintained by [app development agency](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) [Ramotion Inc.](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell)]\rSee our other [open-source projects](https://github.com/ramotion) or [hire](http://ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=foolding-cell) us to design, develop, and grow your product.\n\n[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=https://github.com/ramotion/foolding-cell)\n[![Twitter Follow](https://img.shields.io/twitter/follow/ramotion.svg?style=social)](https://twitter.com/ramotion)\n\n        if case let cell as FoldingCell = cell {\n            if cellHeights![indexPath.row] == C.cellHeights.close {\n                foldingCell.selectedAnimation(false, animated: false, completion:nil)\n            } else {\n                foldingCell.selectedAnimation(true, animated: false, completion: nil)\n            }\n        }\n    }\n```\n\n6) Add this code to your new cell class\n``` swift\n    override func animationDuration(itemIndex:NSInteger, type:AnimationType)-> NSTimeInterval {\n\n        // durations count equal it itemCount\n        let durations = [0.33, 0.26, 0.26] // timing animation for each view\n        return durations[itemIndex]\n    }\n```\n\n## if don\'t use storyboard and xib files\n\nCreate foregroundView and containerView from code (steps 2 - 3) look example:\n[Folding-cell-programmatically](https://github.com/ober01/Folding-cell-programmatically)\n\n## 🗂 Check this library on other language:\n<a href="https://github.com/Ramotion/folding-cell-android">\n<img src="https://github.com/ramotion/navigation-stack/raw/master/Android_Java@2x.png" width="178" height="81"></a>\n\n\n## 📄 License\n\nFolding cell is released under the MIT license.\nSee [LICENSE](./LICENSE) for details.\n\nThis library is a part of a <a href="https://github.com/Ramotion/swift-ui-animation-components-and-libraries"><b>selection of our best UI open-source projects.</b></a>\n\nIf you use the open-source library in your project, please make sure to credit and backlink to https://www.ramotion.com/\n\n## 📱 Get the Showroom App for iOS to give it a try\nTry this UI component and more like this in our iOS app. Contact us if interested.\n\n<a href="https://itunes.apple.com/app/apple-store/id1182360240?pt=550053&ct=folding-cell&mt=8" >\n<img src="https://github.com/ramotion/gliding-collection/raw/master/app_store@2x.png" width="117" height="34"></a>\n\n<a href="https://www.ramotion.com/agency/app-development/?utm_source=gthb&utm_medium=repo&utm_campaign=folding-cell">\n<img src="https://github.com/ramotion/gliding-collection/raw/master/contact_our_team@2x.png" width="187" height="34"></a>\n', 'message': 'Update README.md', 'author_name': 'Juri Vasylenko', 'lang': 'md'}