Remove unneeded overrides in custom views

This commit is contained in:
Danny Moesch 2019-01-27 14:26:11 +01:00
parent 41549b3481
commit 7f6ad5b88c
7 changed files with 33 additions and 70 deletions

View file

@ -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?)
}

View file

@ -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?) { }
}

View file

@ -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 ?? "")
}
}

View file

@ -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?) {}
}

View file

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

View file

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