-
Notifications
You must be signed in to change notification settings - Fork 177
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 iOS-only systemItem prop for buttons in Navigator.Config #102
Conversation
@@ -192,6 +200,36 @@ func barButtonStyleFromString(_ string: String?) -> UIBarButtonItemStyle { | |||
} | |||
} | |||
|
|||
func barButtonSystemItemFromString(_ string: String?) -> UIBarButtonSystemItem? { | |||
switch string { | |||
case .some("done"): return .done |
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't we just check like: case "done":
? Might take out the verbosity here
Dang, I just merged something else. :| Can you rebase so we can get this merged? |
style: UIBarButtonItemStyle, | ||
enabled: Bool?, | ||
tintColor: UIColor?, | ||
titleTextAttributes: [String: Any]? | ||
) { | ||
if let title = title { | ||
self.init(title: title, style: style) | ||
} else if let barButtonSystemItem = barButtonSystemItem { |
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.
Just a side note - in iOS, it's pretty much the fact that you can't have a mixed bar button type of a system vs one with a title/image. In the future, I'd love to support setting both a title AND an image which can be done through the customView
initializer on UIBarButtonItem
. That being said, it'd make sense to have this as the very first case, then if it isn't a system item, go on to title/image etc. Not a big deal now, yet. We can either bump this up now, or perhaps do it in the future, no big deal either way.
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.
moved up
@nfcampos Are you still on this? |
style: UIBarButtonItemStyle, | ||
enabled: Bool?, | ||
tintColor: UIColor?, | ||
titleTextAttributes: [String: Any]? | ||
) { | ||
if let title = title { | ||
if let barButtonSystemItem = barButtonSystemItem { | ||
self.init(barButtonSystemItem: barButtonSystemItem) |
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.
Do we need this new convenience initializer? Can we just call super.init(barButtonSystemItem: barButtonSystemItem, target: self, action: #selector(barButtonItemPressed))
?
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 was just following the style of the other convenience initialisers. I personally don't see the value, but I didn't want to change it in this PR
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.
Ok, it's really just cleaner is all. Not a big deal. I say we merge!
We should get this project set up on a CI system of some sorts... |
yeah definitely |
Hello :)
This PR introduces a
systemItem
property forButton
inNavigator.Config
to allow usage ofUIBarButtonSystemItem
for buttons in the navigation bar (iOS-only, not sure if there is an equivalent in android).This provides easy access to some very common icons and localised buttons on iOS, such as add, edit, done, search, etc, (full list available here https://developer.apple.com/reference/uikit/uibarbuttonsystemitem)
The only one I didn't implement
fixedSpace
as it requires awidth
parameter that I'm not sure how to expose.Changes
systemItem
property onButton
An example with a right button using
add
: