@onekeyfe/react-native-bottom-tabs 6.7.0-20 → 6.7.0-22
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/build.gradle +1 -1
- package/android/src/main/java/com/onekey/bottomtabs/BottomBarBlurRenderer.kt +50 -30
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +82 -11
- package/android/src/main/java/com/onekey/bottomtabs/SharedSvgDecoder.kt +51 -0
- package/docs/SPEC.md +69 -18
- package/ios/RCTBottomAccessoryContainerView.swift +2 -0
- package/ios/RCTBottomTabsContainerView.swift +216 -12
- package/ios/SVG/SvgDecoder.mm +7 -3
- package/ios/TabBarFontSize.swift +2 -0
- package/lib/module/BottomAccessoryViewNativeComponent.ts +10 -10
- package/lib/module/BottomTabs.js +77 -53
- package/lib/module/BottomTabsDrawerNativeComponent.ts +12 -12
- package/lib/module/BottomTabsNativeComponent.ts +22 -23
- package/lib/typescript/src/BottomAccessoryView.d.ts +1 -1
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +6 -7
- package/lib/typescript/src/BottomTabs.d.ts +12 -6
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.d.ts +8 -9
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.web.d.ts +1 -1
- package/lib/typescript/src/BottomTabsNativeComponent.d.ts +15 -16
- package/lib/typescript/src/DelayedFreeze.d.ts +1 -1
- package/lib/typescript/src/SceneMap.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +6 -2
- package/package.json +5 -4
- package/react-native-bottom-tabs.podspec +2 -0
- package/src/BottomAccessoryViewNativeComponent.ts +10 -10
- package/src/BottomTabs.tsx +111 -54
- package/src/BottomTabsDrawerNativeComponent.ts +12 -12
- package/src/BottomTabsNativeComponent.ts +22 -23
- package/src/index.tsx +7 -1
- package/src/types.ts +10 -2
- package/ios/SVG/CoreSVG.h +0 -13
- package/ios/SVG/CoreSVG.mm +0 -177
package/src/types.ts
CHANGED
|
@@ -5,6 +5,14 @@ export type IconSource = string | ImageSourcePropType;
|
|
|
5
5
|
|
|
6
6
|
export type AppleIcon = { sfSymbol: SFSymbol };
|
|
7
7
|
|
|
8
|
+
export type NamedIcon = { iconName: string };
|
|
9
|
+
|
|
10
|
+
export type BottomTabIconSource =
|
|
11
|
+
| ImageSourcePropType
|
|
12
|
+
| AppleIcon
|
|
13
|
+
| NamedIcon
|
|
14
|
+
| string;
|
|
15
|
+
|
|
8
16
|
export type TabRole = 'search';
|
|
9
17
|
|
|
10
18
|
// 'leading' and 'trailing' mean a vertical tab bar on that edge.
|
|
@@ -17,8 +25,8 @@ export type BaseRoute = {
|
|
|
17
25
|
badgeBackgroundColor?: string;
|
|
18
26
|
badgeTextColor?: string;
|
|
19
27
|
lazy?: boolean;
|
|
20
|
-
focusedIcon?:
|
|
21
|
-
unfocusedIcon?:
|
|
28
|
+
focusedIcon?: BottomTabIconSource;
|
|
29
|
+
unfocusedIcon?: BottomTabIconSource;
|
|
22
30
|
activeTintColor?: string;
|
|
23
31
|
hidden?: boolean;
|
|
24
32
|
testID?: string;
|
package/ios/SVG/CoreSVG.h
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
typedef UIImage PlatformImage;
|
|
3
|
-
|
|
4
|
-
@interface CoreSVGWrapper : NSObject
|
|
5
|
-
|
|
6
|
-
+ (instancetype)shared;
|
|
7
|
-
|
|
8
|
-
- (PlatformImage *)imageFromSVGData:(NSData *)data;
|
|
9
|
-
|
|
10
|
-
+ (BOOL)isSVGData:(NSData *)data;
|
|
11
|
-
+ (BOOL)supportsVectorSVGImage;
|
|
12
|
-
|
|
13
|
-
@end
|
package/ios/SVG/CoreSVG.mm
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
#import "CoreSVG.h"
|
|
2
|
-
#import <dlfcn.h>
|
|
3
|
-
#import <objc/runtime.h>
|
|
4
|
-
|
|
5
|
-
#define kSVGTagEnd @"</svg>"
|
|
6
|
-
|
|
7
|
-
typedef struct CF_BRIDGED_TYPE(id) CGSVGDocument *CGSVGDocumentRef;
|
|
8
|
-
|
|
9
|
-
static CGSVGDocumentRef (*CoreSVGDocumentRetain)(CGSVGDocumentRef);
|
|
10
|
-
static void (*CoreSVGDocumentRelease)(CGSVGDocumentRef);
|
|
11
|
-
static CGSVGDocumentRef (*CoreSVGDocumentCreateFromData)(CFDataRef data, CFDictionaryRef options);
|
|
12
|
-
static void (*CoreSVGContextDrawSVGDocument)(CGContextRef context, CGSVGDocumentRef document);
|
|
13
|
-
static CGSize (*CoreSVGDocumentGetCanvasSize)(CGSVGDocumentRef document);
|
|
14
|
-
|
|
15
|
-
#if !TARGET_OS_OSX
|
|
16
|
-
static SEL CoreSVGImageWithDocumentSEL = NULL;
|
|
17
|
-
static SEL CoreSVGDocumentSEL = NULL;
|
|
18
|
-
#endif
|
|
19
|
-
#if TARGET_OS_OSX
|
|
20
|
-
static Class CoreSVGImageRepClass = NULL;
|
|
21
|
-
static Ivar CoreSVGImageRepDocumentIvar = NULL;
|
|
22
|
-
#endif
|
|
23
|
-
|
|
24
|
-
static inline NSString *Base64DecodedString(NSString *base64String) {
|
|
25
|
-
NSData *data = [[NSData alloc] initWithBase64EncodedString:base64String options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
|
26
|
-
if (!data) {
|
|
27
|
-
return nil;
|
|
28
|
-
}
|
|
29
|
-
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@implementation CoreSVGWrapper
|
|
33
|
-
|
|
34
|
-
+ (instancetype)shared {
|
|
35
|
-
static dispatch_once_t onceToken;
|
|
36
|
-
static CoreSVGWrapper *wrapper;
|
|
37
|
-
dispatch_once(&onceToken, ^{
|
|
38
|
-
wrapper = [[CoreSVGWrapper alloc] init];
|
|
39
|
-
});
|
|
40
|
-
return wrapper;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
+ (void)initialize {
|
|
44
|
-
CoreSVGDocumentRetain = (CGSVGDocumentRef (*)(CGSVGDocumentRef))dlsym(RTLD_DEFAULT, Base64DecodedString(@"Q0dTVkdEb2N1bWVudFJldGFpbg==").UTF8String);
|
|
45
|
-
CoreSVGDocumentRelease = (void (*)(CGSVGDocumentRef))dlsym(RTLD_DEFAULT, Base64DecodedString(@"Q0dTVkdEb2N1bWVudFJlbGVhc2U=").UTF8String);
|
|
46
|
-
CoreSVGDocumentCreateFromData = (CGSVGDocumentRef (*)(CFDataRef data, CFDictionaryRef options))dlsym(RTLD_DEFAULT, Base64DecodedString(@"Q0dTVkdEb2N1bWVudENyZWF0ZUZyb21EYXRh").UTF8String);
|
|
47
|
-
CoreSVGContextDrawSVGDocument = (void (*)(CGContextRef context, CGSVGDocumentRef document))dlsym(RTLD_DEFAULT, Base64DecodedString(@"Q0dDb250ZXh0RHJhd1NWR0RvY3VtZW50").UTF8String);
|
|
48
|
-
CoreSVGDocumentGetCanvasSize = (CGSize (*)(CGSVGDocumentRef document))dlsym(RTLD_DEFAULT, Base64DecodedString(@"Q0dTVkdEb2N1bWVudEdldENhbnZhc1NpemU=").UTF8String);
|
|
49
|
-
|
|
50
|
-
#if !TARGET_OS_OSX
|
|
51
|
-
CoreSVGImageWithDocumentSEL = NSSelectorFromString(Base64DecodedString(@"X2ltYWdlV2l0aENHU1ZHRG9jdW1lbnQ6"));
|
|
52
|
-
CoreSVGDocumentSEL = NSSelectorFromString(Base64DecodedString(@"X0NHU1ZHRG9jdW1lbnQ="));
|
|
53
|
-
#endif
|
|
54
|
-
#if TARGET_OS_OSX
|
|
55
|
-
CoreSVGImageRepClass = NSClassFromString(Base64DecodedString(@"X05TU1ZHSW1hZ2VSZXA="));
|
|
56
|
-
if (CoreSVGImageRepClass) {
|
|
57
|
-
CoreSVGImageRepDocumentIvar = class_getInstanceVariable(CoreSVGImageRepClass, Base64DecodedString(@"X2RvY3VtZW50").UTF8String);
|
|
58
|
-
}
|
|
59
|
-
#endif
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
- (PlatformImage *)imageFromSVGData:(NSData *)data {
|
|
63
|
-
if (!data) {
|
|
64
|
-
return nil;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (![self.class supportsVectorSVGImage]) {
|
|
68
|
-
return nil;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return [self createVectorSVGWithData:data];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
- (PlatformImage *)createVectorSVGWithData:(NSData *)data {
|
|
75
|
-
if (!data) return nil;
|
|
76
|
-
|
|
77
|
-
PlatformImage *image;
|
|
78
|
-
|
|
79
|
-
#if TARGET_OS_OSX
|
|
80
|
-
if (!CoreSVGImageRepClass) {
|
|
81
|
-
return nil;
|
|
82
|
-
}
|
|
83
|
-
Class imageRepClass = CoreSVGImageRepClass;
|
|
84
|
-
NSImageRep *imageRep = [[imageRepClass alloc] initWithData:data];
|
|
85
|
-
if (!imageRep) {
|
|
86
|
-
return nil;
|
|
87
|
-
}
|
|
88
|
-
image = [[NSImage alloc] initWithSize:imageRep.size];
|
|
89
|
-
[image addRepresentation:imageRep];
|
|
90
|
-
#else
|
|
91
|
-
if (!CoreSVGDocumentCreateFromData || !CoreSVGDocumentRelease) {
|
|
92
|
-
return nil;
|
|
93
|
-
}
|
|
94
|
-
CGSVGDocumentRef document = CoreSVGDocumentCreateFromData((__bridge CFDataRef)data, NULL);
|
|
95
|
-
|
|
96
|
-
if (!document) {
|
|
97
|
-
return nil;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
image = ((UIImage *(*)(id,SEL,CGSVGDocumentRef))[UIImage.class methodForSelector:CoreSVGImageWithDocumentSEL])(UIImage.class, CoreSVGImageWithDocumentSEL, document);
|
|
101
|
-
CoreSVGDocumentRelease(document);
|
|
102
|
-
#endif
|
|
103
|
-
|
|
104
|
-
#if TARGET_OS_OSX
|
|
105
|
-
// Test render to catch potential CoreSVG crashes on macOS
|
|
106
|
-
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
|
|
107
|
-
initWithBitmapDataPlanes:NULL
|
|
108
|
-
pixelsWide:1
|
|
109
|
-
pixelsHigh:1
|
|
110
|
-
bitsPerSample:8
|
|
111
|
-
samplesPerPixel:4
|
|
112
|
-
hasAlpha:YES
|
|
113
|
-
isPlanar:NO
|
|
114
|
-
colorSpaceName:NSCalibratedRGBColorSpace
|
|
115
|
-
bytesPerRow:0
|
|
116
|
-
bitsPerPixel:0];
|
|
117
|
-
|
|
118
|
-
NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithBitmapImageRep:bitmap];
|
|
119
|
-
[NSGraphicsContext saveGraphicsState];
|
|
120
|
-
[NSGraphicsContext setCurrentContext:context];
|
|
121
|
-
|
|
122
|
-
@try {
|
|
123
|
-
[image drawInRect:NSMakeRect(0, 0, 1, 1)];
|
|
124
|
-
} @catch (...) {
|
|
125
|
-
[NSGraphicsContext restoreGraphicsState];
|
|
126
|
-
return nil;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
[NSGraphicsContext restoreGraphicsState];
|
|
130
|
-
#else
|
|
131
|
-
// Test render to catch potential CoreSVG crashes
|
|
132
|
-
UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 1.0);
|
|
133
|
-
@try {
|
|
134
|
-
[image drawInRect:CGRectMake(0, 0, 1, 1)];
|
|
135
|
-
} @catch (...) {
|
|
136
|
-
UIGraphicsEndImageContext();
|
|
137
|
-
return nil;
|
|
138
|
-
}
|
|
139
|
-
UIGraphicsEndImageContext();
|
|
140
|
-
#endif
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return image;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
+ (BOOL)isSVGData:(NSData *)data {
|
|
147
|
-
if (!data) {
|
|
148
|
-
return NO;
|
|
149
|
-
}
|
|
150
|
-
// Check end with SVG tag
|
|
151
|
-
return [data rangeOfData:[kSVGTagEnd dataUsingEncoding:NSUTF8StringEncoding] options:NSDataSearchBackwards range: NSMakeRange(data.length - MIN(100, data.length), MIN(100, data.length))].location != NSNotFound;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
+ (BOOL)supportsVectorSVGImage {
|
|
155
|
-
static dispatch_once_t onceToken;
|
|
156
|
-
static BOOL supports;
|
|
157
|
-
dispatch_once(&onceToken, ^{
|
|
158
|
-
#if TARGET_OS_OSX
|
|
159
|
-
// macOS 10.15+ supports SVG built-in rendering, use selector to check is more accurate
|
|
160
|
-
if (CoreSVGImageRepClass) {
|
|
161
|
-
supports = YES;
|
|
162
|
-
} else {
|
|
163
|
-
supports = NO;
|
|
164
|
-
}
|
|
165
|
-
#else
|
|
166
|
-
// iOS 13+ supports SVG built-in rendering, use selector to check is more accurate
|
|
167
|
-
if ([UIImage respondsToSelector:CoreSVGImageWithDocumentSEL]) {
|
|
168
|
-
supports = YES;
|
|
169
|
-
} else {
|
|
170
|
-
supports = NO;
|
|
171
|
-
}
|
|
172
|
-
#endif
|
|
173
|
-
});
|
|
174
|
-
return supports;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@end
|