hybrid-navigation 2.13.0-beta.0 → 2.13.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +4 -0
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +2 -1
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +37 -4
- package/ios/HybridNavigation/View/HBDRootView.h +3 -1
- package/ios/HybridNavigation/View/HBDRootView.m +14 -17
- package/ios/HybridNavigation/ViewController/HBDReactViewController.m +2 -2
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +3 -2
- package/lib/Garden.d.ts +3 -0
- package/lib/Garden.js +12 -1
- package/lib/NavigationModule.d.ts +0 -2
- package/lib/NavigationModule.js +0 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -2
- package/src/Garden.ts +15 -1
- package/src/NavigationModule.ts +0 -4
- package/src/index.ts +1 -1
|
@@ -25,9 +25,11 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
25
25
|
import com.facebook.react.bridge.ReadableMap;
|
|
26
26
|
import com.facebook.react.bridge.UiThreadUtil;
|
|
27
27
|
import com.facebook.react.bridge.WritableMap;
|
|
28
|
+
import com.facebook.react.uimanager.PixelUtil;
|
|
28
29
|
import com.navigation.androidx.AwesomeFragment;
|
|
29
30
|
import com.navigation.androidx.DrawerFragment;
|
|
30
31
|
import com.navigation.androidx.FragmentHelper;
|
|
32
|
+
import com.navigation.androidx.SystemUI;
|
|
31
33
|
import com.navigation.androidx.TabBarFragment;
|
|
32
34
|
|
|
33
35
|
import java.util.HashMap;
|
|
@@ -54,6 +56,8 @@ public class GardenModule extends ReactContextBaseJavaModule {
|
|
|
54
56
|
public Map<String, Object> getConstants() {
|
|
55
57
|
final Map<String, Object> constants = new HashMap<>();
|
|
56
58
|
constants.put("TOOLBAR_HEIGHT", 56);
|
|
59
|
+
float statusBarHeight = PixelUtil.toDIPFromPixel(SystemUI.getStatusBarHeight(getReactApplicationContext()));
|
|
60
|
+
constants.put("STATUSBAR_HEIGHT", statusBarHeight);
|
|
57
61
|
return constants;
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
#import <React/RCTLog.h>
|
|
8
8
|
|
|
9
|
+
static NSString *const EVENT_STATUSBAR_FRAME_CHANGE = @"EVENT_STATUSBAR_FRAME_CHANGE";
|
|
10
|
+
|
|
9
11
|
@interface HBDGardenModule ()
|
|
10
12
|
|
|
11
13
|
@property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
|
|
@@ -14,25 +16,56 @@
|
|
|
14
16
|
|
|
15
17
|
@implementation HBDGardenModule
|
|
16
18
|
|
|
19
|
+
RCT_EXPORT_MODULE(GardenModule)
|
|
20
|
+
|
|
17
21
|
+ (BOOL)requiresMainQueueSetup {
|
|
18
22
|
return YES;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
- (dispatch_queue_t)methodQueue {
|
|
26
|
+
return dispatch_get_main_queue();
|
|
27
|
+
}
|
|
22
28
|
|
|
23
29
|
- (instancetype)init {
|
|
24
30
|
if (self = [super init]) {
|
|
25
31
|
_bridgeManager = [HBDReactBridgeManager get];
|
|
32
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleStatusBarFrameChange) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
|
26
33
|
}
|
|
27
34
|
return self;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
- (
|
|
31
|
-
|
|
37
|
+
- (void)dealloc {
|
|
38
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
- (NSDictionary *)constantsToExport {
|
|
35
|
-
return @{
|
|
42
|
+
return @{
|
|
43
|
+
@"TOOLBAR_HEIGHT": @(44),
|
|
44
|
+
@"STATUSBAR_HEIGHT": @([self currentStatusBarHeight]),
|
|
45
|
+
@"EVENT_STATUSBAR_FRAME_CHANGE": EVENT_STATUSBAR_FRAME_CHANGE,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
50
|
+
return @[EVENT_STATUSBAR_FRAME_CHANGE];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (CGFloat)currentStatusBarHeight {
|
|
54
|
+
if (@available(iOS 13.0, *)) {
|
|
55
|
+
UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].keyWindow.windowScene.statusBarManager;
|
|
56
|
+
return statusBarManager.statusBarFrame.size.height;
|
|
57
|
+
} else {
|
|
58
|
+
return [[UIApplication sharedApplication] statusBarFrame].size.height;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)handleStatusBarFrameChange {
|
|
63
|
+
RCTLogInfo(@"handleStatusBarFrameChange: %f", [self currentStatusBarHeight]);
|
|
64
|
+
if ([self.bridge isValid]) {
|
|
65
|
+
[self sendEventWithName:EVENT_STATUSBAR_FRAME_CHANGE body:@{
|
|
66
|
+
@"statusBarHeight": @([self currentStatusBarHeight])
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
36
69
|
}
|
|
37
70
|
|
|
38
71
|
RCT_EXPORT_METHOD(setStyle:(NSDictionary *) style) {
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
#import "HBDRootView.h"
|
|
2
2
|
|
|
3
|
+
@interface HBDRootView ()
|
|
4
|
+
|
|
5
|
+
@property (nonatomic, strong, readonly) RCTRootView *rootView;
|
|
6
|
+
|
|
7
|
+
@end
|
|
8
|
+
|
|
3
9
|
@implementation HBDRootView
|
|
4
10
|
|
|
5
|
-
- (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
UIView *view = self.contentView.subviews.firstObject;
|
|
9
|
-
while (view) {
|
|
10
|
-
if (view == hitView) {
|
|
11
|
-
if (CGRectEqualToRect(view.frame, self.bounds)) {
|
|
12
|
-
return nil;
|
|
13
|
-
} else {
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
} else {
|
|
17
|
-
view = view.subviews.firstObject;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
11
|
+
- (instancetype)initWithRootView:(RCTRootView *)rootView {
|
|
12
|
+
if (self = [super init]) {
|
|
13
|
+
_rootView = rootView;
|
|
20
14
|
}
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
19
|
+
UIView *hitView = [super hitTest:point withEvent:event];
|
|
20
|
+
if (self.rootView.passThroughTouches && hitView == self) {
|
|
23
21
|
return nil;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
return hitView;
|
|
27
24
|
}
|
|
28
25
|
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
- (void)loadView {
|
|
40
|
-
RCTRootView *rootView = [[
|
|
40
|
+
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
|
|
41
41
|
self.rootView = rootView;
|
|
42
42
|
|
|
43
43
|
BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
|
|
44
44
|
rootView.passThroughTouches = passThroughTouches;
|
|
45
45
|
rootView.backgroundColor = UIColor.clearColor;
|
|
46
46
|
rootView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
47
|
-
self.view = [
|
|
47
|
+
self.view = [[HBDRootView alloc] initWithRootView:rootView];
|
|
48
48
|
[self.view addSubview:rootView];
|
|
49
49
|
[self updateReactViewConstraints];
|
|
50
50
|
}
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
#import "HBDUtils.h"
|
|
6
6
|
#import "HBDEventEmitter.h"
|
|
7
7
|
#import "HBDReactTabBar.h"
|
|
8
|
-
#import "HBDRootView.h"
|
|
9
8
|
#import "HBDFadeAnimation.h"
|
|
10
9
|
|
|
10
|
+
#import <React/RCTRootView.h>
|
|
11
11
|
#import <React/RCTRootViewDelegate.h>
|
|
12
12
|
#import <React/RCTLog.h>
|
|
13
13
|
|
|
14
|
+
|
|
14
15
|
@interface HBDTabBarController () <UITabBarControllerDelegate, RCTRootViewDelegate>
|
|
15
16
|
|
|
16
17
|
@property(nonatomic, strong) RCTRootView *rootView;
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
NSString *moduleName = self.tabBarOptions[@"tabBarModuleName"];
|
|
59
60
|
NSMutableDictionary *props = [[self props] mutableCopy];
|
|
60
61
|
props[@"selectedIndex"] = self.tabBarOptions[@"selectedIndex"];
|
|
61
|
-
RCTRootView *rootView = [[
|
|
62
|
+
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:moduleName initialProperties:props];
|
|
62
63
|
rootView.backgroundColor = UIColor.clearColor;
|
|
63
64
|
|
|
64
65
|
BOOL sizeIndeterminate = [self.tabBarOptions[@"sizeIndeterminate"] boolValue];
|
package/lib/Garden.d.ts
CHANGED
|
@@ -65,6 +65,9 @@ declare type Nullable<T> = {
|
|
|
65
65
|
export declare class Garden {
|
|
66
66
|
sceneId: string;
|
|
67
67
|
static setStyle(style?: Style): void;
|
|
68
|
+
static statusBarHeight: number;
|
|
69
|
+
static toolbarHeight: number;
|
|
70
|
+
static topBarHeight: number;
|
|
68
71
|
constructor(sceneId: string);
|
|
69
72
|
setLeftBarButtonItem(buttonItem: Nullable<BarButtonItem> | null): void;
|
|
70
73
|
setRightBarButtonItem(buttonItem: Nullable<BarButtonItem> | null): void;
|
package/lib/Garden.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
2
|
import { bindBarButtonItemClickEvent } from './utils';
|
|
3
3
|
const GardenModule = NativeModules.GardenModule;
|
|
4
|
+
const { STATUSBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE, TOOLBAR_HEIGHT } = GardenModule.getConstants();
|
|
5
|
+
if (Platform.OS === 'ios') {
|
|
6
|
+
const GardenEventEmitter = new NativeEventEmitter(GardenModule);
|
|
7
|
+
GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
8
|
+
Garden.statusBarHeight = statusBarHeight;
|
|
9
|
+
Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
4
12
|
export class Garden {
|
|
5
13
|
sceneId;
|
|
6
14
|
static setStyle(style = {}) {
|
|
7
15
|
GardenModule.setStyle(style);
|
|
8
16
|
}
|
|
17
|
+
static statusBarHeight = STATUSBAR_HEIGHT;
|
|
18
|
+
static toolbarHeight = TOOLBAR_HEIGHT;
|
|
19
|
+
static topBarHeight = TOOLBAR_HEIGHT + STATUSBAR_HEIGHT;
|
|
9
20
|
constructor(sceneId) {
|
|
10
21
|
this.sceneId = sceneId;
|
|
11
22
|
}
|
|
@@ -19,6 +19,4 @@ export declare const KEY_INDEX: string;
|
|
|
19
19
|
export declare const KEY_ACTION: string;
|
|
20
20
|
export declare const RESULT_OK: number;
|
|
21
21
|
export declare const RESULT_CANCEL: number;
|
|
22
|
-
export declare const toolbarHeight: number;
|
|
23
|
-
export declare const TOOLBAR_HEIGHT: number;
|
|
24
22
|
export { EventEmitter, NavigationModule };
|
package/lib/NavigationModule.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
2
|
const NavigationModule = NativeModules.NavigationModule;
|
|
3
|
-
const GardenModule = NativeModules.GardenModule;
|
|
4
3
|
const HBDEventEmitter = NativeModules.HBDEventEmitter;
|
|
5
4
|
const EventEmitter = new NativeEventEmitter(HBDEventEmitter);
|
|
6
5
|
export const EVENT_SWITCH_TAB = HBDEventEmitter.EVENT_SWITCH_TAB;
|
|
@@ -21,6 +20,4 @@ export const KEY_INDEX = HBDEventEmitter.KEY_INDEX;
|
|
|
21
20
|
export const KEY_ACTION = HBDEventEmitter.KEY_ACTION;
|
|
22
21
|
export const RESULT_OK = NavigationModule.RESULT_OK;
|
|
23
22
|
export const RESULT_CANCEL = NavigationModule.RESULT_CANCEL;
|
|
24
|
-
export const toolbarHeight = GardenModule.TOOLBAR_HEIGHT;
|
|
25
|
-
export const TOOLBAR_HEIGHT = GardenModule.TOOLBAR_HEIGHT;
|
|
26
23
|
export { EventEmitter, NavigationModule };
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hybrid-navigation",
|
|
3
3
|
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
-
"version": "2.13.0-beta.
|
|
4
|
+
"version": "2.13.0-beta.1",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"react": "17.0.2",
|
|
64
64
|
"react-native": "^0.67.4",
|
|
65
65
|
"react-native-fast-image": "^8.5.11",
|
|
66
|
-
"react-native-iphone-x-helper": "^1.2.0",
|
|
67
66
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
68
67
|
"react-native-toast-hybrid": "^2.5.0",
|
|
69
68
|
"react-redux": "^7.2.5",
|
package/src/Garden.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native'
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native'
|
|
2
2
|
import { bindBarButtonItemClickEvent } from './utils'
|
|
3
3
|
import { NavigationOption, ImageSource, Color, BarStyle, TitleAlignment, BarButtonItem, TitleItem } from './typing'
|
|
4
4
|
|
|
@@ -77,11 +77,25 @@ type Nullable<T> = {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const GardenModule = NativeModules.GardenModule
|
|
80
|
+
const { STATUSBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE, TOOLBAR_HEIGHT } = GardenModule.getConstants()
|
|
81
|
+
|
|
82
|
+
if (Platform.OS === 'ios') {
|
|
83
|
+
const GardenEventEmitter: NativeEventEmitter = new NativeEventEmitter(GardenModule)
|
|
84
|
+
GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
85
|
+
Garden.statusBarHeight = statusBarHeight
|
|
86
|
+
Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
export class Garden {
|
|
81
91
|
static setStyle(style: Style = {}) {
|
|
82
92
|
GardenModule.setStyle(style)
|
|
83
93
|
}
|
|
84
94
|
|
|
95
|
+
static statusBarHeight: number = STATUSBAR_HEIGHT
|
|
96
|
+
static toolbarHeight: number = TOOLBAR_HEIGHT
|
|
97
|
+
static topBarHeight: number = TOOLBAR_HEIGHT + STATUSBAR_HEIGHT
|
|
98
|
+
|
|
85
99
|
constructor(public sceneId: string) {}
|
|
86
100
|
|
|
87
101
|
// --------------- instance method --------------
|
package/src/NavigationModule.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter } from 'react-native'
|
|
2
2
|
|
|
3
3
|
const NavigationModule = NativeModules.NavigationModule
|
|
4
|
-
const GardenModule = NativeModules.GardenModule
|
|
5
4
|
const HBDEventEmitter = NativeModules.HBDEventEmitter
|
|
6
5
|
|
|
7
6
|
const EventEmitter: NativeEventEmitter = new NativeEventEmitter(HBDEventEmitter)
|
|
@@ -27,7 +26,4 @@ export const KEY_ACTION: string = HBDEventEmitter.KEY_ACTION
|
|
|
27
26
|
export const RESULT_OK: number = NavigationModule.RESULT_OK
|
|
28
27
|
export const RESULT_CANCEL: number = NavigationModule.RESULT_CANCEL
|
|
29
28
|
|
|
30
|
-
export const toolbarHeight: number = GardenModule.TOOLBAR_HEIGHT
|
|
31
|
-
export const TOOLBAR_HEIGHT: number = GardenModule.TOOLBAR_HEIGHT
|
|
32
|
-
|
|
33
29
|
export { EventEmitter, NavigationModule }
|
package/src/index.ts
CHANGED