-
Notifications
You must be signed in to change notification settings - Fork 491
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 feature to change the color for each tags #237
base: swift-4
Are you sure you want to change the base?
Conversation
nator333
commented
Aug 25, 2019
- Add UIColor argument for the constructors
How is this going? |
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.
Thanks for the pr! I have some minor comments.
TagListView/TagListView.swift
Outdated
@@ -292,12 +292,17 @@ open class TagListView: UIView { | |||
return CGSize(width: frame.width, height: height) | |||
} | |||
|
|||
private func createNewTagView(_ title: String) -> TagView { | |||
private func createNewTagView(_ title: String, _ backgroundColor: UIColor? = nil) -> 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.
Can you keep the named argument backgroundColor
here? I think it increases readability.
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.
Thanks so much for the comment!
468738a
TagListView/TagListView.swift
Outdated
@@ -325,6 +330,12 @@ open class TagListView: UIView { | |||
return tagView | |||
} | |||
|
|||
@discardableResult | |||
open func addTag(_ title: String, _ backgroundColor: UIColor? = nil) -> 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.
Same. Please keep backgroundColor
.
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.
} | ||
|
||
@discardableResult | ||
open func addTags(titleWithColors: [String : UIColor]) -> [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.
Can you add some documentation for this in README?
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 give me advice if you think of anything for the improvement.
293fa14
For different colors for each tag view
TagListView/TagListView.swift
Outdated
} else { | ||
tagView.tagBackgroundColor = tagBackgroundColor | ||
} | ||
|
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'd prefer to write as tagView.tagBackgroundColor = backgroundColor ?? tagBackgroundColor
.
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.
Also if you introduced background color to each tag, it would be a little bit vague to mention tagBackgroundColor
here. I'd prefer to rename it as defaultBackgroundColor
.
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.
Will renaming break existing code? If so, I’d suggest keeping the old name.
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.
Will renaming break existing code? If so, I’d suggest keeping the old name.
Yup, that could happen. Both understandable.
@xhacker @Cee @dfmarulanda Thoughts?
Plus, I wanna mention about other states dependent color properties. I ignored those this time. But I thought it's fine at this point. If somebody needs it, he'll implement it.
TagListView/TagListView.swift
Outdated
@@ -325,6 +330,12 @@ open class TagListView: UIView { | |||
return tagView | |||
} | |||
|
|||
@discardableResult | |||
open func addTag(_ title: String, withBgColor backgroundColor: UIColor? = nil) -> 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.
Same here.
TagListView/TagListView.swift
Outdated
@@ -292,12 +292,17 @@ open class TagListView: UIView { | |||
return CGSize(width: frame.width, height: height) | |||
} | |||
|
|||
private func createNewTagView(_ title: String) -> TagView { | |||
private func createNewTagView(_ title: String, withBgColor backgroundColor: UIColor? = nil) -> 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.
Can you replace withBgColor
with withBackgroundColor
?
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.
Thanks for the comment!
Replacing the name is easy, but please clarify the reason.
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.
or simply backgroundColor
.
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 prefer with
because it makes more sense to me.
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.
LGTM. I would like to remove with
if the parameter is not in the first place.
Example: createNewTagView(_ title: String, backgroundColor: UIColor)