fix(mobile): use native toolbar search for licenses (#12011)
This commit is contained in:
1 parent
eed974c122
commit
f8500f1127
1 file changed
+61
-22
@@ -14,7 +14,12 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import {
|
||||
createNativeMailSearchToolbarItem,
|
||||
NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET,
|
||||
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
|
||||
} from "../layout/native-mail-search-toolbar";
|
||||
import { getMobileThirdPartyLicenses } from "./mobileThirdPartyLicenses";
|
||||
|
||||
function useMobileThirdPartyLicenses() {
|
||||
@@ -65,6 +70,7 @@ export function SettingsOpenSourceLicensesRouteScreen() {
|
||||
const navigation = useNavigation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const [query, setQuery] = useState("");
|
||||
const usesNativeMailSearchToolbar = Platform.OS === "ios" && NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED;
|
||||
const manifest = useMobileThirdPartyLicenses();
|
||||
const entries = manifest?.entries ?? [];
|
||||
const filteredEntries = useMemo(
|
||||
@@ -109,6 +115,39 @@ export function SettingsOpenSourceLicensesRouteScreen() {
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
{Platform.OS === "ios" ? (
|
||||
<NativeStackScreenOptions
|
||||
options={{
|
||||
unstable_headerToolbarItems: usesNativeMailSearchToolbar
|
||||
? () => [
|
||||
createNativeMailSearchToolbarItem({
|
||||
onSearchTextChange: setQuery,
|
||||
placeholder: "Search packages",
|
||||
searchTextChangeId: "open-source-licenses-search-text",
|
||||
showsSearchDismissButton: true,
|
||||
}),
|
||||
]
|
||||
: undefined,
|
||||
headerSearchBarOptions: usesNativeMailSearchToolbar
|
||||
? undefined
|
||||
: {
|
||||
allowToolbarIntegration: true,
|
||||
autoCapitalize: "none",
|
||||
hideNavigationBar: false,
|
||||
hideWhenScrolling: false,
|
||||
obscureBackground: false,
|
||||
onCancelButtonPress: () => setQuery(""),
|
||||
onChangeText: (event) => setQuery(event.nativeEvent.text),
|
||||
placeholder: "Search packages",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{Platform.OS === "ios" && !usesNativeMailSearchToolbar ? (
|
||||
<NativeHeaderToolbar placement="bottom">
|
||||
<NativeHeaderToolbar.SearchBarSlot />
|
||||
</NativeHeaderToolbar>
|
||||
) : null}
|
||||
{Platform.OS === "android" ? (
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
@@ -117,7 +156,13 @@ export function SettingsOpenSourceLicensesRouteScreen() {
|
||||
) : null}
|
||||
<LegendList
|
||||
className="flex-1"
|
||||
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
|
||||
contentContainerStyle={{
|
||||
paddingBottom: usesNativeMailSearchToolbar
|
||||
? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 18
|
||||
: Platform.OS === "ios"
|
||||
? 18
|
||||
: Math.max(insets.bottom, 18) + 18,
|
||||
}}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
data={filteredEntries}
|
||||
estimatedItemSize={78}
|
||||
@@ -132,26 +177,20 @@ export function SettingsOpenSourceLicensesRouteScreen() {
|
||||
</View>
|
||||
}
|
||||
ListHeaderComponent={
|
||||
<View className="gap-4 px-5 pt-4 pb-5">
|
||||
<Text className="text-base leading-normal text-foreground-muted">
|
||||
Notices for dependencies, assets, and optional tools used by T3 Code Mobile.
|
||||
</Text>
|
||||
<TextInput
|
||||
accessibilityLabel="Search open-source licenses"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
clearButtonMode="while-editing"
|
||||
onChangeText={setQuery}
|
||||
placeholder="Search packages"
|
||||
returnKeyType="search"
|
||||
value={query}
|
||||
/>
|
||||
<Text className="tabular-nums text-sm text-foreground-muted">
|
||||
{filteredEntries.length === entries.length
|
||||
? `${String(entries.length)} notices`
|
||||
: `${String(filteredEntries.length)} of ${String(entries.length)} notices`}
|
||||
</Text>
|
||||
</View>
|
||||
Platform.OS !== "ios" ? (
|
||||
<View className="px-5 pt-4 pb-5">
|
||||
<TextInput
|
||||
accessibilityLabel="Search open-source licenses"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
clearButtonMode="while-editing"
|
||||
onChangeText={setQuery}
|
||||
placeholder="Search packages"
|
||||
returnKeyType="search"
|
||||
value={query}
|
||||
/>
|
||||
</View>
|
||||
) : null
|
||||
}
|
||||
renderItem={renderItem}
|
||||
showsVerticalScrollIndicator={false}
|
||||
|
||||
Reference in new issue
Block a user