Tusker/Tusker/Views/Silent Action Permissions/SilentActionPermissionTable...

37 lines
957 B
Swift

//
// SilentActionPermissionTableViewCell.swift
// Tusker
//
// Created by Shadowfacts on 9/30/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
class SilentActionPermissionTableViewCell: UITableViewCell {
@IBOutlet weak var sourceLabel: UILabel!
@IBOutlet weak var permissionSwitch: UISwitch!
var source: String!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
func updateUI(source: String, permission: Preferences.Permission) {
self.source = source
sourceLabel.text = source
permissionSwitch.setOn(permission == .accepted, animated: false)
}
@IBAction func permissionSwitchChanged(_ sender: Any) {
Preferences.shared.silentActions[source] = permissionSwitch.isOn ? .accepted : .rejected
}
}