{"id":15037767,"url":"https://github.com/rushisangani/rsselectionmenu","last_synced_at":"2025-04-04T19:14:59.591Z","repository":{"id":37396662,"uuid":"105355478","full_name":"rushisangani/RSSelectionMenu","owner":"rushisangani","description":"An elegant selection list or dropdown menu for iOS with single or multiple selections.","archived":false,"fork":false,"pushed_at":"2022-10-03T00:34:55.000Z","size":21447,"stargazers_count":353,"open_issues_count":2,"forks_count":91,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-29T18:44:29.449Z","etag":null,"topics":["dropdown","dropdown-menus","dropdownbutton","dropdownlist","ios","list","multiselectdropdown","multiselectpopupwindows","popover","popovers","rsselectionmenu","select-multiple","selectbox","selection","selectionmenu","swift","swift-3","swift4","swift5"],"latest_commit_sha":null,"homepage":"","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/rushisangani.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":"2017-09-30T08:34:12.000Z","updated_at":"2024-03-25T04:28:15.000Z","dependencies_parsed_at":"2022-09-10T10:51:16.163Z","dependency_job_id":null,"html_url":"https://github.com/rushisangani/RSSelectionMenu","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FRSSelectionMenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FRSSelectionMenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FRSSelectionMenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushisangani%2FRSSelectionMenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rushisangani","download_url":"https://codeload.github.com/rushisangani/RSSelectionMenu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"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":["dropdown","dropdown-menus","dropdownbutton","dropdownlist","ios","list","multiselectdropdown","multiselectpopupwindows","popover","popovers","rsselectionmenu","select-multiple","selectbox","selection","selectionmenu","swift","swift-3","swift4","swift5"],"created_at":"2024-09-24T20:35:35.889Z","updated_at":"2025-04-04T19:14:59.570Z","avatar_url":"https://github.com/rushisangani.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSSelectionMenu\n\nAn elegant selection list or dropdown menu for iOS with single or multiple selections.\n\n[![https://github.com/rushisangani/RSSelectionMenu/blob/master/Images/multi1.gif](http://img.youtube.com/vi/9Br-3GnxDSo/0.jpg)](http://www.youtube.com/watch?v=9Br-3GnxDSo \"RSSelectionMenu Demo\")\n\n[Demo Video](http://www.youtube.com/watch?v=9Br-3GnxDSo)\n\n## Features\n\n- **Single** and **Multiple** selection.\n- Show menu with presentation styles like **Present**, **Push**, **Popover**, **Formsheet**, **Alert**, **Actionsheet**\n- Set UITableViewCell types like **Basic**, **Subtitle**, **Right Detail**\n- Set UITableViewCell selection style **Tickmark** or **Checkbox**\n- Search Items from the list\n- Works with Custom UITableViewCells\n- Works with Custom model classes and structs\n- Set Maximum selection limit\n- Provide Empty data set text\n- Provide header row as **Empty**, **All**, **None** or **Custom Text**\n- Customizable design for UINavigationBar and UISearchBar\n\n## What's new in 7.1.3\n- Popover Style Improvements\n- Now you can specify UITableView.Style while initializing\n\n## Already using? Migrate to 7.1.3\n- Remove all references of `UniquePropertyDelegate`,  `uniquePropertyName`, and `getUniquePropertyName()`\n- Conform to `Equatable` in your model classes (if required)\n\n## Requirements\n```swift\niOS 9.0+ | Xcode 8.3+ | Swift 3.0+\n```\n\n## Installation\n\n### CocoaPods\n\n```ruby\npod 'RSSelectionMenu' or pod 'RSSelectionMenu', '~\u003e 7.1.3'\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](https://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate RSSelectionMenu into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"rushisangani/RSSelectionMenu\" ~\u003e 7.1\n```\nThen follow below steps:\n- Run `carthage update` to build the framework.\n- Set Framework search path in target build settings : Build Settings  -\u003e Framework Search Paths  :  `$(PROJECT_DIR)/Carthage/Build/iOS` \n- Add  RSSelectionMenu.framework in `Embedded Binaries`.\n- Add  RSSelectionMenu.framework in `Linked Frameworks and Libraries`.\n\n\n## Usage\n\n### Simple Selection List\n```swift\nlet simpleDataArray = [\"Sachin\", \"Rahul\", \"Saurav\", \"Virat\", \"Suresh\", \"Ravindra\", \"Chris\"]\nvar simpleSelectedArray = [String]()\n\n// Show menu with datasource array - Default SelectionStyle = single\n// Here you'll get cell configuration where you'll get array item for each index\n// Cell configuration following parameters.\n// 1. UITableViewCell   2. Item of type T   3. IndexPath\n\nlet selectionMenu = RSSelectionMenu(dataSource: simpleDataArray) { (cell, item, indexPath) in\n    cell.textLabel?.text = item\n}\n\n// set default selected items when menu present on screen.\n// here you'll get handler each time you select a row\n// 1. Selected Item  2. Index of Selected Item  3. Selected or Deselected  4. All Selected Items\n\nselectionMenu.setSelectedItems(items: simpleSelectedArray) { [weak self] (item, index, isSelected, selectedItems) in\n\n    // update your existing array with updated selected items, so when menu show menu next time, updated items will be default selected.\n    self?.simpleSelectedArray = selectedItems\n}\n\n// show as PresentationStyle = push\nselectionMenu.show(style: .push, from: self)\n```\n\n### Multiple Selection List\n```swift\nlet selectionMenu = RSSelectionMenu(selectionStyle: .multiple, dataSource: simpleDataArray) { (cell, name, indexPath) in\n\n    cell.textLabel?.text = name\n\n    // customization\n    // set image\n    cell.imageView?.image = #imageLiteral(resourceName: \"profile\")\n    cell.tintColor = #colorLiteral(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1)\n}\n```\n\n- Set Maximum selection limit (Optional)\n```swift\nselectionMenu.setSelectedItems(items: selectedDataArray, maxSelected: 3) { (item, selected, selectedItems) in\n}\n// or \nselectionMenu.maxSelectionLimit = 3\n```\n\n### Cell Selection Style\n```swift\nselectionMenu.cellSelectionStyle = .tickmark\n// or\nselectionMenu.cellSelectionStyle = .checkbox\n```\n\n### Presentation Style - Formsheet, Popover, Alert, Actionsheet\n```swift\n// show as formSheet\nselectionMenu.show(style: .formSheet, from: self)\n\n\n// show as popover\nselectionMenu.show(style: .popover(sourceView: sourceView, size: nil), from: self) \n\n// or specify popover size\nselectionMenu.show(style: .popover(sourceView: sender, size: CGSize(width: 200, height: 300)), from: self)\n\n\n// show as alert\nselectionMenu.show(style: .alert(title: \"Select\", action: nil, height: nil), from: self)\n\n// or specify alert button title\nselectionMenu.show(style: .alert(title: \"Select\", action: \"Done\", height: nil), from: self)\n\n\n// show as actionsheet\nselectionMenu.show(style: .actionSheet(title: nil, action: \"Done\", height: nil), from: self)\n```\n\n### Auto Dismissal\nPrevent auto dismissal for single selection\n```swift\nselectionMenu.dismissAutomatically = false\n```\n\n### Event Handlers\n\n#### On Dismiss\n```swift\nselectionMenu.onDismiss = { [weak self] selectedItems in\n    self?.selectedDataArray = selectedItems\n    \n    // perform any operation once you get selected items\n}\n```\n\n#### On WillAppear\n```swift\nselectionMenu.onWillAppear = {\n    /// do something..\n}\n```\n\n### Customization\n\n#### SearchBar\n- You'll get notified via handler, when user starts typing in searchbar.\n```swift\n// show searchbar\nselectionMenu.showSearchBar { [weak self] (searchText) -\u003e ([String]) in\n\n  // return filtered array based on any condition\n  // here let's return array where name starts with specified search text\n\n  return self?.dataArray.filter({ $0.lowercased().hasPrefix(searchText.lowercased()) }) ?? []\n}\n```\n\n#### Cell Style - Right Detail or Sub Title\n```swift\nlet selectionMenu = RSSelectionMenu(selectionType: .single, dataSource: dataArray, cellType: .rightDetail) { (cell, item, indexPath) in\n\n    // here you can set any text from object\n    // let's set firstname in title and lastname as right detail\n\n    let firstName = item(separatedBy: \" \").first\n    let lastName = item.components(separatedBy: \" \").last\n\n    cell.textLabel?.text = firstName\n    cell.detailTextLabel?.text = lastName\n}\n\nselectionMenu.setSelectedItems(items: selectedDataArray) { [weak self] (item, selected, selectedItems) in\n    self?.selectedDataArray = selectedItems\n}\n\n// show as default\nselectionMenu.show(from: self)\n```\n\n#### Custom Cells\n- Provide custom cell with xib file name and cell identifier.\n```swift\nlet cellNibName = \"CustomTableViewCell\"\nlet cellIdentifier = \"cell\"\n\n// create menu with multi selection and custom cell\n\nlet selectionMenu =  RSSelectionMenu(selectionStyle: .multiple, dataSource: customDataArray, cellType: .custom(nibName: cellNibName, cellIdentifier: cellIdentifier)) { (cell, person, indexPath) in\n\n    // cast cell to your custom cell type\n    let customCell = cell as! CustomTableViewCell\n\n    // here you'll get specified model object\n    // set data based on your need\n    customCell.setData(person)\n}\n```\n\n#### Header Row - Empty, None, All, or Custom\n```swift\n// To show first row as Empty, when dropdown as no value selected by default\n// add first row as empty -\u003e Allow empty selection\n\nlet isEmpty = (selectedDataArray.count == 0)\nselectionMenu.addFirstRowAs(rowType: .empty, showSelected: isEmpty) { (text, selected) in\n\n    /// do some stuff...\n    if selected {\n        print(\"Empty Option Selected\")\n    }\n}\n```\n\n#### Empty Data String\n```swift\n// show message 'No data found'\nmenu.showEmptyDataLabel()\n\n// or\nmenu.showEmptyDataLabel(text: \"No players found\")\n```\n\n### DataSource - Equatable conformance\n```swift\nstruct Employee: Equatable {\n    \n    let empId: Int?\n    let name: String?\n}\n```\nor\n```swift\nclass Person: NSObject {\n\n    let id: Int\n    let firstName: String\n    let lastName: String\n\n    init(id: Int, firstName: String, lastName: String) {\n        self.id = id\n        self.firstName = firstName\n        self.lastName = lastName\n    }\n}\n```\n\n### UI Customization\n\n#### NavigationBar\n- Set Title, BarButton Titles, TintColor, and Title Color\n```swift\n// set navigation bar title and attributes\nselectionMenu.setNavigationBar(title: \"Select Player\", attributes: [NSAttributedString.Key.foregroundColor: UIColor.white], barTintColor: #colorLiteral(red: 0.1019607857, green: 0.2784313858, blue: 0.400000006, alpha: 1), tintColor: UIColor.white)\n\n// right barbutton title - Default is 'Done'\nselectionMenu.rightBarButtonTitle = \"Submit\"\n\n// left barbutton title - Default is 'Cancel'\nselectionMenu.leftBarButtonTitle = \"Close\"\n```\n\n#### SearchBar\n- Set Placeholder, Tint Color\n```swift\n// show searchbar with placeholder and barTintColor\nselectionMenu.showSearchBar(withPlaceHolder: \"Search Player\", barTintColor: UIColor.lightGray.withAlphaComponent(0.2)) { [weak self] (searchText) -\u003e ([String]) in\n\n    return self?.dataArray.filter({ $0.lowercased().starts(with: searchText.lowercased()) }) ?? []\n}\n```\n\n### Example\nSee [Example](https://github.com/rushisangani/RSSelectionMenu/tree/master/RSSelectionMenuExample) for more details.\n\n## License\n\nRSSelectionMenu is released under the MIT license. [See LICENSE](https://github.com/rushisangani/RSSelectionMenu/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frushisangani%2Frsselectionmenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frushisangani%2Frsselectionmenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frushisangani%2Frsselectionmenu/lists"}