@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.
Files changed (33) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/onekey/bottomtabs/BottomBarBlurRenderer.kt +50 -30
  3. package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +82 -11
  4. package/android/src/main/java/com/onekey/bottomtabs/SharedSvgDecoder.kt +51 -0
  5. package/docs/SPEC.md +69 -18
  6. package/ios/RCTBottomAccessoryContainerView.swift +2 -0
  7. package/ios/RCTBottomTabsContainerView.swift +216 -12
  8. package/ios/SVG/SvgDecoder.mm +7 -3
  9. package/ios/TabBarFontSize.swift +2 -0
  10. package/lib/module/BottomAccessoryViewNativeComponent.ts +10 -10
  11. package/lib/module/BottomTabs.js +77 -53
  12. package/lib/module/BottomTabsDrawerNativeComponent.ts +12 -12
  13. package/lib/module/BottomTabsNativeComponent.ts +22 -23
  14. package/lib/typescript/src/BottomAccessoryView.d.ts +1 -1
  15. package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +6 -7
  16. package/lib/typescript/src/BottomTabs.d.ts +12 -6
  17. package/lib/typescript/src/BottomTabsDrawerNativeComponent.d.ts +8 -9
  18. package/lib/typescript/src/BottomTabsDrawerNativeComponent.web.d.ts +1 -1
  19. package/lib/typescript/src/BottomTabsNativeComponent.d.ts +15 -16
  20. package/lib/typescript/src/DelayedFreeze.d.ts +1 -1
  21. package/lib/typescript/src/SceneMap.d.ts +1 -1
  22. package/lib/typescript/src/index.d.ts +1 -1
  23. package/lib/typescript/src/types.d.ts +6 -2
  24. package/package.json +5 -4
  25. package/react-native-bottom-tabs.podspec +2 -0
  26. package/src/BottomAccessoryViewNativeComponent.ts +10 -10
  27. package/src/BottomTabs.tsx +111 -54
  28. package/src/BottomTabsDrawerNativeComponent.ts +12 -12
  29. package/src/BottomTabsNativeComponent.ts +22 -23
  30. package/src/index.tsx +7 -1
  31. package/src/types.ts +10 -2
  32. package/ios/SVG/CoreSVG.h +0 -13
  33. package/ios/SVG/CoreSVG.mm +0 -177
@@ -1,6 +1,71 @@
1
1
  import Foundation
2
2
  import UIKit
3
+ #if canImport(React)
3
4
  import React
