-
Notifications
You must be signed in to change notification settings - Fork 487
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 next label position #273
Conversation
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.
Hello @ong-yue-huei, sorry for the late response, and thank you so much for your work!
I really appreciate that you have taken the time to provide an example and screenshots.
It's looking good; I think we can replace left and right with leading and trailing and make a couple of adjustments while we're at it, but otherwise, it looks good to me. 🚀
I've added a couple of suggestions. I tried to be thorough; sorry for the 10+ comments. I hope I didn't miss anything in them, and applying them all won't result in a compilation error.
case topRight | ||
case topLeft | ||
case bottomRight | ||
case bottomLeft |
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 suggest using the leading/trailing terminology, so that it's direction-agnostic. Let's add leading & trailing in it as well!
case topRight | |
case topLeft | |
case bottomRight | |
case bottomLeft | |
case leading | |
case trailing | |
case topTrailing | |
case topLeading | |
case bottomTrailing | |
case bottomLeading |
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.
@@ -61,9 +62,10 @@ public class CoachMarkHelper { | |||
withArrow arrow: Bool = true, | |||
arrowOrientation: CoachMarkArrowOrientation? = .top, | |||
hintText: String, | |||
nextText: String? = nil | |||
nextText: String? = nil, | |||
nextLabelPosition: CoachMarkNextLabelPosition? = .none |
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.
It doesn't need to be optional in my opinion, because there's always going to be a position.
nextLabelPosition: CoachMarkNextLabelPosition? = .none | |
nextLabelPosition: CoachMarkNextLabelPosition = .trailing |
case .none: | ||
labelStackView.addArrangedSubview(hintLabel) | ||
labelStackView.addArrangedSubview(separator) | ||
labelStackView.addArrangedSubview(nextLabel) | ||
|
||
separator.heightAnchor.constraint(equalTo: labelStackView.heightAnchor, | ||
constant: -10).isActive = true |
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.
Let's add the .leading
case as well!
case .none: | |
labelStackView.addArrangedSubview(hintLabel) | |
labelStackView.addArrangedSubview(separator) | |
labelStackView.addArrangedSubview(nextLabel) | |
separator.heightAnchor.constraint(equalTo: labelStackView.heightAnchor, | |
constant: -10).isActive = true | |
case .trailing: | |
labelStackView.addArrangedSubview(hintLabel) | |
labelStackView.addArrangedSubview(separator) | |
labelStackView.addArrangedSubview(nextLabel) | |
separator.heightAnchor.constraint(equalTo: labelStackView.heightAnchor, | |
constant: -10).isActive = true | |
case .leading: | |
labelStackView.addArrangedSubview(nextLabel) | |
labelStackView.addArrangedSubview(separator) | |
labelStackView.addArrangedSubview(hintLabel) | |
separator.heightAnchor.constraint(equalTo: labelStackView.heightAnchor, | |
constant: -10).isActive = true |
Sources/Instructions/Extra/Default Views/CoachMarkBodyDefaultView.swift
Outdated
Show resolved
Hide resolved
Sources/Instructions/Extra/Default Views/CoachMarkBodyDefaultView.swift
Outdated
Show resolved
Hide resolved
@@ -24,6 +24,8 @@ public class CoachMarkBodyDefaultView: UIControl, | |||
public lazy var nextLabel: UILabel = makeNextLabel() | |||
public lazy var hintLabel: UITextView = makeHintTextView() | |||
public lazy var separator: UIView = makeSeparator() | |||
private let nextLabelPosition: CoachMarkNextLabelPosition? |
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 set the default position (.trailing
) directly here.
private let nextLabelPosition: CoachMarkNextLabelPosition? | |
private let nextLabelPosition: CoachMarkNextLabelPosition = .trailing |
Sources/Instructions/Extra/Default Views/CoachMarkBodyDefaultView.swift
Outdated
Show resolved
Hide resolved
super.init(frame: frame) | ||
initializeViewHierarchy() | ||
} | ||
|
||
public init(frame: CGRect, hintText: String, nextText: String?) { | ||
public init(frame: CGRect, hintText: String, nextText: String?, nextLabelPosition: CoachMarkNextLabelPosition?) { |
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.
We probably want to force users to provide a position that isn't nil.
public init(frame: CGRect, hintText: String, nextText: String?, nextLabelPosition: CoachMarkNextLabelPosition?) { | |
public init(frame: CGRect, hintText: String, nextText: String?, nextLabelPosition: CoachMarkNextLabelPosition) { |
Sources/Instructions/Helpers/Public/Enums/CoachMarkNextLabelPosition.swift
Show resolved
Hide resolved
- add summary for `CoachMarkNextLabelPosition`
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.
@ong-yue-huei LGTM 👍
I just realised CoachMarkNextLabelPosition
is not part of the Instructions
target in Xcode, but that's okay; I'm going to merge this. 🎉
Thanks again for the PR!
Motivation & Context
Desctiption
Added options to set the position of
nextLabel
:Example: