passforios/pass/Views/FillPasswordTableViewCell.swift

58 lines
1.5 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 passKit
import UIKit
protocol FillPasswordTableViewCellDelegate {
func generateAndCopyPassword()
func showHidePasswordSettings()
}
class FillPasswordTableViewCell: UITableViewCell, ContentProvider {
@IBOutlet var contentTextField: UITextField!
var delegate: FillPasswordTableViewCellDelegate?
2018-12-09 16:59:07 -08:00
@IBOutlet var settingButton: UIButton!
@IBOutlet var generateButton: UIButton!
2018-12-09 16:59:07 -08:00
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
2017-10-07 23:05:26 -07:00
contentTextField.font = Globals.passwordFont
2018-12-09 16:59:07 -08:00
// Force aspect ratio of button images
settingButton.imageView?.contentMode = .scaleAspectFit
generateButton.imageView?.contentMode = .scaleAspectFit
}
@IBAction
func generatePassword(_: UIButton) {
delegate?.generateAndCopyPassword()
}
2018-12-09 16:59:07 -08:00
@IBAction
func showHidePasswordSettings() {
delegate?.showHidePasswordSettings()
}
2018-12-09 16:59:07 -08:00
// re-color
@IBAction
func textFieldDidChange(_ sender: UITextField) {
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
}
2018-12-09 16:59:07 -08:00
func getContent() -> String? {
contentTextField.attributedText?.string
2017-02-13 01:15:42 +08:00
}
2018-12-09 16:59:07 -08:00
func setContent(content: String?) {
2017-03-21 13:16:25 -07:00
contentTextField.attributedText = Utils.attributedPassword(plainPassword: content ?? "")
2017-02-13 01:15:42 +08:00
}
}