Format code with SwiftFormat automatically in every build
This commit is contained in:
parent
f167ab7549
commit
7f9f0e43b2
100 changed files with 1124 additions and 1063 deletions
|
|
@ -6,8 +6,8 @@
|
|||
// Copyright © 2017 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import passKit
|
||||
import UIKit
|
||||
|
||||
protocol FillPasswordTableViewCellDelegate {
|
||||
func generateAndCopyPassword()
|
||||
|
|
@ -15,12 +15,11 @@ protocol FillPasswordTableViewCellDelegate {
|
|||
}
|
||||
|
||||
class FillPasswordTableViewCell: UITableViewCell, ContentProvider {
|
||||
|
||||
@IBOutlet weak var contentTextField: UITextField!
|
||||
@IBOutlet var contentTextField: UITextField!
|
||||
var delegate: FillPasswordTableViewCellDelegate?
|
||||
|
||||
@IBOutlet weak var settingButton: UIButton!
|
||||
@IBOutlet weak var generateButton: UIButton!
|
||||
@IBOutlet var settingButton: UIButton!
|
||||
@IBOutlet var generateButton: UIButton!
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
|
@ -32,21 +31,24 @@ class FillPasswordTableViewCell: UITableViewCell, ContentProvider {
|
|||
generateButton.imageView?.contentMode = .scaleAspectFit
|
||||
}
|
||||
|
||||
@IBAction func generatePassword(_ sender: UIButton) {
|
||||
self.delegate?.generateAndCopyPassword()
|
||||
@IBAction
|
||||
func generatePassword(_: UIButton) {
|
||||
delegate?.generateAndCopyPassword()
|
||||
}
|
||||
|
||||
@IBAction func showHidePasswordSettings() {
|
||||
self.delegate?.showHidePasswordSettings()
|
||||
@IBAction
|
||||
func showHidePasswordSettings() {
|
||||
delegate?.showHidePasswordSettings()
|
||||
}
|
||||
|
||||
// re-color
|
||||
@IBAction func textFieldDidChange(_ sender: UITextField) {
|
||||
@IBAction
|
||||
func textFieldDidChange(_ sender: UITextField) {
|
||||
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
|
||||
}
|
||||
|
||||
func getContent() -> String? {
|
||||
return contentTextField.attributedText?.string
|
||||
contentTextField.attributedText?.string
|
||||
}
|
||||
|
||||
func setContent(content: String?) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
// Copyright © 2017 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SVProgressHUD
|
||||
import passKit
|
||||
import SVProgressHUD
|
||||
import UIKit
|
||||
|
||||
struct LabelTableViewCellData {
|
||||
var title: String
|
||||
|
|
@ -16,9 +16,8 @@ struct LabelTableViewCellData {
|
|||
}
|
||||
|
||||
class LabelTableViewCell: UITableViewCell {
|
||||
|
||||
@IBOutlet weak var contentLabel: UILabel!
|
||||
@IBOutlet weak var titleLabel: UILabel!
|
||||
@IBOutlet var contentLabel: UILabel!
|
||||
@IBOutlet var titleLabel: UILabel!
|
||||
|
||||
private enum CellType {
|
||||
case password, URL, HOTP, other
|
||||
|
|
@ -27,7 +26,7 @@ class LabelTableViewCell: UITableViewCell {
|
|||
private var type = CellType.other
|
||||
private var isReveal = false
|
||||
|
||||
weak var delegatePasswordTableView : PasswordDetailTableViewController?
|
||||
weak var delegatePasswordTableView: PasswordDetailTableViewController?
|
||||
|
||||
private var passwordDisplayButton: UIButton?
|
||||
private var buttons: UIView?
|
||||
|
|
@ -74,12 +73,10 @@ class LabelTableViewCell: UITableViewCell {
|
|||
}
|
||||
|
||||
override var canBecomeFirstResponder: Bool {
|
||||
get {
|
||||
return true
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
override func canPerformAction(_ action: Selector, withSender _: Any?) -> Bool {
|
||||
switch type {
|
||||
case .password:
|
||||
if isReveal {
|
||||
|
|
@ -100,11 +97,12 @@ class LabelTableViewCell: UITableViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
override func copy(_ sender: Any?) {
|
||||
override func copy(_: Any?) {
|
||||
SecurePasteboard.shared.copy(textToCopy: cellData?.content)
|
||||
}
|
||||
|
||||
@objc func revealPassword(_ sender: Any?) {
|
||||
@objc
|
||||
func revealPassword(_: Any?) {
|
||||
let plainPassword = cellData?.content ?? ""
|
||||
if type == .password {
|
||||
contentLabel.attributedText = Utils.attributedPassword(plainPassword: plainPassword)
|
||||
|
|
@ -115,7 +113,8 @@ class LabelTableViewCell: UITableViewCell {
|
|||
passwordDisplayButton?.setImage(#imageLiteral(resourceName: "Invisible"), for: .normal)
|
||||
}
|
||||
|
||||
@objc func concealPassword(_ sender: Any?) {
|
||||
@objc
|
||||
func concealPassword(_: Any?) {
|
||||
if type == .password {
|
||||
if cellData?.content.isEmpty == false {
|
||||
contentLabel.text = Globals.passwordDots
|
||||
|
|
@ -130,7 +129,8 @@ class LabelTableViewCell: UITableViewCell {
|
|||
passwordDisplayButton?.setImage(#imageLiteral(resourceName: "Visible"), for: .normal)
|
||||
}
|
||||
|
||||
@objc func reversePasswordDisplay(_ sender: Any?) {
|
||||
@objc
|
||||
func reversePasswordDisplay(_ sender: Any?) {
|
||||
if isReveal {
|
||||
// conceal
|
||||
concealPassword(sender)
|
||||
|
|
@ -140,19 +140,21 @@ class LabelTableViewCell: UITableViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
@objc func openLink(_ sender: Any?) {
|
||||
@objc
|
||||
func openLink(_: Any?) {
|
||||
// if isURLCell, passwordTableView should not be nil
|
||||
delegatePasswordTableView!.openLink(to: cellData?.content)
|
||||
}
|
||||
|
||||
@objc func getNextHOTP(_ sender: Any?) {
|
||||
@objc
|
||||
func getNextHOTP(_: Any?) {
|
||||
// if isHOTPCell, passwordTableView should not be nil
|
||||
delegatePasswordTableView!.getNextHOTP()
|
||||
}
|
||||
|
||||
private func updateButtons() {
|
||||
// total width and height of a button
|
||||
let height = min(self.bounds.height, 36.0)
|
||||
let height = min(bounds.height, 36.0)
|
||||
let width = max(height * 0.8, Globals.tableCellButtonSize)
|
||||
|
||||
// margins (between button boundary and icon)
|
||||
|
|
@ -167,7 +169,7 @@ class LabelTableViewCell: UITableViewCell {
|
|||
passwordDisplayButton!.frame = CGRect(x: 0, y: 0, width: width, height: height)
|
||||
passwordDisplayButton!.setImage(#imageLiteral(resourceName: "Visible"), for: .normal)
|
||||
passwordDisplayButton!.imageView?.contentMode = .scaleAspectFit
|
||||
passwordDisplayButton!.contentEdgeInsets = UIEdgeInsets.init(top: marginY, left: marginX, bottom: marginY, right: marginX)
|
||||
passwordDisplayButton!.contentEdgeInsets = UIEdgeInsets(top: marginY, left: marginX, bottom: marginY, right: marginX)
|
||||
passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControl.Event.touchUpInside)
|
||||
buttons = passwordDisplayButton
|
||||
}
|
||||
|
|
@ -177,7 +179,7 @@ class LabelTableViewCell: UITableViewCell {
|
|||
nextButton.frame = CGRect(x: 0, y: 0, width: width, height: height)
|
||||
nextButton.setImage(#imageLiteral(resourceName: "Refresh"), for: .normal)
|
||||
nextButton.imageView?.contentMode = .scaleAspectFit
|
||||
nextButton.contentEdgeInsets = UIEdgeInsets.init(top: marginY, left: marginX, bottom: marginY, right: marginX)
|
||||
nextButton.contentEdgeInsets = UIEdgeInsets(top: marginY, left: marginX, bottom: marginY, right: marginX)
|
||||
nextButton.addTarget(self, action: #selector(getNextHOTP), for: UIControl.Event.touchUpInside)
|
||||
|
||||
// password button
|
||||
|
|
@ -186,7 +188,7 @@ class LabelTableViewCell: UITableViewCell {
|
|||
|
||||
passwordDisplayButton!.setImage(#imageLiteral(resourceName: "Visible"), for: .normal)
|
||||
passwordDisplayButton!.imageView?.contentMode = .scaleAspectFit
|
||||
passwordDisplayButton!.contentEdgeInsets = UIEdgeInsets.init(top: marginY, left: marginX, bottom: marginY, right: marginX)
|
||||
passwordDisplayButton!.contentEdgeInsets = UIEdgeInsets(top: marginY, left: marginX, bottom: marginY, right: marginX)
|
||||
passwordDisplayButton!.addTarget(self, action: #selector(reversePasswordDisplay), for: UIControl.Event.touchUpInside)
|
||||
|
||||
buttons = UIView()
|
||||
|
|
@ -197,6 +199,6 @@ class LabelTableViewCell: UITableViewCell {
|
|||
passwordDisplayButton = nil
|
||||
buttons = nil
|
||||
}
|
||||
self.accessoryView = buttons
|
||||
accessoryView = buttons
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,12 @@
|
|||
import UIKit
|
||||
|
||||
class PasswordDetailTitleTableViewCell: UITableViewCell {
|
||||
@IBOutlet weak var categoryLabel: UILabel!
|
||||
@IBOutlet weak var nameLabel: UILabel!
|
||||
@IBOutlet weak var passwordImageImageView: UIImageView!
|
||||
@IBOutlet var categoryLabel: UILabel!
|
||||
@IBOutlet var nameLabel: UILabel!
|
||||
@IBOutlet var passwordImageImageView: UIImageView!
|
||||
@IBOutlet var labelImageConstraint: NSLayoutConstraint!
|
||||
@IBOutlet var labelCellConstraint: NSLayoutConstraint!
|
||||
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
}
|
||||
|
|
@ -25,5 +24,4 @@ class PasswordDetailTitleTableViewCell: UITableViewCell {
|
|||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import passKit
|
|||
import UIKit
|
||||
|
||||
class SliderTableViewCell: UITableViewCell {
|
||||
|
||||
@IBOutlet var titleLabel: UILabel!
|
||||
@IBOutlet var valueLabel: UILabel!
|
||||
@IBOutlet var slider: UISlider!
|
||||
|
|
@ -20,7 +19,8 @@ class SliderTableViewCell: UITableViewCell {
|
|||
|
||||
private var delegate: PasswordSettingSliderTableViewCellDelegate!
|
||||
|
||||
@IBAction func handleSliderValueChange(_ sender: UISlider) {
|
||||
@IBAction
|
||||
func handleSliderValueChange(_ sender: UISlider) {
|
||||
let newRoundedValue = Int(sender.value)
|
||||
// Proceed only if the rounded value gets updated.
|
||||
guard checker(newRoundedValue) else {
|
||||
|
|
@ -67,9 +67,8 @@ class SliderTableViewCell: UITableViewCell {
|
|||
}
|
||||
|
||||
extension SliderTableViewCell: ContentProvider {
|
||||
|
||||
func getContent() -> String? {
|
||||
return nil
|
||||
nil
|
||||
}
|
||||
|
||||
func setContent(content _: String?) {}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import passKit
|
|||
import UIKit
|
||||
|
||||
class SwitchTableViewCell: UITableViewCell {
|
||||
|
||||
@IBOutlet var titleLabel: UILabel!
|
||||
@IBOutlet var controlSwitch: UISwitch!
|
||||
|
||||
|
|
@ -18,7 +17,8 @@ class SwitchTableViewCell: UITableViewCell {
|
|||
|
||||
private var delegate: PasswordSettingSliderTableViewCellDelegate!
|
||||
|
||||
@IBAction func switchValueChanged(_: Any) {
|
||||
@IBAction
|
||||
func switchValueChanged(_: Any) {
|
||||
updater(controlSwitch.isOn)
|
||||
delegate.generateAndCopyPassword()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,10 @@
|
|||
import UIKit
|
||||
|
||||
class TextFieldTableViewCell: UITableViewCell, ContentProvider {
|
||||
|
||||
@IBOutlet weak var contentTextField: UITextField!
|
||||
@IBOutlet var contentTextField: UITextField!
|
||||
|
||||
func getContent() -> String? {
|
||||
return contentTextField.text
|
||||
contentTextField.text
|
||||
}
|
||||
|
||||
func setContent(content: String?) {
|
||||
|
|
|
|||
|
|
@ -9,17 +9,16 @@
|
|||
import UIKit
|
||||
|
||||
class TextViewTableViewCell: UITableViewCell, ContentProvider {
|
||||
@IBOutlet var contentTextView: UITextView!
|
||||
|
||||
@IBOutlet weak var contentTextView: UITextView!
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
self.contentTextView.textContainer.lineFragmentPadding = 0
|
||||
self.contentTextView.textContainerInset = .zero
|
||||
contentTextView.textContainer.lineFragmentPadding = 0
|
||||
contentTextView.textContainerInset = .zero
|
||||
}
|
||||
|
||||
func getContent() -> String? {
|
||||
return contentTextView.text
|
||||
contentTextView.text
|
||||
}
|
||||
|
||||
func setContent(content: String?) {
|
||||
|
|
|
|||
|
|
@ -6,11 +6,10 @@
|
|||
Copyright © 2019 Bob Sun. All rights reserved.
|
||||
*/
|
||||
|
||||
import UIKit
|
||||
import passKit
|
||||
import UIKit
|
||||
|
||||
class UICodeHighlightingLabel: UILocalizedLabel {
|
||||
|
||||
private static let CODE_ATTRIBUTES: [NSAttributedString.Key: Any] = [.font: UIFont(name: "Menlo-Regular", size: 12)!]
|
||||
private static let ATTRIBUTED_NEWLINE = NSAttributedString(string: "\n")
|
||||
|
||||
|
|
@ -43,4 +42,3 @@ class UICodeHighlightingLabel: UILocalizedLabel {
|
|||
return formattedText
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,10 @@
|
|||
Copyright © 2019 Bob Sun. All rights reserved.
|
||||
*/
|
||||
|
||||
import UIKit
|
||||
import passKit
|
||||
import UIKit
|
||||
|
||||
class UILocalizedLabel: UILabel {
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
text = text?.localize()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue