Tab switcher
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
const Content = ({ className, children }) => (
|
import classNames from 'classnames';
|
||||||
<div
|
|
||||||
className={`${className} flex-1 overflow-auto"`}
|
const Content = ({ className, visible, children }) => (
|
||||||
style={{
|
<div className={classNames(`h-full overflow-auto py-2 absolute top-0 ${className || ''}`, {
|
||||||
paddingTop: `calc(env(safe-area-inset-top, 0px) + 16px)`, // Care for the notch
|
visible,
|
||||||
}}>
|
invisible: !visible
|
||||||
|
})}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+16
-3
@@ -1,13 +1,26 @@
|
|||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import { Plugins } from '@capacitor/core';
|
||||||
|
|
||||||
const Nav = ({ page }) => {
|
const Nav = ({ page }) => {
|
||||||
const [showMenu, setShowMenu] = useState(false);
|
const [showMenu, setShowMenu] = useState(false);
|
||||||
|
|
||||||
const [showMobileMenu, setShowMobileMenu] = useState(false);
|
const [showMobileMenu, setShowMobileMenu] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
Plugins.StatusBar.setStyle({
|
||||||
|
style: 'DARK'
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="bg-gray-800 w-full flex-0 h-auto">
|
<nav
|
||||||
<div className="max-w-7xl mx-auto px-2 sm:px-6 lg:px-8">
|
className="bg-gray-800 w-full flex-0 flex items-end flex-row"
|
||||||
|
style={{
|
||||||
|
height: `calc(env(safe-area-inset-bottom, 0px) + 64px)`
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="max-w-7xl mx-auto px-2 sm:px-6 lg:px-8 flex-1">
|
||||||
<div className="relative flex items-center justify-between h-16">
|
<div className="relative flex items-center justify-between h-16">
|
||||||
<div
|
<div
|
||||||
className="absolute inset-y-0 left-0 flex items-center sm:hidden"
|
className="absolute inset-y-0 left-0 flex items-center sm:hidden"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const TabBar = ({ children }) => (
|
const TabBar = ({ children }) => (
|
||||||
<nav
|
<nav
|
||||||
id="tab-bar"
|
id="tab-bar"
|
||||||
className="py-2 h-16 bg-white bottom-0 w-full flex justify-center items-start bg-gray-50"
|
className="py-2 h-16 bg-white w-full flex justify-center items-start bg-gray-50"
|
||||||
style={{
|
style={{
|
||||||
height: `calc(env(safe-area-inset-bottom, 0px) + 56px)`
|
height: `calc(env(safe-area-inset-bottom, 0px) + 56px)`
|
||||||
}}>
|
}}>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { homeItems } from "../../data";
|
|||||||
import PostCard from "../Card";
|
import PostCard from "../Card";
|
||||||
import Content from "../Content";
|
import Content from "../Content";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = ({ selected }) => {
|
||||||
return (
|
return (
|
||||||
<Content>
|
<Content visible={selected}>
|
||||||
{homeItems.map(i => (
|
{homeItems.map(i => (
|
||||||
<PostCard {...i} />
|
<PostCard {...i} />
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { homeItems } from "../../data";
|
import { homeItems } from "../../data";
|
||||||
import Content from "../Content";
|
import Content from "../Content";
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = ({ selected }) => {
|
||||||
return (
|
return (
|
||||||
<Content>
|
<Content visible={selected}>
|
||||||
<h2>Profile</h2>
|
<h2>Profile</h2>
|
||||||
</Content>
|
</Content>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import Content from "../Content";
|
import Content from "../Content";
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = ({ selected }) => {
|
||||||
return (
|
return (
|
||||||
<Content className="p-4">
|
<Content visible={selected}>
|
||||||
<h2>Settings</h2>
|
<h2>Settings</h2>
|
||||||
</Content>
|
</Content>
|
||||||
)
|
)
|
||||||
|
|||||||
+8
-2
@@ -15,8 +15,14 @@ const pages = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const CurrentPage = ({ page }) => {
|
const CurrentPage = ({ page }) => {
|
||||||
const Page = page.component;
|
return (
|
||||||
return <Page />;
|
<div className="flex-1 overflow-hidden relative">
|
||||||
|
{pages.map(p => {
|
||||||
|
const Page = p.component;
|
||||||
|
return <Page selected={page.id === p.id} />
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
body {
|
body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
#__next {
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user