-
-
Notifications
You must be signed in to change notification settings - Fork 644
Expand file tree
/
Copy pathTabsHost.android.tsx
More file actions
65 lines (56 loc) · 1.81 KB
/
TabsHost.android.tsx
File metadata and controls
65 lines (56 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use client';
import React from 'react';
import { StyleSheet } from 'react-native';
import TabsHostAndroidNativeComponent, {
type NativeProps as TabsHostAndroidNativeComponentProps,
} from '../../../fabric/tabs/TabsHostAndroidNativeComponent';
import type { TabsHostProps } from './TabsHost.types';
import { RNSLog } from '../../../private';
import { useTabsHost } from './useTabsHost';
/**
* EXPERIMENTAL API, MIGHT CHANGE W/O ANY NOTICE
*/
function TabsHost(props: TabsHostProps) {
RNSLog.log(`TabsHost render`);
// android props (even if unused for now) are extracted - these should be handled separately from base props
// ios props are safely dropped
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { android, ios, ...baseProps } = props;
const {
children,
direction,
nativeContainerStyle,
onTabSelected,
navStateRequest,
...filteredBaseProps
} = baseProps;
const componentNodeRef =
React.useRef<React.Component<TabsHostAndroidNativeComponentProps>>(null);
const { onTabSelected: onTabSelectedCallback } =
useTabsHost<TabsHostAndroidNativeComponentProps>({
componentNodeRef,
onTabSelected,
});
return (
<TabsHostAndroidNativeComponent
style={[styles.fillParent, { direction }]}
navStateRequest={navStateRequest}
onTabSelected={onTabSelectedCallback}
nativeContainerBackgroundColor={nativeContainerStyle?.backgroundColor}
// @ts-ignore suppress ref - debug only
ref={componentNodeRef}
{...filteredBaseProps}
// Android-specific
tabBarRespectsIMEInsets={android?.tabBarRespectsIMEInsets}>
{children}
</TabsHostAndroidNativeComponent>
);
}
export default TabsHost;
const styles = StyleSheet.create({
fillParent: {
flex: 1,
width: '100%',
height: '100%',
},
});