Centralize native Mail search toolbar config

This commit is contained in:
Julius Marminge committed 2026-06-30 02:30:55 -07:00
1 parent c1f87cc48b
commit 035eb3b2e6
3 files changed
+30 -8

No files matched your search

@@ -26,6 +26,7 @@ import { ProjectFavicon } from "../../components/ProjectFavicon";
import { relativeTime } from "../../lib/time";
import { useThemeColor } from "../../lib/useThemeColor";
import { ThreadSwipeable } from "../home/thread-swipe-actions";
import { createNativeMailSearchToolbarItem } from "../layout/native-mail-search-toolbar";
import type { ArchivedThreadGroup, ArchivedThreadSortOrder } from "./archivedThreadList";
export interface ArchivedThreadsHeaderEnvironment {
@@ -116,7 +117,7 @@ function ArchivedThreadsHeader(props: {
unstable_navigationItemStyle: usesNativeChrome ? "editor" : undefined,
unstable_headerToolbarItems: usesCompactMailToolbar
? () => [
{
createNativeMailSearchToolbarItem({
composeButtonId: "archived-refresh",
composeSystemImageName: "arrow.clockwise",
filterMenu: archiveFilterMenu,
@@ -128,9 +129,7 @@ function ArchivedThreadsHeader(props: {
onSearchTextChange: props.onSearchQueryChange,
placeholder: "Search",
searchTextChangeId: "archived-search-text",
type: "mailSearchToolbar",
useFallbackSearchField: true,
},
}),
]
: undefined,
headerSearchBarOptions: usesCompactMailToolbar
+3 -4
View File
@@ -10,6 +10,7 @@ import type { SearchBarCommands } from "react-native-screens";
import { useThemeColor } from "../../lib/useThemeColor";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { createNativeMailSearchToolbarItem } from "../layout/native-mail-search-toolbar";
import type { HomeProjectSortOrder } from "./homeThreadList";
import {
buildHomeListFilterMenu,
@@ -82,7 +83,7 @@ export function HomeHeader(props: {
unstable_headerToolbarItems:
Platform.OS === "ios"
? () => [
{
createNativeMailSearchToolbarItem({
composeButtonId: "home-new-task",
composeSystemImageName: "square.and.pencil",
filterMenu,
@@ -94,9 +95,7 @@ export function HomeHeader(props: {
onSearchTextChange: props.onSearchQueryChange,
placeholder: "Search",
searchTextChangeId: "home-search-text",
type: "mailSearchToolbar",
useFallbackSearchField: true,
},
}),
]
: undefined,
headerSearchBarOptions:
@@ -0,0 +1,24 @@
import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";
type NativeMailSearchToolbarInput = Omit<
HeaderBarButtonMailSearchToolbarItem,
"type" | "useFallbackSearchField"
>;
/**
* Builds the patched react-native-screens Mail-style bottom search toolbar.
*
* Keeping this behind an app-level helper makes the iOS-only RNS patch an
* explicit layout primitive instead of a per-screen object literal. Android can
* keep using Expo Router toolbar primitives without depending on this helper.
*/
export function createNativeMailSearchToolbarItem(
input: NativeMailSearchToolbarInput,
): HeaderBarButtonMailSearchToolbarItem {
return {
placeholder: "Search",
...input,
type: "mailSearchToolbar",
useFallbackSearchField: true,
};
}