passforios/pass/Views/FillPasswordTableViewCell.swift

62 lines
1.7 KiB
Swift
Raw Normal View History

//
// FillPasswordTableViewCell.swift
// pass
//
// Created by Mingshen Sun on 11/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import passKit
protocol FillPasswordTableViewCellDelegate {
func generateAndCopyPassword()
func showHidePasswordSettings()
}
2017-02-13 01:15:42 +08:00
class FillPasswordTableViewCell: ContentTableViewCell {
@IBOutlet weak var contentTextField: UITextField!
var delegate: FillPasswordTableViewCellDelegate?
@IBOutlet weak var settingButton: UIButton!
@IBOutlet weak var generateButton: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
2017-10-07 23:05:26 -07:00
contentTextField.font = Globals.passwordFont
// Force aspect ratio of button images
settingButton.imageView?.contentMode = .scaleAspectFit
generateButton.imageView?.contentMode = .scaleAspectFit
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
@IBAction func generatePassword(_ sender: UIButton) {
self.delegate?.generateAndCopyPassword()
}
2017-02-13 01:15:42 +08:00
@IBAction func showHidePasswordSettings() {
self.delegate?.showHidePasswordSettings()
}
// re-color
@IBAction func textFieldDidChange(_ sender: UITextField) {
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
}
2017-02-13 01:15:42 +08:00
override func getContent() -> String? {
2017-02-26 00:58:18 +08:00
return contentTextField.attributedText?.string
2017-02-13 01:15:42 +08:00
}
2017-03-21 13:16:25 -07:00
override func setContent(content: String?) {
contentTextField.attributedText = Utils.attributedPassword(plainPassword: content ?? "")
2017-02-13 01:15:42 +08:00
}
}