Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/RNNNavigationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
@property(nonatomic, strong) WindowOptions *window;

@property(nonatomic, strong) Bool *popGesture;
@property(nonatomic, strong) Bool *navigationButtonEventOnSwipeBack;
@property(nonatomic, strong) Image *backgroundImage;
@property(nonatomic, strong) Image *rootBackgroundImage;
@property(nonatomic, strong) Text *modalPresentationStyle;
Expand Down
4 changes: 4 additions & 0 deletions ios/RNNNavigationOptions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
self.window = [[WindowOptions alloc] initWithDict:dict[@"window"]];

self.popGesture = [[Bool alloc] initWithValue:dict[@"popGesture"]];
self.navigationButtonEventOnSwipeBack = [[Bool alloc] initWithValue:dict[@"navigationButtonEventOnSwipeBack"]];
self.backgroundImage = [ImageParser parse:dict key:@"backgroundImage"];
self.rootBackgroundImage = [ImageParser parse:dict key:@"rootBackgroundImage"];
self.modalPresentationStyle = [[Text alloc] initWithValue:dict[@"modalPresentationStyle"]];
Expand Down Expand Up @@ -73,6 +74,8 @@ - (RNNNavigationOptions *)mergeOptions:(RNNNavigationOptions *)options {

if (options.popGesture.hasValue)
result.popGesture = options.popGesture;
if (options.navigationButtonEventOnSwipeBack.hasValue)
result.navigationButtonEventOnSwipeBack = options.navigationButtonEventOnSwipeBack;
if (options.backgroundImage.hasValue)
result.backgroundImage = options.backgroundImage;
if (options.rootBackgroundImage.hasValue)
Expand Down Expand Up @@ -104,6 +107,7 @@ - (RNNNavigationOptions *)copy {
[newOptions.window mergeOptions:self.window];

newOptions.popGesture = self.popGesture;
newOptions.navigationButtonEventOnSwipeBack = self.navigationButtonEventOnSwipeBack;
newOptions.backgroundImage = self.backgroundImage;
newOptions.rootBackgroundImage = self.rootBackgroundImage;
newOptions.modalPresentationStyle = self.modalPresentationStyle;
Expand Down
24 changes: 21 additions & 3 deletions ios/StackControllerDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,27 @@ - (instancetype)initWithEventEmitter:(RNNEventEmitter *)eventEmitter {
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if (_presentedViewController &&
![navigationController.viewControllers containsObject:_presentedViewController]) {
_isPopping = YES;
if (_presentedViewController) {
if (![navigationController.viewControllers containsObject:_presentedViewController]) {
_isPopping = YES;
}

id<UIViewControllerTransitionCoordinator> coordinator = navigationController.transitionCoordinator;
if (coordinator && coordinator.isInteractive) {
UIViewController *poppingViewController = _presentedViewController;
[coordinator notifyWhenInteractionChangesUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) {
if (!context.isCancelled) {
if ([poppingViewController conformsToProtocol:@protocol(RNNLayoutProtocol)]) {
UIViewController<RNNLayoutProtocol> *rnnVC = (UIViewController<RNNLayoutProtocol> *)poppingViewController;
if ([rnnVC.options.navigationButtonEventOnSwipeBack withDefault:NO]) {
NSString *buttonId = [rnnVC.options.topBar.backButton.identifier withDefault:@"RNN.back"];
[self->_eventEmitter sendOnNavigationButtonPressed:rnnVC.layoutInfo.componentId
buttonId:buttonId];
}
}
}
}];
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions website/docs/api/options-root.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ Enable or disable swipe back to pop gesture.
| ------- | -------- | -------- |
| boolean | No | iOS |

## `navigationButtonEventOnSwipeBack`

Enable NavigationButtonPressed event sending on Swipe-back on pushed VC.

| Type | Required | Platform | Default |
| ------- | -------- | -------- | ------- |
| boolean | No | iOS | false |

## `backgroundImage`

Background image of the screen.
Expand Down