Update UI to support more customizable password generator

This commit is contained in:
Danny Moesch 2020-02-28 19:05:23 +01:00 committed by Mingshen Sun
parent ff014a5699
commit b84f2dce13
8 changed files with 252 additions and 71 deletions

View 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
}
}