Open History to see the last commit
1import { useNavigation } from "@react-navigation/native";
2import type { ReactNode } from "react";
3import { Platform, View } from "react-native";
4import { useSafeAreaInsets } from "react-native-safe-area-context";
5
6import { AppBar } from "../../components/ui/AppBar";
7import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
8import { NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET } from "../layout/native-mail-search-toolbar";
9
10/** A searchable picker over a pull request list or a pull request. */
11export function PullRequestSearchSheet(props: {
12 readonly title: string;
13 readonly placeholder: string;
14 readonly closeAccessibilityLabel: string;
15 readonly clearAccessibilityLabel: string;
16 readonly query: string;
17 readonly onQueryChange: (query: string) => void;
18 /** Renders the list, given the bottom padding that keeps its end clear of the search bar. */
19 readonly children: (list: { readonly paddingBottom: number }) => ReactNode;
20}) {
21 const navigation = useNavigation();
22 // The compact search toolbar floats over the end of the list.
23 const bottomSearch = useNativeMailSearchToolbar();
24 const insets = useSafeAreaInsets();
25 return (
26 <View className="flex-1 bg-sheet" collapsable={false}>
27 <AppBar
28 title={props.title}
29 onClose={() => navigation.goBack()}
30 closeAccessibilityLabel={props.closeAccessibilityLabel}
31 hideBottomBorder
32 search={{
33 mode: "inline",
34 compactToolbar: true,
35 value: props.query,
36 onChangeText: props.onQueryChange,
37 placeholder: props.placeholder,
38 clearAccessibilityLabel: props.clearAccessibilityLabel,
39 }}
40 />
41 {props.children({
42 // Android's bottom inset also covers the floating workspace tabs while Settings is open.
43 paddingBottom:
44 Platform.OS === "android"
45 ? insets.bottom + 16
46 : bottomSearch
47 ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16
48 : 16,
49 })}
50 </View>
51 );
52}