CheckingTableViewCell.swift 1.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//
//  CheckingTableViewCell.swift
//  WhatsOpen
//
//  Created by Zach Knox on 5/25/17.
//  Copyright © 2017 SRCT. All rights reserved.
//

import UIKit

class CheckingTableViewCell: UITableViewCell {

	var onlyOne: OnlyOneChecked!
	var cellIndex: Int!
Zach Knox's avatar
Zach Knox committed
15
16
	var selectingEnum: Any?
	var selectFunc: ((Any?) -> Bool)!
17
18
19
20
21
22
23
24
25
	
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
		if(selected) {
26
			_ = selectFunc(selectingEnum)
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
			onlyOne.setCheckToCellWithID(cellIndex)
			super.setSelected(false, animated: animated)
		}
        // Configure the view for the selected state
    }

	
}

class OnlyOneChecked {
	
	var view: FiltersTableViewController
	var cellChecked: Int //if -1, no cell is checked.
	
	init(tableView: FiltersTableViewController, tableCellChecked: Int) {
		self.view = tableView
		self.cellChecked = tableCellChecked
	}
	
	func setCheckToCellWithID(_ id: Int) {
		for cell in view.sortOptions {
			if(id == cell.cellIndex) {
49
				cell.accessoryType = UITableViewCell.accessoryType.checkmark
50
51
			}
			else {
52
				cell.accessoryType = UITableViewCell.accessoryType.none
53
54
55
56
57
58
59
			}
		}
		
		//also do something here to update the filters object in view
	}
	
}