Files
otunes/apps/mobile/components/tablet-sidebar.tsx
T

42 lines
1.2 KiB
TypeScript

import { useOpenSettings } from "@/hooks/use-open-settings"
import { requireNativeView } from "expo"
import { useIsFocused } from "expo-router"
import { Platform, type ViewProps } from "react-native"
import { useCachedQuery } from "@/hooks/use-cached-query"
import { useProfileImageUrl } from "@/hooks/use-profile-image-url"
import { initialsFromName } from "@/lib/format"
import { api } from "@otunes/convex/_generated/api"
const NativeSidebar =
Platform.OS === "ios"
? requireNativeView<
ViewProps & {
accountName: string
initials: string
imageURL?: string
active: boolean
onProfilePress: () => void
}
>("TabletSidebar")
: null
export function TabletSidebar() {
const user = useCachedQuery(api.auth.currentUser)
const imageUrl = useProfileImageUrl(user?.image)
const openSettings = useOpenSettings()
const active = useIsFocused()
if (!NativeSidebar) return null
return (
<NativeSidebar
style={{ position: "absolute", width: 0, height: 0 }}
accountName={user?.name ?? "Account"}
initials={initialsFromName(user?.name ?? "Me")}
imageURL={imageUrl}
active={active}
onProfilePress={openSettings}
/>
)
}