Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

GlassSafeAreaView.tsx

52 lines1.6 KB

1import type { ReactNode } from "react";
2import { View, type StyleProp, type ViewStyle } from "react-native";
3import { useSafeAreaInsets } from "react-native-safe-area-context";
4import { useThemeColor } from "../lib/useThemeColor";
5​
6import { GlassSurface } from "./GlassSurface";
7​
8export interface GlassSafeAreaViewProps {
9 readonly leftSlot?: ReactNode;
10 readonly centerSlot?: ReactNode;
11 readonly rightSlot?: ReactNode;
12 readonly style?: StyleProp<ViewStyle>;
14​
15export function GlassSafeAreaView({
16 leftSlot,
17 centerSlot,
18 rightSlot,
19 style,
20}: GlassSafeAreaViewProps) {
21 const insets = useSafeAreaInsets();
22 const headerColor = useThemeColor("--color-header");
23 const headerBorderColor = useThemeColor("--color-header-border");
24 const glassTint = useThemeColor("--color-glass-tint");
25 const headerPaddingTop = insets.top + 16;
26 const surfaceStyle = {
27 borderRadius: 0,
28 backgroundColor: headerColor,
29 borderBottomWidth: 1,
30 borderBottomColor: headerBorderColor,
31 } as const;
32​
33 return (
34 <View style={[surfaceStyle, style]}>
35 <GlassSurface
36 chrome="none"
37 glassEffectStyle="regular"
38 tintColor={glassTint}
39 style={{ borderRadius: 0, backgroundColor: "transparent" }}
40 >
41 <View
42 className="flex-row items-center gap-2.5 px-5 pb-4"
43 style={{ paddingTop: headerPaddingTop }}
44 >
45 <View className="items-start justify-center">{leftSlot}</View>
46 <View className="flex-1 items-center justify-center overflow-hidden">{centerSlot}</View>
47 <View className="items-end justify-center">{rightSlot}</View>
48 </View>
49 </GlassSurface>
50 </View>
51 );