Open History to see the last commit
1import type { ReactNode } from "react";
2import { Platform, Pressable, View } from "react-native";
3import { useSafeAreaInsets } from "react-native-safe-area-context";
4
5import { SymbolView } from "../../components/AppSymbol";
6
7/**
8 * Android-only wrapper that overlays a bottom-right new-task FAB on a thread
9 * list. Other platforms render children unchanged.
10 */
11export function AndroidHomeFabLayout(props: {
12 readonly onStartNewTask: () => void;
13 readonly children: ReactNode;
14}) {
15 if (Platform.OS !== "android") {
16 return <>{props.children}</>;
17 }
18
19 return <AndroidHomeFab {...props} />;
20}
21
22function AndroidHomeFab(props: {
23 readonly onStartNewTask: () => void;
24 readonly children: ReactNode;
25}) {
26 const insets = useSafeAreaInsets();
27 return (
28 <View className="flex-1">
29 {props.children}
30 <Pressable
31 accessibilityLabel="New task"
32 accessibilityRole="button"
33 onPress={props.onStartNewTask}
34 className="absolute right-5 size-14 items-center justify-center rounded-full bg-primary shadow-lg"
35 style={{
36 bottom: Math.max(insets.bottom, 16) + 16,
37 }}
38 >
39 <SymbolView
40 name="square.and.pencil"
41 size={22}
42 tintColorClassName={"accent-primary-foreground"}
43 type="monochrome"
44 />
45 </Pressable>
46 </View>
47 );
48}