| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import {
- useEffect
- } from "react";
- import {
- Platform
- } from "react-native";
- import type RootStackParamList from "./type";
- import {
- NCoreUIKitEmbeddedMenu,
- NCoreUIKitLocalize,
- NCoreUIKitTheme,
- MainHeader
- } from "ncore-ui-kit";
- import {
- NavigationContainer,
- useNavigation
- } from "@react-navigation/native";
- import {
- type NativeStackNavigationProp,
- createNativeStackNavigator
- } from "@react-navigation/native-stack";
- import {
- ComponentIcon,
- HomeIcon
- } from "lucide-react-native";
- import Home from "../pages/home";
- import TextPage from "../pages/text";
- const RootStack = createNativeStackNavigator();
- const ComponentsStack = createNativeStackNavigator();
- const ComponentsNav = () => {
- return <ComponentsStack.Navigator
- initialRouteName="TextPage"
- screenOptions={{
- headerShown: true
- }}
- >
- <ComponentsStack.Screen
- name="TextPage"
- component={TextPage}
- />
- </ComponentsStack.Navigator>;
- };
- const RootNav = () => {
- const {
- colors
- } = NCoreUIKitTheme.useContext();
- const {
- localize
- } = NCoreUIKitLocalize.useContext();
- const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
- useEffect(() => {
- const currentMenuStatus = Platform.OS === "web" ? window.localStorage.getItem("main-menu-status") : "false";
- NCoreUIKitEmbeddedMenu.load({
- isCollapse: currentMenuStatus === "true" ? true : false,
- isWorkWithSafeAreaView: false,
- siteLogoProps: {
- isShowIcon: false,
- title: localize("menu")
- },
- buttons: [
- {
- redirectMain: "Home",
- isUseLocalize: true,
- title: "home",
- icon: ({
- color
- }) => <HomeIcon
- color={colors.content.icon[color]}
- />
- },
- {
- redirectMain: "Components",
- isUseLocalize: true,
- isCollapsible: true,
- title: "components",
- icon: ({
- color
- }) => <ComponentIcon
- color={colors.content.icon[color]}
- />,
- subButtons: [
- {
- redirectMain: "Components",
- redirectSub: "TextPage",
- title: "Text"
- }
- ]
- }
- ],
- isAutoClosed: true,
- id: "main-menu"
- });
- NCoreUIKitEmbeddedMenu.addEventListener("state", updateStorage);
- }, []);
- const updateStorage = () => {
- const data = NCoreUIKitEmbeddedMenu.state.data;
- if(Platform.OS === "web" && data && data.length) {
- const currentMenu = data.find(dI => dI.id === "main-menu");
- if(currentMenu) {
- window.localStorage.setItem("main-menu-status", String(currentMenu.isCollapse));
- }
- }
- };
- return <MainHeader
- isWorkWithSeperator={true}
- siteLogoProps={{
- imageUrl: "http://ncore.nibgat.space/assets/images/ncorelogo.png",
- onPress: () => {
- navigation.navigate("Home");
- },
- imageProps: {
- resizeMode: "stretch"
- },
- subTitle: "Design System - UI Kit",
- title: "NİBGAT® | NCore",
- isWorkWithAction: true,
- isWorkWithFlex1: true
- }}
- isWorkWithSticky={true}
- glassEffect={5}
- >
- <NCoreUIKitEmbeddedMenu.Render
- navigation={navigation as unknown as NCoreUIKit.Navigation}
- id="main-menu"
- >
- <RootStack.Navigator
- initialRouteName="Home"
- screenOptions={{
- headerShown: false
- }}
- >
- <RootStack.Screen
- component={Home}
- name="Home"
- />
- <RootStack.Screen
- component={ComponentsNav}
- name="Components"
- />
- </RootStack.Navigator>
- </NCoreUIKitEmbeddedMenu.Render>
- </MainHeader>;
- };
- const Navigation = () => {
- return <NavigationContainer
- linking={{
- prefixes: [
- "http://localhost:3000",
- "https://ncore.nibgat.space"
- ],
- config: {
- screens: {
- Home: "",
- TestSubPage: "text"
- }
- }
- }}
- >
- <RootNav/>
- </NavigationContainer>;
- };
- export default Navigation;
|