5
+ #endif
6
+
7
+ @objc private protocol OneKeyNamedSVGBridgeProtocol: AnyObject {
8
+ @objc(cancelWithOwner:)
9
+ func cancel(owner: AnyObject)
10
+
11
+ @objc(requestWithOwner:name:color:width:height:scale:complete:)
12
+ func request(
13
+ owner: AnyObject,
14
+ name: String,
15
+ color: String,
16
+ width: Int,
17
+ height: Int,
18
+ scale: Double,
19
+ complete: @escaping (UIImage?) -> Void
20
+ )
21
+ }
22
+
23
+ /// Bridges to OneKeyNamedSVG.shared in OneKeyImage without importing the OneKeyImage
24
+ /// Swift module (which transitively imports NitroModules C++ headers).
25
+ private enum OneKeyNamedSVGLoader {
26
+ private static var bridge: OneKeyNamedSVGBridgeProtocol? {
27
+ guard let cls: AnyClass = NSClassFromString("OneKeyNamedSVGBridge")
28
+ ?? NSClassFromString("OneKeyImage.OneKeyNamedSVGBridge")
29
+ else {
30
+ return nil
31
+ }
32
+ let meta = cls as AnyObject
33
+ guard meta.responds(to: #selector(OneKeyNamedSVGBridgeProtocol.cancel(owner:))),
34
+ meta.responds(to: #selector(OneKeyNamedSVGBridgeProtocol.request(owner:name:color:width:height:scale:complete:)))
35
+ else {
36
+ return nil
37
+ }
38
+ return unsafeBitCast(meta, to: OneKeyNamedSVGBridgeProtocol.self)
39
+ }
40
+
41
+ static func cancel(owner: AnyObject) {
42
+ bridge?.cancel(owner: owner)
43
+ }
44
+
45
+ static func request(
46
+ owner: AnyObject,
47
+ name: String,
48
+ color: String,
49
+ width: Int,
50
+ height: Int,
51
+ scale: CGFloat,
52
+ complete: @escaping (UIImage?) -> Void
53
+ ) {
54
+ guard let bridge else {
55
+ complete(nil)
56
+ return
57
+ }
58
+ bridge.request(
59
+ owner: owner,
60
+ name: name,
61
+ color: color,
62
+ width: width,
63
+ height: height,
64
+ scale: Double(scale),
65
+ complete: complete
66
+ )
67
+ }
68
+ }
4
69
 
5
70
  // MARK: - Data types for props from JS
6
71
 
@@ -77,6 +142,10 @@ class RCTBottomTabsContainerView: UIView {
77
142
  private var loadedSideAccessoryIcon: UIImage?
78
143
  // Increments per icon load; a completion applies only to the latest one.
79
144
  private var sideAccessoryIconRequest = 0
145
+ private static let oneKeyIconSchemePrefix = "onekey-icon://"
146
+ private var iconRequestTokens: [Int: NSObject] = [:]
147
+ private var selectedIconRequestTokens: [Int: NSObject] = [:]
148
+ private var sideAccessoryRequestToken = NSObject()
80
149
  private var isSideAccessoryLayoutScheduled = false
81
150
  private static let sideAccessorySize: CGFloat = 48
82
151
  private static let sideAccessorySpacing: CGFloat = 12
@@ -188,6 +257,22 @@ class RCTBottomTabsContainerView: UIView {
188
257
  fatalError("init(coder:) has not been implemented")
189
258
  }
190
259
 
260
+ deinit {
261
+ for token in iconRequestTokens.values {
262
+ OneKeyNamedSVGLoader.cancel(owner: token)
263
+ }
264
+ for token in selectedIconRequestTokens.values {
265
+ OneKeyNamedSVGLoader.cancel(owner: token)
266
+ }
267
+ OneKeyNamedSVGLoader.cancel(owner: sideAccessoryRequestToken)
268
+ }
269
+
270
+ private static func oneKeyIconName(from uri: String) -> String? {
271
+ guard uri.hasPrefix(oneKeyIconSchemePrefix) else { return nil }
272
+ let name = String(uri.dropFirst(oneKeyIconSchemePrefix.count)).trimmingCharacters(in: .whitespacesAndNewlines)
273
+ return name.isEmpty ? nil : name
274
+ }
275
+
191
276
  override func didAddSubview(_ subview: UIView) {
192
277
  super.didAddSubview(subview)
193
278
  if let tbcView = tabBarController?.view, subview !== tbcView {
@@ -217,7 +302,7 @@ class RCTBottomTabsContainerView: UIView {
217
302
  /// Where the system draws the tab bar: "bottom", or "leading"/"trailing" for
218
303
  /// the vertical bar some devices (iPhone Duo) place in a side strip.
219
304
  private func currentTabBarPlacement() -> String {
220
- #if compiler(>=6.4)
305
+ #if compiler(>=6.4) && !targetEnvironment(macCatalyst)
221
306
  if #available(iOS 27.1, *), let tbc = tabBarController {
222
307
  switch tbc.traitCollection.verticalBarEdge {
223
308
  case .leading: return "leading"
@@ -230,7 +315,7 @@ class RCTBottomTabsContainerView: UIView {
230
315
  }
231
316
 
232
317
  private func registerVerticalBarTraitChanges(_ tbc: UITabBarController) {
233
- #if compiler(>=6.4)
318
+ #if compiler(>=6.4) && !targetEnvironment(macCatalyst)
234
319
  if #available(iOS 27.1, *) {
235
320
  tbc.registerForTraitChanges(
236
321
  UITraitCollection.systemTraitsAffectingVerticalBarEdge
@@ -340,6 +425,7 @@ class RCTBottomTabsContainerView: UIView {
340
425
  private func loadSideAccessoryIcon() {
341
426
  sideAccessoryIconRequest += 1
342
427
  let request = sideAccessoryIconRequest
428
+ OneKeyNamedSVGLoader.cancel(owner: sideAccessoryRequestToken)
343
429
  // Drop the previous icon so a slower or failed load never leaves it shown
344
430
  // for the new source.
345
431
  if loadedSideAccessoryIcon != nil {
@@ -347,7 +433,37 @@ class RCTBottomTabsContainerView: UIView {
347
433
  scheduleSideAccessoryLayout()
348
434
  }
349
435
  let source = sideAccessoryIcon.map { IconSource(dict: $0) }
350
- guard let source, let url = URL(string: source.uri) else { return }
436
+ guard let source, !source.uri.isEmpty else { return }
437
+ if let iconName = Self.oneKeyIconName(from: source.uri) {
438
+ let token = NSObject()
439
+ sideAccessoryRequestToken = token
440
+ let scale = max(1.0, window?.screen.scale ?? UIScreen.main.scale)
441
+ let pxW = max(1, Int(ceil(iconSize.width * scale)))
442
+ let pxH = max(1, Int(ceil(iconSize.height * scale)))
443
+ OneKeyNamedSVGLoader.request(
444
+ owner: token,
445
+ name: iconName,
446
+ color: "rgba(0,0,0,1)",
447
+ width: pxW,
448
+ height: pxH,
449
+ scale: scale
450
+ ) { [weak self] image in
451
+ guard let self,
452
+ request == self.sideAccessoryIconRequest,
453
+ self.sideAccessoryRequestToken === token,
454
+ let image else { return }
455
+ let scaledImage: UIImage
456
+ if let cgImage = image.cgImage {
457
+ scaledImage = UIImage(cgImage: cgImage, scale: scale, orientation: .up)
458
+ } else {
459
+ scaledImage = image
460
+ }
461
+ self.loadedSideAccessoryIcon = scaledImage.withRenderingMode(.alwaysTemplate)
462
+ self.scheduleSideAccessoryLayout()
463
+ }
464
+ return
465
+ }
466
+ guard let url = URL(string: source.uri) else { return }
351
467
  // The image loader arrives with the first state update; setImageLoader
352
468
  // calls this again.
353
469
  guard let imageLoader else { return }
@@ -755,21 +871,69 @@ class RCTBottomTabsContainerView: UIView {
755
871
 
756
872
  @objc func setImageLoader(_ loader: RCTImageLoaderProtocol) {
757
873
  self.imageLoader = loader
758
- loadIconsFromSources()
759
- loadSelectedIconsFromSources()
760
- loadSideAccessoryIcon()
874
+ let iconSources = (icons ?? []).map { IconSource(dict: $0) }
875
+ if iconSources.contains(where: { !$0.uri.isEmpty && Self.oneKeyIconName(from: $0.uri) == nil }) {
876
+ loadIconsFromSources()
877
+ }
878
+ let selectedIconSources = (selectedIcons ?? []).map { IconSource(dict: $0) }
879
+ if selectedIconSources.contains(where: { !$0.uri.isEmpty && Self.oneKeyIconName(from: $0.uri) == nil }) {
880
+ loadSelectedIconsFromSources()
881
+ }
882
+ if let sideSource = sideAccessoryIcon.map({ IconSource(dict: $0) }),
883
+ !sideSource.uri.isEmpty,
884
+ Self.oneKeyIconName(from: sideSource.uri) == nil {
885
+ loadSideAccessoryIcon()
886
+ }
761
887
  }
762
888
 
763
889
  private func loadIconsFromSources() {
764
- guard let imageLoader, let iconDicts = icons else { return }
890
+ guard let iconDicts = icons else { return }
765
891
 
766
892
  let iconSources = iconDicts.map { IconSource(dict: $0) }
893
+ let imageLoader = self.imageLoader
894
+
895
+ for staleIndex in iconRequestTokens.keys where staleIndex >= iconSources.count {
896
+ if let previous = iconRequestTokens.removeValue(forKey: staleIndex) {
897
+ OneKeyNamedSVGLoader.cancel(owner: previous)
898
+ }
899
+ }
767
900
 
768
901
  for (index, source) in iconSources.enumerated() {
902
+ if let previous = iconRequestTokens.removeValue(forKey: index) {
903
+ OneKeyNamedSVGLoader.cancel(owner: previous)
904
+ }
769
905
  guard !source.uri.isEmpty else { continue }
906
+ let token = NSObject()
907
+ iconRequestTokens[index] = token
908
+
909
+ if let iconName = Self.oneKeyIconName(from: source.uri) {
910
+ let scale = max(1.0, window?.screen.scale ?? UIScreen.main.scale)
911
+ let pxW = max(1, Int(ceil(iconSize.width * scale)))
912
+ let pxH = max(1, Int(ceil(iconSize.height * scale)))
913
+ OneKeyNamedSVGLoader.request(
914
+ owner: token,
915
+ name: iconName,
916
+ color: "rgba(0,0,0,1)",
917
+ width: pxW,
918
+ height: pxH,
919
+ scale: scale
920
+ ) { [weak self] image in
921
+ guard let self,
922
+ self.iconRequestTokens[index] === token,
923
+ let image else { return }
924
+ let scaledImage: UIImage
925
+ if let cgImage = image.cgImage {
926
+ scaledImage = UIImage(cgImage: cgImage, scale: scale, orientation: .up)
927
+ } else {
928
+ scaledImage = image
929
+ }
930
+ self.loadedIcons[index] = scaledImage
931
+ self.rebuildViewControllers()
932
+ }
933
+ continue
934
+ }
770
935
 
771
- let url = URL(string: source.uri)
772
- guard let url else { continue }
936
+ guard let imageLoader, let url = URL(string: source.uri) else { continue }
773
937
 
774
938
  let request = URLRequest(url: url)
775
939
  let size = CGSize(width: source.width, height: source.height)
@@ -787,6 +951,7 @@ class RCTBottomTabsContainerView: UIView {
787
951
  if error != nil { return }
788
952
  guard let image, let self else { return }
789
953
  DispatchQueue.main.async {
954
+ guard self.iconRequestTokens[index] === token else { return }
790
955
  self.loadedIcons[index] = image.resizeImageTo(size: self.iconSize)
791
956
  self.rebuildViewControllers()
792
957
  }
@@ -795,15 +960,53 @@ class RCTBottomTabsContainerView: UIView {
795
960
  }
796
961
 
797
962
  private func loadSelectedIconsFromSources() {
798
- guard let imageLoader, let iconDicts = selectedIcons else { return }
963
+ guard let iconDicts = selectedIcons else { return }
799
964
 
800
965
  let iconSources = iconDicts.map { IconSource(dict: $0) }
966
+ let imageLoader = self.imageLoader
967
+
968
+ for staleIndex in selectedIconRequestTokens.keys where staleIndex >= iconSources.count {
969
+ if let previous = selectedIconRequestTokens.removeValue(forKey: staleIndex) {
970
+ OneKeyNamedSVGLoader.cancel(owner: previous)
971
+ }
972
+ }
801
973
 
802
974
  for (index, source) in iconSources.enumerated() {
975
+ if let previous = selectedIconRequestTokens.removeValue(forKey: index) {
976
+ OneKeyNamedSVGLoader.cancel(owner: previous)
977
+ }
803
978
  guard !source.uri.isEmpty else { continue }
979
+ let token = NSObject()
980
+ selectedIconRequestTokens[index] = token
981
+
982
+ if let iconName = Self.oneKeyIconName(from: source.uri) {
983
+ let scale = max(1.0, window?.screen.scale ?? UIScreen.main.scale)
984
+ let pxW = max(1, Int(ceil(iconSize.width * scale)))
985
+ let pxH = max(1, Int(ceil(iconSize.height * scale)))
986
+ OneKeyNamedSVGLoader.request(
987
+ owner: token,
988
+ name: iconName,
989
+ color: "rgba(0,0,0,1)",
990
+ width: pxW,
991
+ height: pxH,
992
+ scale: scale
993
+ ) { [weak self] image in
994
+ guard let self,
995
+ self.selectedIconRequestTokens[index] === token,
996
+ let image else { return }
997
+ let scaledImage: UIImage
998
+ if let cgImage = image.cgImage {
999
+ scaledImage = UIImage(cgImage: cgImage, scale: scale, orientation: .up)
1000
+ } else {
1001
+ scaledImage = image
1002
+ }
1003
+ self.loadedSelectedIcons[index] = scaledImage
1004
+ self.rebuildViewControllers()
1005
+ }
1006
+ continue
1007
+ }
804
1008
 
805
- let url = URL(string: source.uri)
806
- guard let url else { continue }
1009
+ guard let imageLoader, let url = URL(string: source.uri) else { continue }
807
1010
 
808
1011
  let request = URLRequest(url: url)
809
1012
  let size = CGSize(width: source.width, height: source.height)
@@ -821,6 +1024,7 @@ class RCTBottomTabsContainerView: UIView {
821
1024
  if error != nil { return }
822
1025
  guard let image, let self else { return }
823
1026
  DispatchQueue.main.async {
1027
+ guard self.selectedIconRequestTokens[index] === token else { return }
824
1028
  self.loadedSelectedIcons[index] = image.resizeImageTo(size: self.iconSize)
825
1029
  self.rebuildViewControllers()
826
1030
  }
@@ -1,5 +1,5 @@
1
1
  #import "SvgDecoder.h"
2
- #import "CoreSVG.h"
2
+ #import <OneKeyImage/OneKeyImageCoderBridge.h>
3
3
 
4
4
  @implementation SvgDecoder
5
5
 
@@ -7,7 +7,11 @@ RCT_EXPORT_MODULE()
7
7
 
8
8
  - (BOOL)canDecodeImageData:(NSData *)imageData
9
9
  {
10
- return [CoreSVGWrapper isSVGData:imageData];
10
+ if (!imageData) return NO;
11
+ // Preserve the existing global React image-decoder selection boundary.
12
+ return [imageData rangeOfData:[@"</svg>" dataUsingEncoding:NSUTF8StringEncoding]
13
+ options:NSDataSearchBackwards
14
+ range:NSMakeRange(imageData.length - MIN(100, imageData.length), MIN(100, imageData.length))].location != NSNotFound;
11
15
  }
12
16
 
13
17
  - (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData
@@ -16,7 +20,7 @@ RCT_EXPORT_MODULE()
16
20
  resizeMode:(RCTResizeMode)resizeMode
17
21
  completionHandler:(RCTImageLoaderCompletionBlock)completionHandler
18
22
  {
19
- UIImage *image = [CoreSVGWrapper.shared imageFromSVGData:imageData];
23
+ UIImage *image = [OneKeyImageCoderBridge decodeSVGData:imageData pixelSize:CGSizeZero];
20
24
 
21
25
  if (image) {
22
26
  completionHandler(nil, image);
@@ -1,4 +1,6 @@
1
+ #if canImport(React)
1
2
  import React
3
+ #endif
2
4
  import UIKit
3
5
 
4
6
  enum TabBarFontSize {
@@ -1,13 +1,13 @@
1
- import { codegenNativeComponent } from 'react-native';
2
- import type { ViewProps } from 'react-native';
3
- import type {
4
- DirectEventHandler,
5
- Double,
6
- } from 'react-native/Libraries/Types/CodegenTypes';
1
+ import {
2
+ codegenNativeComponent,
3
+ type CodegenTypes,
4
+ type ViewProps,
5
+ } from 'react-native';
6
+
7
7
 
8
8
  export type OnNativeLayout = Readonly<{
9
- width: Double;
10
- height: Double;
9
+ width: CodegenTypes.Double;
10
+ height: CodegenTypes.Double;
11
11
  }>;
12
12
 
13
13
  export type OnPlacementChanged = Readonly<{
@@ -15,8 +15,8 @@ export type OnPlacementChanged = Readonly<{
15
15
  }>;
16
16
 
17
17
  export interface BottomAccessoryViewNativeProps extends ViewProps {
18
- onNativeLayout?: DirectEventHandler<OnNativeLayout>;
19
- onPlacementChanged?: DirectEventHandler<OnPlacementChanged>;
18
+ onNativeLayout?: CodegenTypes.DirectEventHandler<OnNativeLayout>;
19
+ onPlacementChanged?: CodegenTypes.DirectEventHandler<OnPlacementChanged>;
20
20
  }
21
21
 
22
22
  export default codegenNativeComponent<BottomAccessoryViewNativeProps>(
@@ -3,16 +3,83 @@
3
3
  import React, { useLayoutEffect, useRef } from "react";
4
4
  import { Image, Platform, StyleSheet, View, processColor } from "react-native";
5
5
  import { BottomTabBarHeightContext } from "./utils/BottomTabBarHeightContext.js";
6
-
7
- // eslint-disable-next-line @react-native/no-deep-imports
8
-
9
6
  import NativeBottomTabs from "./BottomTabsNativeComponent";
10
7
  import useLatestCallback from "use-latest-callback";
11
8
  import DelayedFreeze from "./DelayedFreeze.js";
12
9
  import NativeBottomTabsDrawer from "./BottomTabsDrawerNativeComponent";
13
10
  import { BottomAccessoryView } from "./BottomAccessoryView.js";
14
11
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- const isAppleSymbol = icon => icon?.sfSymbol;
12
+ const isAppleSymbol = icon => Boolean(typeof icon === "object" && icon !== null && "sfSymbol" in icon && typeof icon.sfSymbol === "string");
13
+ const ONEKEY_ICON_URI_PREFIX = "onekey-icon://";
14
+ export const resolveTabIconSource = icon => {
15
+ if (!icon || isAppleSymbol(icon)) {
16
+ return {
17
+ uri: "",
18
+ width: 0,
19
+ height: 0,
20
+ scale: 1
21
+ };
22
+ }
23
+ if (typeof icon === "string") {
24
+ const trimmed = icon.trim();
25
+ if (!trimmed) {
26
+ return {
27
+ uri: "",
28
+ width: 0,
29
+ height: 0,
30
+ scale: 1
31
+ };
32
+ }
33
+ if (trimmed.startsWith(ONEKEY_ICON_URI_PREFIX) || /^[A-Z][A-Za-z0-9]*$/.test(trimmed)) {
34
+ const uri = trimmed.startsWith(ONEKEY_ICON_URI_PREFIX) ? trimmed : `${ONEKEY_ICON_URI_PREFIX}${trimmed}`;
35
+ return {
36
+ uri,
37
+ width: 24,
38
+ height: 24,
39
+ scale: 1
40
+ };
41
+ }
42
+ icon = {
43
+ uri: trimmed
44
+ };
45
+ }
46
+ if (typeof icon === "object" && !Array.isArray(icon) && "iconName" in icon && typeof icon.iconName === "string") {
47
+ const trimmed = icon.iconName.trim();
48
+ if (!trimmed) {
49
+ return {
50
+ uri: "",
51
+ width: 0,
52
+ height: 0,
53
+ scale: 1
54
+ };
55
+ }
56
+ return {
57
+ uri: `${ONEKEY_ICON_URI_PREFIX}${trimmed}`,
58
+ width: 24,
59
+ height: 24,
60
+ scale: 1
61
+ };
62
+ }
63
+ if (typeof icon === "object" && !Array.isArray(icon) && "uri" in icon && typeof icon.uri === "string" && icon.uri.startsWith(ONEKEY_ICON_URI_PREFIX)) {
64
+ return {
65
+ uri: icon.uri,
66
+ width: typeof icon.width === "number" && icon.width > 0 ? icon.width : 24,
67
+ height: typeof icon.height === "number" && icon.height > 0 ? icon.height : 24,
68
+ scale: typeof icon.scale === "number" && icon.scale > 0 ? icon.scale : 1
69
+ };
70
+ }
71
+ const resolved = Image.resolveAssetSource(icon);
72
+ return {
73
+ uri: resolved?.uri ?? "",
74
+ width: resolved?.width ?? 0,
75
+ height: resolved?.height ?? 0,
76
+ scale: resolved?.scale ?? 1
77
+ };
78
+ };
79
+ const defaultGetIcon = ({
80
+ route,
81
+ focused
82
+ }) => route.unfocusedIcon ? focused ? route.focusedIcon : route.unfocusedIcon : route.focusedIcon;
16
83
  const ANDROID_MAX_TABS = 100;
17
84
  const BottomTabs = ({
18
85
  navigationState,
@@ -42,10 +109,7 @@ const BottomTabs = ({
42
109
  getLabelText = ({
43
110
  route
44
111
  }) => route.title,
45
- getIcon = ({
46
- route,
47
- focused
48
- }) => route.unfocusedIcon ? focused ? route.focusedIcon : route.unfocusedIcon : route.focusedIcon,
112
+ getIcon = defaultGetIcon,
49
113
  getHidden = ({
50
114
  route
51
115
  }) => route.hidden,
@@ -169,45 +233,11 @@ const BottomTabs = ({
169
233
  })
170
234
  };
171
235
  }), [trimmedRoutes, icons, getLabelText, getBadge, getBadgeBackgroundColor, getBadgeTextColor, getActiveTintColor, getHidden, getTestID, getRole, getPreventsDefault]);
172
- const resolvedIconAssets = React.useMemo(() => icons.map(icon => {
173
- if (icon && !isAppleSymbol(icon)) {
174
- // @ts-ignore - resolveAssetSource accepts ImageSourcePropType
175
- const resolved = Image.resolveAssetSource(icon);
176
- return {
177
- uri: resolved?.uri ?? "",
178
- width: resolved?.width ?? 0,
179
- height: resolved?.height ?? 0,
180
- scale: resolved?.scale ?? 1
181
- };
182
- }
183
- return {
184
- uri: "",
185
- width: 0,
186
- height: 0,
187
- scale: 1
188
- };
189
- }), [icons]);
236
+ const resolvedIconAssets = React.useMemo(() => icons.map(icon => resolveTabIconSource(icon)), [icons]);
190
237
 
191
238
  // Focused (solid) assets passed to iOS as selectedImage. iOS only — Android
192
239
  // ignores selectedIcons and keeps swapping via the focusedKey array above.
193
- const resolvedSelectedIconAssets = React.useMemo(() => focusedIcons.map(icon => {
194
- if (icon && !isAppleSymbol(icon)) {
195
- // @ts-ignore - resolveAssetSource accepts ImageSourcePropType
196
- const resolved = Image.resolveAssetSource(icon);
197
- return {
198
- uri: resolved?.uri ?? "",
199
- width: resolved?.width ?? 0,
200
- height: resolved?.height ?? 0,
201
- scale: resolved?.scale ?? 1
202
- };
203
- }
204
- return {
205
- uri: "",
206
- width: 0,
207
- height: 0,
208
- scale: 1
209
- };
210
- }), [focusedIcons]);
240
+ const resolvedSelectedIconAssets = React.useMemo(() => focusedIcons.map(icon => resolveTabIconSource(icon)), [focusedIcons]);
211
241
  const jumpTo = useLatestCallback(key => {
212
242
  const index = trimmedRoutes.findIndex(route => route.key === key);
213
243
  if (index === -1) {
@@ -258,15 +288,9 @@ const BottomTabs = ({
258
288
  if (!isIOS || !sideAccessoryIcon) {
259
289
  return undefined;
260
290
  }
261
- // @ts-ignore - resolveAssetSource accepts ImageSourcePropType
262
- const resolved = Image.resolveAssetSource(sideAccessoryIcon);
263
- return resolved?.uri ? {
264
- uri: resolved.uri,
265
- width: resolved.width ?? 0,
266
- height: resolved.height ?? 0,
267
- scale: resolved.scale ?? 1
268
- } : undefined;
269
- }, [sideAccessoryIcon]);
291
+ const resolved = resolveTabIconSource(sideAccessoryIcon);
292
+ return resolved.uri ? resolved : undefined;
293
+ }, [isIOS, sideAccessoryIcon]);
270
294
  useLayoutEffect(() => {
271
295
  if (renderCustomTabBar && customTabBarWrapperRef.current) {
272
296
  customTabBarWrapperRef.current.measure((_x, _y, _width, height) => {
@@ -1,17 +1,17 @@
1
- import { codegenNativeComponent, type ViewProps } from "react-native";
2
- import type {
3
- DirectEventHandler,
4
- Double,
5
- WithDefault,
6
- } from "react-native/Libraries/Types/CodegenTypes";
1
+ import {
2
+ codegenNativeComponent,
3
+ type CodegenTypes,
4
+ type ViewProps,
5
+ } from "react-native";
6
+
7
7
 
8
8
  export interface BottomTabsDrawerNativeProps extends ViewProps {
9
- enabled?: WithDefault<boolean, false>;
10
- open?: WithDefault<boolean, false>;
11
- swipeEnabled?: WithDefault<boolean, false>;
12
- hapticFeedbackEnabled?: WithDefault<boolean, false>;
13
- bottomBarHeight?: Double;
14
- onDrawerOpenChange?: DirectEventHandler<Readonly<{ open: boolean }>>;
9
+ enabled?: CodegenTypes.WithDefault<boolean, false>;
10
+ open?: CodegenTypes.WithDefault<boolean, false>;
11
+ swipeEnabled?: CodegenTypes.WithDefault<boolean, false>;
12
+ hapticFeedbackEnabled?: CodegenTypes.WithDefault<boolean, false>;
13
+ bottomBarHeight?: CodegenTypes.Double;
14
+ onDrawerOpenChange?: CodegenTypes.DirectEventHandler<Readonly<{ open: boolean }>>;
15
15
  }
16
16
 
17
17
  export default codegenNativeComponent<BottomTabsDrawerNativeProps>(
@@ -1,12 +1,11 @@
1
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
- import type { ColorValue, ProcessedColorValue, ViewProps } from 'react-native';
3
- import type {
4
- DirectEventHandler,
5
- Double,
6
- Int32,
7
- WithDefault,
8
- } from 'react-native/Libraries/Types/CodegenTypes';
9
- //@ts-ignore
1
+ import {
2
+ codegenNativeComponent,
3
+ type CodegenTypes,
4
+ type ColorValue,
5
+ type ProcessedColorValue,
6
+ type ViewProps,
7
+ } from 'react-native';
8
+ // @ts-ignore
10
9
  import type { ImageSource } from 'react-native/Libraries/Image/ImageSource';
11
10
 
12
11
  export type OnPageSelectedEventData = Readonly<{
@@ -14,12 +13,12 @@ export type OnPageSelectedEventData = Readonly<{
14
13
  }>;
15
14
 
16
15
  export type OnTabBarMeasured = Readonly<{
17
- height: Int32;
16
+ height: CodegenTypes.Int32;
18
17
  }>;
19
18
 
20
19
  export type OnNativeLayout = Readonly<{
21
- width: Double;
22
- height: Double;
20
+ width: CodegenTypes.Double;
21
+ height: CodegenTypes.Double;
23
22
  }>;
24
23
 
25
24
  // Where the system draws the tab bar: 'bottom', or 'leading' / 'trailing' for
@@ -47,10 +46,10 @@ export type BottomTabsItems = ReadonlyArray<{
47
46
  export interface BottomTabsNativeProps extends ViewProps {
48
47
  items: BottomTabsItems;
49
48
  selectedPage: string;
50
- onPageSelected?: DirectEventHandler<OnPageSelectedEventData>;
51
- onTabDoublePress?: DirectEventHandler<OnPageSelectedEventData>;
52
- onTabBarMeasured?: DirectEventHandler<OnTabBarMeasured>;
53
- onNativeLayout?: DirectEventHandler<OnNativeLayout>;
49
+ onPageSelected?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
50
+ onTabDoublePress?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
51
+ onTabBarMeasured?: CodegenTypes.DirectEventHandler<OnTabBarMeasured>;
52
+ onNativeLayout?: CodegenTypes.DirectEventHandler<OnNativeLayout>;
54
53
  icons?: ReadonlyArray<ImageSource>;
55
54
  selectedIcons?: ReadonlyArray<ImageSource>;
56
55
  tabBarHidden?: boolean;
@@ -58,8 +57,8 @@ export interface BottomTabsNativeProps extends ViewProps {
58
57
  sidebarAdaptable?: boolean;
59
58
  scrollEdgeAppearance?: string;
60
59
  barTintColor?: ColorValue;
61
- translucent?: WithDefault<boolean, true>;
62
- androidBottomBlurEnabled?: WithDefault<boolean, false>;
60
+ translucent?: CodegenTypes.WithDefault<boolean, true>;
61
+ androidBottomBlurEnabled?: CodegenTypes.WithDefault<boolean, false>;
63
62
  rippleColor?: ColorValue;
64
63
  activeTintColor?: ColorValue;
65
64
  inactiveTintColor?: ColorValue;
@@ -69,15 +68,15 @@ export interface BottomTabsNativeProps extends ViewProps {
69
68
  minimizeBehavior?: string;
70
69
  fontFamily?: string;
71
70
  fontWeight?: string;
72
- fontSize?: Int32;
71
+ fontSize?: CodegenTypes.Int32;
73
72
  ignoreBottomInsets?: boolean;
74
- androidTabBarStyle?: WithDefault<'default' | 'floating', 'default'>;
75
- ignoreKeyboardInsets?: WithDefault<boolean, true>;
76
- onTabBarPlacementChange?: DirectEventHandler<OnTabBarPlacementChange>;
73
+ androidTabBarStyle?: CodegenTypes.WithDefault<'default' | 'floating', 'default'>;
74
+ ignoreKeyboardInsets?: CodegenTypes.WithDefault<boolean, true>;
75
+ onTabBarPlacementChange?: CodegenTypes.DirectEventHandler<OnTabBarPlacementChange>;
77
76
  // A round button drawn above a vertical tab bar; iOS only.
78
77
  sideAccessoryIcon?: ImageSource;
79
78
  sideAccessoryLabel?: string;
80
- onSideAccessoryPress?: DirectEventHandler<OnSideAccessoryPress>;
79
+ onSideAccessoryPress?: CodegenTypes.DirectEventHandler<OnSideAccessoryPress>;
81
80
  }
82
81
 
83
82
  export default codegenNativeComponent<BottomTabsNativeProps>('RNBottomTabsView');
@@ -4,5 +4,5 @@ export interface RNBottomTabsAccessoryViewProps {
4
4
  placement: 'inline' | 'expanded' | 'none';
5
5
  }) => React.ReactNode;
6
6
  }
7
- export declare const BottomAccessoryView: (props: RNBottomTabsAccessoryViewProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const BottomAccessoryView: (props: RNBottomTabsAccessoryViewProps) => React.JSX.Element;
8
8
  //# sourceMappingURL=BottomAccessoryView.d.ts.map