46 lines
1.1 KiB
Swift
46 lines
1.1 KiB
Swift
|
|
//
|
||
|
|
// SwitchTableViewCell.swift
|
||
|
|
// pass
|
||
|
|
//
|
||
|
|
// Created by Danny Moesch on 28.02.20.
|
||
|
|
// Copyright © 2020 Bob Sun. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
import passKit
|
||
|
|
import UIKit
|
||
|
|
|
||
|
|
class SwitchTableViewCell: UITableViewCell {
|
||
|
|
|
||
|
|
@IBOutlet var titleLabel: UILabel!
|
||
|
|
@IBOutlet var controlSwitch: UISwitch!
|
||
|
|
|
||
|
|
private var updater: ((Bool) -> Void)!
|
||
|
|
|
||
|
|
private var delegate: PasswordSettingSliderTableViewCellDelegate!
|
||
|
|
|
||
|
|
@IBAction func switchValueChanged(_: Any) {
|
||
|
|
updater(controlSwitch.isOn)
|
||
|
|
delegate.generateAndCopyPassword()
|
||
|
|
}
|
||
|
|
|
||
|
|
func set(title: String) -> SwitchTableViewCell {
|
||
|
|
titleLabel.text = title
|
||
|
|
return self
|
||
|
|
}
|
||
|
|
|
||
|
|
func set(initialValue: Bool) -> SwitchTableViewCell {
|
||
|
|
controlSwitch.isOn = initialValue
|
||
|
|
return self
|
||
|
|
}
|
||
|
|
|
||
|
|
func updateNewValue(using updater: @escaping (Bool) -> Void) -> SwitchTableViewCell {
|
||
|
|
self.updater = updater
|
||
|
|
return self
|
||
|
|
}
|
||
|
|
|
||
|
|
func delegate(to delegate: PasswordSettingSliderTableViewCellDelegate) -> SwitchTableViewCell {
|
||
|
|
self.delegate = delegate
|
||
|
|
return self
|
||
|
|
}
|
||
|
|
}
|