{"id":13770783,"url":"https://github.com/hfrahmann/HFCardCollectionViewLayout","last_synced_at":"2025-05-11T03:32:54.876Z","repository":{"id":56913276,"uuid":"72861638","full_name":"hfrahmann/HFCardCollectionViewLayout","owner":"hfrahmann","description":"The HFCardCollectionViewLayout provides a card stack layout not quite similar like the apps Reminder and Wallet.","archived":true,"fork":false,"pushed_at":"2019-03-10T10:22:09.000Z","size":2655,"stargazers_count":302,"open_issues_count":14,"forks_count":58,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-20T11:48:33.277Z","etag":null,"topics":["cards","collectionview","ios","swift","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hfrahmann.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-04T15:44:52.000Z","updated_at":"2025-02-07T09:31:35.000Z","dependencies_parsed_at":"2022-08-21T03:20:21.981Z","dependency_job_id":null,"html_url":"https://github.com/hfrahmann/HFCardCollectionViewLayout","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfrahmann%2FHFCardCollectionViewLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfrahmann%2FHFCardCollectionViewLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfrahmann%2FHFCardCollectionViewLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfrahmann%2FHFCardCollectionViewLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hfrahmann","download_url":"https://codeload.github.com/hfrahmann/HFCardCollectionViewLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514352,"owners_count":21920327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cards","collectionview","ios","swift","xcode"],"created_at":"2024-08-03T17:00:42.078Z","updated_at":"2025-05-11T03:32:54.115Z","avatar_url":"https://github.com/hfrahmann.png","language":"Swift","funding_links":[],"categories":["Cards"],"sub_categories":[],"readme":"# HFCardCollectionViewLayout\nThe HFCardCollectionViewLayout provides a card stack layout not quite similar like the apps Reminder and Wallet.\n\nFeatures:\n\n- Many options, also within the InterfaceBuilder\n- Flip animation to have a backview\n- Move/Order the cards\n- Simple integration (only set the Layout class in the CollectionView)\n\n![Screenshot](https://raw.githubusercontent.com/hfrahmann/HFCardCollectionViewLayout/master/ReadmeAssets/Screenshot.png)\n![Screenplay](https://raw.githubusercontent.com/hfrahmann/HFCardCollectionViewLayout/master/ReadmeAssets/Screenplay.gif)\n\n\n## Installation\n\nInstall it with Cocoapods, Swift Package Manager, Carthage  or just use the files inside the **Source** directory.\n\n\n**Cocoapods:**\n```\npod 'HFCardCollectionViewLayout'\n```\n\n\n**Carthage:**\n```\ngithub \"hfrahmann/HFCardCollectionViewLayout\"\n```\n\n\n**Swift Package Manager:**\n```\ndependencies: [\n    .Package(url: \"https://github.com/hfrahmann/HFCardCollectionViewLayout.git\")\n]\n```\n\n\n\n## Implementation\n\nJust set *HFCardCollectionViewLayout* as the custom layout class in your UICollectionView.\n\n![CollectionView_LayoutClass](https://raw.githubusercontent.com/hfrahmann/HFCardCollectionViewLayout/master/ReadmeAssets/CollectionView_LayoutClass.png)\n\n\nThere is also a cell class called **HFCardCollectionViewCell** containing rounded corners and a shadow.\nBut this class has no dependency on the *HFCardCollectionViewLayout*.\nIt's only there to have a cell that looks like a card.\n\n**Important: This collectionView layout does support only one section!**\n\n\n### HFCardCollectionView\n\nBecause of some problems with inserting items while a card is revealed, you have to use the **HFCardCollectionView** instead of the UICollectionView.\nOr if you use your own collectionview class, you can copy the lines from the file to your own.\n\n\n## Delegate\n\nThese are the delegate functions of the **HFCardCollectionViewLayoutDelegate** inherits from *UICollectionViewDelete* so you don't need to connect a further delegate.\n\n```swift\n/// Asks if the card at the specific index can be revealed.\n/// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout.\n/// - Parameter canRevealCardAtIndex: Index of the card.\nfunc cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, canRevealCardAtIndex index: Int) -\u003e Bool\n\n/// Asks if the card at the specific index can be unrevealed.\n/// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout.\n/// - Parameter canUnrevealCardAtIndex: Index of the card.\nfunc cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, canUnrevealCardAtIndex index: Int) -\u003e Bool\n\n/// Feedback when the card at the given index will be revealed.\n/// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout.\n/// - Parameter didRevealedCardAtIndex: Index of the card.\nfunc cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, willRevealCardAtIndex index: Int)\n    \n/// Feedback when the card at the given index was revealed.\n/// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout.\n/// - Parameter didRevealedCardAtIndex: Index of the card.\nfunc cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, didRevealCardAtIndex index: Int)\n    \n/// Feedback when the card at the given index will be unrevealed.\n/// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout.\n/// - Parameter didUnrevealedCardAtIndex: Index of the card.\nfunc cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, willUnrevealCardAtIndex index: Int)\n\n/// Feedback when the card at the given index was unrevealed.\n/// - Parameter collectionViewLayout: The current HFCardCollectionViewLayout.\n/// - Parameter didUnrevealedCardAtIndex: Index of the card.\nfunc cardCollectionViewLayout(_ collectionViewLayout: HFCardCollectionViewLayout, didUnrevealCardAtIndex index: Int)\n```\n\n\n\n## Options and Actions\n\nYou also have access to the options and (some) actions at the *HFCardCollectionViewLayout* object in the interface builder.\n\n![CardLayoutOptions2](https://raw.githubusercontent.com/hfrahmann/HFCardCollectionViewLayout/master/ReadmeAssets/CardLayoutOptions.png)\n![CardLayoutActions](https://raw.githubusercontent.com/hfrahmann/HFCardCollectionViewLayout/master/ReadmeAssets/CardLayoutActions.png)\n\nThese are the public variables of *HFCardCollectionViewLayout*.\n\n```swift\n/////////////// Public Variables\n\n/// Only cards with index equal or greater than firstMovableIndex can be moved through the collectionView.\n@IBInspectable var firstMovableIndex: Int = 0\n\n/// Specifies the height that is showing the cardhead when the collectionView is showing all cards.\n/// The minimum value is 20.\n@IBInspectable var cardHeadHeight: CGFloat = 80\n\n/// When th collectionView is showing all cards but there are not enough cards to fill the full height,\n/// the cardHeadHeight will be expanded to equally fill the height.\n@IBInspectable var cardShouldExpandHeadHeight: Bool = true\n\n/// Stretch the cards when scrolling up\n@IBInspectable var cardShouldStretchAtScrollTop: Bool = true\n\n/// Specifies the maximum height of the cards.\n/// But the height can be less if the frame size of collectionView is smaller.\n@IBInspectable var cardMaximumHeight: CGFloat = 0\n\n/// Count of bottom stacked cards when a card is revealed.\n/// Value must be between 0 and 10\n@IBInspectable var bottomNumberOfStackedCards: Int = 5\n\n/// All bottom stacked cards are scaled to produce the 3D effect.\n@IBInspectable var bottomStackedCardsShouldScale: Bool = true\n\n/// Specifies the margin for the top margin of a bottom stacked card.\n/// Value can be between 0 and 20\n@IBInspectable var bottomCardLookoutMargin: CGFloat = 10\n\n/// An additional topspace to show the top of the collectionViews backgroundView.\n@IBInspectable var spaceAtTopForBackgroundView: CGFloat = 0\n\n/// Snaps the scrollView if the contentOffset is on the 'spaceAtTopForBackgroundView'\n@IBInspectable var spaceAtTopShouldSnap: Bool = true\n\n/// Additional space at the bottom to expand the contentsize of the collectionView.\n@IBInspectable var spaceAtBottom: CGFloat = 0\n\n/// Area the top where to autoscroll while moving a card.\n@IBInspectable var scrollAreaTop: CGFloat = 120\n\n/// Area ot the bottom where to autoscroll while moving a card.\n@IBInspectable var scrollAreaBottom: CGFloat = 120\n\n/// The scrollView should snap the cardhead to the top.\n@IBInspectable var scrollShouldSnapCardHead: Bool = false\n\n/// Cards are stopping at top while scrolling.\n@IBInspectable var scrollStopCardsAtTop: Bool = true\n\n/// All cards are collapsed at bottom.\n@IBInspectable var collapseAllCards: Bool = false\n    \n/// Contains the revealed index.\n/// ReadOnly.\nprivate(set) var revealedIndex: Int = -1\n```\n\nInterface builder actions\n```swift\n/////////////// InterfaceBuilder Actions\n\n\n/// Action for the InterfaceBuilder to flip back the revealed card.\n@IBAction func flipBackRevealedCardAction()\n\n/// Action for the InterfaceBuilder to unreveal the revealed card.\n@IBAction func unrevealRevealedCardAction()\n\n/// Action to collapse all cards.\n@IBAction func collapseAllCardsAction()\n```\n\nPublic functions\n```swift\n/////////////// Public Functions\n\n\n/// Reveal a card at the given index.\n///\n/// - Parameter index: The index of the card.\n/// - Parameter completion: An optional completion block. Will be executed the animation is finished.\npublic func revealCardAt(index: Int, completion: (() -\u003e Void)? = nil)\n\n/// Unreveal the revealed card\n///\n/// - Parameter completion: An optional completion block. Will be executed the animation is finished.\npublic func unrevealCard(completion: (() -\u003e Void)? = nil)\n\n\n/// Flips the revealed card to the given view.\n/// The frame for the view will be the same as the cell\n///\n/// - Parameter toView: The view for the backview of te card.\n/// - Parameter completion: An optional completion block. Will be executed the animation is finished.\npublic func flipRevealedCard(toView: UIView, completion: (() -\u003e Void)? = nil)\n\n\n/// Flips the flipped card back to the frontview.\n///\n/// - Parameter completion: An optional completion block. Will be executed the animation is finished.\npublic func flipRevealedCardBack(completion: (() -\u003e Void)? = nil)\n```\n\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfrahmann%2FHFCardCollectionViewLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhfrahmann%2FHFCardCollectionViewLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfrahmann%2FHFCardCollectionViewLayout/lists"}