Skip to content
Closed
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
2 changes: 1 addition & 1 deletion lib/ios/RNNBottomTabsController.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import <UIKit/UIKit.h>
#import "BottomTabPresenter.h"
#import "BottomTabsBaseAttacher.h"
#import "RNNBottomTabsPresenter.h"
#import "RNNDotIndicatorPresenter.h"
#import "RNNEventEmitter.h"
#import "UIViewController+LayoutProtocol.h"
#import <UIKit/UIKit.h>

@interface RNNBottomTabsController
: UITabBarController <RNNLayoutProtocol, UITabBarControllerDelegate>
Expand Down
4 changes: 3 additions & 1 deletion lib/ios/RNNBridgeEventEmitter.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#import "RNNEventEmitter.h"
#import <React/RCTBridgeModule.h>

@interface RNNBridgeEventEmitter : RNNEventEmitter
@interface RNNBridgeEventEmitter : RNNEventEmitter <RCTBridgeModule>
@end

3 changes: 2 additions & 1 deletion lib/ios/RNNBridgeEventEmitter.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "RNNBridgeEventEmitter.h"

@implementation RNNBridgeEventEmitter {}
@implementation RNNBridgeEventEmitter

RCT_EXPORT_MODULE()
@end
16 changes: 16 additions & 0 deletions lib/ios/RNNEmitterConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
typedef NSString * EmitterEvents NS_STRING_ENUM;
extern EmitterEvents const AppLaunched;
extern EmitterEvents const CommandCompleted;
extern EmitterEvents const BottomTabSelected;
extern EmitterEvents const BottomTabLongPressed;
extern EmitterEvents const ComponentWillAppear;
extern EmitterEvents const ComponentDidAppear;
extern EmitterEvents const ComponentDidDisappear;
extern EmitterEvents const NavigationButtonPressed;
extern EmitterEvents const ModalDismissed;
extern EmitterEvents const ModalAttemptedToDismiss;
extern EmitterEvents const SearchBarUpdated;
extern EmitterEvents const SearchBarCancelPressed;
extern EmitterEvents const PreviewCompleted;
extern EmitterEvents const ScreenPopped;
extern EmitterEvents const BottomTabPressed;
18 changes: 18 additions & 0 deletions lib/ios/RNNEmitterConstants.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import "RNNEmitterConstants.h"

EmitterEvents const AppLaunched = @"RNN.AppLaunched";
EmitterEvents const CommandCompleted = @"RNN.CommandCompleted";
EmitterEvents const BottomTabSelected = @"RNN.BottomTabSelected";
EmitterEvents const BottomTabLongPressed = @"RNN.BottomTabLongPressed";
EmitterEvents const ComponentWillAppear = @"RNN.ComponentWillAppear";
EmitterEvents const ComponentDidAppear = @"RNN.ComponentDidAppear";
EmitterEvents const ComponentDidDisappear = @"RNN.ComponentDidDisappear";
EmitterEvents const NavigationButtonPressed = @"RNN.NavigationButtonPressed";
EmitterEvents const ModalDismissed = @"RNN.ModalDismissed";
EmitterEvents const ModalAttemptedToDismiss = @"RNN.ModalAttemptedToDismiss";
EmitterEvents const SearchBarUpdated = @"RNN.SearchBarUpdated";
EmitterEvents const SearchBarCancelPressed = @"RNN.SearchBarCancelPressed";
EmitterEvents const PreviewCompleted = @"RNN.PreviewCompleted";
EmitterEvents const ScreenPopped = @"RNN.ScreenPopped";
EmitterEvents const BottomTabPressed = @"RNN.BottomTabPressed";

10 changes: 8 additions & 2 deletions lib/ios/RNNEventEmitter.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#import <Foundation/Foundation.h>
#ifndef RCT_NEW_ARCH_ENABLED
#import <React/RCTEventEmitter.h>
#endif

#ifdef RCT_NEW_ARCH_ENABLED
@class RCTHost;
@class RCTBridge;

@interface RNNEventEmitter : NSObject
#else
@interface RNNEventEmitter : RCTEventEmitter
#endif

#ifdef RCT_NEW_ARCH_ENABLED
- (void)setHost:(RCTHost *)host;
@property(nonatomic, strong, readonly) RCTHost *host;
#endif

- (void)sendOnAppLaunched;

Expand Down
54 changes: 52 additions & 2 deletions lib/ios/RNNEventEmitter.mm
Original file line number Diff line number Diff line change
@@ -1,22 +1,65 @@
#import "RNNEventEmitter.h"
#import "RNNUtils.h"
#import "RNNEmitterConstants.h"

#ifdef RCT_NEW_ARCH_ENABLED
#import "RNNTurboEventEmitter.h"
#import <React-RuntimeApple/ReactCommon/RCTHost.h>
#else

#endif

@implementation RNNEventEmitter { }
@implementation RNNEventEmitter {
#ifndef RCT_NEW_ARCH_ENABLED
RCTEventEmitter *_emitter;
NSInteger _appLaunchedListenerCount;
BOOL _appLaunchedEventDeferred;
#endif
}

#ifdef RCT_NEW_ARCH_ENABLED
- (void)setHost:(RCTHost *)host {
if (_host != nil) {
return;
}
_host = host;
}

#else
- (NSArray<NSString *> *)supportedEvents {
return @[
AppLaunched, CommandCompleted, BottomTabSelected, BottomTabLongPressed, BottomTabPressed,
ComponentWillAppear, ComponentDidAppear, ComponentDidDisappear, NavigationButtonPressed,
ModalDismissed, SearchBarUpdated, SearchBarCancelPressed, PreviewCompleted, ScreenPopped,
ModalAttemptedToDismiss
];
}

- (void)addListener:(NSString *)eventName {
[super addListener:eventName];
if ([eventName isEqualToString:AppLaunched]) {
_appLaunchedListenerCount++;
if (_appLaunchedEventDeferred) {
_appLaunchedEventDeferred = FALSE;
[self sendOnAppLaunched];
}
}
}
#endif
#pragma mark public

#ifdef RCT_NEW_ARCH_ENABLED
- (void)sendOnAppLaunched {
[self send:AppLaunched body:nil];
}
#else
- (void)sendOnAppLaunched {
if (_appLaunchedListenerCount > 0) {
[self send:AppLaunched body:nil];
} else {
_appLaunchedEventDeferred = TRUE;
}
}
#endif

- (void)sendComponentWillAppear:(NSString *)componentId
componentName:(NSString *)componentName
Expand Down Expand Up @@ -119,6 +162,7 @@ - (void)sendScreenPoppedEvent:(NSString *)componentId {
#pragma mark private

- (void)send:(NSString *)eventName body:(id)body {
#ifdef RCT_NEW_ARCH_ENABLED
if (_host == nil) {
return;
}
Expand All @@ -129,6 +173,12 @@ - (void)send:(NSString *)eventName body:(id)body {
}

[_eventEmitter send:eventName body:body];
#else
if (self.bridge == nil) {
return;
}
[self sendEventWithName:eventName body:body];
#endif
}

@end
3 changes: 2 additions & 1 deletion lib/ios/RNNModalManagerEventHandler.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "RNNEventEmitter.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "RNNEventEmitter.h"

@interface RNNModalManagerEventHandler : NSObject

Expand Down
2 changes: 1 addition & 1 deletion lib/ios/RNNReactRootViewCreator.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import "RNNComponentViewCreator.h"
#import "RNNEventEmitter.h"
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>

@interface RNNReactRootViewCreator : NSObject <RNNComponentViewCreator>
Expand Down
4 changes: 2 additions & 2 deletions lib/ios/RNNViewControllerFactory.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "BottomTabsAttachModeFactory.h"
#import "RNNComponentViewCreator.h"
#import "RNNEventEmitter.h"
#import "RNNExternalComponentStore.h"
#import "RNNNavigationOptions.h"
#import "RNNReactComponentRegistry.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface RNNViewControllerFactory : NSObject

Expand Down
5 changes: 3 additions & 2 deletions lib/ios/StackControllerDelegate.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import "RNNEventEmitter.h"
#else
#import "RNNEventEmitter.h"
#endif
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class RCTHost;

Expand Down
20 changes: 1 addition & 19 deletions lib/ios/TurboModules/RNNTurboEventEmitter.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNNEventEmitter.h"
#import <React/RCTEventEmitter.h>
#import <rnnavigation/rnnavigation.h>

typedef NSString * EmitterEvents NS_STRING_ENUM;

extern EmitterEvents const AppLaunched;
extern EmitterEvents const CommandCompleted;
extern EmitterEvents const BottomTabSelected;
extern EmitterEvents const BottomTabLongPressed;
extern EmitterEvents const ComponentWillAppear;
extern EmitterEvents const ComponentDidAppear;
extern EmitterEvents const ComponentDidDisappear;
extern EmitterEvents const NavigationButtonPressed;
extern EmitterEvents const ModalDismissed;
extern EmitterEvents const ModalAttemptedToDismiss;
extern EmitterEvents const SearchBarUpdated;
extern EmitterEvents const SearchBarCancelPressed;
extern EmitterEvents const PreviewCompleted;
extern EmitterEvents const ScreenPopped;
extern EmitterEvents const BottomTabPressed;

@interface RNNTurboEventEmitter : RCTEventEmitter <NativeRNNTurboEventEmitterSpec>
- (void)send:(NSString *)eventName body:(id)body;
@end
Expand Down
18 changes: 1 addition & 17 deletions lib/ios/TurboModules/RNNTurboEventEmitter.mm
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNNTurboEventEmitter.h"

#import "RNNEmitterConstants.h"
#import "RNNUtils.h"

EmitterEvents const AppLaunched = @"RNN.AppLaunched";
EmitterEvents const CommandCompleted = @"RNN.CommandCompleted";
EmitterEvents const BottomTabSelected = @"RNN.BottomTabSelected";
EmitterEvents const BottomTabLongPressed = @"RNN.BottomTabLongPressed";
EmitterEvents const ComponentWillAppear = @"RNN.ComponentWillAppear";
EmitterEvents const ComponentDidAppear = @"RNN.ComponentDidAppear";
EmitterEvents const ComponentDidDisappear = @"RNN.ComponentDidDisappear";
EmitterEvents const NavigationButtonPressed = @"RNN.NavigationButtonPressed";
EmitterEvents const ModalDismissed = @"RNN.ModalDismissed";
EmitterEvents const ModalAttemptedToDismiss = @"RNN.ModalAttemptedToDismiss";
EmitterEvents const SearchBarUpdated = @"RNN.SearchBarUpdated";
EmitterEvents const SearchBarCancelPressed = @"RNN.SearchBarCancelPressed";
EmitterEvents const PreviewCompleted = @"RNN.PreviewCompleted";
EmitterEvents const ScreenPopped = @"RNN.ScreenPopped";
EmitterEvents const BottomTabPressed = @"RNN.BottomTabPressed";

@implementation RNNTurboEventEmitter {
NSInteger _appLaunchedListenerCount;
BOOL _appLaunchedEventDeferred;
Expand Down
2 changes: 1 addition & 1 deletion lib/ios/UIViewController+LayoutProtocol.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import <UIKit/UIKit.h>
#import "RNNEventEmitter.h"
#import "RNNLayoutProtocol.h"
#import <UIKit/UIKit.h>

typedef void (^RNNReactViewReadyCompletionBlock)(void);

Expand Down
Loading