Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion AnimatedTextInput/Classes/AnimatedTextInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ open class AnimatedTextInput: UIControl {
textInput.font = style.textInputFont
textInput.autocorrection = autocorrection
textInput.view.translatesAutoresizingMaskIntoConstraints = false
configureRightView()
addSubview(textInput.view)
invalidateIntrinsicContentSize()
}
Expand Down Expand Up @@ -372,6 +373,15 @@ open class AnimatedTextInput: UIControl {
transactionAnimation(with: duration, timingFuncion: function, animations: applyConfiguration)
}

fileprivate func configureRightView() {
if let button = textInput.rightView as? UIButton {
if let selectedImage = button.image(for: .selected) {
button.tintColor = style.activeColor
button.setImage(selectedImage.withRenderingMode(.alwaysTemplate), for: .selected)
}
}
}

// mark: Behaviours

@objc fileprivate func viewWasTapped(sender: UIGestureRecognizer) {
Expand All @@ -391,6 +401,7 @@ open class AnimatedTextInput: UIControl {
textInput.view.tintColor = style.activeColor
textInput.textColor = style.textInputFontColor
textInput.font = style.textInputFont
configureRightView()
invalidateIntrinsicContentSize()
layoutIfNeeded()
}
Expand Down Expand Up @@ -583,7 +594,8 @@ public protocol TextInput {
var currentBeginningOfDocument: UITextPosition? { get }
var currentKeyboardAppearance: UIKeyboardAppearance { get set }
var contentInset: UIEdgeInsets { get set }
var autocorrection: UITextAutocorrectionType {get set}
var autocorrection: UITextAutocorrectionType { get set }
var rightView: UIView? { get set }


func configureInputView(newInputView: UIView)
Expand Down
5 changes: 5 additions & 0 deletions AnimatedTextInput/Classes/AnimatedTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ extension AnimatedTextView: TextInput {
set { self.autocorrectionType = newValue }
}

public var rightView: UIView? {
get { return nil }
set { }
}

public func changeReturnKeyType(with newReturnKeyType: UIReturnKeyType) {
returnKeyType = newReturnKeyType
}
Expand Down