aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/components/ui/CustomSafeAreaView.tsx
blob: 8e7755c2f94b862d9c5b43cc4c1fa1e9abe4dc9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { SafeAreaView } from "react-native-safe-area-context";
import { useColorScheme } from "@/lib/useColorScheme";
import { useHeaderHeight } from "@react-navigation/elements";

export default function CustomSafeAreaView({
  children,
  edges = ["top", "bottom"],
}: {
  children: React.ReactNode;
  edges?: ("top" | "bottom")[];
}) {
  const headerHeight = useHeaderHeight();
  const { colors } = useColorScheme();

  return (
    <SafeAreaView
      style={{
        flex: 1,
        backgroundColor: colors.background,
        paddingTop: edges.includes("top")
          ? headerHeight > 0
            ? headerHeight
            : undefined
          : undefined,
      }}
    >
      {children}
    </SafeAreaView>
  );
}