| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import {
- type FC
- } from "react";
- import {
- ScrollView,
- View
- } from "react-native";
- import type IPageContainerProps from "./type";
- import stylesheet from "./stylesheet";
- import {
- NCoreUIKitTheme
- } from "../../core/hooks";
- const PageContainer: FC<IPageContainerProps> = ({
- backgroundColor = "default" as keyof NCoreUIKit.ContainerContentColors,
- isScrollable = false,
- scrollViewStyle,
- scrollViewProps,
- children,
- style,
- ...props
- }) => {
- const {
- spaces
- } = NCoreUIKitTheme.useContext();
- const renderScrollview = () => {
- if(style) {
- console.log("Hey!. You make wrong things. If you must be use isScrollable={true}, you must be use scrollViewStyle. Do not use style prop for this case.");
- }
- if(props) {
- console.log("Hey!. You make wrong things. If you must be use isScrollable={true}, you must be use scrollViewProps. Do not use default view props for this case.");
- }
- return <ScrollView
- {...scrollViewProps}
- contentContainerStyle={[
- {
- padding: spaces.spacingMd
- },
- scrollViewProps?.contentContainerStyle
- ]}
- style={[
- {
- backgroundColor: backgroundColor
- },
- stylesheet.container,
- scrollViewStyle
- ]}
- >
- {children}
- </ScrollView>;
- };
- const renderView = () => {
- if(scrollViewStyle) {
- console.log("Hey!. You make wrong things. If you must be use isScrollable={false}, you must be use style. Do not use scrollViewStyle prop for this case.");
- }
- if(scrollViewProps) {
- console.log("Hey!. You make wrong things. If you must be use isScrollable={false}, you musn't use scrollViewProps.");
- }
- return <View
- {...props}
- style={[
- {
- backgroundColor: backgroundColor,
- padding: spaces.spacingMd
- },
- stylesheet.container,
- style
- ]}
- >
- {children}
- </View>;
- };
- return isScrollable ? renderScrollview() : renderView();
- };
- export default PageContainer;
|