Browse Source

On tab press event (#5880)

* Open modal from tab iOS

* Open modal from tab Android

* Remove playground changes

Co-authored-by: Yogev Ben David <yogevbd@wix.com>
Pontus Abrahamsson 4 years ago
parent
commit
b1531428a0

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java View File

42
         options.fontSize = NumberParser.parse(json, "fontSize");
42
         options.fontSize = NumberParser.parse(json, "fontSize");
43
         options.selectedFontSize = NumberParser.parse(json, "selectedFontSize");
43
         options.selectedFontSize = NumberParser.parse(json, "selectedFontSize");
44
         options.dotIndicator = DotIndicatorOptions.parse(json.optJSONObject("dotIndicator"));
44
         options.dotIndicator = DotIndicatorOptions.parse(json.optJSONObject("dotIndicator"));
45
+        options.selectTabOnPress = BoolParser.parse(json, "selectTabOnPress");
46
+
45
         return options;
47
         return options;
46
     }
48
     }
47
 
49
 
59
     public DotIndicatorOptions dotIndicator = new DotIndicatorOptions();
61
     public DotIndicatorOptions dotIndicator = new DotIndicatorOptions();
60
     public Number fontSize = new NullNumber();
62
     public Number fontSize = new NullNumber();
61
     public Number selectedFontSize = new NullNumber();
63
     public Number selectedFontSize = new NullNumber();
64
+    public Bool selectTabOnPress = new NullBool();
62
     @Nullable public Typeface fontFamily;
65
     @Nullable public Typeface fontFamily;
63
 
66
 
64
 
67
 
78
         if (other.selectedFontSize.hasValue()) selectedFontSize = other.selectedFontSize;
81
         if (other.selectedFontSize.hasValue()) selectedFontSize = other.selectedFontSize;
79
         if (other.fontFamily != null) fontFamily = other.fontFamily;
82
         if (other.fontFamily != null) fontFamily = other.fontFamily;
80
         if (other.dotIndicator.hasValue()) dotIndicator = other.dotIndicator;
83
         if (other.dotIndicator.hasValue()) dotIndicator = other.dotIndicator;
84
+        if (other.selectTabOnPress.hasValue()) selectTabOnPress = other.selectTabOnPress;
81
     }
85
     }
82
 
86
 
83
     void mergeWithDefault(final BottomTabOptions defaultOptions) {
87
     void mergeWithDefault(final BottomTabOptions defaultOptions) {
96
         if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
100
         if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
97
         if (!testId.hasValue()) testId = defaultOptions.testId;
101
         if (!testId.hasValue()) testId = defaultOptions.testId;
98
         if (!dotIndicator.hasValue()) dotIndicator = defaultOptions.dotIndicator;
102
         if (!dotIndicator.hasValue()) dotIndicator = defaultOptions.dotIndicator;
103
+        if (!selectTabOnPress.hasValue()) selectTabOnPress = defaultOptions.selectTabOnPress;
99
     }
104
     }
100
 }
105
 }

+ 7
- 0
lib/android/app/src/main/java/com/reactnativenavigation/react/events/EventEmitter.java View File

15
     private static final String AppLaunched = "RNN.AppLaunched";
15
     private static final String AppLaunched = "RNN.AppLaunched";
16
     private static final String CommandCompleted = "RNN.CommandCompleted";
16
     private static final String CommandCompleted = "RNN.CommandCompleted";
17
     private static final String BottomTabSelected = "RNN.BottomTabSelected";
17
     private static final String BottomTabSelected = "RNN.BottomTabSelected";
18
+    private static final String BottomTabPressed = "RNN.BottomTabPressed";
18
     private static final String ComponentDidAppear = "RNN.ComponentDidAppear";
19
     private static final String ComponentDidAppear = "RNN.ComponentDidAppear";
19
     private static final String ComponentDidDisappear = "RNN.ComponentDidDisappear";
20
     private static final String ComponentDidDisappear = "RNN.ComponentDidDisappear";
20
     private static final String NavigationButtonPressed = "RNN.NavigationButtonPressed";
21
     private static final String NavigationButtonPressed = "RNN.NavigationButtonPressed";
61
         emit(BottomTabSelected, event);
62
         emit(BottomTabSelected, event);
62
     }
63
     }
63
 
64
 
65
+    public void emitBottomTabPressed(int tabIndex) {
66
+        WritableMap event = Arguments.createMap();
67
+        event.putInt("tabIndex", tabIndex);
68
+        emit(BottomTabPressed, event);
69
+    }
70
+
64
     public void emitCommandCompleted(String commandName, String commandId, long completionTime) {
71
     public void emitCommandCompleted(String commandName, String commandId, long completionTime) {
65
         WritableMap event = Arguments.createMap();
72
         WritableMap event = Arguments.createMap();
66
         event.putString("commandName", commandName);
73
         event.putString("commandName", commandName);

+ 12
- 4
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java View File

144
 
144
 
145
     @Override
145
     @Override
146
     public boolean onTabSelected(int index, boolean wasSelected) {
146
     public boolean onTabSelected(int index, boolean wasSelected) {
147
-        eventEmitter.emitBottomTabSelected(bottomTabs.getCurrentItem(), index);
148
-        if (wasSelected) return false;
149
-        selectTab(index);
150
-        return false;
147
+        BottomTabOptions options = tabs.get(index).resolveCurrentOptions().bottomTabOptions;
148
+
149
+        eventEmitter.emitBottomTabPressed(index);
150
+
151
+        if (options.selectTabOnPress.get(true)){
152
+            eventEmitter.emitBottomTabSelected(bottomTabs.getCurrentItem(), index);
153
+            if (wasSelected) return false;
154
+            selectTab(index);
155
+            return false;
156
+        } else {
157
+            return false;
158
+        }
151
 	}
159
 	}
152
 
160
 
153
 	private List<AHBottomNavigationItem> createTabs() {
161
 	private List<AHBottomNavigationItem> createTabs() {

+ 1
- 0
lib/ios/RNNBottomTabOptions.h View File

21
 @property(nonatomic, strong) Color *textColor;
21
 @property(nonatomic, strong) Color *textColor;
22
 @property(nonatomic, strong) Number *fontSize;
22
 @property(nonatomic, strong) Number *fontSize;
23
 @property(nonatomic, strong) Bool *visible;
23
 @property(nonatomic, strong) Bool *visible;
24
+@property(nonatomic, strong) Bool *selectTabOnPress;
24
 
25
 
25
 
26
 
26
 @end
27
 @end

+ 1
- 0
lib/ios/RNNBottomTabOptions.m View File

27
     self.textColor = [ColorParser parse:dict key:@"textColor"];
27
     self.textColor = [ColorParser parse:dict key:@"textColor"];
28
     self.fontSize = [NumberParser parse:dict key:@"fontSize"];
28
     self.fontSize = [NumberParser parse:dict key:@"fontSize"];
29
     self.visible = [BoolParser parse:dict key:@"visible"];
29
     self.visible = [BoolParser parse:dict key:@"visible"];
30
+    self.selectTabOnPress = [BoolParser parse:dict key:@"selectTabOnPress"];
30
 
31
 
31
     return self;
32
     return self;
32
 }
33
 }

+ 12
- 0
lib/ios/RNNBottomTabsController.m View File

79
     }
79
     }
80
 }
80
 }
81
 
81
 
82
+- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
83
+{
84
+    NSUInteger _index = [tabBarController.viewControllers indexOfObject:viewController];
85
+    [self.eventEmitter sendBottomTabPressed:@(_index)];
86
+    
87
+    if([[viewController resolveOptions].bottomTab.selectTabOnPress getWithDefaultValue:YES]){
88
+        return YES;
89
+    }
90
+
91
+    return NO;
92
+}
93
+
82
 @end
94
 @end

+ 1
- 0
lib/ios/RNNButtonOptions.h View File

11
 @property (nonatomic, strong) Image* icon;
11
 @property (nonatomic, strong) Image* icon;
12
 @property (nonatomic, strong) Bool* enabled;
12
 @property (nonatomic, strong) Bool* enabled;
13
 @property (nonatomic, strong) RNNInsetsOptions* iconInsets;
13
 @property (nonatomic, strong) RNNInsetsOptions* iconInsets;
14
+@property(nonatomic, strong) Bool *selectTabOnPress;
14
 
15
 
15
 @end
16
 @end

+ 2
- 1
lib/ios/RNNButtonOptions.m View File

13
 	self.icon = [ImageParser parse:dict key:@"icon"];
13
 	self.icon = [ImageParser parse:dict key:@"icon"];
14
 	self.iconInsets = [[RNNInsetsOptions alloc] initWithDict:dict[@"iconInsets"]];
14
 	self.iconInsets = [[RNNInsetsOptions alloc] initWithDict:dict[@"iconInsets"]];
15
 	self.enabled = [BoolParser parse:dict key:@"enabled"];
15
 	self.enabled = [BoolParser parse:dict key:@"enabled"];
16
-	
16
+	self.selectTabOnPress = [BoolParser parse:dict key:@"selectTabOnPress"];
17
+
17
 
18
 
18
 	return self;
19
 	return self;
19
 }
20
 }

+ 2
- 0
lib/ios/RNNEventEmitter.h View File

