-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Added rightButtonSystemItem to NavigatorIOS Routes. #3959
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,13 @@ @implementation RCTNavItem | |
| @synthesize leftButtonItem = _leftButtonItem; | ||
| @synthesize rightButtonItem = _rightButtonItem; | ||
|
|
||
| -(id)init { | ||
| if (self = [super init]) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use double (( for assignment inside if, i.e. |
||
| _rightButtonSystemItem = -1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use NSNotFound instead of -1 as the "null" value? It's more idiomatic for Obj-C (and also doesn't rely on the implementation detail that UIBarButtonSystemItem happens to be an NSInteger rather than NSUInteger). |
||
| } | ||
| return self; | ||
| } | ||
|
|
||
| - (void)setBackButtonTitle:(NSString *)backButtonTitle | ||
| { | ||
| _backButtonTitle = backButtonTitle; | ||
|
|
@@ -101,6 +108,12 @@ - (void)setRightButtonIcon:(UIImage *)rightButtonIcon | |
| _rightButtonItem = nil; | ||
| } | ||
|
|
||
| - (void)setRightButtonSystemItem:(UIBarButtonSystemItem)rightButtonSystemItem | ||
| { | ||
| _rightButtonSystemItem = rightButtonSystemItem; | ||
| _rightButtonItem = nil; | ||
| } | ||
|
|
||
| - (UIBarButtonItem *)rightButtonItem | ||
| { | ||
| if (!_rightButtonItem) { | ||
|
|
@@ -117,6 +130,11 @@ - (UIBarButtonItem *)rightButtonItem | |
| style:UIBarButtonItemStylePlain | ||
| target:self | ||
| action:@selector(handleRightButtonPress)]; | ||
| } else if (_rightButtonSystemItem >= 0) { | ||
| _rightButtonItem = | ||
| [[UIBarButtonItem alloc] initWithBarButtonSystemItem:_rightButtonSystemItem | ||
| target:self | ||
| action:@selector(handleRightButtonPress)]; | ||
| } else { | ||
| _rightButtonItem = nil; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,37 @@ | |
| #import "RCTConvert.h" | ||
| #import "RCTNavItem.h" | ||
|
|
||
| @implementation RCTConvert (BarButtonSystemItem) | ||
|
|
||
| RCT_ENUM_CONVERTER(UIBarButtonSystemItem, (@{ | ||
| @"done": @(UIBarButtonSystemItemDone), | ||
| @"cancel": @(UIBarButtonSystemItemCancel), | ||
| @"edit": @(UIBarButtonSystemItemEdit), | ||
| @"save": @(UIBarButtonSystemItemSave), | ||
| @"add": @(UIBarButtonSystemItemAdd), | ||
| @"flexible-space": @(UIBarButtonSystemItemFlexibleSpace), | ||
| @"fixed-space": @(UIBarButtonSystemItemFixedSpace), | ||
| @"compose": @(UIBarButtonSystemItemCompose), | ||
| @"reply": @(UIBarButtonSystemItemReply), | ||
| @"action": @(UIBarButtonSystemItemAction), | ||
| @"organize": @(UIBarButtonSystemItemOrganize), | ||
| @"bookmarks": @(UIBarButtonSystemItemBookmarks), | ||
| @"search": @(UIBarButtonSystemItemSearch), | ||
| @"refresh": @(UIBarButtonSystemItemRefresh), | ||
| @"stop": @(UIBarButtonSystemItemStop), | ||
| @"camera": @(UIBarButtonSystemItemCamera), | ||
| @"trash": @(UIBarButtonSystemItemTrash), | ||
| @"play": @(UIBarButtonSystemItemPlay), | ||
| @"pause": @(UIBarButtonSystemItemPause), | ||
| @"rewind": @(UIBarButtonSystemItemRewind), | ||
| @"fast-forward": @(UIBarButtonSystemItemFastForward), | ||
| @"undo": @(UIBarButtonSystemItemUndo), | ||
| @"redo": @(UIBarButtonSystemItemRedo), | ||
| @"page-curl": @(UIBarButtonSystemItemPageCurl) | ||
| }), -1, integerValue); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See note about NSNotFound, above |
||
|
|
||
| @end | ||
|
|
||
| @implementation RCTNavItemManager | ||
|
|
||
| RCT_EXPORT_MODULE() | ||
|
|
@@ -38,6 +69,7 @@ - (UIView *)view | |
|
|
||
| RCT_EXPORT_VIEW_PROPERTY(rightButtonIcon, UIImage) | ||
| RCT_EXPORT_VIEW_PROPERTY(rightButtonTitle, NSString) | ||
| RCT_EXPORT_VIEW_PROPERTY(rightButtonSystemItem, UIBarButtonSystemItem) | ||
|
|
||
| RCT_EXPORT_VIEW_PROPERTY(onLeftButtonPress, RCTBubblingEventBlock) | ||
| RCT_EXPORT_VIEW_PROPERTY(onRightButtonPress, RCTBubblingEventBlock) | ||
|
|
||
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.
nit: { on new line