Update UI to support more customizable password generator
This commit is contained in:
parent
ff014a5699
commit
b84f2dce13
8 changed files with 252 additions and 71 deletions
45
pass/Views/SwitchTableViewCell.swift
Normal file
45
pass/Views/SwitchTableViewCell.swift
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue