Open History to see the last commit
1import { SymbolView } from "../../components/AppSymbol";
2import { Pressable, StyleSheet, View, useColorScheme } from "react-native";
3
4import { useThemeColor } from "../../lib/useThemeColor";
5
6export interface SidebarHeaderActionsProps {
7 readonly onOpenSettings: () => void;
8 /** Rendered inside a shared capsule group — buttons drop their own chrome. */
9 readonly grouped?: boolean;
10}
11
12function FallbackHeaderButton(props: {
13 readonly accessibilityLabel: string;
14 readonly icon: "gearshape" | "square.and.pencil";
15 readonly grouped?: boolean;
16 readonly onPress: () => void;
17}) {
18 const iconColor = useThemeColor("--color-foreground");
19 const pressedBackgroundColor = useThemeColor("--color-subtle");
20 const colorScheme = useColorScheme() === "dark" ? "dark" : "light";
21 const idleBackgroundColor =
22 colorScheme === "dark" ? "rgba(118,118,128,0.24)" : "rgba(255,255,255,0.72)";
23 const borderColor = colorScheme === "dark" ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)";
24
25 return (
26 <Pressable
27 className="h-11 w-[50px] items-center justify-center rounded-[22px]"
28 accessibilityLabel={props.accessibilityLabel}
29 accessibilityRole="button"
30 hitSlop={4}
31 onPress={props.onPress}
32 style={({ pressed }) => [
33 props.grouped
34 ? { backgroundColor: pressed ? pressedBackgroundColor : "transparent", borderWidth: 0 }
35 : {
36 backgroundColor: pressed ? pressedBackgroundColor : idleBackgroundColor,
37 borderColor,
38 borderWidth: StyleSheet.hairlineWidth,
39 },
40 ]}
41 >
42 <SymbolView name={props.icon} size={20} tintColor={iconColor} type="monochrome" />
43 </Pressable>
44 );
45}
46
47export function SidebarHeaderActions(props: SidebarHeaderActionsProps) {
48 return (
49 <View className="flex-row items-center gap-0.5">
50 <FallbackHeaderButton
51 accessibilityLabel="Open settings"
52 grouped={props.grouped}
53 icon="gearshape"
54 onPress={props.onOpenSettings}
55 />
56 </View>
57 );
58}