@soundtrackio/react-native-bottom-tabs 1.4.0

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 (125) hide show
  1. package/README.md +32 -0
  2. package/android/build.gradle +132 -0
  3. package/android/gradle.properties +5 -0
  4. package/android/src/main/AndroidManifest.xml +3 -0
  5. package/android/src/main/AndroidManifestNew.xml +2 -0
  6. package/android/src/main/java/com/rcttabview/ImageSource.kt +86 -0
  7. package/android/src/main/java/com/rcttabview/LatestRequestTracker.kt +19 -0
  8. package/android/src/main/java/com/rcttabview/RCTTabView.kt +689 -0
  9. package/android/src/main/java/com/rcttabview/RCTTabViewManager.kt +222 -0
  10. package/android/src/main/java/com/rcttabview/RCTTabViewPackage.kt +19 -0
  11. package/android/src/main/java/com/rcttabview/RCTTabViewPrewarm.kt +40 -0
  12. package/android/src/main/java/com/rcttabview/RebuildBatch.kt +31 -0
  13. package/android/src/main/java/com/rcttabview/TabBarVisibility.kt +14 -0
  14. package/android/src/main/java/com/rcttabview/Utils.kt +31 -0
  15. package/android/src/main/java/com/rcttabview/events/OnNativeLayoutEvent.kt +25 -0
  16. package/android/src/main/java/com/rcttabview/events/OnTabBarMeasuredEvent.kt +24 -0
  17. package/android/src/main/java/com/rcttabview/events/PageSelectedEvent.kt +32 -0
  18. package/android/src/main/java/com/rcttabview/events/TabLongPressedEvent.kt +24 -0
  19. package/android/src/test/java/com/rcttabview/LatestRequestTrackerTest.kt +37 -0
  20. package/android/src/test/java/com/rcttabview/RebuildBatchTest.kt +44 -0
  21. package/android/src/test/java/com/rcttabview/TabBarVisibilityTest.kt +58 -0
  22. package/app.plugin.js +1 -0
  23. package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewComponentDescriptor.h +33 -0
  24. package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.cpp +19 -0
  25. package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.h +35 -0
  26. package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewState.cpp +15 -0
  27. package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewState.h +25 -0
  28. package/ios/BottomAccessoryProvider.swift +27 -0
  29. package/ios/Extensions.swift +101 -0
  30. package/ios/PlatformAliases.swift +43 -0
  31. package/ios/RCTBottomAccessoryComponentView.h +17 -0
  32. package/ios/RCTBottomAccessoryComponentView.mm +76 -0
  33. package/ios/RCTTabViewComponentView.h +16 -0
  34. package/ios/RCTTabViewComponentView.mm +285 -0
  35. package/ios/RepresentableView.swift +55 -0
  36. package/ios/SVG/CoreSVG.h +19 -0
  37. package/ios/SVG/CoreSVG.mm +177 -0
  38. package/ios/SVG/SvgDecoder.h +10 -0
  39. package/ios/SVG/SvgDecoder.mm +38 -0
  40. package/ios/TabAppearModifier.swift +38 -0
  41. package/ios/TabBarFontSize.swift +88 -0
  42. package/ios/TabItem.swift +35 -0
  43. package/ios/TabItemEventModifier.swift +163 -0
  44. package/ios/TabView/AnyTabView.swift +7 -0
  45. package/ios/TabView/LegacyTabView.swift +70 -0
  46. package/ios/TabView/NewTabView.swift +138 -0
  47. package/ios/TabViewImpl.swift +566 -0
  48. package/ios/TabViewProps.swift +109 -0
  49. package/ios/TabViewProvider.swift +368 -0
  50. package/ios/react-native-bottom-tabs-Bridging-Header.h +4 -0
  51. package/lib/module/BottomAccessoryView.js +47 -0
  52. package/lib/module/BottomAccessoryView.js.map +1 -0
  53. package/lib/module/BottomAccessoryViewNativeComponent.ts +27 -0
  54. package/lib/module/DelayedFreeze.js +31 -0
  55. package/lib/module/DelayedFreeze.js.map +1 -0
  56. package/lib/module/NativeSVGDecoder.js +5 -0
  57. package/lib/module/NativeSVGDecoder.js.map +1 -0
  58. package/lib/module/SceneMap.js +28 -0
  59. package/lib/module/SceneMap.js.map +1 -0
  60. package/lib/module/TabView.js +294 -0
  61. package/lib/module/TabView.js.map +1 -0
  62. package/lib/module/TabViewNativeComponent.ts +73 -0
  63. package/lib/module/expo.js +35 -0
  64. package/lib/module/expo.js.map +1 -0
  65. package/lib/module/index.js +20 -0
  66. package/lib/module/index.js.map +1 -0
  67. package/lib/module/package.json +1 -0
  68. package/lib/module/types.js +4 -0
  69. package/lib/module/types.js.map +1 -0
  70. package/lib/module/utils/BottomTabBarHeightContext.js +5 -0
  71. package/lib/module/utils/BottomTabBarHeightContext.js.map +1 -0
  72. package/lib/module/utils/useBottomTabBarHeight.js +12 -0
  73. package/lib/module/utils/useBottomTabBarHeight.js.map +1 -0
  74. package/lib/typescript/package.json +1 -0
  75. package/lib/typescript/src/BottomAccessoryView.d.ts +7 -0
  76. package/lib/typescript/src/BottomAccessoryView.d.ts.map +1 -0
  77. package/lib/typescript/src/BottomAccessoryView.js +24 -0
  78. package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +15 -0
  79. package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts.map +1 -0
  80. package/lib/typescript/src/BottomAccessoryViewNativeComponent.js +4 -0
  81. package/lib/typescript/src/DelayedFreeze.d.ts +7 -0
  82. package/lib/typescript/src/DelayedFreeze.d.ts.map +1 -0
  83. package/lib/typescript/src/DelayedFreeze.js +21 -0
  84. package/lib/typescript/src/NativeSVGDecoder.d.ts +5 -0
  85. package/lib/typescript/src/NativeSVGDecoder.d.ts.map +1 -0
  86. package/lib/typescript/src/NativeSVGDecoder.js +2 -0
  87. package/lib/typescript/src/SceneMap.d.ts +9 -0
  88. package/lib/typescript/src/SceneMap.d.ts.map +1 -0
  89. package/lib/typescript/src/SceneMap.js +15 -0
  90. package/lib/typescript/src/TabView.d.ts +219 -0
  91. package/lib/typescript/src/TabView.d.ts.map +1 -0
  92. package/lib/typescript/src/TabView.js +157 -0
  93. package/lib/typescript/src/TabViewNativeComponent.d.ts +59 -0
  94. package/lib/typescript/src/TabViewNativeComponent.d.ts.map +1 -0
  95. package/lib/typescript/src/TabViewNativeComponent.js +4 -0
  96. package/lib/typescript/src/expo.d.ts +6 -0
  97. package/lib/typescript/src/expo.d.ts.map +1 -0
  98. package/lib/typescript/src/expo.js +34 -0
  99. package/lib/typescript/src/index.d.ts +15 -0
  100. package/lib/typescript/src/index.d.ts.map +1 -0
  101. package/lib/typescript/src/index.js +11 -0
  102. package/lib/typescript/src/types.d.ts +31 -0
  103. package/lib/typescript/src/types.d.ts.map +1 -0
  104. package/lib/typescript/src/types.js +1 -0
  105. package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts +2 -0
  106. package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts.map +1 -0
  107. package/lib/typescript/src/utils/BottomTabBarHeightContext.js +2 -0
  108. package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts +1 -0
  109. package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts.map +1 -0
  110. package/lib/typescript/src/utils/useBottomTabBarHeight.js +9 -0
  111. package/lib/typescript/tsconfig.tsbuildinfo +1 -0
  112. package/package.json +135 -0
  113. package/react-native-bottom-tabs.podspec +43 -0
  114. package/src/BottomAccessoryView.tsx +59 -0
  115. package/src/BottomAccessoryViewNativeComponent.ts +27 -0
  116. package/src/DelayedFreeze.tsx +31 -0
  117. package/src/NativeSVGDecoder.ts +5 -0
  118. package/src/SceneMap.tsx +34 -0
  119. package/src/TabView.tsx +558 -0
  120. package/src/TabViewNativeComponent.ts +73 -0
  121. package/src/expo.ts +58 -0
  122. package/src/index.tsx +23 -0
  123. package/src/types.ts +36 -0
  124. package/src/utils/BottomTabBarHeightContext.ts +5 -0
  125. package/src/utils/useBottomTabBarHeight.ts +15 -0
