|
@@ -1,3 +1,7 @@
|
|
|
|
|
+import {
|
|
|
|
|
+ useEffect,
|
|
|
|
|
+ useState
|
|
|
|
|
+} from "react";
|
|
|
import {
|
|
import {
|
|
|
View
|
|
View
|
|
|
} from "react-native";
|
|
} from "react-native";
|
|
@@ -11,21 +15,29 @@ import {
|
|
|
import {
|
|
import {
|
|
|
SafeAreaView
|
|
SafeAreaView
|
|
|
} from "react-native-safe-area-context";
|
|
} from "react-native-safe-area-context";
|
|
|
-import SiteLogo from "../siteLogo";
|
|
|
|
|
import {
|
|
import {
|
|
|
Portal
|
|
Portal
|
|
|
} from "../../helpers/portalize";
|
|
} from "../../helpers/portalize";
|
|
|
|
|
+import SiteLogo from "../siteLogo";
|
|
|
|
|
|
|
|
const MainHeader = ({
|
|
const MainHeader = ({
|
|
|
isWorkWithSafeAreaView = true,
|
|
isWorkWithSafeAreaView = true,
|
|
|
|
|
+ isWorkWithStickySpace = false,
|
|
|
|
|
+ isSetAutoHeaderSpace = true,
|
|
|
isWorkWithSeperator = false,
|
|
isWorkWithSeperator = false,
|
|
|
backgroundColor = "default",
|
|
backgroundColor = "default",
|
|
|
portalName = "main-header",
|
|
portalName = "main-header",
|
|
|
isWorkWithPortal = false,
|
|
isWorkWithPortal = false,
|
|
|
|
|
+ isWorkWithSticky = false,
|
|
|
renderRight: RenderRight,
|
|
renderRight: RenderRight,
|
|
|
renderLeft: RenderLeft,
|
|
renderLeft: RenderLeft,
|
|
|
|
|
+ customBackgroundColor,
|
|
|
|
|
+ onContentHeight,
|
|
|
siteLogoProps,
|
|
siteLogoProps,
|
|
|
- children
|
|
|
|
|
|
|
+ glassEffect,
|
|
|
|
|
+ children,
|
|
|
|
|
+ style,
|
|
|
|
|
+ ...props
|
|
|
}: IMainHeader) => {
|
|
}: IMainHeader) => {
|
|
|
const {
|
|
const {
|
|
|
borders,
|
|
borders,
|
|
@@ -34,15 +46,28 @@ const MainHeader = ({
|
|
|
} = NCoreUIKitTheme.useContext();
|
|
} = NCoreUIKitTheme.useContext();
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
|
|
+ safeAreaView: safeAreaViewDynamicStyle,
|
|
|
container: containerDynamicStyle
|
|
container: containerDynamicStyle
|
|
|
} = useStyles({
|
|
} = useStyles({
|
|
|
|
|
+ isWorkWithSafeAreaView,
|
|
|
isWorkWithSeperator,
|
|
isWorkWithSeperator,
|
|
|
|
|
+ isWorkWithSticky,
|
|
|
backgroundColor,
|
|
backgroundColor,
|
|
|
|
|
+ glassEffect,
|
|
|
borders,
|
|
borders,
|
|
|
spaces,
|
|
spaces,
|
|
|
colors
|
|
colors
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const [
|
|
|
|
|
+ contentHeight,
|
|
|
|
|
+ setContentHeight
|
|
|
|
|
+ ] = useState<null | number>(null);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if(onContentHeight) onContentHeight(contentHeight);
|
|
|
|
|
+ }, [contentHeight]);
|
|
|
|
|
+
|
|
|
const renderRight = () => {
|
|
const renderRight = () => {
|
|
|
if(RenderRight) {
|
|
if(RenderRight) {
|
|
|
return <RenderRight/>;
|
|
return <RenderRight/>;
|
|
@@ -65,10 +90,29 @@ const MainHeader = ({
|
|
|
|
|
|
|
|
const renderContent = () => {
|
|
const renderContent = () => {
|
|
|
return <View
|
|
return <View
|
|
|
|
|
+ {...props}
|
|
|
style={[
|
|
style={[
|
|
|
|
|
+ style,
|
|
|
stylesheet.container,
|
|
stylesheet.container,
|
|
|
containerDynamicStyle
|
|
containerDynamicStyle
|
|
|
]}
|
|
]}
|
|
|
|
|
+ onLayout={(event) => {
|
|
|
|
|
+ if(props && props.onLayout) {
|
|
|
|
|
+ props.onLayout(event);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isWorkWithSticky) {
|
|
|
|
|
+ const _contentHeight = event.nativeEvent.layout.height;
|
|
|
|
|
+
|
|
|
|
|
+ setContentHeight(_contentHeight);
|
|
|
|
|
+
|
|
|
|
|
+ if(isSetAutoHeaderSpace) {
|
|
|
|
|
+ NCoreUIKitTheme.updateConfigs({
|
|
|
|
|
+ headerSpace: _contentHeight
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
>
|
|
>
|
|
|
{renderLeft()}
|
|
{renderLeft()}
|
|
|
{renderRight()}
|
|
{renderRight()}
|
|
@@ -92,6 +136,9 @@ const MainHeader = ({
|
|
|
edges={[
|
|
edges={[
|
|
|
"top"
|
|
"top"
|
|
|
]}
|
|
]}
|
|
|
|
|
+ style={[
|
|
|
|
|
+ safeAreaViewDynamicStyle
|
|
|
|
|
+ ]}
|
|
|
>
|
|
>
|
|
|
{renderContentContainer()}
|
|
{renderContentContainer()}
|
|
|
</SafeAreaView>;
|
|
</SafeAreaView>;
|
|
@@ -103,9 +150,15 @@ const MainHeader = ({
|
|
|
stylesheet.baseContainer
|
|
stylesheet.baseContainer
|
|
|
]}
|
|
]}
|
|
|
>
|
|
>
|
|
|
- {isWorkWithPortal ? children : null}
|
|
|
|
|
{isWorkWithSafeAreaView ? renderSafeAreaView() : renderContentContainer()}
|
|
{isWorkWithSafeAreaView ? renderSafeAreaView() : renderContentContainer()}
|
|
|
- {isWorkWithPortal ? null : children}
|
|
|
|
|
|
|
+ {isWorkWithSticky && isWorkWithStickySpace ? <View
|
|
|
|
|
+ style={{
|
|
|
|
|
+ backgroundColor: customBackgroundColor ? colors.project[customBackgroundColor] : colors.content.container[backgroundColor],
|
|
|
|
|
+ height: contentHeight,
|
|
|
|
|
+ width: "100%"
|
|
|
|
|
+ }}
|
|
|
|
|
+ /> : null}
|
|
|
|
|
+ {children}
|
|
|
</View>;
|
|
</View>;
|
|
|
};
|
|
};
|
|
|
|
|
|