30
 
30
 
31
 - (void)sendScreenPoppedEvent:(NSString *)componentId;
31
 - (void)sendScreenPoppedEvent:(NSString *)componentId;
32
 
32
 
33
+- (void)sendBottomTabPressed:(NSNumber *)tabIndex;
34
+
33
 
35
 
34
 @end
36
 @end

+ 8
- 0
lib/ios/RNNEventEmitter.m View File

21
 static NSString* const SearchBarCancelPressed 	= @"RNN.SearchBarCancelPressed";
21
 static NSString* const SearchBarCancelPressed 	= @"RNN.SearchBarCancelPressed";
22
 static NSString* const PreviewCompleted         = @"RNN.PreviewCompleted";
22
 static NSString* const PreviewCompleted         = @"RNN.PreviewCompleted";
23
 static NSString* const ScreenPopped             = @"RNN.ScreenPopped";
23
 static NSString* const ScreenPopped             = @"RNN.ScreenPopped";
24
+static NSString* const BottomTabPressed         = @"RNN.BottomTabPressed";
24
 
25
 
25
 -(NSArray<NSString *> *)supportedEvents {
26
 -(NSArray<NSString *> *)supportedEvents {
26
 	return @[AppLaunched,
27
 	return @[AppLaunched,
27
 			 CommandCompleted,
28
 			 CommandCompleted,
28
 			 BottomTabSelected,
29
 			 BottomTabSelected,
29
        BottomTabLongPressed,
30
        BottomTabLongPressed,
31
+       BottomTabPressed,
30
 			 ComponentDidAppear,
32
 			 ComponentDidAppear,
31
 			 ComponentDidDisappear,
33
 			 ComponentDidDisappear,
32
 			 NavigationButtonPressed,
34
 			 NavigationButtonPressed,
84
                                         				  }];
86
                                         				  }];
85
 }
87
 }
86
 
88
 
