use ui back button for non tma mode
This commit is contained in:
parent
12686f0712
commit
0bc83446b5
@ -1,14 +1,22 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
import { UpdateProfile } from '@/components/auth';
|
import { UpdateProfile } from '@/components/auth';
|
||||||
import { BottomNav } from '@/components/navigation';
|
import { BottomNav } from '@/components/navigation';
|
||||||
|
import { EmptyProvider } from '@/providers/empty';
|
||||||
import { TelegramProvider } from '@/providers/telegram';
|
import { TelegramProvider } from '@/providers/telegram';
|
||||||
|
import { isTMA } from '@telegram-apps/sdk-react';
|
||||||
import { type PropsWithChildren } from 'react';
|
import { type PropsWithChildren } from 'react';
|
||||||
|
|
||||||
export default async function Layout({ children }: Readonly<PropsWithChildren>) {
|
export default function Layout({ children }: Readonly<PropsWithChildren>) {
|
||||||
|
const isTG = isTMA('simple');
|
||||||
|
|
||||||
|
const Provider = isTG ? TelegramProvider : EmptyProvider;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TelegramProvider>
|
<Provider>
|
||||||
<UpdateProfile />
|
<UpdateProfile />
|
||||||
<main className="grow">{children}</main>
|
<main className="grow">{children}</main>
|
||||||
<BottomNav />
|
<BottomNav />
|
||||||
</TelegramProvider>
|
</Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,21 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
import { BackButton } from './back-button';
|
||||||
|
import { cn } from '@repo/ui/lib/utils';
|
||||||
|
import { isTMA } from '@telegram-apps/sdk-react';
|
||||||
|
|
||||||
type Props = { title: string | undefined };
|
type Props = { title: string | undefined };
|
||||||
|
|
||||||
export function PageHeader(props: Readonly<Props>) {
|
export function PageHeader(props: Readonly<Props>) {
|
||||||
|
const isTG = isTMA('simple');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sticky top-0 z-50 flex h-12 items-center rounded-b-lg bg-transparent px-4 font-bold tracking-wide backdrop-blur-md">
|
<div
|
||||||
{/* <BackButton /> */}
|
className={cn(
|
||||||
|
'sticky top-0 z-50 flex h-12 items-center rounded-b-lg bg-transparent font-bold tracking-wide backdrop-blur-md',
|
||||||
|
isTG ? 'px-4' : 'px-2',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{!isTG && <BackButton />}
|
||||||
{props.title}
|
{props.title}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -21,10 +21,12 @@ export function useBackButton() {
|
|||||||
}, [onBackClick]);
|
}, [onBackClick]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isRootLevelPage(pathname)) {
|
if (backButton.isMounted()) {
|
||||||
backButton.hide();
|
if (isRootLevelPage(pathname)) {
|
||||||
} else {
|
backButton.hide();
|
||||||
backButton.show();
|
} else {
|
||||||
|
backButton.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [pathname]);
|
}, [pathname]);
|
||||||
}
|
}
|
||||||
|
|||||||
5
apps/web/providers/empty.tsx
Normal file
5
apps/web/providers/empty.tsx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { type PropsWithChildren } from 'react';
|
||||||
|
|
||||||
|
export function EmptyProvider({ children }: Readonly<PropsWithChildren>) {
|
||||||
|
return <>{children}</>;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user