-
-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add toggle for multiple select and removable tags #108
base: master
Are you sure you want to change the base?
Conversation
@mochat97 Nice one, thank you. I'll test this and review it shortly. Exciting! |
addTag(tag) | ||
if let tagView = tagViews.last, autoSelectTagWhenAdded { | ||
//There's a bug that causes the text to be truncated during animation ("New York" becomes "New Y..."). This delays animating the TagView until after it's set in the TextField. | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think we should do another approach. This could not always solve the problem.
@@ -401,6 +416,15 @@ open class WSTagsField: UIScrollView { | |||
repositionViews() | |||
} | |||
|
|||
open func setRemovable(tags: [String], removable: Bool = false) { | |||
assert(tagViews.count > 0, "There are no tagViews. Did you call this method after adding tags?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to find another way avoiding the use of asserts
. This is quite unsafe in runtime.
@@ -13,19 +13,19 @@ protocol BackspaceDetectingTextFieldDelegate: UITextFieldDelegate { | |||
func textFieldDidDeleteBackwards(_ textField: UITextField) | |||
} | |||
|
|||
class BackspaceDetectingTextField: UITextField { | |||
open class BackspaceDetectingTextField: UITextField { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be open, we don't want to expose this to lib users.
Please provide a functional code in the Example app. Thank you for your contribution. |
This pull request addresses issue #100. It adds a boolean toggle named
allowMultipleSelection
that allows a user to select multiple tags at once.Also, a boolean toggle named
removable
is added that doesn't allow a tag to be removed. This is insideWSTagView
and set with a setter namedsetRemovable(tags: [String], removable: Bool = false)
. This method will throw an exception if called before any tags are added.Finally, a helper function is created named
getSelectedTagStrings()
that gets all tags as a list of strings.