index.tsx 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. import {
  2. useEffect
  3. } from "react";
  4. import {
  5. Platform,
  6. View
  7. } from "react-native";
  8. import type RootStackParamList from "./type";
  9. import stylesheet from "./stylesheet";
  10. import {
  11. NCoreUIKitEmbeddedMenu,
  12. NCoreUIKitLocalize,
  13. NCoreUIKitTheme,
  14. PaletteSwitcher,
  15. LocaleSwitcher,
  16. ThemeSwitcher,
  17. MainHeader
  18. } from "ncore-ui-kit";
  19. import {
  20. NavigationContainer,
  21. type LinkingOptions,
  22. getStateFromPath,
  23. useNavigation
  24. } from "@react-navigation/native";
  25. import TypesOverridePage from "../pages/coreFeatures/typesOverride";
  26. import {
  27. type NativeStackNavigationProp,
  28. createNativeStackNavigator
  29. } from "@react-navigation/native-stack";
  30. import {
  31. ComponentIcon,
  32. SettingsIcon,
  33. GoalIcon,
  34. HomeIcon
  35. } from "lucide-react-native";
  36. import NotificationIndicatorPage from "../pages/components/notificationIndicator";
  37. import HighlightButtonPage from "../pages/components/highlightButton";
  38. import PaletteSwitcherPage from "../pages/components/paletteSwitcher";
  39. import LocaleExamplesPage from "../pages/coreFeatures/localeExamples";
  40. import DateTimePickerPage from "../pages/components/dateTimePicker";
  41. import LocaleSwitcherPage from "../pages/components/localeSwitcher";
  42. import MarkdownEditorPage from "../pages/components/markdownEditor";
  43. import MarkdownViewerPage from "../pages/components/markdownViewer";
  44. import ThemeExamplesPage from "../pages/coreFeatures/themeExamples";
  45. import DateTimeSheetPage from "../pages/components/dateTimeSheet";
  46. import MonthSelectorPage from "../pages/components/monthSelector";
  47. import PageContainerPage from "../pages/components/pageContainer";
  48. import SystemToolbarPage from "../pages/components/systemToolbar";
  49. import TextAreaInputPage from "../pages/components/textAreaInput";
  50. import ThemeSwitcherPage from "../pages/components/themeSwitcher";
  51. import DefaultJSONsPage from "../pages/coreFeatures/defaultJSONs";
  52. import DateSelectorPage from "../pages/components/dateSelector";
  53. import EmbeddedMenuPage from "../pages/components/embeddedMenu";
  54. import NumericInputPage from "../pages/components/numericInput";
  55. import TimeSelectorPage from "../pages/components/timeSelector";
  56. import WebScrollbarPage from "../pages/components/webScrollbar";
  57. import YearSelectorPage from "../pages/components/yearSelector";
  58. import AvatarGroupPage from "../pages/components/avatarGroup";
  59. import BottomSheetPage from "../pages/components/bottomSheet";
  60. import RadioButtonPage from "../pages/components/radioButton";
  61. import SelectSheetPage from "../pages/components/selectSheet";
  62. import ToolsUsagePage from "../pages/coreFeatures/toolsUsage";
  63. import CodeEditorPage from "../pages/components/codeEditor";
  64. import CodeViewerPage from "../pages/components/codeViewer";
  65. import MainHeaderPage from "../pages/components/mainHeader";
  66. import SelectBoxPage from "../pages/components/selectBox";
  67. import SeperatorPage from "../pages/components/seperator";
  68. import StateCardPage from "../pages/components/stateCard";
  69. import TextInputPage from "../pages/components/textInput";
  70. import ImplementationPage from "../pages/implementation";
  71. import CheckBoxPage from "../pages/components/checkBox";
  72. import SiteLogoPage from "../pages/components/siteLogo";
  73. import SnackBarPage from "../pages/components/snackBar";
  74. import LoadingPage from "../pages/components/loading";
  75. import RowCardPage from "../pages/components/rowCard";
  76. import StickerPage from "../pages/components/sticker";
  77. import TooltipPage from "../pages/components/tooltip";
  78. import InstallationPage from "../pages/installation";
  79. import AvatarPage from "../pages/components/avatar";
  80. import ButtonPage from "../pages/components/button";
  81. import DialogPage from "../pages/components/dialog";
  82. import HeaderPage from "../pages/components/header";
  83. import SwitchPage from "../pages/components/switch";
  84. import ModalPage from "../pages/components/modal";
  85. import ToastPage from "../pages/components/toast";
  86. import ChipPage from "../pages/components/chip";
  87. import MenuPage from "../pages/components/menu";
  88. import TextPage from "../pages/components/text";
  89. import Home from "../pages/home";
  90. const RootStack = createNativeStackNavigator();
  91. const ComponentsStack = createNativeStackNavigator();
  92. const GettingStartedStack = createNativeStackNavigator();
  93. const CoreFeaturesStack = createNativeStackNavigator();
  94. const CoreFeaturesNav = () => {
  95. return <CoreFeaturesStack.Navigator
  96. initialRouteName="ToolsUsage"
  97. screenOptions={{
  98. headerShown: true
  99. }}
  100. >
  101. <CoreFeaturesStack.Screen
  102. component={ToolsUsagePage}
  103. name="ToolsUsage"
  104. />
  105. <CoreFeaturesStack.Screen
  106. component={ThemeExamplesPage}
  107. name="ThemeExamples"
  108. />
  109. <CoreFeaturesStack.Screen
  110. component={LocaleExamplesPage}
  111. name="LocaleExamples"
  112. />
  113. <CoreFeaturesStack.Screen
  114. component={TypesOverridePage}
  115. name="TypesOverride"
  116. />
  117. <CoreFeaturesStack.Screen
  118. component={DefaultJSONsPage}
  119. name="DefaultJSONs"
  120. />
  121. </CoreFeaturesStack.Navigator>;
  122. };
  123. const GettingStartedNav = () => {
  124. return <GettingStartedStack.Navigator
  125. initialRouteName="Installation"
  126. screenOptions={{
  127. headerShown: true
  128. }}
  129. >
  130. <GettingStartedStack.Screen
  131. component={InstallationPage}
  132. name="Installation"
  133. />
  134. <GettingStartedStack.Screen
  135. component={ImplementationPage}
  136. name="Implementation"
  137. />
  138. </GettingStartedStack.Navigator>;
  139. };
  140. const ComponentsNav = () => {
  141. return <ComponentsStack.Navigator
  142. initialRouteName="Text"
  143. screenOptions={{
  144. headerShown: true
  145. }}
  146. >
  147. <ComponentsStack.Screen
  148. component={AvatarPage}
  149. name="Avatar"
  150. />
  151. <ComponentsStack.Screen
  152. component={AvatarGroupPage}
  153. name="AvatarGroup"
  154. />
  155. <ComponentsStack.Screen
  156. component={BottomSheetPage}
  157. name="BottomSheet"
  158. />
  159. <ComponentsStack.Screen
  160. component={ButtonPage}
  161. name="Button"
  162. />
  163. <ComponentsStack.Screen
  164. component={CheckBoxPage}
  165. name="CheckBox"
  166. />
  167. <ComponentsStack.Screen
  168. component={CodeViewerPage}
  169. name="CodeViewer"
  170. />
  171. <ComponentsStack.Screen
  172. component={CodeEditorPage}
  173. name="CodeEditor"
  174. />
  175. <ComponentsStack.Screen
  176. component={ChipPage}
  177. name="Chip"
  178. />
  179. <ComponentsStack.Screen
  180. component={DateSelectorPage}
  181. name="DateSelector"
  182. />
  183. <ComponentsStack.Screen
  184. component={DateTimePickerPage}
  185. name="DateTimePicker"
  186. />
  187. <ComponentsStack.Screen
  188. component={DateTimeSheetPage}
  189. name="DateTimeSheet"
  190. />
  191. <ComponentsStack.Screen
  192. component={DialogPage}
  193. name="Dialog"
  194. />
  195. <ComponentsStack.Screen
  196. component={EmbeddedMenuPage}
  197. name="EmbeddedMenu"
  198. />
  199. <ComponentsStack.Screen
  200. component={HeaderPage}
  201. name="Header"
  202. />
  203. <ComponentsStack.Screen
  204. component={HighlightButtonPage}
  205. name="HighlightButton"
  206. />
  207. <ComponentsStack.Screen
  208. component={LoadingPage}
  209. name="Loading"
  210. />
  211. <ComponentsStack.Screen
  212. component={LocaleSwitcherPage}
  213. name="LocaleSwitcher"
  214. />
  215. <ComponentsStack.Screen
  216. component={MainHeaderPage}
  217. name="MainHeader"
  218. />
  219. <ComponentsStack.Screen
  220. component={MarkdownViewerPage}
  221. name="MarkdownViewer"
  222. />
  223. <ComponentsStack.Screen
  224. component={MarkdownEditorPage}
  225. name="MarkdownEditor"
  226. />
  227. <ComponentsStack.Screen
  228. component={MenuPage}
  229. name="Menu"
  230. />
  231. <ComponentsStack.Screen
  232. component={ModalPage}
  233. name="Modal"
  234. />
  235. <ComponentsStack.Screen
  236. component={MonthSelectorPage}
  237. name="MonthSelector"
  238. />
  239. <ComponentsStack.Screen
  240. component={NotificationIndicatorPage}
  241. name="NotificationIndicator"
  242. />
  243. <ComponentsStack.Screen
  244. component={NumericInputPage}
  245. name="NumericInput"
  246. />
  247. <ComponentsStack.Screen
  248. component={PageContainerPage}
  249. name="PageContainer"
  250. />
  251. <ComponentsStack.Screen
  252. component={PaletteSwitcherPage}
  253. name="PaletteSwitcher"
  254. />
  255. <ComponentsStack.Screen
  256. component={RadioButtonPage}
  257. name="RadioButton"
  258. />
  259. <ComponentsStack.Screen
  260. component={RowCardPage}
  261. name="RowCard"
  262. />
  263. <ComponentsStack.Screen
  264. component={SelectBoxPage}
  265. name="SelectBox"
  266. />
  267. <ComponentsStack.Screen
  268. component={SelectSheetPage}
  269. name="SelectSheet"
  270. />
  271. <ComponentsStack.Screen
  272. component={SeperatorPage}
  273. name="Seperator"
  274. />
  275. <ComponentsStack.Screen
  276. component={SiteLogoPage}
  277. name="SiteLogo"
  278. />
  279. <ComponentsStack.Screen
  280. component={SnackBarPage}
  281. name="SnackBar"
  282. />
  283. <ComponentsStack.Screen
  284. component={StateCardPage}
  285. name="StateCard"
  286. />
  287. <ComponentsStack.Screen
  288. component={StickerPage}
  289. name="Sticker"
  290. />
  291. <ComponentsStack.Screen
  292. component={SwitchPage}
  293. name="Switch"
  294. />
  295. <ComponentsStack.Screen
  296. component={SystemToolbarPage}
  297. name="SystemToolbar"
  298. />
  299. <ComponentsStack.Screen
  300. component={TextPage}
  301. name="Text"
  302. />
  303. <ComponentsStack.Screen
  304. component={TextAreaInputPage}
  305. name="TextAreaInput"
  306. />
  307. <ComponentsStack.Screen
  308. component={TextInputPage}
  309. name="TextInput"
  310. />
  311. <ComponentsStack.Screen
  312. component={ThemeSwitcherPage}
  313. name="ThemeSwitcher"
  314. />
  315. <ComponentsStack.Screen
  316. component={TimeSelectorPage}
  317. name="TimeSelector"
  318. />
  319. <ComponentsStack.Screen
  320. component={ToastPage}
  321. name="Toast"
  322. />
  323. <ComponentsStack.Screen
  324. component={TooltipPage}
  325. name="Tooltip"
  326. />
  327. <ComponentsStack.Screen
  328. component={WebScrollbarPage}
  329. name="WebScrollbar"
  330. />
  331. <ComponentsStack.Screen
  332. component={YearSelectorPage}
  333. name="YearSelector"
  334. />
  335. </ComponentsStack.Navigator>;
  336. };
  337. const RenderHomeIcon = ({
  338. color
  339. }: {
  340. color: keyof NCoreUIKit.IconContentColors;
  341. }) => {
  342. const {
  343. colors
  344. } = NCoreUIKitTheme.useContext();
  345. return <HomeIcon
  346. color={colors.content.icon[color]}
  347. />;
  348. };
  349. const RenderComponentIcon = ({
  350. color
  351. }: {
  352. color: keyof NCoreUIKit.IconContentColors;
  353. }) => {
  354. const {
  355. colors
  356. } = NCoreUIKitTheme.useContext();
  357. return <ComponentIcon
  358. color={colors.content.icon[color]}
  359. />;
  360. };
  361. const RenderGettingStartedIcon = ({
  362. color
  363. }: {
  364. color: keyof NCoreUIKit.IconContentColors;
  365. }) => {
  366. const {
  367. colors
  368. } = NCoreUIKitTheme.useContext();
  369. return <GoalIcon
  370. color={colors.content.icon[color]}
  371. />;
  372. };
  373. const RenderCoreFeaturesIcon = ({
  374. color
  375. }: {
  376. color: keyof NCoreUIKit.IconContentColors;
  377. }) => {
  378. const {
  379. colors
  380. } = NCoreUIKitTheme.useContext();
  381. return <SettingsIcon
  382. color={colors.content.icon[color]}
  383. />;
  384. };
  385. const RootNav = () => {
  386. const {
  387. activeTheme,
  388. spaces
  389. } = NCoreUIKitTheme.useContext();
  390. const {
  391. localize
  392. } = NCoreUIKitLocalize.useContext();
  393. const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  394. useEffect(() => {
  395. const currentMenuStatus = Platform.OS === "web" ? window.localStorage.getItem("main-menu-status") : "false";
  396. NCoreUIKitEmbeddedMenu.load({
  397. isCollapse: currentMenuStatus === "true" ? true : false,
  398. buttons: [
  399. {
  400. icon: ({
  401. color
  402. }) => <RenderHomeIcon
  403. color={color}
  404. />,
  405. redirectMain: "Home",
  406. isUseLocalize: true,
  407. title: "home"
  408. },
  409. {
  410. subButtons: [
  411. {
  412. redirectMain: "GettingStarted",
  413. redirectSub: "Installation",
  414. title: "installation",
  415. isUseLocalize: true
  416. },
  417. {
  418. redirectMain: "GettingStarted",
  419. redirectSub: "Implementation",
  420. title: "implementation",
  421. isUseLocalize: true
  422. }
  423. ],
  424. icon: ({
  425. color
  426. }) => <RenderGettingStartedIcon
  427. color={color}
  428. />,
  429. redirectMain: "GettingStarted",
  430. title: "gettingStarted",
  431. isCollapsible: true,
  432. isUseLocalize: true
  433. },
  434. {
  435. subButtons: [
  436. {
  437. redirectMain: "CoreFeatures",
  438. redirectSub: "ToolsUsage",
  439. title: "toolsUsage",
  440. isUseLocalize: true
  441. },
  442. {
  443. redirectMain: "CoreFeatures",
  444. redirectSub: "ThemeExamples",
  445. title: "themeExamples",
  446. isUseLocalize: true
  447. },
  448. {
  449. redirectSub: "LocaleExamples",
  450. redirectMain: "CoreFeatures",
  451. title: "localeExamples",
  452. isUseLocalize: true
  453. },
  454. {
  455. redirectMain: "CoreFeatures",
  456. redirectSub: "TypesOverride",
  457. title: "typesOverride",
  458. isUseLocalize: true
  459. },
  460. {
  461. redirectMain: "CoreFeatures",
  462. redirectSub: "DefaultJSONs",
  463. title: "defaultJSONs",
  464. isUseLocalize: true
  465. }
  466. ],
  467. icon: ({
  468. color
  469. }) => <RenderCoreFeaturesIcon
  470. color={color}
  471. />,
  472. redirectMain: "CoreFeatures",
  473. title: "coreFeatures",
  474. isCollapsible: true,
  475. isUseLocalize: true
  476. },
  477. {
  478. subButtons: [
  479. {
  480. redirectMain: "Components",
  481. redirectSub: "Text",
  482. title: "Text"
  483. },
  484. {
  485. redirectMain: "Components",
  486. redirectSub: "Button",
  487. title: "Button"
  488. },
  489. {
  490. redirectSub: "HighlightButton",
  491. redirectMain: "Components",
  492. title: "HighlightButton"
  493. },
  494. {
  495. redirectMain: "Components",
  496. redirectSub: "TextInput",
  497. title: "TextInput"
  498. },
  499. {
  500. redirectSub: "TextAreaInput",
  501. redirectMain: "Components",
  502. title: "TextAreaInput"
  503. },
  504. {
  505. redirectSub: "NumericInput",
  506. redirectMain: "Components",
  507. title: "NumericInput"
  508. },
  509. {
  510. redirectMain: "Components",
  511. redirectSub: "SelectBox",
  512. title: "SelectBox"
  513. },
  514. {
  515. redirectMain: "Components",
  516. redirectSub: "SelectSheet",
  517. title: "SelectSheet"
  518. },
  519. {
  520. redirectMain: "Components",
  521. redirectSub: "CheckBox",
  522. title: "CheckBox"
  523. },
  524. {
  525. redirectMain: "Components",
  526. redirectSub: "RadioButton",
  527. title: "RadioButton"
  528. },
  529. {
  530. redirectMain: "Components",
  531. redirectSub: "Switch",
  532. title: "Switch"
  533. },
  534. {
  535. redirectSub: "DateTimePicker",
  536. redirectMain: "Components",
  537. title: "DateTimePicker"
  538. },
  539. {
  540. redirectSub: "DateTimeSheet",
  541. redirectMain: "Components",
  542. title: "DateTimeSheet"
  543. },
  544. {
  545. redirectSub: "DateSelector",
  546. redirectMain: "Components",
  547. title: "DateSelector"
  548. },
  549. {
  550. redirectSub: "TimeSelector",
  551. redirectMain: "Components",
  552. title: "TimeSelector"
  553. },
  554. {
  555. redirectSub: "MonthSelector",
  556. redirectMain: "Components",
  557. title: "MonthSelector"
  558. },
  559. {
  560. redirectSub: "YearSelector",
  561. redirectMain: "Components",
  562. title: "YearSelector"
  563. },
  564. {
  565. redirectMain: "Components",
  566. redirectSub: "Avatar",
  567. title: "Avatar"
  568. },
  569. {
  570. redirectMain: "Components",
  571. redirectSub: "AvatarGroup",
  572. title: "AvatarGroup"
  573. },
  574. {
  575. redirectMain: "Components",
  576. redirectSub: "CodeViewer",
  577. title: "CodeViewer"
  578. },
  579. {
  580. redirectMain: "Components",
  581. redirectSub: "CodeEditor",
  582. title: "CodeEditor",
  583. isUseLocalize: true
  584. },
  585. {
  586. redirectSub: "SystemToolbar",
  587. redirectMain: "Components",
  588. title: "SystemToolbar",
  589. isUseLocalize: true
  590. },
  591. {
  592. redirectMain: "Components",
  593. redirectSub: "Chip",
  594. title: "Chip"
  595. },
  596. {
  597. redirectMain: "Components",
  598. redirectSub: "Sticker",
  599. title: "Sticker"
  600. },
  601. {
  602. redirectMain: "Components",
  603. redirectSub: "RowCard",
  604. title: "RowCard"
  605. },
  606. {
  607. redirectMain: "Components",
  608. redirectSub: "StateCard",
  609. title: "StateCard"
  610. },
  611. {
  612. redirectMain: "Components",
  613. redirectSub: "Dialog",
  614. title: "Dialog"
  615. },
  616. {
  617. redirectMain: "Components",
  618. redirectSub: "Modal",
  619. title: "Modal"
  620. },
  621. {
  622. redirectMain: "Components",
  623. redirectSub: "BottomSheet",
  624. title: "BottomSheet"
  625. },
  626. {
  627. redirectMain: "Components",
  628. redirectSub: "SnackBar",
  629. title: "SnackBar"
  630. },
  631. {
  632. redirectMain: "Components",
  633. redirectSub: "Toast",
  634. title: "Toast"
  635. },
  636. {
  637. redirectMain: "Components",
  638. redirectSub: "Tooltip",
  639. title: "Tooltip"
  640. },
  641. {
  642. redirectMain: "Components",
  643. redirectSub: "Loading",
  644. title: "Loading"
  645. },
  646. {
  647. redirectSub: "NotificationIndicator",
  648. title: "NotificationIndicator",
  649. redirectMain: "Components"
  650. },
  651. {
  652. redirectSub: "MarkdownViewer",
  653. redirectMain: "Components",
  654. title: "MarkdownViewer"
  655. },
  656. {
  657. redirectSub: "MarkdownEditor",
  658. redirectMain: "Components",
  659. title: "MarkdownEditor"
  660. },
  661. {
  662. redirectMain: "Components",
  663. redirectSub: "Seperator",
  664. title: "Seperator"
  665. },
  666. {
  667. redirectMain: "Components",
  668. redirectSub: "SiteLogo",
  669. title: "SiteLogo"
  670. },
  671. {
  672. redirectSub: "WebScrollbar",
  673. redirectMain: "Components",
  674. title: "WebScrollbar"
  675. },
  676. {
  677. redirectSub: "PageContainer",
  678. redirectMain: "Components",
  679. title: "PageContainer"
  680. },
  681. {
  682. redirectMain: "Components",
  683. redirectSub: "Header",
  684. title: "Header"
  685. },
  686. {
  687. redirectMain: "Components",
  688. redirectSub: "MainHeader",
  689. title: "MainHeader"
  690. },
  691. {
  692. redirectMain: "Components",
  693. redirectSub: "Menu",
  694. title: "Menu"
  695. },
  696. {
  697. redirectSub: "EmbeddedMenu",
  698. redirectMain: "Components",
  699. title: "EmbeddedMenu"
  700. },
  701. {
  702. redirectSub: "ThemeSwitcher",
  703. redirectMain: "Components",
  704. title: "ThemeSwitcher"
  705. },
  706. {
  707. redirectSub: "PaletteSwitcher",
  708. redirectMain: "Components",
  709. title: "PaletteSwitcher"
  710. },
  711. {
  712. redirectSub: "LocaleSwitcher",
  713. redirectMain: "Components",
  714. title: "LocaleSwitcher"
  715. }
  716. ],
  717. redirectMain: "Components",
  718. icon: ({
  719. color
  720. }) => <RenderComponentIcon
  721. color={color}
  722. />,
  723. isCollapsible: true,
  724. isUseLocalize: true,
  725. title: "components"
  726. }
  727. ],
  728. isWorkWithSafeAreaView: false,
  729. siteLogoProps: {
  730. title: localize("menu"),
  731. isShowIcon: false
  732. },
  733. isAutoClosed: true,
  734. id: "main-menu"
  735. });
  736. NCoreUIKitLocalize.addEventListener("state", updateLocaleStorage);
  737. NCoreUIKitEmbeddedMenu.addEventListener("state", updateStorage);
  738. NCoreUIKitTheme.addEventListener("state", updateThemeStorage);
  739. }, []);
  740. const updateStorage = () => {
  741. if(Platform.OS === "web") {
  742. const data = NCoreUIKitEmbeddedMenu.state.data;
  743. if(data && data.length) {
  744. const currentMenu = data.find(dI => dI.id === "main-menu");
  745. if(currentMenu) {
  746. window.localStorage.setItem("main-menu-status", String(currentMenu.isCollapse));
  747. }
  748. }
  749. }
  750. };
  751. const updateLocaleStorage = () => {
  752. if(Platform.OS === "web") {
  753. const localeData = NCoreUIKitLocalize.state;
  754. if(localeData) {
  755. window.localStorage.setItem("locale", JSON.stringify(localeData));
  756. }
  757. }
  758. };
  759. const updateThemeStorage = () => {
  760. if(Platform.OS === "web") {
  761. const themeData = NCoreUIKitTheme.state;
  762. if(themeData) {
  763. window.localStorage.setItem("theme", JSON.stringify(themeData));
  764. }
  765. }
  766. };
  767. return <MainHeader
  768. siteLogoProps={{
  769. imageUrl: activeTheme.indexOf("dark") !== -1 ? "http://ncore.nibgat.space/assets/images/darklogo.png" : "http://ncore.nibgat.space/assets/images/ncorelogo.png",
  770. subTitle: "Design System - UI Kit",
  771. onPress: () => {
  772. navigation.navigate("Home");
  773. },
  774. imageProps: {
  775. resizeMode: "stretch"
  776. },
  777. title: "NİBGAT® | NCore",
  778. isWorkWithAction: true,
  779. isWorkWithFlex1: true
  780. }}
  781. renderRight={() => {
  782. return <View
  783. style={[
  784. stylesheet.rightContainer,
  785. {
  786. gap: spaces.spacingMd
  787. }
  788. ]}
  789. >
  790. <LocaleSwitcher/>
  791. <PaletteSwitcher/>
  792. <ThemeSwitcher/>
  793. </View>;
  794. }}
  795. isWorkWithSeperator={true}
  796. isWorkWithSticky={true}
  797. glassEffect={5}
  798. >
  799. <NCoreUIKitEmbeddedMenu.Render
  800. navigation={navigation as unknown as NCoreUIKit.Navigation}
  801. id="main-menu"
  802. >
  803. <RootStack.Navigator
  804. initialRouteName="Home"
  805. screenOptions={{
  806. headerShown: false
  807. }}
  808. >
  809. <RootStack.Screen
  810. component={GettingStartedNav}
  811. name="GettingStarted"
  812. />
  813. <RootStack.Screen
  814. component={CoreFeaturesNav}
  815. name="CoreFeatures"
  816. />
  817. <RootStack.Screen
  818. component={Home}
  819. name="Home"
  820. />
  821. <RootStack.Screen
  822. component={ComponentsNav}
  823. name="Components"
  824. />
  825. </RootStack.Navigator>
  826. </NCoreUIKitEmbeddedMenu.Render>
  827. </MainHeader>;
  828. };
  829. const Navigation = () => {
  830. return <NavigationContainer
  831. documentTitle={{
  832. formatter: (options, route) => `${options?.title ?? route?.name ?? "Home"} || NCore - Design System | UI Kit`
  833. }}
  834. linking={{
  835. config: {
  836. screens: {
  837. Components: {
  838. screens: {
  839. NotificationIndicator: "notificationindicator",
  840. HighlightButton: "highlightbutton",
  841. PaletteSwitcher: "paletteswitcher",
  842. DateTimePicker: "datetimepicker",
  843. LocaleSwitcher: "localeswitcher",
  844. MarkdownEditor: "markdowneditor",
  845. MarkdownViewer: "markdownviewer",
  846. DateTimeSheet: "datetimesheet",
  847. MonthSelector: "monthselector",
  848. PageContainer: "pagecontainer",
  849. SystemToolbar: "systemtoolber",
  850. TextAreaInput: "textareainput",
  851. ThemeSwitcher: "themeswitcher",
  852. DateSelector: "dateselector",
  853. EmbeddedMenu: "embeddedmenu",
  854. NumericInput: "numericinput",
  855. TimeSelector: "timeselector",
  856. WebScrollbar: "webscrollbar",
  857. YearSelector: "yearselector",
  858. AvatarGroup: "avatargroup",
  859. BottomSheet: "bottomsheet",
  860. RadioButton: "radiobutton",
  861. SelectSheet: "selectsheet",
  862. CodeEditor: "codeeditor",
  863. CodeViewer: "codeviewer",
  864. MainHeader: "mainheader",
  865. SelectBox: "selectbox",
  866. Seperator: "seperator",
  867. StateCard: "statecard",
  868. TextInput: "textinput",
  869. CheckBox: "checkbox",
  870. SiteLogo: "sitelogo",
  871. SnackBar: "snackbar",
  872. Loading: "loading",
  873. RowCard: "rowcard",
  874. Sticker: "sticker",
  875. Tooltip: "tooltip",
  876. Avatar: "avatar",
  877. Button: "button",
  878. Dialog: "dialog",
  879. Header: "header",
  880. Switch: "switch",
  881. Modal: "modal",
  882. Toast: "toast",
  883. Chip: "chip",
  884. Menu: "menu",
  885. Text: "text"
  886. },
  887. path: "components"
  888. },
  889. CoreFeatures: {
  890. screens: {
  891. LocaleExamples: "localeexamples",
  892. ThemeExamples: "themeexamples",
  893. TypesOverride: "typesoverride",
  894. DefaultJSONs: "defaultjsons",
  895. ToolsUsage: "toolsusage"
  896. },
  897. path: "corefeatures"
  898. },
  899. GettingStarted: {
  900. screens: {
  901. Implementation: "implementation",
  902. Installation: "installation"
  903. },
  904. path: "gettingstarted"
  905. },
  906. Home: "home"
  907. }
  908. },
  909. getStateFromPath: (path, options) => {
  910. return getStateFromPath(path.toLowerCase(), options);
  911. },
  912. prefixes: [
  913. "http://localhost:3000",
  914. "https://ncore.nibgat.space"
  915. ]
  916. } as LinkingOptions<RootStackParamList>}
  917. >
  918. <RootNav/>
  919. </NavigationContainer>;
  920. };
  921. export default Navigation;