75 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-06-08 00:07:04 +08:00
import Player from '@/web/components/New/PlayerMobile'
import { css, cx } from '@emotion/css'
import { useMemo } from 'react'
import { player } from '@/web/store'
import { useSnapshot } from 'valtio'
import Router from '@/web/components/New/Router'
import MenuBar from './MenuBar'
2022-06-25 13:47:07 +08:00
import Topbar from './Topbar/TopbarMobile'
2022-06-08 11:48:22 +08:00
import { isIOS, isPWA, isSafari } from '@/web/utils/common'
2022-06-14 23:23:34 +08:00
import Login from './Login'
2022-06-25 13:47:07 +08:00
import { useLocation } from 'react-router-dom'
import PlayingNext from './PlayingNextMobile'
2022-06-08 00:07:04 +08:00
const LayoutMobile = () => {
const playerSnapshot = useSnapshot(player)
2022-06-11 00:19:07 +08:00
const showPlayer = !!playerSnapshot.track
2022-06-25 13:47:07 +08:00
const location = useLocation()
2022-06-08 00:07:04 +08:00
return (
2022-06-25 13:47:07 +08:00
<div id='layout' className='select-none bg-white pb-28 dark:bg-black'>
2022-06-09 20:16:05 +08:00
<main className='min-h-screen overflow-y-auto overflow-x-hidden pb-16'>
2022-06-25 13:47:07 +08:00
{location.pathname === '/' && <Topbar />}
2022-06-08 00:07:04 +08:00
<Router />
</main>
2022-06-08 11:48:22 +08:00
<div
className={cx(
2022-06-25 13:47:07 +08:00
'fixed bottom-0 left-0 right-0 z-20 pt-3 dark:bg-black',
2022-06-08 11:48:22 +08:00
css`
padding-bottom: calc(
${isIOS && isSafari && isPWA
? '24px'
: 'env(safe-area-inset-bottom)'} + 0.75rem
);
`
)}
>
{showPlayer && (
<div
className={cx(
2022-06-25 13:47:07 +08:00
'absolute left-7 right-7 z-20',
2022-06-08 11:48:22 +08:00
css`
top: calc(
-100% - 6px + ${isIOS && isSafari && isPWA ? '24px' : 'env(safe-area-inset-bottom)'}
);
`
)}
>
<Player />
</div>
)}
2022-06-08 00:07:04 +08:00
<MenuBar />
2022-06-25 13:47:07 +08:00
{/* <PlayingNext /> */}
2022-06-08 00:07:04 +08:00
</div>
2022-06-09 20:16:05 +08:00
2022-06-14 23:23:34 +08:00
<Login />
2022-06-09 20:16:05 +08:00
{/* Notch background */}
{isIOS && isSafari && isPWA && (
<div
className={cx(
'fixed left-0 right-0 bg-black/30 backdrop-blur-sm',
css`
top: -50px;
height: 50px;
`
)}
></div>
)}
2022-06-08 00:07:04 +08:00
</div>
)
}
export default LayoutMobile