From 1a8d9c529ea80828992177f0830fe2cf115f5690 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Wed, 30 Dec 2020 16:10:30 -0600 Subject: [PATCH] Routing shell --- components/AppShell.jsx | 89 ++++++++++++++++++++--------------- components/pages/Lists.jsx | 7 ++- components/pages/Settings.jsx | 2 +- components/ui/Tab.jsx | 39 ++++++++------- hooks/useLocation.js | 86 +++++++++++++++++++++++++++++++++ pages/lists.js | 6 +++ pages/settings.js | 6 +++ 7 files changed, 175 insertions(+), 60 deletions(-) create mode 100644 hooks/useLocation.js create mode 100644 pages/lists.js create mode 100644 pages/settings.js diff --git a/components/AppShell.jsx b/components/AppShell.jsx index 0de06ba..ce0347f 100644 --- a/components/AppShell.jsx +++ b/components/AppShell.jsx @@ -1,5 +1,7 @@ +import { useCallback, useEffect, useState } from 'react'; import { useDrag } from 'react-use-gesture'; -import { Route, Switch } from 'wouter'; +import { Router, Route, Switch, useRoute } from 'wouter'; +import { cog, cogOutline, home, homeOutline, list, listOutline } from 'ionicons/icons'; import Store from '../store'; import * as actions from '../store/actions'; @@ -16,13 +18,16 @@ import TabBar from '../components/ui/TabBar'; import { SafeAreaProvider } from '../components/ui/SafeArea'; import Notifications from '../components/Notifications'; import MenuContent from '../components/MenuContent'; -import { useEffect, useState } from 'react'; import Home from './pages/Home'; -import { cog, cogOutline, home, homeOutline, list, listOutline } from 'ionicons/icons'; +import Lists from './pages/Lists'; +import Settings from './pages/Settings'; +import useLocation from '../hooks/useLocation'; const CurrentPage = ({ page }) => { const currentPage = Store.useState(selectors.getCurrentPage); + const [match, params] = useRoute('/lists'); + console.log('Matches?', match); // const Page = currentPage.component; const Page = page; @@ -32,19 +37,23 @@ const CurrentPage = ({ page }) => { setLocal(true); }, []); + console.log('Rendering current page', local); + return ( {local ? ( + + ) : ( )} {/*pages.map(p => { - const Page = p.component; - return ; - })*/} + const Page = p.component; + return ; + })*/} {/**/} ); @@ -87,39 +96,41 @@ const AppShell = ({ page }) => { }} > - - - -