hybrid-navigation 2.13.0-beta.2 → 2.13.0-beta.3
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/ios/HybridNavigation/HBDUtils.h +3 -6
- package/ios/HybridNavigation/HBDUtils.m +10 -0
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +7 -2
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +1 -1
- package/ios/HybridNavigation/View/HBDRootView.m +9 -3
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +0 -30
- package/ios/HybridNavigation/ViewController/HBDViewController.m +7 -3
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -3
- package/lib/Event.d.ts +22 -0
- package/lib/Event.js +117 -0
- package/lib/Garden.d.ts +2 -64
- package/lib/Garden.js +9 -47
- package/lib/GardenModule.d.ts +20 -0
- package/lib/GardenModule.js +3 -0
- package/lib/NavigationModule.d.ts +33 -22
- package/lib/NavigationModule.js +79 -22
- package/lib/Navigator.d.ts +33 -17
- package/lib/Navigator.js +106 -170
- package/lib/{typing.d.ts → Options.d.ts} +46 -50
- package/lib/{typing.js → Options.js} +0 -0
- package/lib/ReactRegistry.d.ts +2 -3
- package/lib/ReactRegistry.js +8 -28
- package/lib/Route.d.ts +74 -0
- package/lib/{router/typing.js → Route.js} +0 -0
- package/lib/hooks.d.ts +0 -1
- package/lib/hooks.js +18 -24
- package/lib/index.d.ts +3 -2
- package/lib/index.js +4 -2
- package/lib/router/drawer.d.ts +1 -1
- package/lib/router/index.d.ts +4 -7
- package/lib/router/index.js +1 -6
- package/lib/router/screen.d.ts +1 -1
- package/lib/router/stack.d.ts +1 -1
- package/lib/router/tabs.d.ts +1 -1
- package/lib/store.d.ts +0 -9
- package/lib/store.js +0 -22
- package/package.json +1 -1
- package/src/Event.ts +188 -0
- package/src/Garden.ts +18 -122
- package/src/GardenModule.ts +24 -0
- package/src/NavigationModule.ts +118 -29
- package/src/Navigator.ts +164 -209
- package/src/{typing.ts → Options.ts} +51 -57
- package/src/ReactRegistry.tsx +17 -40
- package/src/Route.ts +88 -0
- package/src/hooks.ts +23 -32
- package/src/index.ts +5 -2
- package/src/router/drawer.ts +1 -1
- package/src/router/index.ts +21 -12
- package/src/router/screen.ts +1 -1
- package/src/router/stack.ts +1 -1
- package/src/router/tabs.ts +1 -1
- package/src/store.ts +0 -28
- package/lib/router/typing.d.ts +0 -37
- package/lib/utils.d.ts +0 -9
- package/lib/utils.js +0 -50
- package/src/router/typing.ts +0 -45
- package/src/utils.ts +0 -83
|
@@ -5,12 +5,7 @@ UIKIT_STATIC_INLINE BOOL colorHasAlphaComponent(UIColor *color) {
|
|
|
5
5
|
if (!color) {
|
|
6
6
|
return YES;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
CGFloat green = 0;
|
|
10
|
-
CGFloat blue = 0;
|
|
11
|
-
CGFloat alpha = 0;
|
|
12
|
-
[color getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
13
|
-
return alpha < 1.0;
|
|
8
|
+
return CGColorGetAlpha(color.CGColor) < 1.0;
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
UIKIT_STATIC_INLINE BOOL imageHasAlphaChannel(UIImage *image) {
|
|
@@ -51,4 +46,6 @@ UIKIT_STATIC_INLINE void hbd_exchangeImplementations(Class clazz, SEL originalSe
|
|
|
51
46
|
|
|
52
47
|
+ (BOOL)isInCall;
|
|
53
48
|
|
|
49
|
+
+ (void)printViewHierarchy:(UIView *)view withPrefix:(NSString *)prefix;
|
|
50
|
+
|
|
54
51
|
@end
|
|
@@ -178,6 +178,16 @@
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
+ (void)printViewHierarchy:(UIView *)view withPrefix:(NSString *)prefix {
|
|
182
|
+
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
183
|
+
NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
|
|
184
|
+
if (view.subviews.count > 0) {
|
|
185
|
+
for (UIView *sub in view.subviews) {
|
|
186
|
+
[self printViewHierarchy:sub withPrefix:[NSString stringWithFormat:@"--%@", prefix]];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
181
191
|
static void (*__SWZ_didMoveToWindow_orig)(id self, SEL _cmd);
|
|
182
192
|
|
|
183
193
|
static void __HBD_didMoveToWindow(UIView *self, SEL _cmd) {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
- (void)handlePushWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras
|
|
121
|
+
- (void)handlePushWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
|
|
122
122
|
UIViewController *vc = [self viewControllerWithExtras:extras];
|
|
123
123
|
if (!vc) {
|
|
124
124
|
callback(@[NSNull.null, @NO]);
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
[self animateAlongsideTransition:nav callback:callback];
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
- (void)handlePopToWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras
|
|
139
|
+
- (void)handlePopToWithNavigationController:(UINavigationController *)nav extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
|
|
140
140
|
UIViewController *vc = [self findViewControllerWithNavigationController:nav extras:extras];
|
|
141
141
|
if (!vc) {
|
|
142
142
|
callback(@[NSNull.null, @NO]);
|
|
@@ -172,6 +172,11 @@
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
- (void)handleRedirectToWithNavigationController:(UINavigationController *)nav target:(UIViewController *)target extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
|
|
175
|
+
if (![nav.childViewControllers containsObject:target]) {
|
|
176
|
+
callback(@[NSNull.null, @NO]);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
175
180
|
UIViewController *vc = [self viewControllerWithExtras:extras];
|
|
176
181
|
if (!vc) {
|
|
177
182
|
callback(@[NSNull.null, @NO]);
|
|
@@ -61,7 +61,7 @@ RCT_EXPORT_METHOD(signalFirstRenderComplete:(NSString *) sceneId) {
|
|
|
61
61
|
// RCTLogInfo(@"[Navigator] signalFirstRenderComplete sceneId:%@", sceneId);
|
|
62
62
|
UIViewController *vc = [self.bridgeManager viewControllerWithSceneId:sceneId];
|
|
63
63
|
if ([vc isKindOfClass:[HBDReactViewController class]]) {
|
|
64
|
-
[(HBDReactViewController *)
|
|
64
|
+
[(HBDReactViewController *)vc signalFirstRenderComplete];
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
@implementation HBDRootView
|
|
10
10
|
|
|
11
11
|
- (instancetype)initWithRootView:(RCTRootView *)rootView {
|
|
12
|
-
if (self = [super
|
|
12
|
+
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
|
|
13
13
|
_rootView = rootView;
|
|
14
14
|
}
|
|
15
15
|
return self;
|
|
@@ -17,8 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
19
19
|
UIView *hitView = [super hitTest:point withEvent:event];
|
|
20
|
-
if (self.rootView.passThroughTouches
|
|
21
|
-
|
|
20
|
+
if (self.rootView.passThroughTouches) {
|
|
21
|
+
if (hitView == self) {
|
|
22
|
+
return nil;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (hitView && CGRectEqualToRect(hitView.frame, self.rootView.bounds)) {
|
|
26
|
+
return nil;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
29
|
return hitView;
|
|
24
30
|
}
|
|
@@ -11,36 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
#define hairlineWidth (1.f/[UIScreen mainScreen].scale)
|
|
13
13
|
|
|
14
|
-
UIColor *blendColor(UIColor *from, UIColor *to, CGFloat percent) {
|
|
15
|
-
CGFloat fromRed = 0;
|
|
16
|
-
CGFloat fromGreen = 0;
|
|
17
|
-
CGFloat fromBlue = 0;
|
|
18
|
-
CGFloat fromAlpha = 0;
|
|
19
|
-
[from getRed:&fromRed green:&fromGreen blue:&fromBlue alpha:&fromAlpha];
|
|
20
|
-
|
|
21
|
-
CGFloat toRed = 0;
|
|
22
|
-
CGFloat toGreen = 0;
|
|
23
|
-
CGFloat toBlue = 0;
|
|
24
|
-
CGFloat toAlpha = 0;
|
|
25
|
-
[to getRed:&toRed green:&toGreen blue:&toBlue alpha:&toAlpha];
|
|
26
|
-
|
|
27
|
-
CGFloat newRed = fromRed + (toRed - fromRed) * fminf(1, (float) (percent * 4));
|
|
28
|
-
CGFloat newGreen = fromGreen + (toGreen - fromGreen) * fminf(1, (float) (percent * 4));
|
|
29
|
-
CGFloat newBlue = fromBlue + (toBlue - fromBlue) * fminf(1, (float) (percent * 4));
|
|
30
|
-
CGFloat newAlpha = fromAlpha + (toAlpha - fromAlpha) * fminf(1, (float) (percent * 4));
|
|
31
|
-
return [UIColor colorWithRed:newRed green:newGreen blue:newBlue alpha:newAlpha];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
35
|
-
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
36
|
-
NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
|
|
37
|
-
if (view.subviews.count > 0) {
|
|
38
|
-
for (UIView *sub in view.subviews) {
|
|
39
|
-
printViewHierarchy(sub, [NSString stringWithFormat:@"--%@", prefix]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
14
|
@interface HBDNavigationControllerDelegate : UIScreenEdgePanGestureRecognizer <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
45
15
|
|
|
46
16
|
@property(nonatomic, weak) id <UINavigationControllerDelegate> proxyDelegate;
|
|
@@ -201,8 +201,12 @@
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
if ([GlobalStyle globalStyle].isBackTitleHidden) {
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
if (@available(iOS 14.0, *)) {
|
|
205
|
+
self.navigationItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
|
|
206
|
+
} else {
|
|
207
|
+
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:NULL];
|
|
208
|
+
self.navigationItem.backBarButtonItem = buttonItem;
|
|
209
|
+
}
|
|
206
210
|
}
|
|
207
211
|
|
|
208
212
|
NSDictionary *backItem = options[@"backItemIOS"];
|
|
@@ -215,7 +219,7 @@
|
|
|
215
219
|
}
|
|
216
220
|
self.navigationItem.backBarButtonItem = backButton;
|
|
217
221
|
}
|
|
218
|
-
|
|
222
|
+
|
|
219
223
|
NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
|
|
220
224
|
if (swipeBackEnabled) {
|
|
221
225
|
self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
- (void)redirectToViewController:(UIViewController *)controller target:(UIViewController *)target animated:(BOOL)animated {
|
|
10
10
|
NSMutableArray *children = [self.childViewControllers mutableCopy];
|
|
11
11
|
NSUInteger index = [children indexOfObject:target];
|
|
12
|
-
if (index == NSNotFound) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
12
|
NSUInteger count = self.childViewControllers.count;
|
|
16
13
|
[children removeObjectsInRange:NSMakeRange(index, count - index)];
|
|
17
14
|
[children addObject:controller];
|
package/lib/Event.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare function listenStatusBarHeightChanged(listener: (statusBarHeight: number) => void): import("react-native").EmitterSubscription;
|
|
2
|
+
declare function listenComponentResult(listener: (sceneId: string, requestCode: number, resultCode: number, resultData: object) => void): import("react-native").EmitterSubscription;
|
|
3
|
+
declare function listenComponentVisibility(componentDidAppear: (sceneId: string) => void, componentDidDisappear: (sceneId: string) => void): import("react-native").EmitterSubscription;
|
|
4
|
+
declare function listenSwitchTab(listener: (sceneId: string, from: number, to: number) => void): import("react-native").EmitterSubscription;
|
|
5
|
+
declare function listenSetRoot(willSetRoot: () => void, didSetRoot: (tag: number) => void): {
|
|
6
|
+
remove: () => void;
|
|
7
|
+
};
|
|
8
|
+
declare let barButtonClickHandlerFactory: () => (sceneId: string, value: Function) => void;
|
|
9
|
+
declare function setBarButtonClickHandlerFactory(generator: typeof barButtonClickHandlerFactory): void;
|
|
10
|
+
declare function bindBarButtonClickEvent(sceneId: string, item: object | null | undefined): object | null;
|
|
11
|
+
declare function removeBarButtonClickEvent(sceneId: string): void;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
listenStatusBarHeightChanged: typeof listenStatusBarHeightChanged;
|
|
14
|
+
listenComponentResult: typeof listenComponentResult;
|
|
15
|
+
listenComponentVisibility: typeof listenComponentVisibility;
|
|
16
|
+
listenSwitchTab: typeof listenSwitchTab;
|
|
17
|
+
listenSetRoot: typeof listenSetRoot;
|
|
18
|
+
bindBarButtonClickEvent: typeof bindBarButtonClickEvent;
|
|
19
|
+
removeBarButtonClickEvent: typeof removeBarButtonClickEvent;
|
|
20
|
+
setBarButtonClickHandlerFactory: typeof setBarButtonClickHandlerFactory;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
package/lib/Event.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import GardenModule from './GardenModule';
|
|
3
|
+
function listenStatusBarHeightChanged(listener) {
|
|
4
|
+
const GardenEventReceiver = new NativeEventEmitter(GardenModule);
|
|
5
|
+
const { EVENT_STATUSBAR_FRAME_CHANGE } = GardenModule.getConstants();
|
|
6
|
+
return GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
7
|
+
listener(statusBarHeight);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
const HBDEventEmitter = NativeModules.HBDEventEmitter;
|
|
11
|
+
const HBDEventReceiver = new NativeEventEmitter(HBDEventEmitter);
|
|
12
|
+
function listenComponentResult(listener) {
|
|
13
|
+
const { EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_RESULT, KEY_REQUEST_CODE, KEY_RESULT_CODE, KEY_RESULT_DATA, KEY_SCENE_ID, } = HBDEventEmitter.getConstants();
|
|
14
|
+
return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
|
|
15
|
+
if (data[KEY_ON] === ON_COMPONENT_RESULT) {
|
|
16
|
+
const requestCode = data[KEY_REQUEST_CODE];
|
|
17
|
+
const resultCode = data[KEY_RESULT_CODE];
|
|
18
|
+
const resultData = data[KEY_RESULT_DATA];
|
|
19
|
+
const sceneId = data[KEY_SCENE_ID];
|
|
20
|
+
listener(sceneId, requestCode, resultCode, resultData);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function listenComponentVisibility(componentDidAppear, componentDidDisappear) {
|
|
25
|
+
const { EVENT_NAVIGATION, KEY_ON, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, KEY_SCENE_ID } = HBDEventEmitter.getConstants();
|
|
26
|
+
return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
|
|
27
|
+
if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
|
|
28
|
+
componentDidAppear(data[KEY_SCENE_ID]);
|
|
29
|
+
}
|
|
30
|
+
else if (data[KEY_ON] === ON_COMPONENT_DISAPPEAR) {
|
|
31
|
+
componentDidDisappear(data[KEY_SCENE_ID]);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function listenBarButtonItemClick(listener) {
|
|
36
|
+
const { EVENT_NAVIGATION, KEY_ON, ON_BAR_BUTTON_ITEM_CLICK, KEY_ACTION, KEY_SCENE_ID } = HBDEventEmitter.getConstants();
|
|
37
|
+
return HBDEventReceiver.addListener(EVENT_NAVIGATION, data => {
|
|
38
|
+
if (data[KEY_ON] === ON_BAR_BUTTON_ITEM_CLICK) {
|
|
39
|
+
listener(data[KEY_SCENE_ID], data[KEY_ACTION]);
|
|
40
|
+
}
|
|
41
|
+
}, {});
|
|
42
|
+
}
|
|
43
|
+
function listenSwitchTab(listener) {
|
|
44
|
+
const { EVENT_SWITCH_TAB, KEY_INDEX, KEY_SCENE_ID } = HBDEventEmitter.getConstants();
|
|
45
|
+
return HBDEventReceiver.addListener(EVENT_SWITCH_TAB, event => {
|
|
46
|
+
const index = event[KEY_INDEX];
|
|
47
|
+
const [from, to] = index.split('-');
|
|
48
|
+
listener(event[KEY_SCENE_ID], parseInt(from, 10), parseInt(to, 10));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function listenSetRoot(willSetRoot, didSetRoot) {
|
|
52
|
+
const { EVENT_WILL_SET_ROOT, EVENT_DID_SET_ROOT } = HBDEventEmitter.getConstants();
|
|
53
|
+
const subscriptions = [];
|
|
54
|
+
subscriptions.push(HBDEventReceiver.addListener(EVENT_WILL_SET_ROOT, _ => {
|
|
55
|
+
willSetRoot();
|
|
56
|
+
}));
|
|
57
|
+
subscriptions.push(HBDEventReceiver.addListener(EVENT_DID_SET_ROOT, (event) => {
|
|
58
|
+
didSetRoot(event.tag);
|
|
59
|
+
}));
|
|
60
|
+
return {
|
|
61
|
+
remove: () => {
|
|
62
|
+
subscriptions.forEach(subscription => subscription.remove());
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const actions = {};
|
|
67
|
+
const keyPairs = {};
|
|
68
|
+
let actionIdGenerator = 0;
|
|
69
|
+
let barButtonClickHandlerFactory = () => {
|
|
70
|
+
return (sceneId, value) => {
|
|
71
|
+
console.warn(`barButtonClickHandlerFactory 没有正确绑定`, sceneId, value);
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
function setBarButtonClickHandlerFactory(generator) {
|
|
75
|
+
barButtonClickHandlerFactory = generator;
|
|
76
|
+
}
|
|
77
|
+
function bindBarButtonClickEvent(sceneId, item) {
|
|
78
|
+
if (item === null || item === undefined) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return JSON.parse(JSON.stringify(item, (key, value) => {
|
|
82
|
+
if (key !== 'action' || typeof value !== 'function') {
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
const actionKey = 'ON_BAR_BUTTON_ITEM_CLICK_' + actionIdGenerator++;
|
|
86
|
+
if (!keyPairs[sceneId]) {
|
|
87
|
+
keyPairs[sceneId] = [];
|
|
88
|
+
}
|
|
89
|
+
keyPairs[sceneId].push(actionKey);
|
|
90
|
+
actions[actionKey] = value;
|
|
91
|
+
return actionKey;
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
function removeBarButtonClickEvent(sceneId) {
|
|
95
|
+
const keys = keyPairs[sceneId];
|
|
96
|
+
delete keyPairs[sceneId];
|
|
97
|
+
if (keys) {
|
|
98
|
+
keys.forEach(key => delete actions[key]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
listenBarButtonItemClick((sceneId, action) => {
|
|
102
|
+
const listeners = actions;
|
|
103
|
+
if (listeners[action]) {
|
|
104
|
+
const handler = barButtonClickHandlerFactory();
|
|
105
|
+
handler(sceneId, listeners[action]);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
export default {
|
|
109
|
+
listenStatusBarHeightChanged,
|
|
110
|
+
listenComponentResult,
|
|
111
|
+
listenComponentVisibility,
|
|
112
|
+
listenSwitchTab,
|
|
113
|
+
listenSetRoot,
|
|
114
|
+
bindBarButtonClickEvent,
|
|
115
|
+
removeBarButtonClickEvent,
|
|
116
|
+
setBarButtonClickHandlerFactory,
|
|
117
|
+
};
|
package/lib/Garden.d.ts
CHANGED
|
@@ -1,70 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ShadowImage {
|
|
3
|
-
image?: ImageSource;
|
|
4
|
-
color?: Color;
|
|
5
|
-
}
|
|
6
|
-
export interface Style {
|
|
7
|
-
screenBackgroundColor?: Color;
|
|
8
|
-
topBarStyle?: BarStyle;
|
|
9
|
-
topBarColor?: Color;
|
|
10
|
-
topBarColorDarkContent?: Color;
|
|
11
|
-
topBarColorLightContent?: Color;
|
|
12
|
-
statusBarColorAndroid?: Color;
|
|
13
|
-
navigationBarColorAndroid?: Color;
|
|
14
|
-
hideBackTitleIOS?: boolean;
|
|
15
|
-
elevationAndroid?: number;
|
|
16
|
-
shadowImage?: ShadowImage;
|
|
17
|
-
backIcon?: ImageSource;
|
|
18
|
-
topBarTintColor?: Color;
|
|
19
|
-
topBarTintColorDarkContent?: Color;
|
|
20
|
-
topBarTintColorLightContent?: Color;
|
|
21
|
-
titleTextColor?: Color;
|
|
22
|
-
titleTextColorDarkContent?: Color;
|
|
23
|
-
titleTextColorLightContent?: Color;
|
|
24
|
-
titleTextSize?: number;
|
|
25
|
-
titleAlignmentAndroid?: TitleAlignment;
|
|
26
|
-
barButtonItemTextSize?: number;
|
|
27
|
-
swipeBackEnabledAndroid?: boolean;
|
|
28
|
-
splitTopBarTransitionIOS?: boolean;
|
|
29
|
-
scrimAlphaAndroid?: number;
|
|
30
|
-
displayCutoutWhenLandscapeAndroid?: boolean;
|
|
31
|
-
tabBarColor?: Color;
|
|
32
|
-
tabBarShadowImage?: ShadowImage;
|
|
33
|
-
tabBarItemColor?: Color;
|
|
34
|
-
tabBarUnselectedItemColor?: Color;
|
|
35
|
-
tabBarBadgeColor?: Color;
|
|
36
|
-
}
|
|
37
|
-
export declare type TabBarStyle = Pick<Style, 'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'>;
|
|
38
|
-
export interface TabBadge {
|
|
39
|
-
index: number;
|
|
40
|
-
text?: string;
|
|
41
|
-
hidden: boolean;
|
|
42
|
-
dot?: boolean;
|
|
43
|
-
}
|
|
44
|
-
export interface TabItemInfo {
|
|
45
|
-
index: number;
|
|
46
|
-
title?: string;
|
|
47
|
-
badge?: {
|
|
48
|
-
text?: string;
|
|
49
|
-
hidden: boolean;
|
|
50
|
-
dot?: boolean;
|
|
51
|
-
};
|
|
52
|
-
icon?: {
|
|
53
|
-
selected: ImageSource;
|
|
54
|
-
unselected?: ImageSource;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export interface TabIcon {
|
|
58
|
-
index: number;
|
|
59
|
-
icon: ImageSource;
|
|
60
|
-
unselectedIcon?: ImageSource;
|
|
61
|
-
}
|
|
1
|
+
import { BarButtonItem, DefaultOptions, NavigationOption, TabBarStyle, TabItemInfo, TitleItem } from './Options';
|
|
62
2
|
declare type Nullable<T> = {
|
|
63
3
|
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P];
|
|
64
4
|
};
|
|
65
5
|
export declare class Garden {
|
|
66
6
|
sceneId: string;
|
|
67
|
-
static setStyle(style?:
|
|
7
|
+
static setStyle(style?: DefaultOptions): void;
|
|
68
8
|
static statusBarHeight: number;
|
|
69
9
|
static toolbarHeight: number;
|
|
70
10
|
static topBarHeight: number;
|
|
@@ -77,8 +17,6 @@ export declare class Garden {
|
|
|
77
17
|
updateOptions(options: NavigationOption): void;
|
|
78
18
|
updateTabBar(options: TabBarStyle): void;
|
|
79
19
|
setTabItem(item: TabItemInfo | TabItemInfo[]): void;
|
|
80
|
-
setTabIcon(icon: TabIcon | TabIcon[]): void;
|
|
81
|
-
setTabBadge(badge: TabBadge | TabBadge[]): void;
|
|
82
20
|
setMenuInteractive(enabled: boolean): void;
|
|
83
21
|
}
|
|
84
22
|
export {};
|
package/lib/Garden.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const { STATUSBAR_HEIGHT,
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import GardenModule from './GardenModule';
|
|
3
|
+
import Event from './Event';
|
|
4
|
+
const { STATUSBAR_HEIGHT, TOOLBAR_HEIGHT } = GardenModule.getConstants();
|
|
5
5
|
if (Platform.OS === 'ios') {
|
|
6
|
-
|
|
7
|
-
GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
6
|
+
Event.listenStatusBarHeightChanged(statusBarHeight => {
|
|
8
7
|
Garden.statusBarHeight = statusBarHeight;
|
|
9
8
|
Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT;
|
|
10
9
|
});
|
|
@@ -22,19 +21,19 @@ export class Garden {
|
|
|
22
21
|
}
|
|
23
22
|
// --------------- instance method --------------
|
|
24
23
|
setLeftBarButtonItem(buttonItem) {
|
|
25
|
-
const options =
|
|
24
|
+
const options = Event.bindBarButtonClickEvent(this.sceneId, buttonItem);
|
|
26
25
|
GardenModule.setLeftBarButtonItem(this.sceneId, options);
|
|
27
26
|
}
|
|
28
27
|
setRightBarButtonItem(buttonItem) {
|
|
29
|
-
const options =
|
|
28
|
+
const options = Event.bindBarButtonClickEvent(this.sceneId, buttonItem);
|
|
30
29
|
GardenModule.setRightBarButtonItem(this.sceneId, options);
|
|
31
30
|
}
|
|
32
31
|
setLeftBarButtonItems(buttonItems) {
|
|
33
|
-
const options =
|
|
32
|
+
const options = Event.bindBarButtonClickEvent(this.sceneId, buttonItems);
|
|
34
33
|
GardenModule.setLeftBarButtonItems(this.sceneId, options);
|
|
35
34
|
}
|
|
36
35
|
setRightBarButtonItems(buttonItems) {
|
|
37
|
-
const options =
|
|
36
|
+
const options = Event.bindBarButtonClickEvent(this.sceneId, buttonItems);
|
|
38
37
|
GardenModule.setRightBarButtonItems(this.sceneId, options);
|
|
39
38
|
}
|
|
40
39
|
setTitleItem(titleItem) {
|
|
@@ -52,43 +51,6 @@ export class Garden {
|
|
|
52
51
|
}
|
|
53
52
|
GardenModule.setTabItem(this.sceneId, item);
|
|
54
53
|
}
|
|
55
|
-
setTabIcon(icon) {
|
|
56
|
-
console.warn(`Garden#setTabIcon is deprecated, use Garden#setTabItem instead.`);
|
|
57
|
-
if (!Array.isArray(icon)) {
|
|
58
|
-
icon = [icon];
|
|
59
|
-
}
|
|
60
|
-
const icons = icon;
|
|
61
|
-
const items = [];
|
|
62
|
-
for (const i of icons) {
|
|
63
|
-
items.push({
|
|
64
|
-
index: i.index,
|
|
65
|
-
icon: {
|
|
66
|
-
selected: i.icon,
|
|
67
|
-
unselected: i.unselectedIcon,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
this.setTabItem(items);
|
|
72
|
-
}
|
|
73
|
-
setTabBadge(badge) {
|
|
74
|
-
console.warn(`Garden#setTabBadge is deprecated, use Garden#setTabItem instead.`);
|
|
75
|
-
if (!Array.isArray(badge)) {
|
|
76
|
-
badge = [badge];
|
|
77
|
-
}
|
|
78
|
-
const badges = badge;
|
|
79
|
-
const items = [];
|
|
80
|
-
for (const b of badges) {
|
|
81
|
-
items.push({
|
|
82
|
-
index: b.index,
|
|
83
|
-
badge: {
|
|
84
|
-
hidden: b.hidden,
|
|
85
|
-
text: b.text,
|
|
86
|
-
dot: b.dot,
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
this.setTabItem(items);
|
|
91
|
-
}
|
|
92
54
|
setMenuInteractive(enabled) {
|
|
93
55
|
GardenModule.setMenuInteractive(this.sceneId, enabled);
|
|
94
56
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NativeModule } from 'react-native';
|
|
2
|
+
interface GardenModule extends NativeModule {
|
|
3
|
+
getConstants: () => {
|
|
4
|
+
TOOLBAR_HEIGHT: number;
|
|
5
|
+
STATUSBAR_HEIGHT: number;
|
|
6
|
+
EVENT_STATUSBAR_FRAME_CHANGE: string;
|
|
7
|
+
};
|
|
8
|
+
setStyle: (style: object) => void;
|
|
9
|
+
setTitleItem: (sceneId: string, item: object) => void;
|
|
10
|
+
setLeftBarButtonItem: (sceneId: string, item: object | null) => void;
|
|
11
|
+
setRightBarButtonItem: (sceneId: string, item: object | null) => void;
|
|
12
|
+
setLeftBarButtonItems: (sceneId: string, item: object | null) => void;
|
|
13
|
+
setRightBarButtonItems: (sceneId: string, item: object | null) => void;
|
|
14
|
+
updateOptions: (sceneId: string, options: object) => void;
|
|
15
|
+
updateTabBar: (sceneId: string, item: object) => void;
|
|
16
|
+
setTabItem: (sceneId: string, item: object) => void;
|
|
17
|
+
setMenuInteractive: (sceneId: string, enabled: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const GardenModule: GardenModule;
|
|
20
|
+
export default GardenModule;
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { Route, RouteGraph } from './Route';
|
|
2
|
+
declare function getConstants(): {
|
|
3
|
+
RESULT_OK: number;
|
|
4
|
+
RESULT_CANCEL: number;
|
|
5
|
+
};
|
|
6
|
+
declare function startRegisterReactComponent(): void;
|
|
7
|
+
declare function endRegisterReactComponent(): void;
|
|
8
|
+
declare function registerReactComponent(appKey: string, options: object): void;
|
|
9
|
+
declare function signalFirstRenderComplete(sceneId: string): void;
|
|
10
|
+
declare function setResult(sceneId: string, resultCode: number, data: object | null): void;
|
|
11
|
+
declare function setRoot(layout: object, sticky: boolean, tag: number): void;
|
|
12
|
+
declare function dispatch(sceneId: string, action: string, params: object): Promise<boolean>;
|
|
13
|
+
declare function currentTab(sceneId: string): Promise<number>;
|
|
14
|
+
declare function isStackRoot(sceneId: string): Promise<boolean>;
|
|
15
|
+
declare function findSceneIdByModuleName(moduleName: string): Promise<string | null>;
|
|
16
|
+
declare function currentRoute(): Promise<Route>;
|
|
17
|
+
declare function routeGraph(): Promise<RouteGraph[]>;
|
|
18
|
+
declare const _default: {
|
|
19
|
+
getConstants: typeof getConstants;
|
|
20
|
+
startRegisterReactComponent: typeof startRegisterReactComponent;
|
|
21
|
+
endRegisterReactComponent: typeof endRegisterReactComponent;
|
|
22
|
+
registerReactComponent: typeof registerReactComponent;
|
|
23
|
+
signalFirstRenderComplete: typeof signalFirstRenderComplete;
|
|
24
|
+
setResult: typeof setResult;
|
|
25
|
+
setRoot: typeof setRoot;
|
|
26
|
+
dispatch: typeof dispatch;
|
|
27
|
+
currentTab: typeof currentTab;
|
|
28
|
+
isStackRoot: typeof isStackRoot;
|
|
29
|
+
findSceneIdByModuleName: typeof findSceneIdByModuleName;
|
|
30
|
+
currentRoute: typeof currentRoute;
|
|
31
|
+
routeGraph: typeof routeGraph;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|