Skip to content

Commit ad3dedb

Browse files
refactor(mobile): reuse search fields in licenses and branch picker
1 parent b50a316 commit ad3dedb

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

‎apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SearchField } from "../../components/ui/SearchField";
12
import { Toolbar } from "../../components/ui/Toolbar";
23
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
34
import { LegendList } from "@legendapp/list/react-native";
@@ -9,12 +10,12 @@ import {
910
thirdPartyLicenseEntryKey,
1011
type ThirdPartyLicenseEntry,
1112
} from "@t3tools/shared/thirdPartyLicenses";
12-
import { useCallback, useMemo, useState } from "react";
13-
import { Linking, Platform, Pressable, View } from "react-native";
13+
import { useCallback, useMemo, useRef, useState } from "react";
14+
import { Linking, Platform, Pressable, type TextInputInstance, View } from "react-native";
1415
import { useSafeAreaInsets } from "react-native-safe-area-context";
1516

1617
import { SymbolView } from "../../components/ui/AppSymbol";
17-
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
18+
import { AppText as Text } from "../../components/ui/AppText";
1819
import { ListRow } from "../../components/ui/ListRow";
1920
import { SettingsScreen } from "./components/SettingsScreen";
2021
import { NativeStackScreenOptions } from "../../native/StackHeader";
@@ -52,6 +53,7 @@ function LicenseRow(props: {
5253
}
5354

5455
export function SettingsOpenSourceLicensesRouteScreen() {
56+
const searchRef = useRef<TextInputInstance>(null);
5557
const navigation = useNavigation();
5658
const insets = useSafeAreaInsets();
5759
const [query, setQuery] = useState("");
@@ -153,14 +155,13 @@ export function SettingsOpenSourceLicensesRouteScreen() {
153155
ListHeaderComponent={
154156
Platform.OS !== "ios" ? (
155157
<View className="px-5 pt-4 pb-5">
156-
<TextInput
158+
<SearchField
159+
inputRef={searchRef}
160+
autoFocus={false}
157161
accessibilityLabel="Search open-source licenses"
158-
autoCapitalize="none"
159-
autoCorrect={false}
160-
clearButtonMode="while-editing"
162+
clearAccessibilityLabel="Clear package search"
161163
onChangeText={setQuery}
162164
placeholder="Search packages"
163-
returnKeyType="search"
164165
value={query}
165166
/>
166167
</View>

‎apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SearchField } from "../../components/ui/SearchField";
12
import { Button } from "../../components/ui/Button";
23
import { Toolbar } from "../../components/ui/Toolbar";
34
import * as Dialog from "../../components/ui/Dialog";
@@ -15,7 +16,7 @@ import {
1516
import * as Haptics from "expo-haptics";
1617
import { useNavigation } from "@react-navigation/native";
1718
import { useEffect, useRef, useState, type ReactNode } from "react";
18-
import { Platform, Pressable, ScrollView, TextInput, View } from "react-native";
19+
import { Platform, Pressable, ScrollView, View } from "react-native";
1920
import { useSafeAreaInsets } from "react-native-safe-area-context";
2021

2122
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
@@ -397,6 +398,7 @@ export function BranchPickerScreen(props: {
397398
readonly onChangeStartFromOrigin: (value: boolean) => void;
398399
};
399400
}) {
401+
const searchRef = useRef<import("react-native").TextInputInstance>(null);
400402
const navigation = useNavigation();
401403
const insets = useSafeAreaInsets();
402404
const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
@@ -516,17 +518,13 @@ export function BranchPickerScreen(props: {
516518
onBack={() => navigation.goBack()}
517519
/>
518520
<View className="bg-header px-4 pb-3 pt-1">
519-
<TextInput
520-
autoCapitalize="none"
521-
autoCorrect={false}
521+
<SearchField
522+
inputRef={searchRef}
523+
autoFocus={false}
522524
accessibilityLabel="Find a branch"
523-
className="h-12 rounded-full border border-input-border bg-input px-4 font-sans text-base text-foreground"
524-
selectionColorClassName="accent-focus/32"
525-
cursorColorClassName="accent-focus"
526-
selectionHandleColorClassName="accent-focus"
525+
clearAccessibilityLabel="Clear branch search"
527526
onChangeText={props.onQueryChange}
528527
placeholder="Find a branch"
529-
placeholderTextColorClassName="accent-placeholder"
530528
value={props.query}
531529
/>
532530
</View>

0 commit comments

Comments
 (0)