@@ -0,0 +1,73 @@
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
10
+ import type { ImageSource } from 'react-native/Libraries/Image/ImageSource';
11
+
12
+ export type OnPageSelectedEventData = Readonly<{
13
+ key: string;
14
+ }>;
15
+
16
+ export type OnTabBarMeasured = Readonly<{
17
+ height: Int32;
18
+ }>;
19
+
20
+ export type OnNativeLayout = Readonly<{
21
+ width: Double;
22
+ height: Double;
23
+ }>;
24
+
25
+ export type TabViewItems = ReadonlyArray<{
26
+ key: string;
27
+ title: string;
28
+ sfSymbol?: string;
29
+ focusedSfSymbol?: string;
30
+ badge?: string;
31
+ badgeBackgroundColor?: ProcessedColorValue | null;
32
+ badgeTextColor?: ProcessedColorValue | null;
33
+ activeTintColor?: ProcessedColorValue | null;
34
+ iconRenderingMode?: string;
35
+ hidden?: boolean;
36
+ testID?: string;
37
+ role?: string;
38
+ preventsDefault?: boolean;
39
+ }>;
40
+
41
+ export interface TabViewProps extends ViewProps {
42
+ items: TabViewItems;
43
+ selectedPage: string;
44
+ onPageSelected?: DirectEventHandler<OnPageSelectedEventData>;
45
+ onTabLongPress?: DirectEventHandler<OnPageSelectedEventData>;
46
+ onTabBarMeasured?: DirectEventHandler<OnTabBarMeasured>;
47
+ onNativeLayout?: DirectEventHandler<OnNativeLayout>;
48
+ icons?: ReadonlyArray<ImageSource>;
49
+ focusedIcons?: ReadonlyArray<ImageSource>;
50
+ tabBarHidden?: boolean;
51
+ tabBarHideOnKeyboard?: boolean;
52
+ labeled?: boolean;
53
+ sidebarAdaptable?: boolean;
54
+ scrollEdgeAppearance?: string;
55
+ barTintColor?: ColorValue;
56
+ translucent?: WithDefault<boolean, true>;
57
+ rippleColor?: ColorValue;
58
+ activeTintColor?: ColorValue;
59
+ inactiveTintColor?: ColorValue;
60
+ experimentalBakedTintColors?: WithDefault<boolean, false>;
61
+ disablePageAnimations?: boolean;
62
+ activeIndicatorColor?: ColorValue;
63
+ hapticFeedbackEnabled?: boolean;
64
+ layoutDirection?: string;
65
+ minimizeBehavior?: string;
66
+ fontFamily?: string;
67
+ fontWeight?: string;
68
+ fontSize?: Int32;
69
+ }
70
+
71
+ export default codegenNativeComponent<TabViewProps>('RNCTabView', {
72
+ interfaceOnly: true,
73
+ });
package/src/expo.ts ADDED
@@ -0,0 +1,58 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ import { createRequire } from 'node:module';
3
+
4
+ const require = createRequire(import.meta.url);
5
+
6
+ const ConfigPlugins = require('@expo/config-plugins');
7
+
8
+ const { createRunOncePlugin, withAndroidStyles } =
9
+ ConfigPlugins as typeof import('@expo/config-plugins');
10
+
11
+ const MATERIAL3_THEME_DYANMIC =
12
+ 'Theme.Material3.DynamicColors.DayNight.NoActionBar';
13
+ const MATERIAL3_THEME = 'Theme.Material3.DayNight.NoActionBar';
14
+ const MATERIAL2_THEME = 'Theme.MaterialComponents.DayNight.NoActionBar';
15
+ const MATERIAL3_EXPRESSIVE_THEME =
16
+ 'Theme.Material3Expressive.DayNight.NoActionBar';
17
+
18
+ type ConfigProps = {
19
+ /*
20
+ * Define theme that should be used.
21
+ * @default 'material3'
22
+ */
23
+ theme:
24
+ | 'material2'
25
+ | 'material3'
26
+ | 'material3-dynamic'
27
+ | 'material3-expressive';
28
+ };
29
+
30
+ const withMaterial3Theme: ConfigPlugin<ConfigProps> = (config, options) => {
31
+ const theme = options?.theme;
32
+
33
+ return withAndroidStyles(config, (stylesConfig) => {
34
+ stylesConfig.modResults.resources.style =
35
+ stylesConfig.modResults.resources.style?.map((style) => {
36
+ if (style.$.name === 'AppTheme') {
37
+ if (theme === 'material3-dynamic') {
38
+ style.$.parent = MATERIAL3_THEME_DYANMIC;
39
+ } else if (theme === 'material2') {
40
+ style.$.parent = MATERIAL2_THEME;
41
+ } else if (theme === 'material3-expressive') {
42
+ style.$.parent = MATERIAL3_EXPRESSIVE_THEME;
43
+ } else {
44
+ style.$.parent = MATERIAL3_THEME;
45
+ }
46
+ }
47
+
48
+ return style;
49
+ });
50
+
51
+ return stylesConfig;
52
+ });
53
+ };
54
+
55
+ export default createRunOncePlugin(
56
+ withMaterial3Theme,
57
+ 'react-native-bottom-tabs'
58
+ );
package/src/index.tsx ADDED
@@ -0,0 +1,23 @@
1
+ import TabView from './TabView';
2
+
3
+ /**
4
+ * Views
5
+ */
6
+ export default TabView;
7
+
8
+ /**
9
+ * Utilities
10
+ */
11
+ export { SceneMap } from './SceneMap';
12
+ export { useBottomTabBarHeight } from './utils/useBottomTabBarHeight';
13
+ export { BottomTabBarHeightContext } from './utils/BottomTabBarHeightContext';
14
+
15
+ /**
16
+ * Types
17
+ */
18
+ export type {
19
+ AppleIcon,
20
+ IconRenderingMode,
21
+ LayoutDirection,
22
+ TabRole,
23
+ } from './types';
package/src/types.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { ImageSourcePropType, StyleProp, ViewStyle } from 'react-native';
2
+ import type { SFSymbol } from 'sf-symbols-typescript';
3
+
4
+ export type IconSource = string | ImageSourcePropType;
5
+
6
+ export type AppleIcon = { sfSymbol: SFSymbol };
7
+
8
+ export type TabRole = 'search';
9
+
10
+ export type IconRenderingMode = 'automatic' | 'original';
11
+
12
+ export type LayoutDirection = 'ltr' | 'rtl' | 'locale';
13
+
14
+ export type BaseRoute = {
15
+ key: string;
16
+ title?: string;
17
+ badge?: string;
18
+ badgeBackgroundColor?: string;
19
+ badgeTextColor?: string;
20
+ lazy?: boolean;
21
+ focusedIcon?: ImageSourcePropType | AppleIcon;
22
+ unfocusedIcon?: ImageSourcePropType | AppleIcon;
23
+ iconRenderingMode?: IconRenderingMode;
24
+ activeTintColor?: string;
25
+ hidden?: boolean;
26
+ testID?: string;
27
+ role?: TabRole;
28
+ freezeOnBlur?: boolean;
29
+ style?: StyleProp<ViewStyle>;
30
+ preventsDefault?: boolean;
31
+ };
32
+
33
+ export type NavigationState<Route extends BaseRoute> = {
34
+ index: number;
35
+ routes: Route[];
36
+ };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+
3
+ export const BottomTabBarHeightContext = React.createContext<
4
+ number | undefined
5
+ >(undefined);
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+
3
+ import { BottomTabBarHeightContext } from './BottomTabBarHeightContext';
4
+
5
+ export function useBottomTabBarHeight() {
6
+ const height = React.useContext(BottomTabBarHeightContext);
7
+
8
+ if (height === undefined) {
9
+ throw new Error(
10
+ "Couldn't find the bottom tab bar height. Are you inside a screen in Native Bottom Tab Navigator?"
11
+ );
12
+ }
13
+
14
+ return height;
15
+ }