Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Added property for autocorrection #97

Merged
merged 2 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions AnimatedTextInput/Classes/AnimatedTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ extension AnimatedTextField: TextInput {
get { return text }
set { self.text = newValue }
}

public var autocorrection: UITextAutocorrectionType {
get { return self.autocorrectionType }
set { self.autocorrectionType = newValue }
}

public var currentSelectedTextRange: UITextRange? {
get { return self.selectedTextRange }
Expand Down
11 changes: 10 additions & 1 deletion AnimatedTextInput/Classes/AnimatedTextInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ open class AnimatedTextInput: UIControl {
configureType()
}
}


open var autocorrection: UITextAutocorrectionType = .no {
didSet {
configureType()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? configureType() removes the whole view from its superview and generates a new input. I would simply do textInput.autocorrection = autocorrection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, you are right.
I made the proposed change and will do the commit soon.

}
}

open var returnKeyType: UIReturnKeyType = .default {
didSet {
textInput.changeReturnKeyType(with: returnKeyType)
Expand Down Expand Up @@ -291,6 +297,7 @@ open class AnimatedTextInput: UIControl {
textInput.view.tintColor = style.activeColor
textInput.textColor = style.textInputFontColor
textInput.font = style.textInputFont
textInput.autocorrection = autocorrection
textInput.view.translatesAutoresizingMaskIntoConstraints = false
addSubview(textInput.view)
invalidateIntrinsicContentSize()
Expand Down Expand Up @@ -559,6 +566,8 @@ public protocol TextInput {
var currentSelectedTextRange: UITextRange? { get set }
var currentBeginningOfDocument: UITextPosition? { get }
var contentInset: UIEdgeInsets { get set }
var autocorrection: UITextAutocorrectionType {get set}


func configureInputView(newInputView: UIView)
func changeReturnKeyType(with newReturnKeyType: UIReturnKeyType)
Expand Down
5 changes: 5 additions & 0 deletions AnimatedTextInput/Classes/AnimatedTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ extension AnimatedTextView: TextInput {
return self.beginningOfDocument
}

public var autocorrection: UITextAutocorrectionType {
get { return self.autocorrectionType }
set { self.autocorrectionType = newValue }
}

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