{"id":2535,"url":"https://github.com/kunalverma25/KVCardSelectionVC","last_synced_at":"2025-08-03T00:32:00.450Z","repository":{"id":56917685,"uuid":"75077230","full_name":"kunalverma25/KVCardSelectionVC","owner":"kunalverma25","description":"Awesome looking Dial like card selection ViewController","archived":false,"fork":false,"pushed_at":"2016-12-05T09:48:42.000Z","size":7673,"stargazers_count":23,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-08T04:40:20.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kunalverma25.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-29T12:00:39.000Z","updated_at":"2023-11-05T23:27:19.000Z","dependencies_parsed_at":"2022-08-20T21:20:34.335Z","dependency_job_id":null,"html_url":"https://github.com/kunalverma25/KVCardSelectionVC","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalverma25%2FKVCardSelectionVC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalverma25%2FKVCardSelectionVC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalverma25%2FKVCardSelectionVC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalverma25%2FKVCardSelectionVC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kunalverma25","download_url":"https://codeload.github.com/kunalverma25/KVCardSelectionVC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228510730,"owners_count":17931759,"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":[],"created_at":"2024-01-05T20:16:16.188Z","updated_at":"2024-12-06T18:30:34.424Z","avatar_url":"https://github.com/kunalverma25.png","language":"Swift","funding_links":[],"categories":["UI"],"sub_categories":["Cards","Other free courses"],"readme":"# KVCardSelectionVC\nAwesome looking Dial like card selection ViewController\n\nAn updated Swift 3 working version of : https://github.com/atljeremy/JFCardSelectionViewController\n\nWhat It Looks Like:\n------------------\n\n![Example](https://github.com/kunalverma25/KVCardSelectionVC/raw/master/KVVC2.gif)\n\nHow To Use It:\n-------------\n\n### Compatibility\niOS 9+\n\nSwift 3.0+\n\nxCode 8.0+\n\n\n### Basic Example\n\nFirst create a new class that subclasses `KVCardSelectionViewController`\n```swift\nimport UIKit\nimport KVCardSelectionVC\n\nclass UserSelectionViewController: KVCardSelectionViewController {\n    \n    var cards: [User]? {\n      didSet {\n        // Call `reloadData()` once you are ready to display your `CardPresentable` data or when there have been changes to that data that need to be represented in the UI.\n        reloadData()\n      }\n    }\n    \n    override func viewDidLoad() {\n        \n        // You can set a permanent background by setting a UIImage on the `backgroundImage` property. If not set, the `backgroundImage` will be set using the currently selected Card's `imageURLString`.\n        // backgroundImage = UIImage(named: \"bg\")\n        \n        // Set the datasource so that `KVCardSelectionViewController` can get the CardPresentable data you want to dispaly\n        dataSource = self\n        \n        // Set the delegate so that `KVCardSelectionViewController` can notify the `delegate` of events that take place on the focused CardPresentable.\n        delegate = self\n        \n        // Set the desired `KVCardSelectionViewSelectionAnimationStyle` to either `.slide` or `.fade`. Defaults to `.fade`.\n        selectionAnimationStyle = .slide\n        \n        // Call up to super after configuring your subclass of `KVCardSelectionViewController`. Calling super before configuring will cause undesirable side effects.\n        super.viewDidLoad()\n        \n    }\n    \n    override func viewWillAppear(animated: Bool) {\n        super.viewWillAppear(animated)\n        \n        /*\n        NOTE: If you are displaying an instance of `KVCardSelectionViewController` within a `UINavigationController`, you can use the code below to hide the navigation bar. This isn't required to use `KVCardSelectionViewController`, but `KVCardSelectionViewController` was designed to be used without a UINavigationBar.\n        let image = UIImage()\n        let navBar = navigationController?.navigationBar\n        navBar?.setBackgroundImage(image, for: .default)\n        navBar?.shadowImage = image\n        */\n        \n        // Load your dynamic CardPresentable data\n        cards = [\n          User(name: \"Jennifer Adams\", photoURL: \"https://s-media-cache-ak0.pinimg.com/736x/5d/43/0b/5d430bd15603971c939fcc9a4358a35f.jpg\", address: \"123 Main St\", city: \"Atlanta\", state: \"GA\", zip: 12345),\n          User(name: \"Jim Adel\", photoURL: \"http://a3.files.blazepress.com/image/upload/c_fit,cs_srgb,dpr_1.0,q_80,w_620/MTI4OTkyOTM4OTM5MTYxMDU0.jpg\", address: \"234 Main St\", city: \"Atlanta\", state: \"GA\", zip: 12345),\n          User(name: \"Jane Aden\", photoURL: \"https://s-media-cache-ak0.pinimg.com/236x/b7/65/2d/b7652d8c4cf40bc0b1ebac37bb254fcb.jpg\", address: \"345 Main St\", city: \"Atlanta\", state: \"GA\", zip: 12345),\n          User(name: \"Avery Adil\", photoURL: \"http://boofos.com/wp-content/uploads/2013/02/Celebrity-Portraits-by-Andy-Gotts-10.jpg\", address: \"456 Main St\", city: \"Atlanta\", state: \"GA\", zip: 12345),\n          User(name: \"Jamar Baar\", photoURL: \"https://s-media-cache-ak0.pinimg.com/736x/85/e3/8a/85e38ab9e480790e216c4f9359bb677f.jpg\", address: \"567 Main St\", city: \"Atlanta\", state: \"GA\", zip: 12345),\n          User(name: \"Steven Babel\", photoURL: \"http://blog.picr.com/wp-content/uploads/2015/09/Andy-Gotts.jpeg\", address: \"678 Main St\", city: \"Atlanta\", state: \"GA\", zip: 12345)\n        ]\n    }\n}\n```\n\nSecond, conform to the `KVCardSelectionViewControllerDelegate` and `KVCardSelectionViewControllerDataSource` protocols so that you can provide the CardPresentable data to the `KVCardSelectionViewController` and to receive callbacks of touch events in the action buttons.\n```swift\nextension UserSelectionViewController: KVCardSelectionViewControllerDataSource {\n    public func cardSelectionViewController(_ cardSelectionViewController: KVCardSelectionViewController, cardForItemAtIndexPath indexPath: IndexPath) -\u003e CardPresentable {\n        return cards[indexPath.row]\n    }\n    \n    \n    func numberOfCardsForCardSelectionViewController(_ cardSelectionViewController: KVCardSelectionViewController) -\u003e Int {\n        return cards.count\n    }\n    \n}\n\nextension UserSelectionViewController: KVCardSelectionViewControllerDelegate {\n    \n    func cardSelectionViewController(_ cardSelectionViewController: KVCardSelectionViewController, didSelectCardAction cardAction: CardAction, forCardAtIndexPath indexPath: IndexPath) {\n        let card = cards[(indexPath as NSIndexPath).row]\n        if let action = card.actionOne , action.title == cardAction.title {\n            print(\"----------- \\nCard action fired! \\nAction Title: \\(cardAction.title) \\nIndex Path: \\(indexPath)\")\n        }\n        if let action = card.actionTwo , action.title == cardAction.title {\n            print(\"----------- \\nCard action fired! \\nAction Title: \\(cardAction.title) \\nIndex Path: \\(indexPath)\")\n        }\n    }\n    \n    func cardSelectionViewController(_ cardSelectionViewController: KVCardSelectionViewController, didSelectDetailActionForCardAtIndexPath indexPath: IndexPath) {\n        print(\"CARD SELECTED for \\(indexPath)\")\n    }\n}\n```\n\nThen, in the models you want to be presentable within the card selection view controller, just have them conform to the `CardPresentable` protocol.\n```swift\nstruct User {\n    var name: String\n    var photoURL: String\n    var address: String\n    var city: String\n    var state: String\n    var zip: Int\n}\n\nextension User: CardPresentable {\n    \n    var imageURLString: String {\n        return photoURL\n    }\n    \n    var placeholderImage: UIImage? {\n        return UIImage(named: \"default\")\n    }\n    \n    var titleText: String {\n        return name\n    }\n    \n    var detailTextLineOne: String {\n        return address\n    }\n    \n    var detailTextLineTwo: String {\n        return \"\\(city), \\(state) \\(zip)\"\n    }\n    \n    var actionOne: CardAction? {\n        return CardAction(title: \"Call\")\n    }\n    \n    var actionTwo: CardAction? {\n        return CardAction(title: \"Email\")\n    }\n    \n}\n```\n\n### Installation\n\n#### CocoaPods\n```\npod 'KVCardSelectionVC'\n```\n\n#### Example\nCheck Example Folder for the same.\n\n#### Dependencies\nKVCardSelectionVC has dependencies on pod 'Try' and pod 'Kingfisher'\n\nTry is used for handling NSExceptions which swift cannot handle.\n\nKingfisher is used for Image downloading and cache.\n\nThe max size of cache is 50 Mb and cache expiry is one week.\n\n#### Images Not Showing/Downloading\nQuick Fix - Add Allow Arbitrary Loads to your project's Info.plist\n\nLicense\n-------\nDistributed under the ```MIT``` license. See ```LICENSE``` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkunalverma25%2FKVCardSelectionVC","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkunalverma25%2FKVCardSelectionVC","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkunalverma25%2FKVCardSelectionVC/lists"}