Open imacInfo opened 6 years ago
I have added following codes in CheckboxDialogViewController.swift
//properties exposed to developer/user
open var selectType: Int = 0 // added 0 : single choice , 1 : multiple choice
open var titleDialog: String = ""
// Changed
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let object = tableData[indexPath.row]
if (selectType == 1) {
selectedValues[object.name] = object.translated
} else {
var temporary: [(name: String, translated: String)]?
temporary = dictionaryToTuples(dictionary: selectedValues)
var index = 0
while index < tableData.count {
let item = tableData[index]
if (temporary?.count)! > 0 && tupleContainsByTuple(temporary!, needle: (name: item.name, translated: item.translated)) {
let indexPath = IndexPath(row: index, section: 0)
tableView.deselectRow(at: indexPath, animated: false)
}
index = index + 1
}
selectedValues.removeAll()
selectedValues[object.name] = object.translated
}
}
//
open func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
let object = tableData[indexPath.row]
if (selectType == 1) {
selectedValues.removeValue(forKey: object.name)
} else {
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .middle)
selectedValues[object.name] = object.translated
}
}
Please optimize above codes and update this repository.
Thanks
There is not any variable for choice type either single or multiple.