2022-10-28 20:29:04 +08:00
|
|
|
import Player from '@/web/components/PlayerMobile'
|
2022-06-08 00:07:04 +08:00
|
|
|
import { css, cx } from '@emotion/css'
|
|
|
|
import { useMemo } from 'react'
|
2022-07-11 11:06:41 +08:00
|
|
|
import player from '@/web/states/player'
|
2022-06-08 00:07:04 +08:00
|
|
|
import { useSnapshot } from 'valtio'
|
2022-10-28 20:29:04 +08:00
|
|
|
import Router from '@/web/components/Router'
|
2022-06-08 00:07:04 +08:00
|
|
|
import MenuBar from './MenuBar'
|
2022-06-25 13:47:07 +08:00
|
|
|
import Topbar from './Topbar/TopbarMobile'
|
2022-06-30 00:02:21 +08:00
|
|
|
import { isIOS, isIosPwa, 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-07-11 11:06:41 +08:00
|
|
|
<div id='layout' className='select-none bg-white pb-28 dark:bg-black'>
|
|
|
|
<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
|
2023-01-24 16:29:33 +08:00
|
|
|
className={cx('fixed bottom-0 left-0 right-0 z-20 pt-3 dark:bg-black')}
|
|
|
|
style={{
|
|
|
|
paddingBottom: `calc(
|
2022-06-30 00:02:21 +08:00
|
|
|
${isIosPwa ? '24px' : 'env(safe-area-inset-bottom)'} + 0.75rem
|
2023-01-24 16:29:33 +08:00
|
|
|
)`,
|
|
|
|
}}
|
2022-06-08 11:48:22 +08:00
|
|
|
>
|
|
|
|
{showPlayer && (
|
|
|
|
<div
|
2023-01-24 16:29:33 +08:00
|
|
|
className={cx('absolute left-7 right-7 z-20')}
|
|
|
|
style={{
|
|
|
|
top: `calc(-100% - 6px + ${isIosPwa ? '24px' : 'env(safe-area-inset-bottom)'})`,
|
|
|
|
}}
|
2022-06-08 11:48:22 +08:00
|
|
|
>
|
|
|
|
<Player />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2022-06-08 00:07:04 +08:00
|
|
|
<MenuBar />
|
2022-07-11 11:06:41 +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 */}
|
2022-06-30 00:02:21 +08:00
|
|
|
{isIosPwa && (
|
2022-06-09 20:16:05 +08:00
|
|
|
<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
|