@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.
- package/README.md +32 -0
- package/android/build.gradle +132 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/rcttabview/ImageSource.kt +86 -0
- package/android/src/main/java/com/rcttabview/LatestRequestTracker.kt +19 -0
- package/android/src/main/java/com/rcttabview/RCTTabView.kt +689 -0
- package/android/src/main/java/com/rcttabview/RCTTabViewManager.kt +222 -0
- package/android/src/main/java/com/rcttabview/RCTTabViewPackage.kt +19 -0
- package/android/src/main/java/com/rcttabview/RCTTabViewPrewarm.kt +40 -0
- package/android/src/main/java/com/rcttabview/RebuildBatch.kt +31 -0
- package/android/src/main/java/com/rcttabview/TabBarVisibility.kt +14 -0
- package/android/src/main/java/com/rcttabview/Utils.kt +31 -0
- package/android/src/main/java/com/rcttabview/events/OnNativeLayoutEvent.kt +25 -0
- package/android/src/main/java/com/rcttabview/events/OnTabBarMeasuredEvent.kt +24 -0
- package/android/src/main/java/com/rcttabview/events/PageSelectedEvent.kt +32 -0
- package/android/src/main/java/com/rcttabview/events/TabLongPressedEvent.kt +24 -0
- package/android/src/test/java/com/rcttabview/LatestRequestTrackerTest.kt +37 -0
- package/android/src/test/java/com/rcttabview/RebuildBatchTest.kt +44 -0
- package/android/src/test/java/com/rcttabview/TabBarVisibilityTest.kt +58 -0
- package/app.plugin.js +1 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewComponentDescriptor.h +33 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.cpp +19 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.h +35 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewState.cpp +15 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewState.h +25 -0
- package/ios/BottomAccessoryProvider.swift +27 -0
- package/ios/Extensions.swift +101 -0
- package/ios/PlatformAliases.swift +43 -0
- package/ios/RCTBottomAccessoryComponentView.h +17 -0
- package/ios/RCTBottomAccessoryComponentView.mm +76 -0
- package/ios/RCTTabViewComponentView.h +16 -0
- package/ios/RCTTabViewComponentView.mm +285 -0
- package/ios/RepresentableView.swift +55 -0
- package/ios/SVG/CoreSVG.h +19 -0
- package/ios/SVG/CoreSVG.mm +177 -0
- package/ios/SVG/SvgDecoder.h +10 -0
- package/ios/SVG/SvgDecoder.mm +38 -0
- package/ios/TabAppearModifier.swift +38 -0
- package/ios/TabBarFontSize.swift +88 -0
- package/ios/TabItem.swift +35 -0
- package/ios/TabItemEventModifier.swift +163 -0
- package/ios/TabView/AnyTabView.swift +7 -0
- package/ios/TabView/LegacyTabView.swift +70 -0
- package/ios/TabView/NewTabView.swift +138 -0
- package/ios/TabViewImpl.swift +566 -0
- package/ios/TabViewProps.swift +109 -0
- package/ios/TabViewProvider.swift +368 -0
- package/ios/react-native-bottom-tabs-Bridging-Header.h +4 -0
- package/lib/module/BottomAccessoryView.js +47 -0
- package/lib/module/BottomAccessoryView.js.map +1 -0
- package/lib/module/BottomAccessoryViewNativeComponent.ts +27 -0
- package/lib/module/DelayedFreeze.js +31 -0
- package/lib/module/DelayedFreeze.js.map +1 -0
- package/lib/module/NativeSVGDecoder.js +5 -0
- package/lib/module/NativeSVGDecoder.js.map +1 -0
- package/lib/module/SceneMap.js +28 -0
- package/lib/module/SceneMap.js.map +1 -0
- package/lib/module/TabView.js +294 -0
- package/lib/module/TabView.js.map +1 -0
- package/lib/module/TabViewNativeComponent.ts +73 -0
- package/lib/module/expo.js +35 -0
- package/lib/module/expo.js.map +1 -0
- package/lib/module/index.js +20 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/BottomTabBarHeightContext.js +5 -0
- package/lib/module/utils/BottomTabBarHeightContext.js.map +1 -0
- package/lib/module/utils/useBottomTabBarHeight.js +12 -0
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/BottomAccessoryView.d.ts +7 -0
- package/lib/typescript/src/BottomAccessoryView.d.ts.map +1 -0
- package/lib/typescript/src/BottomAccessoryView.js +24 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +15 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.js +4 -0
- package/lib/typescript/src/DelayedFreeze.d.ts +7 -0
- package/lib/typescript/src/DelayedFreeze.d.ts.map +1 -0
- package/lib/typescript/src/DelayedFreeze.js +21 -0
- package/lib/typescript/src/NativeSVGDecoder.d.ts +5 -0
- package/lib/typescript/src/NativeSVGDecoder.d.ts.map +1 -0
- package/lib/typescript/src/NativeSVGDecoder.js +2 -0
- package/lib/typescript/src/SceneMap.d.ts +9 -0
- package/lib/typescript/src/SceneMap.d.ts.map +1 -0
- package/lib/typescript/src/SceneMap.js +15 -0
- package/lib/typescript/src/TabView.d.ts +219 -0
- package/lib/typescript/src/TabView.d.ts.map +1 -0
- package/lib/typescript/src/TabView.js +157 -0
- package/lib/typescript/src/TabViewNativeComponent.d.ts +59 -0
- package/lib/typescript/src/TabViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/TabViewNativeComponent.js +4 -0
- package/lib/typescript/src/expo.d.ts +6 -0
- package/lib/typescript/src/expo.d.ts.map +1 -0
- package/lib/typescript/src/expo.js +34 -0
- package/lib/typescript/src/index.d.ts +15 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.js +11 -0
- package/lib/typescript/src/types.d.ts +31 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/types.js +1 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts +2 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts.map +1 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.js +2 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts +1 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts.map +1 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.js +9 -0
- package/lib/typescript/tsconfig.tsbuildinfo +1 -0
- package/package.json +135 -0
- package/react-native-bottom-tabs.podspec +43 -0
- package/src/BottomAccessoryView.tsx +59 -0
- package/src/BottomAccessoryViewNativeComponent.ts +27 -0
- package/src/DelayedFreeze.tsx +31 -0
- package/src/NativeSVGDecoder.ts +5 -0
- package/src/SceneMap.tsx +34 -0
- package/src/TabView.tsx +558 -0
- package/src/TabViewNativeComponent.ts +73 -0
- package/src/expo.ts +58 -0
- package/src/index.tsx +23 -0
- package/src/types.ts +36 -0
- package/src/utils/BottomTabBarHeightContext.ts +5 -0
- 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,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
|
+
}
|