diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index d1b8616..fec6535 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -127,7 +127,7 @@ DCFB77A31E500D9C008DE471 /* PasswordDetailTitleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCFB77A21E500D9C008DE471 /* PasswordDetailTitleTableViewCell.xib */; }; DCFB77A71E502DF9008DE471 /* EditPasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77A61E502DF9008DE471 /* EditPasswordTableViewController.swift */; }; DCFB77A91E502FF6008DE471 /* PasswordEditorTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77A81E502FF6008DE471 /* PasswordEditorTableViewController.swift */; }; - DCFB77AB1E503729008DE471 /* ContentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77AA1E503729008DE471 /* ContentTableViewCell.swift */; }; + DCFB77AB1E503729008DE471 /* ContentProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77AA1E503729008DE471 /* ContentProvider.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -327,7 +327,7 @@ DCFB77A21E500D9C008DE471 /* PasswordDetailTitleTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordDetailTitleTableViewCell.xib; sourceTree = ""; }; DCFB77A61E502DF9008DE471 /* EditPasswordTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditPasswordTableViewController.swift; sourceTree = ""; }; DCFB77A81E502FF6008DE471 /* PasswordEditorTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordEditorTableViewController.swift; sourceTree = ""; }; - DCFB77AA1E503729008DE471 /* ContentTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentTableViewCell.swift; sourceTree = ""; }; + DCFB77AA1E503729008DE471 /* ContentProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentProvider.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -628,7 +628,7 @@ DC19400F1E4B3A9E0077E0A3 /* Views */ = { isa = PBXGroup; children = ( - DCFB77AA1E503729008DE471 /* ContentTableViewCell.swift */, + DCFB77AA1E503729008DE471 /* ContentProvider.swift */, DCFB779C1E4F40C7008DE471 /* FillPasswordTableViewCell.swift */, DCFB779D1E4F40C7008DE471 /* FillPasswordTableViewCell.xib */, DC4914941E434301007FF592 /* LabelTableViewCell.swift */, @@ -1115,7 +1115,7 @@ A2A61C201EEFABAD00CFE063 /* UtilsExtension.swift in Sources */, DC8963C01E38EEB900828B09 /* SSHKeySettingTableViewController.swift in Sources */, DC193FFA1E49B4430077E0A3 /* AdvancedSettingsTableViewController.swift in Sources */, - DCFB77AB1E503729008DE471 /* ContentTableViewCell.swift in Sources */, + DCFB77AB1E503729008DE471 /* ContentProvider.swift in Sources */, DCA0499C1E3362F400522E8F /* PGPKeySettingTableViewController.swift in Sources */, DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */, DC5F385B1E56AADB00C69ACA /* PGPKeyArmorSettingTableViewController.swift in Sources */, diff --git a/pass/Views/ContentProvider.swift b/pass/Views/ContentProvider.swift new file mode 100644 index 0000000..f655d47 --- /dev/null +++ b/pass/Views/ContentProvider.swift @@ -0,0 +1,12 @@ +// +// ContentTableViewCell.swift +// pass +// +// Created by Mingshen Sun on 12/2/2017. +// Copyright © 2017 Bob Sun. All rights reserved. +// + +protocol ContentProvider { + func getContent() -> String? + func setContent(content: String?) +} diff --git a/pass/Views/ContentTableViewCell.swift b/pass/Views/ContentTableViewCell.swift deleted file mode 100644 index 34b462b..0000000 --- a/pass/Views/ContentTableViewCell.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// ContentTableViewCell.swift -// pass -// -// Created by Mingshen Sun on 12/2/2017. -// Copyright © 2017 Bob Sun. All rights reserved. -// - -import UIKit - -class ContentTableViewCell: UITableViewCell { - - override func awakeFromNib() { - super.awakeFromNib() - // Initialization code - } - - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) - } - - func getContent() -> String? { - return nil - } - - func setContent(content: String?) { } - -} diff --git a/pass/Views/FillPasswordTableViewCell.swift b/pass/Views/FillPasswordTableViewCell.swift index 9e1727b..442fffb 100644 --- a/pass/Views/FillPasswordTableViewCell.swift +++ b/pass/Views/FillPasswordTableViewCell.swift @@ -14,7 +14,7 @@ protocol FillPasswordTableViewCellDelegate { func showHidePasswordSettings() } -class FillPasswordTableViewCell: ContentTableViewCell { +class FillPasswordTableViewCell: UITableViewCell, ContentProvider { @IBOutlet weak var contentTextField: UITextField! var delegate: FillPasswordTableViewCellDelegate? @@ -32,12 +32,6 @@ class FillPasswordTableViewCell: ContentTableViewCell { 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() } @@ -51,11 +45,11 @@ class FillPasswordTableViewCell: ContentTableViewCell { contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "") } - override func getContent() -> String? { + func getContent() -> String? { return contentTextField.attributedText?.string } - override func setContent(content: String?) { + func setContent(content: String?) { contentTextField.attributedText = Utils.attributedPassword(plainPassword: content ?? "") } } diff --git a/pass/Views/SliderTableViewCell.swift b/pass/Views/SliderTableViewCell.swift index e782951..8de7e4c 100644 --- a/pass/Views/SliderTableViewCell.swift +++ b/pass/Views/SliderTableViewCell.swift @@ -13,7 +13,7 @@ protocol PasswordSettingSliderTableViewCellDelegate { func generateAndCopyPassword() } -class SliderTableViewCell: ContentTableViewCell { +class SliderTableViewCell: UITableViewCell, ContentProvider { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var valueLabel: UILabel! @@ -27,17 +27,6 @@ class SliderTableViewCell: ContentTableViewCell { } } - override func awakeFromNib() { - super.awakeFromNib() - // Initialization code - } - - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) - - // Configure the view for the selected state - } - @IBAction func handleSliderValueChange(_ sender: UISlider) { let oldRoundedValue = self.roundedValue let newRoundedValue = Int(sender.value) @@ -67,4 +56,9 @@ class SliderTableViewCell: ContentTableViewCell { } } + func getContent() -> String? { + return nil + } + + func setContent(content: String?) {} } diff --git a/pass/Views/TextFieldTableViewCell.swift b/pass/Views/TextFieldTableViewCell.swift index 68d4eb4..72ee559 100644 --- a/pass/Views/TextFieldTableViewCell.swift +++ b/pass/Views/TextFieldTableViewCell.swift @@ -8,22 +8,15 @@ import UIKit -class TextFieldTableViewCell: ContentTableViewCell { +class TextFieldTableViewCell: UITableViewCell, ContentProvider { @IBOutlet weak var contentTextField: UITextField! - override func awakeFromNib() { - super.awakeFromNib() - } - - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) - } - - override func getContent() -> String? { + func getContent() -> String? { return contentTextField.text } - override func setContent(content: String?) { + + func setContent(content: String?) { contentTextField.text = content } } diff --git a/pass/Views/TextViewTableViewCell.swift b/pass/Views/TextViewTableViewCell.swift index 4b00187..bd4bdde 100644 --- a/pass/Views/TextViewTableViewCell.swift +++ b/pass/Views/TextViewTableViewCell.swift @@ -8,23 +8,21 @@ import UIKit -class TextViewTableViewCell: ContentTableViewCell { +class TextViewTableViewCell: UITableViewCell, ContentProvider { @IBOutlet weak var contentTextView: UITextView! + override func awakeFromNib() { super.awakeFromNib() self.contentTextView.textContainer.lineFragmentPadding = 0 self.contentTextView.textContainerInset = .zero } - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) - } - override func getContent() -> String? { + func getContent() -> String? { return contentTextView.text } - override func setContent(content: String?) { + func setContent(content: String?) { contentTextView.text = content } }