Move ChatInputItem selected and enabled properties to protocol extension

This commit is contained in:
Anton Schukin 2016-07-26 17:55:42 +01:00
parent a8ba3531b7
commit c17a99014b
4 changed files with 20 additions and 16 deletions

View File

@ -60,10 +60,10 @@ protocol ChatInputBarPresenter: class {
private(set) var focusedItem: ChatInputItemProtocol? {
willSet {
self.focusedItem?.selected = false
self.focusedItem?.setSelected(false)
}
didSet {
self.focusedItem?.selected = true
self.focusedItem?.setSelected(true)
}
}

View File

@ -35,7 +35,24 @@ public protocol ChatInputItemProtocol: AnyObject {
var inputView: UIView? { get }
var presentationMode: ChatInputItemPresentationMode { get }
var showsSendButton: Bool { get }
var selected: Bool { get set }
func handleInput(input: AnyObject)
}
extension ChatInputItemProtocol {
func selected() -> Bool {
return self.inputButton.selected
}
func setSelected(selected: Bool) {
self.inputButton.selected = selected
}
func enabled() -> Bool {
return self.inputButton.enabled
}
func setEnabled(enabled: Bool) {
self.inputButton.enabled = enabled
}
}

View File

@ -57,12 +57,6 @@ public class PhotosChatInputItem: ChatInputItemProtocol {
return photosInputView
}()
public var selected = false {
didSet {
self.internalInputButton.selected = self.selected
}
}
// MARK: - ChatInputItemProtocol
public var presentationMode: ChatInputItemPresentationMode {

View File

@ -45,13 +45,6 @@ public class TextChatInputItem {
lazy private var internalInputButton: ChatInputButton = {
return ChatInputButton.makeInputButton(withAppearance: self.buttonAppearance)
}()
// Move to protocol extension
public var selected = false {
didSet {
self.internalInputButton.selected = self.selected
}
}
}
// MARK: - ChatInputItemProtocol