-
Notifications
You must be signed in to change notification settings - Fork 494
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
Custom tag views #143
base: master
Are you sure you want to change the base?
Custom tag views #143
Conversation
TagListView/TagListView.swift
Outdated
|
||
|
||
@discardableResult | ||
open func stylize(tag tagView: TagView) -> TagView{ |
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.
I think tag
is unnecessary here. Can you rename to stylize(_ tagView: TagView)
? Also, there should be a space between TagView
and {
.
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.
TagListView/TagListView.swift
Outdated
@discardableResult | ||
open func addTagViews(_ tagViews: [TagView]) -> [TagView] { | ||
for tagView in tagViews { | ||
self.tagViews.append(tagView) | ||
tagBackgroundViews.append(UIView(frame: tagView.bounds)) | ||
addTagView(tagView) |
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.
With the change, rearrangeViews()
would be called tagViews.count
times instead of one time. Can you address that?
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.
I addressed this in 892b412 by adding an extra argument to addTagView(_:)
that specifies if it should call rearrangeViews()
. It is true
by default, so the impact to existing code both inside the library and in modules that imports it is 0. It's explicitly set to false
inside this loop, and is called after the loop ends
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.
Looks good! With minor comments.
… called when addTagView(_:) is called
👍 to the PR would love to see this one merged! |
@anti-transmission when do you think it will be release? :) |
I just pushed some commits to fix the previous merge conflicts with the latest |
This provides a fix for Issue #142. This moves the applying of default stylings from a factory method in
TagListView
that's called inaddTag(_:)
to a method that just handles styling and is called inaddTagView(_:)
andinsertTagView(_:at:)
. I also changed the implementation ofaddTagViews(_:)
to call out toaddTagView(_:)
for each individual tag. Ultimately, this allows for the easy addition of custom subclasses toTagView
. I added documentation comments for each of the relevant methods to make it clear that they unconditionally apply the styling of theTagListView
that theTagView
/subclass is being added to, so any individual tag stylization should take place after callingaddTagView(_:)
,addTagViews(_:)
, orinsertTagView(_:at:)