Skip to content

Commit

Permalink
fix: toast offset
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Sep 8, 2024
1 parent 61ee26a commit 037d64e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { AppState, LogBox } from 'react-native'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { createModalStack, ModalProvider } from 'react-native-modalfy'
import { SafeAreaView } from 'react-native-safe-area-context'
import { Toaster } from 'sonner-native'
import { SWRConfig } from 'swr'

import { Text } from '~/components'
import { AIDailyModal } from '~/components/ai-daily'
import { Toaster } from '~/components/toaster'
import { db, expoDb } from '~/db'
import migrations from '~/drizzle/migrations'
import { useNavigationTheme, useTheme } from '~/hooks/use-theme'
Expand Down Expand Up @@ -124,7 +124,7 @@ export default function Root() {
<BottomSheetModalProvider>
<ModalProvider stack={stack}>
<Slot />
<Toaster position="bottom-center" offset={75} duration={1000} />
<Toaster />
</ModalProvider>
</BottomSheetModalProvider>
</GestureHandlerRootView>
Expand Down
20 changes: 20 additions & 0 deletions components/toaster.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { usePathname } from 'expo-router'
import { useMemo } from 'react'
import { Toaster as SoonerToaster } from 'sonner-native'

import { tabViewList } from '~/consts/view'

export function Toaster() {
const pathname = usePathname()
const isInTabView = useMemo(
() => tabViewList.some(tabView => tabView.path === pathname),
[pathname],
)
return (
<SoonerToaster
position="bottom-center"
offset={isInTabView ? 75 : undefined}
duration={1000}
/>
)
}

0 comments on commit 037d64e

Please sign in to comment.