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
18 changes: 14 additions & 4 deletions ios/react-native-navigation-sdk/NavView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ @interface NavView () <RCTNavViewViewProtocol>

@property(nonatomic, strong) NavViewController *viewController;
@property(nonatomic, assign) BOOL initialized;
@property(nonatomic, copy) NSString *registeredNativeID;

@end

Expand All @@ -63,12 +64,20 @@ - (void)dealloc {
[self unregisterView];
}

- (void)invalidate {
[self unregisterView];
[super invalidate];
}

- (void)unregisterView {
const auto &currentProps = *std::static_pointer_cast<NavViewProps const>(_props);
if (_registeredNativeID != nil) {
[[NavViewModule viewControllersRegistry] removeObjectForKey:_registeredNativeID];
_registeredNativeID = nil;
}

if (!currentProps.nativeID.empty()) {
NSString *nativeIDString = [NSString stringWithUTF8String:currentProps.nativeID.c_str()];
[[NavViewModule viewControllersRegistry] removeObjectForKey:nativeIDString];
if (_viewController != nil) {
[_viewController cleanup];
_viewController = nil;
}
}

Expand Down Expand Up @@ -140,6 +149,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
// Register view controller with nativeID in the registry
NSString *nativeIDString = [NSString stringWithUTF8String:newViewProps.nativeID.c_str()];
[NavViewModule viewControllersRegistry][nativeIDString] = _viewController;
self.registeredNativeID = nativeIDString;

// If navigation session is already initialized, trigger attachment check
NavModule *navModule = [NavModule sharedInstance];
Expand Down
1 change: 1 addition & 0 deletions ios/react-native-navigation-sdk/NavViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef void (^OnArrayResult)(NSArray *_Nullable result);
- (void)setSpeedLimitIconEnabled:(BOOL)isEnabled;
- (void)setZoomLevel:(NSNumber *)level;
- (void)setNavigationViewCallbacks:(id<INavigationViewCallback>)fn;
- (void)cleanup;
- (void)setIndoorEnabled:(BOOL)isEnabled;
- (void)setIndoorLevelPickerEnabled:(BOOL)isEnabled;
- (void)setTrafficEnabled:(BOOL)isEnabled;
Expand Down
Loading