Skip to content
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

Open
wants to merge 5 commits into
base: swift-4
Choose a base branch
from

Conversation

nator333
Copy link

  • Add UIColor argument for the constructors

@dfmarulanda
Copy link

How is this going?

Copy link
Member

@xhacker xhacker left a 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.

@@ -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 {
Copy link
Member

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.

Copy link
Author

@nator333 nator333 Oct 13, 2019

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

@@ -325,6 +330,12 @@ open class TagListView: UIView {
return tagView
}

@discardableResult
open func addTag(_ title: String, _ backgroundColor: UIColor? = nil) -> TagView {
Copy link
Member

Choose a reason for hiding this comment

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

Same. Please keep backgroundColor.

Copy link
Author

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] {
Copy link
Member

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?

Copy link
Author

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

} else {
tagView.tagBackgroundColor = tagBackgroundColor
}

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Member

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.

Copy link
Author

@nator333 nator333 Oct 15, 2019

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.

@@ -325,6 +330,12 @@ open class TagListView: UIView {
return tagView
}

@discardableResult
open func addTag(_ title: String, withBgColor backgroundColor: UIColor? = nil) -> TagView {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

@@ -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 {
Copy link
Collaborator

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?

Copy link
Author

@nator333 nator333 Oct 14, 2019

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.

Copy link
Member

Choose a reason for hiding this comment

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

or simply backgroundColor.

Copy link
Author

@nator333 nator333 Oct 15, 2019

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.

Copy link
Collaborator

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)

@nator333 nator333 requested a review from Cee October 15, 2019 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants