Open History to see the last commit
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>;
13}
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 style={{
43 flexDirection: "row",
44 alignItems: "center",
45 paddingHorizontal: 20,
46 paddingTop: headerPaddingTop,
47 paddingBottom: 16,
48 gap: 10,
49 }}
50 >
51 <View style={{ alignItems: "flex-start", justifyContent: "center" }}>{leftSlot}</View>
52 <View
53 style={{ flex: 1, alignItems: "center", justifyContent: "center", overflow: "hidden" }}
54 >
55 {centerSlot}
56 </View>
57 <View style={{ alignItems: "flex-end", justifyContent: "center" }}>{rightSlot}</View>
58 </View>
59 </GlassSurface>
60 </View>
61 );
62}