Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting last clicked index in Multi select #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class ViewController: UIViewController {
self?.chooseArticleButton.setTitle(item, for: .normal)
}

chooseArticleDropDown.multiSelectionAction = { [weak self] (indices, items) in
print("Muti selection action called with: \(items)")
chooseArticleDropDown.multiSelectionAction = { [weak self] (lastClickedIndex,indices, items) in
print("Muti selection action called with: \(items) & last clicked index : \(lastClickedIndex)")
if items.isEmpty {
self?.chooseArticleButton.setTitle("", for: .normal)
}
Expand Down
6 changes: 3 additions & 3 deletions DropDown/src/DropDown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
public typealias Index = Int
public typealias Closure = () -> Void
public typealias SelectionClosure = (Index, String) -> Void
public typealias MultiSelectionClosure = ([Index], [String]) -> Void
public typealias MultiSelectionClosure = (Int,[Index], [String]) -> Void
public typealias ConfigurationClosure = (Index, String) -> String
public typealias CellConfigurationClosure = (Index, String, DropDownCell) -> Void
private typealias ComputeLayoutTuple = (x: CGFloat, y: CGFloat, width: CGFloat, offscreenHeight: CGFloat)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ extension DropDown: UITableViewDataSource, UITableViewDelegate {

let selectedRowIndicesArray = Array(selectedRowIndices)
let selectedRows = selectedRowIndicesArray.map { dataSource[$0] }
multiSelectionCallback(selectedRowIndicesArray, selectedRows)
multiSelectionCallback(selectedRowIndex,selectedRowIndicesArray, selectedRows)
return
}
else {
Expand All @@ -1048,7 +1048,7 @@ extension DropDown: UITableViewDataSource, UITableViewDelegate {
let selectedRows = selectedRowIndicesArray.map { dataSource[$0] }

selectionAction?(selectedRowIndex, dataSource[selectedRowIndex])
multiSelectionCallback(selectedRowIndicesArray, selectedRows)
multiSelectionCallback(selectedRowIndex,selectedRowIndicesArray, selectedRows)
tableView.reloadData()
return
}
Expand Down