Open History to see the last commit
1import type { Ref } from "react";
2import { Keyboard, Pressable, TextInput, View, type TextInputInstance } from "react-native";
3import { useResolveClassNames } from "uniwind";
4
5import { SymbolView } from "../../components/ui/AppSymbol";
6import { GlassSurface } from "../../components/ui/GlassSurface";
7import { WORKSPACE_TOOLBAR, type WorkspaceTab } from "./workspace-tabs-state";
8
9export function WorkspaceSearchField({
10 ref,
11 ...props
12}: {
13 readonly ref?: Ref<TextInputInstance>;
14 readonly tab: WorkspaceTab;
15 readonly query: string;
16 readonly onChangeQuery: (query: string) => void;
17 readonly onFocus: () => void;
18 readonly onBlur?: () => void;
19 readonly onClear: () => void;
20}) {
21 const inputStyle = useResolveClassNames("text-foreground font-sans text-base");
22 const placeholderStyle = useResolveClassNames("text-foreground-muted");
23 const label = props.tab === "pullRequests" ? "Search pull requests" : "Search threads";
24 return (
25 <GlassSurface
26 className="min-w-0 flex-1"
27 style={{ height: WORKSPACE_TOOLBAR.height, borderRadius: WORKSPACE_TOOLBAR.height / 2 }}
28 >
29 <View className="flex-1 flex-row items-center pl-4">
30 <SymbolView name="magnifyingglass" size={20} tintColorClassName="accent-icon-muted" />
31 <TextInput
32 ref={ref}
33 accessibilityLabel={label}
34 placeholder={label}
35 placeholderTextColor={placeholderStyle.color}
36 value={props.query}
37 onChangeText={props.onChangeQuery}
38 onFocus={props.onFocus}
39 onBlur={props.onBlur}
40 onSubmitEditing={() => Keyboard.dismiss()}
41 autoCapitalize="none"
42 autoCorrect={false}
43 returnKeyType="search"
44 maxLength={props.tab === "pullRequests" ? 200 : undefined}
45 style={[inputStyle, { flex: 1, minWidth: 0, paddingHorizontal: 8, paddingVertical: 0 }]}
46 />
47 {props.query ? (
48 <Pressable
49 accessibilityRole="button"
50 accessibilityLabel="Clear search"
51 onPress={props.onClear}
52 className="h-11 w-11 items-center justify-center"
53 >
54 <SymbolView name="xmark.circle.fill" size={18} tintColorClassName="accent-icon-muted" />
55 </Pressable>
56 ) : null}
57 </View>
58 </GlassSurface>
59 );
60}