89
+-(void)sendBottomTabPressed:(NSNumber *)tabIndex {
90
+    [self send:BottomTabPressed body:@{
91
+                                        @"tabIndex": tabIndex
92
+                                        }];
93
+}
94
+
87
 -(void)sendOnNavigationCommandCompletion:(NSString *)commandName commandId:(NSString *)commandId params:(NSDictionary*)params {
95
 -(void)sendOnNavigationCommandCompletion:(NSString *)commandName commandId:(NSString *)commandId params:(NSDictionary*)params {
88
 	[self send:CommandCompleted body:@{
96
 	[self send:CommandCompleted body:@{
89
 									   @"commandId":commandId,
97
 									   @"commandId":commandId,

+ 59
- 17
lib/src/adapters/NativeEventsReceiver.ts View File

1
-import { NativeModules, NativeEventEmitter, EventEmitter, EmitterSubscription } from 'react-native';
1
+import {
2
+  NativeModules,
3
+  NativeEventEmitter,
4
+  EventEmitter,
5
+  EmitterSubscription
6
+} from 'react-native';
2
 import {
7
 import {
3
   ComponentDidAppearEvent,
8
   ComponentDidAppearEvent,
4
   ComponentDidDisappearEvent,
9
   ComponentDidDisappearEvent,
10
   ScreenPoppedEvent,
15
   ScreenPoppedEvent,
11
   ModalAttemptedToDismissEvent
16
   ModalAttemptedToDismissEvent
12
 } from '../interfaces/ComponentEvents';
17
 } from '../interfaces/ComponentEvents';
13
-import { CommandCompletedEvent, BottomTabSelectedEvent, BottomTabLongPressedEvent } from '../interfaces/Events';
18
+import {
19
+  CommandCompletedEvent,
20
+  BottomTabSelectedEvent,
21
+  BottomTabLongPressedEvent,
22
+  BottomTabPressedEvent
23
+} from '../interfaces/Events';
14
 
24
 
15
 export class NativeEventsReceiver {
25
 export class NativeEventsReceiver {
16
   private emitter: EventEmitter;
26
   private emitter: EventEmitter;
20
     try {
30
     try {
21
       this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
31
       this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
22
     } catch (e) {
32
     } catch (e) {
23
-      this.emitter = {
33
+      this.emitter = ({
24
         addListener: () => {
34
         addListener: () => {
25
           return {
35
           return {
26
             remove: () => undefined
36
             remove: () => undefined
27
           };
37
           };
28
         }
38
         }
29
-      } as any as EventEmitter;
39
+      } as any) as EventEmitter;
30
     }
40
     }
31
   }
41
   }
32
 
42
 
33
-  public registerAppLaunchedListener(callback: () => void): EmitterSubscription {
43
+  public registerAppLaunchedListener(
44
+    callback: () => void
45
+  ): EmitterSubscription {
34
     return this.emitter.addListener('RNN.AppLaunched', callback);
46
     return this.emitter.addListener('RNN.AppLaunched', callback);
35
   }
47
   }
36
 
48
 
37
-  public registerComponentDidAppearListener(callback: (event: ComponentDidAppearEvent) => void): EmitterSubscription {
49
+  public registerComponentDidAppearListener(
50
+    callback: (event: ComponentDidAppearEvent) => void
51
+  ): EmitterSubscription {
38
     return this.emitter.addListener('RNN.ComponentDidAppear', callback);
52
     return this.emitter.addListener('RNN.ComponentDidAppear', callback);
39
   }
53
   }
40
 
54
 
41
-  public registerComponentDidDisappearListener(callback: (event: ComponentDidDisappearEvent) => void): EmitterSubscription {
55
+  public registerComponentDidDisappearListener(
56
+    callback: (event: ComponentDidDisappearEvent) => void
57
+  ): EmitterSubscription {
42
     return this.emitter.addListener('RNN.ComponentDidDisappear', callback);
58
     return this.emitter.addListener('RNN.ComponentDidDisappear', callback);
43
   }
59
   }
44
 
60
 
45
-  public registerNavigationButtonPressedListener(callback: (event: NavigationButtonPressedEvent) => void): EmitterSubscription {
61
+  public registerNavigationButtonPressedListener(
62
+    callback: (event: NavigationButtonPressedEvent) => void
63
+  ): EmitterSubscription {
46
     return this.emitter.addListener('RNN.NavigationButtonPressed', callback);
64
     return this.emitter.addListener('RNN.NavigationButtonPressed', callback);
47
   }
65
   }
48
 
66
 
49
-  public registerModalDismissedListener(callback: (event: ModalDismissedEvent) => void): EmitterSubscription {
67
+  public registerBottomTabPressedListener(
68
+    callback: (data: BottomTabPressedEvent) => void
69
+  ): EmitterSubscription {
70
+    return this.emitter.addListener('RNN.BottomTabPressed', callback);
71
+  }
72
+
73
+  public registerModalDismissedListener(
74
+    callback: (event: ModalDismissedEvent) => void
75
+  ): EmitterSubscription {
50
     return this.emitter.addListener('RNN.ModalDismissed', callback);
76
     return this.emitter.addListener('RNN.ModalDismissed', callback);
51
   }
77
   }
52
 
78
 
53
-  public registerModalAttemptedToDismissListener(callback: (event: ModalAttemptedToDismissEvent) => void): EmitterSubscription {
79
+  public registerModalAttemptedToDismissListener(
80
+    callback: (event: ModalAttemptedToDismissEvent) => void
81
+  ): EmitterSubscription {
54
     return this.emitter.addListener('RNN.ModalAttemptedToDismiss', callback);
82
     return this.emitter.addListener('RNN.ModalAttemptedToDismiss', callback);
55
   }
83
   }
56
 
84
 
57
-  public registerSearchBarUpdatedListener(callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription {
85
+  public registerSearchBarUpdatedListener(
86
+    callback: (event: SearchBarUpdatedEvent) => void
87
+  ): EmitterSubscription {
58
     return this.emitter.addListener('RNN.SearchBarUpdated', callback);
88
     return this.emitter.addListener('RNN.SearchBarUpdated', callback);
59
   }
89
   }
60
 
90
 
61
-  public registerSearchBarCancelPressedListener(callback: (event: SearchBarCancelPressedEvent) => void): EmitterSubscription {
91
+  public registerSearchBarCancelPressedListener(
92
+    callback: (event: SearchBarCancelPressedEvent) => void
93
+  ): EmitterSubscription {
62
     return this.emitter.addListener('RNN.SearchBarCancelPressed', callback);
94
     return this.emitter.addListener('RNN.SearchBarCancelPressed', callback);
63
   }
95
   }
64
 
96
 
65
-  public registerPreviewCompletedListener(callback: (event: PreviewCompletedEvent) => void): EmitterSubscription {
97
+  public registerPreviewCompletedListener(
98
+    callback: (event: PreviewCompletedEvent) => void
99
+  ): EmitterSubscription {
66
     return this.emitter.addListener('RNN.PreviewCompleted', callback);
100
     return this.emitter.addListener('RNN.PreviewCompleted', callback);
67
   }
101
   }
68
 
102
 
69
-  public registerCommandCompletedListener(callback: (data: CommandCompletedEvent) => void): EmitterSubscription {
103
+  public registerCommandCompletedListener(
104
+    callback: (data: CommandCompletedEvent) => void
105
+  ): EmitterSubscription {
70
     return this.emitter.addListener('RNN.CommandCompleted', callback);
106
     return this.emitter.addListener('RNN.CommandCompleted', callback);
71
   }
107
   }
72
 
108
 
73
-  public registerBottomTabSelectedListener(callback: (data: BottomTabSelectedEvent) => void): EmitterSubscription {
109
+  public registerBottomTabSelectedListener(
110
+    callback: (data: BottomTabSelectedEvent) => void
111
+  ): EmitterSubscription {
74
     return this.emitter.addListener('RNN.BottomTabSelected', callback);
112
     return this.emitter.addListener('RNN.BottomTabSelected', callback);
75
   }
113
   }
76
 
114
 
77
-  public registerBottomTabLongPressedListener(callback: (data: BottomTabLongPressedEvent) => void): EmitterSubscription {
115
+  public registerBottomTabLongPressedListener(
116
+    callback: (data: BottomTabLongPressedEvent) => void
117
+  ): EmitterSubscription {
78
     return this.emitter.addListener('RNN.BottomTabLongPressed', callback);
118
     return this.emitter.addListener('RNN.BottomTabLongPressed', callback);
79
   }
119
   }
80
 
120
 
81
-  public registerScreenPoppedListener(callback: (event: ScreenPoppedEvent) => void): EmitterSubscription {
121
+  public registerScreenPoppedListener(
122
+    callback: (event: ScreenPoppedEvent) => void
123
+  ): EmitterSubscription {
82
     return this.emitter.addListener('RNN.ScreenPopped', callback);
124
     return this.emitter.addListener('RNN.ScreenPopped', callback);
83
   }
125
   }
84
 }
126
 }

+ 85
- 26
lib/src/events/EventsRegistry.ts View File

15
   ScreenPoppedEvent,
15
   ScreenPoppedEvent,
16
   ModalAttemptedToDismissEvent
16
   ModalAttemptedToDismissEvent
17
 } from '../interfaces/ComponentEvents';
17
 } from '../interfaces/ComponentEvents';
18
-import { CommandCompletedEvent, BottomTabSelectedEvent, BottomTabLongPressedEvent } from '../interfaces/Events';
18
+import {
19
+  CommandCompletedEvent,
20
+  BottomTabSelectedEvent,
21
+  BottomTabLongPressedEvent,
22
+  BottomTabPressedEvent
23
+} from '../interfaces/Events';
19
 
24
 
20
 export class EventsRegistry {
25
 export class EventsRegistry {
21
-  constructor(private nativeEventsReceiver: NativeEventsReceiver, private commandsObserver: CommandsObserver, private componentEventsObserver: ComponentEventsObserver) { }
22
-
23
-  public registerAppLaunchedListener(callback: () => void): EmitterSubscription {
26
+  constructor(
27
+    private nativeEventsReceiver: NativeEventsReceiver,
28
+    private commandsObserver: CommandsObserver,
29
+    private componentEventsObserver: ComponentEventsObserver
30
+  ) {}
31
+
32
+  public registerAppLaunchedListener(
33
+    callback: () => void
34
+  ): EmitterSubscription {
24
     return this.nativeEventsReceiver.registerAppLaunchedListener(callback);
35
     return this.nativeEventsReceiver.registerAppLaunchedListener(callback);
25
   }
36
   }
26
 
37
 
27
-  public registerComponentDidAppearListener(callback: (event: ComponentDidAppearEvent) => void): EmitterSubscription {
28
-    return this.nativeEventsReceiver.registerComponentDidAppearListener(callback);
38
+  public registerComponentDidAppearListener(
39
+    callback: (event: ComponentDidAppearEvent) => void
40
+  ): EmitterSubscription {
41
+    return this.nativeEventsReceiver.registerComponentDidAppearListener(
42
+      callback
43
+    );
29
   }
44
   }
30
 
45
 
31
-  public registerComponentDidDisappearListener(callback: (event: ComponentDidDisappearEvent) => void): EmitterSubscription {
32
-    return this.nativeEventsReceiver.registerComponentDidDisappearListener(callback);
46
+  public registerComponentDidDisappearListener(
47
+    callback: (event: ComponentDidDisappearEvent) => void
48
+  ): EmitterSubscription {
49
+    return this.nativeEventsReceiver.registerComponentDidDisappearListener(
50
+      callback
51
+    );
33
   }
52
   }
34
 
53
 
35
-  public registerCommandCompletedListener(callback: (event: CommandCompletedEvent) => void): EmitterSubscription {
54
+  public registerCommandCompletedListener(
55
+    callback: (event: CommandCompletedEvent) => void
56
+  ): EmitterSubscription {
36
     return this.nativeEventsReceiver.registerCommandCompletedListener(callback);
57
     return this.nativeEventsReceiver.registerCommandCompletedListener(callback);
37
   }
58
   }
38
 
59
 
39
-  public registerBottomTabSelectedListener(callback: (event: BottomTabSelectedEvent) => void): EmitterSubscription {
40
-    return this.nativeEventsReceiver.registerBottomTabSelectedListener(callback);
60
+  public registerBottomTabSelectedListener(
61
+    callback: (event: BottomTabSelectedEvent) => void
62
+  ): EmitterSubscription {
63
+    return this.nativeEventsReceiver.registerBottomTabSelectedListener(
64
+      callback
65
+    );
41
   }
66
   }
42
 
67
 
43
-  public registerBottomTabLongPressedListener(callback: (event: BottomTabLongPressedEvent) => void): EmitterSubscription {
44
-    return this.nativeEventsReceiver.registerBottomTabLongPressedListener(callback);
68
+  public registerBottomTabPressedListener(
69
+    callback: (event: BottomTabPressedEvent) => void
70
+  ): EmitterSubscription {
71
+    return this.nativeEventsReceiver.registerBottomTabPressedListener(callback);
45
   }
72
   }
46
 
73
 
47
-  public registerNavigationButtonPressedListener(callback: (event: NavigationButtonPressedEvent) => void): EmitterSubscription {
48
-    return this.nativeEventsReceiver.registerNavigationButtonPressedListener(callback);
74
+  public registerBottomTabLongPressedListener(
75
+    callback: (event: BottomTabLongPressedEvent) => void
76
+  ): EmitterSubscription {
77
+    return this.nativeEventsReceiver.registerBottomTabLongPressedListener(
78
+      callback
79
+    );
49
   }
80
   }
50
 
81
 
51
-  public registerModalDismissedListener(callback: (event: ModalDismissedEvent) => void): EmitterSubscription {
82
+  public registerNavigationButtonPressedListener(
83
+    callback: (event: NavigationButtonPressedEvent) => void
84
+  ): EmitterSubscription {
85
+    return this.nativeEventsReceiver.registerNavigationButtonPressedListener(
86
+      callback
87
+    );
88
+  }
89
+
90
+  public registerModalDismissedListener(
91
+    callback: (event: ModalDismissedEvent) => void
92
+  ): EmitterSubscription {
52
     return this.nativeEventsReceiver.registerModalDismissedListener(callback);
93
     return this.nativeEventsReceiver.registerModalDismissedListener(callback);
53
   }
94
   }
54
 
95
 
55
-  public registerModalAttemptedToDismissListener(callback: (event: ModalAttemptedToDismissEvent) => void): EmitterSubscription {
56
-    return this.nativeEventsReceiver.registerModalAttemptedToDismissListener(callback);
96
+  public registerModalAttemptedToDismissListener(
97
+    callback: (event: ModalAttemptedToDismissEvent) => void
98
+  ): EmitterSubscription {
99
+    return this.nativeEventsReceiver.registerModalAttemptedToDismissListener(
100
+      callback
101
+    );
57
   }
102
   }
58
 
103
 
59
-  public registerSearchBarUpdatedListener(callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription {
104
+  public registerSearchBarUpdatedListener(
105
+    callback: (event: SearchBarUpdatedEvent) => void
106
+  ): EmitterSubscription {
60
     return this.nativeEventsReceiver.registerSearchBarUpdatedListener(callback);
107
     return this.nativeEventsReceiver.registerSearchBarUpdatedListener(callback);
61
   }
108
   }
62
 
109
 
63
-  public registerSearchBarCancelPressedListener(callback: (event: SearchBarCancelPressedEvent) => void): EmitterSubscription {
64
-    return this.nativeEventsReceiver.registerSearchBarCancelPressedListener(callback);
110
+  public registerSearchBarCancelPressedListener(
111
+    callback: (event: SearchBarCancelPressedEvent) => void
112
+  ): EmitterSubscription {
113
+    return this.nativeEventsReceiver.registerSearchBarCancelPressedListener(
114
+      callback
115
+    );
65
   }
116
   }
66
 
117
 
67
-  public registerPreviewCompletedListener(callback: (event: PreviewCompletedEvent) => void): EmitterSubscription {
118
+  public registerPreviewCompletedListener(
119
+    callback: (event: PreviewCompletedEvent) => void
120
+  ): EmitterSubscription {
68
     return this.nativeEventsReceiver.registerPreviewCompletedListener(callback);
121
     return this.nativeEventsReceiver.registerPreviewCompletedListener(callback);
69
   }
122
   }
70
 
123
 
71
-  public registerCommandListener(callback: (name: string, params: any) => void): EventSubscription {
124
+  public registerCommandListener(
125
+    callback: (name: string, params: any) => void
126
+  ): EventSubscription {
72
     return this.commandsObserver.register(callback);
127
     return this.commandsObserver.register(callback);
73
   }
128
   }
74
 
129
 
75
-  public bindComponent(component: React.Component<any>, componentId?: string): EventSubscription {
130
+  public bindComponent(
131
+    component: React.Component<any>,
132
+    componentId?: string
133
+  ): EventSubscription {
76
     return this.componentEventsObserver.bindComponent(component, componentId);
134
     return this.componentEventsObserver.bindComponent(component, componentId);
77
   }
135
   }
78
 
136
 
79
-  public registerScreenPoppedListener(callback: (event: ScreenPoppedEvent) => void): EmitterSubscription {
137
+  public registerScreenPoppedListener(
138
+    callback: (event: ScreenPoppedEvent) => void
139
+  ): EmitterSubscription {
80
     return this.nativeEventsReceiver.registerScreenPoppedListener(callback);
140
     return this.nativeEventsReceiver.registerScreenPoppedListener(callback);
81
   }
141
   }
82
-
83
 }
142
 }

+ 4
- 0
lib/src/interfaces/Events.ts View File

13
 export interface BottomTabLongPressedEvent {
13
 export interface BottomTabLongPressedEvent {
14
   selectedTabIndex: number;
14
   selectedTabIndex: number;
15
 }
15
 }
16
+
17
+export interface BottomTabPressedEvent {
18
+  tabIndex: number;
19
+}

+ 54
- 18
lib/src/interfaces/Options.ts View File

3
 
3
 
4
 type Color = string;
4
 type Color = string;
5
 type FontFamily = string;
5
 type FontFamily = string;
6
-type FontWeight = 'regular' | 'bold' | 'thin' | 'ultraLight' | 'light' | 'medium' | 'semibold' | 'heavy' | 'black';
6
+type FontWeight =
7
+  | 'regular'
8
+  | 'bold'
9
+  | 'thin'
10
+  | 'ultraLight'
11
+  | 'light'
12
+  | 'medium'
13
+  | 'semibold'
14
+  | 'heavy'
15
+  | 'black';
7
 type LayoutOrientation = 'portrait' | 'landscape';
16
 type LayoutOrientation = 'portrait' | 'landscape';
8
 type AndroidDensityNumber = number;
17
 type AndroidDensityNumber = number;
9
-type SystemItemIcon = 'done' | 'cancel' | 'edit'
10
-  | 'save' | 'add' | 'flexibleSpace' | 'fixedSpace'
11
-  | 'compose' | 'reply' | 'action' | 'organize'
12
-  | 'bookmarks' | 'search' | 'refresh' | 'stop'
13
-  | 'camera' | 'trash' | 'play' | 'pause'
14
-  | 'rewind' | 'fastForward' | 'undo' | 'redo';
18
+type SystemItemIcon =
19
+  | 'done'
20
+  | 'cancel'
21
+  | 'edit'
22
+  | 'save'
23
+  | 'add'
24
+  | 'flexibleSpace'
25
+  | 'fixedSpace'
26
+  | 'compose'
27
+  | 'reply'
28
+  | 'action'
29
+  | 'organize'
30
+  | 'bookmarks'
31
+  | 'search'
32
+  | 'refresh'
33
+  | 'stop'
34
+  | 'camera'
35
+  | 'trash'
36
+  | 'play'
37
+  | 'pause'
38
+  | 'rewind'
39
+  | 'fastForward'
40
+  | 'undo'
41
+  | 'redo';
15
 
42
 
16
 export interface OptionsSplitView {
43
 export interface OptionsSplitView {
17
   /**
44
   /**
55
    * #### (Android specific)
82
    * #### (Android specific)
56
    */
83
    */
57
   drawBehind?: boolean;
84
   drawBehind?: boolean;
85
+  /**
86
+   * If it's set to false, pressing a tab won't select the tab
87
+   * instead it will emit a bottomTabPressedEvent
88
+   */
89
+  selectTabOnPress?: boolean;
58
 }
90
 }
59
 
91
 
60
 export interface OptionsLayout {
92
 export interface OptionsLayout {
280
    */
312
    */
281
   icon?: ImageRequireSource;
313
   icon?: ImageRequireSource;
282
   /**
314
   /**
283
-  * Set the button icon insets
284
-  */
315
+   * Set the button icon insets
316
+   */
285
   iconInsets?: IconInsets;
317
   iconInsets?: IconInsets;
286
   /**
318
   /**
287
    * Set the button as a custom component
319
    * Set the button as a custom component
536
    * Control the text display mode below the tab icon
568
    * Control the text display mode below the tab icon
537
    * #### (Android specific)
569
    * #### (Android specific)
538
    */
570
    */
539
-  titleDisplayMode?: 'alwaysShow' | 'showWhenActive' | 'alwaysHide' | 'showWhenActiveForce';
571
+  titleDisplayMode?:
572
+    | 'alwaysShow'
573
+    | 'showWhenActive'
574
+    | 'alwaysHide'
575
+    | 'showWhenActiveForce';
540
   /**
576
   /**
541
    * Set the elevation of the Bottom Tabs in dp
577
    * Set the elevation of the Bottom Tabs in dp
542
    * #### (Android specific)
578
    * #### (Android specific)
545
 }
581
 }
546
 
582
 
547
 export interface DotIndicatorOptions {
583
 export interface DotIndicatorOptions {
548
-    // default red
549
-    color?: Color;
550
-    // default 6
551
-    size?: number;
552
-    // default false
553
-    visible?: boolean;
584
+  // default red
585
+  color?: Color;
586
+  // default 6
587
+  size?: number;
588
+  // default false
589
+  visible?: boolean;
554
 }
590
 }
555
 
591
 
556
 export type ImageResource = string;
592
 export type ImageResource = string;
557
 
593
 
558
 export interface OptionsBottomTab {
594
 export interface OptionsBottomTab {
559
-    dotIndicator?: DotIndicatorOptions;
595
+  dotIndicator?: DotIndicatorOptions;
560
 
596
 
561
   /**
597
   /**
562
    * Set the text to display below the icon
598
    * Set the text to display below the icon
599
    * Set the text font family
635
    * Set the text font family
600
    */
636
    */
601
   fontFamily?: FontFamily;
637
   fontFamily?: FontFamily;
602
-    /**
638
+  /**
603
    * Set the font weight, ignore fontFamily and use the iOS system fonts instead
639
    * Set the font weight, ignore fontFamily and use the iOS system fonts instead
604
    * #### (iOS specific)
640
    * #### (iOS specific)
605
    */
641
    */

+ 4
- 4
playground/ios/Podfile.lock View File

220
     - ReactCommon/jscallinvoker (= 0.61.4)
220
     - ReactCommon/jscallinvoker (= 0.61.4)
221
   - ReactNativeKeyboardTrackingView (5.6.1):
221
   - ReactNativeKeyboardTrackingView (5.6.1):
222
     - React
222
     - React
223
-  - ReactNativeNavigation (4.0.6):
223
+  - ReactNativeNavigation (4.6.0):
224
     - React
224
     - React
225
   - Yoga (1.14.0)
225
   - Yoga (1.14.0)
226
 
226
 
258
   - Yoga (from `../../node_modules/react-native/ReactCommon/yoga`)
258
   - Yoga (from `../../node_modules/react-native/ReactCommon/yoga`)
259
 
259
 
260
 SPEC REPOS:
260
 SPEC REPOS:
261
-  https://github.com/cocoapods/specs.git:
261
+  https://github.com/CocoaPods/Specs.git:
262
     - boost-for-react-native
262
     - boost-for-react-native
263
     - OCMock
263
     - OCMock
264
 
264
 
346
   React-RCTVibration: 0f76400ee3cec6edb9c125da49fed279340d145a
346
   React-RCTVibration: 0f76400ee3cec6edb9c125da49fed279340d145a
347
   ReactCommon: a6a294e7028ed67b926d29551aa9394fd989c24c
347
   ReactCommon: a6a294e7028ed67b926d29551aa9394fd989c24c
348
   ReactNativeKeyboardTrackingView: a240a6a0dba852bb107109a7ec7e98b884055977
348
   ReactNativeKeyboardTrackingView: a240a6a0dba852bb107109a7ec7e98b884055977
349
-  ReactNativeNavigation: a04159cfe472aa4d9dd48d1185b4a2539b9dbbe2
349
+  ReactNativeNavigation: fb74494c1b6f0abd36a17c7af40f804f77d3181f
350
   Yoga: ba3d99dbee6c15ea6bbe3783d1f0cb1ffb79af0f
350
   Yoga: ba3d99dbee6c15ea6bbe3783d1f0cb1ffb79af0f
351
 
351
 
352
 PODFILE CHECKSUM: 781f49751a12b13af3e83d5dfc4b122aa5770543
352
 PODFILE CHECKSUM: 781f49751a12b13af3e83d5dfc4b122aa5770543
353
 
353
 
354
-COCOAPODS: 1.7.1
354
+COCOAPODS: 1.8.4