Use native Mail toolbar for file search

This commit is contained in:
Julius Marminge committed 2026-06-30 03:14:16 -07:00
1 parent 7cddaba1da
commit ffdacaf73d
3 files changed
+114 -74

No files matched your search

@@ -39,6 +39,7 @@ import {
useAdaptiveWorkspaceLayout,
useAdaptiveWorkspacePaneRole,
} from "../layout/AdaptiveWorkspaceLayout";
import { createNativeMailSearchToolbarItem } from "../layout/native-mail-search-toolbar";
import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
import { ReviewHighlighterProvider } from "../review/ReviewHighlighterProvider";
import { ThreadRouteScreen } from "../threads/ThreadRouteScreen";
@@ -572,6 +573,8 @@ export function ThreadFilesTreeScreen() {
);
}
const usesCompactMailToolbar = Platform.OS === "ios" && !layout.usesSplitView;
return (
<View className="flex-1 bg-sheet">
<Stack.Screen
@@ -589,42 +592,62 @@ export function ThreadFilesTreeScreen() {
right: "hidden",
},
unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
headerSearchBarOptions: {
allowToolbarIntegration: true,
autoCapitalize: "none",
hideNavigationBar: false,
placeholder: "Search files",
onChangeText: (event) => {
setSearchQuery(event.nativeEvent.text);
},
onCancelButtonPress: () => {
setSearchQuery("");
},
},
unstable_headerToolbarItems: usesCompactMailToolbar
? () => [
createNativeMailSearchToolbarItem({
composeButtonId: "files-refresh",
composeSystemImageName: "arrow.clockwise",
onComposePress: entriesQuery.refresh,
onSearchTextChange: setSearchQuery,
placeholder: "Search files",
searchTextChangeId: "files-search-text",
}),
]
: undefined,
headerSearchBarOptions: usesCompactMailToolbar
? undefined
: {
allowToolbarIntegration: true,
autoCapitalize: "none",
hideNavigationBar: false,
placeholder: "Search files",
onChangeText: (event) => {
setSearchQuery(event.nativeEvent.text);
},
onCancelButtonPress: () => {
setSearchQuery("");
},
},
}}
/>
<Stack.Toolbar placement="right">
{layout.usesSplitView ? (
<Stack.Toolbar.Button
accessibilityLabel={
panes.primarySidebarVisible ? "Maximize files" : "Show thread sidebar"
}
icon={
panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"
}
onPress={togglePrimarySidebar}
separateBackground
/>
) : null}
<Stack.Toolbar.Button
accessibilityLabel="Refresh files"
icon="arrow.clockwise"
onPress={entriesQuery.refresh}
/>
</Stack.Toolbar>
<Stack.Toolbar placement="bottom">
<Stack.Toolbar.SearchBarSlot />
</Stack.Toolbar>
{layout.usesSplitView || !usesCompactMailToolbar ? (
<Stack.Toolbar placement="right">
{layout.usesSplitView ? (
<Stack.Toolbar.Button
accessibilityLabel={
panes.primarySidebarVisible ? "Maximize files" : "Show thread sidebar"
}
icon={
panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"
}
onPress={togglePrimarySidebar}
separateBackground
/>
) : null}
{!usesCompactMailToolbar ? (
<Stack.Toolbar.Button
accessibilityLabel="Refresh files"
icon="arrow.clockwise"
onPress={entriesQuery.refresh}
/>
) : null}
</Stack.Toolbar>
) : null}
{usesCompactMailToolbar ? null : (
<Stack.Toolbar placement="bottom">
<Stack.Toolbar.SearchBarSlot />
</Stack.Toolbar>
)}
<FileTreeBrowser
entries={entriesData?.entries ?? []}
error={entriesQuery.error}
+53 -36
View File
@@ -255,9 +255,15 @@ index 5970e3e3a624b9498b8dedfc16831df03a274d0c..99a8bce383d46e0452eea857e84c7a2f
+ glassView.layer.cornerRadius = 28.0;
+ glassView.translatesAutoresizingMaskIntoConstraints = NO;
+ [toolbarHost addSubview:glassView];
+ BOOL hasFilterButton =
+ mailSearchToolbarConfig[@"filterButtonId"] != nil || mailSearchToolbarConfig[@"filterMenu"] != nil;
+ BOOL hasComposeButton =
+ mailSearchToolbarConfig[@"composeButtonId"] != nil || mailSearchToolbarConfig[@"composeMenu"] != nil;
+ CGFloat glassLeadingInset = hasFilterButton ? 64.0 : 0.0;
+ CGFloat glassTrailingInset = hasComposeButton ? -64.0 : 0.0;
+ [NSLayoutConstraint activateConstraints:@[
+ [glassView.leadingAnchor constraintEqualToAnchor:toolbarHost.leadingAnchor constant:64.0],
+ [glassView.trailingAnchor constraintEqualToAnchor:toolbarHost.trailingAnchor constant:-64.0],
+ [glassView.leadingAnchor constraintEqualToAnchor:toolbarHost.leadingAnchor constant:glassLeadingInset],
+ [glassView.trailingAnchor constraintEqualToAnchor:toolbarHost.trailingAnchor constant:glassTrailingInset],
+ [glassView.centerYAnchor constraintEqualToAnchor:toolbarHost.centerYAnchor],
+ [glassView.heightAnchor constraintEqualToConstant:56.0],
+ ]];
@@ -353,31 +359,35 @@ index 5970e3e3a624b9498b8dedfc16831df03a274d0c..99a8bce383d46e0452eea857e84c7a2f
+ ]];
+ }
+
+ UIButton *filterButton = makeGlassButton(
+ mailSearchToolbarConfig[@"filterSystemImageName"] ?: @"line.3.horizontal.decrease",
+ mailSearchToolbarConfig[@"filterButtonId"],
+ mailSearchToolbarConfig[@"filterMenu"]);
+ filterButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [toolbarHost addSubview:filterButton];
+ [NSLayoutConstraint activateConstraints:@[
+ [filterButton.leadingAnchor constraintEqualToAnchor:toolbarHost.leadingAnchor],
+ [filterButton.centerYAnchor constraintEqualToAnchor:toolbarHost.centerYAnchor],
+ [filterButton.widthAnchor constraintEqualToConstant:56.0],
+ [filterButton.heightAnchor constraintEqualToConstant:56.0],
+ ]];
+ if (hasFilterButton) {
+ UIButton *filterButton = makeGlassButton(
+ mailSearchToolbarConfig[@"filterSystemImageName"] ?: @"line.3.horizontal.decrease",
+ mailSearchToolbarConfig[@"filterButtonId"],
+ mailSearchToolbarConfig[@"filterMenu"]);
+ filterButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [toolbarHost addSubview:filterButton];
+ [NSLayoutConstraint activateConstraints:@[
+ [filterButton.leadingAnchor constraintEqualToAnchor:toolbarHost.leadingAnchor],
+ [filterButton.centerYAnchor constraintEqualToAnchor:toolbarHost.centerYAnchor],
+ [filterButton.widthAnchor constraintEqualToConstant:56.0],
+ [filterButton.heightAnchor constraintEqualToConstant:56.0],
+ ]];
+ }
+
+ UIButton *composeButton = makeGlassButton(
+ mailSearchToolbarConfig[@"composeSystemImageName"] ?: @"square.and.pencil",
+ mailSearchToolbarConfig[@"composeButtonId"],
+ mailSearchToolbarConfig[@"composeMenu"]);
+ composeButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [toolbarHost addSubview:composeButton];
+ [NSLayoutConstraint activateConstraints:@[
+ [composeButton.trailingAnchor constraintEqualToAnchor:toolbarHost.trailingAnchor],
+ [composeButton.centerYAnchor constraintEqualToAnchor:toolbarHost.centerYAnchor],
+ [composeButton.widthAnchor constraintEqualToConstant:56.0],
+ [composeButton.heightAnchor constraintEqualToConstant:56.0],
+ ]];
+ if (hasComposeButton) {
+ UIButton *composeButton = makeGlassButton(
+ mailSearchToolbarConfig[@"composeSystemImageName"] ?: @"square.and.pencil",
+ mailSearchToolbarConfig[@"composeButtonId"],
+ mailSearchToolbarConfig[@"composeMenu"]);
+ composeButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [toolbarHost addSubview:composeButton];
+ [NSLayoutConstraint activateConstraints:@[
+ [composeButton.trailingAnchor constraintEqualToAnchor:toolbarHost.trailingAnchor],
+ [composeButton.centerYAnchor constraintEqualToAnchor:toolbarHost.centerYAnchor],
+ [composeButton.widthAnchor constraintEqualToConstant:56.0],
+ [composeButton.heightAnchor constraintEqualToConstant:56.0],
+ ]];
+ }
+ }
+#endif
+ }
@@ -482,11 +492,16 @@ index 5970e3e3a624b9498b8dedfc16831df03a274d0c..99a8bce383d46e0452eea857e84c7a2f
+ return button;
+ };
+
+ UIButton *filterButton = makeGlassButton(
+ dict[@"filterSystemImageName"] ?: @"line.3.horizontal.decrease",
+ dict[@"filterButtonId"],
+ dict[@"filterMenu"]);
+ [stackView addArrangedSubview:filterButton];
+ BOOL hasFilterButton = dict[@"filterButtonId"] != nil || dict[@"filterMenu"] != nil;
+ BOOL hasComposeButton = dict[@"composeButtonId"] != nil || dict[@"composeMenu"] != nil;
+
+ if (hasFilterButton) {
+ UIButton *filterButton = makeGlassButton(
+ dict[@"filterSystemImageName"] ?: @"line.3.horizontal.decrease",
+ dict[@"filterButtonId"],
+ dict[@"filterMenu"]);
+ [stackView addArrangedSubview:filterButton];
+ }
+
+ UISearchBar *searchBar = navitem.searchController != nil ? navitem.searchController.searchBar : [UISearchBar new];
+ NSString *placeholder = dict[@"placeholder"];
@@ -498,11 +513,13 @@ index 5970e3e3a624b9498b8dedfc16831df03a274d0c..99a8bce383d46e0452eea857e84c7a2f
+ [searchBar.heightAnchor constraintEqualToConstant:50.0].active = YES;
+ [stackView addArrangedSubview:searchBar];
+
+ UIButton *composeButton = makeGlassButton(
+ dict[@"composeSystemImageName"] ?: @"square.and.pencil",
+ dict[@"composeButtonId"],
+ dict[@"composeMenu"]);
+ [stackView addArrangedSubview:composeButton];
+ if (hasComposeButton) {
+ UIButton *composeButton = makeGlassButton(
+ dict[@"composeSystemImageName"] ?: @"square.and.pencil",
+ dict[@"composeButtonId"],
+ dict[@"composeMenu"]);
+ [stackView addArrangedSubview:composeButton];
+ }
+
+ UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:container];
+ [items addObject:item];
+4 -4
View File
@@ -91,7 +91,7 @@ patchedDependencies:
hash: 825622aae63a8fb5b904f3c77908a0e216261d727ea171709f2c0b6088422675
path: patches/[email protected]
[email protected]:
hash: 9a555061147ecd74107ca21a77697a0515cd6a9359abbe4baf8b44295565e61b
hash: fdfee13625b106d658de40cceb9947a4a1f658e55faa4ad2192304763050dcb9
path: patches/[email protected]
importers:
@@ -381,7 +381,7 @@ importers:
version: 5.7.0([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-screens:
specifier: 4.25.2
version: 4.25.2(patch_hash=9a555061147ecd74107ca21a77697a0515cd6a9359abbe4baf8b44295565e61b)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
version: 4.25.2(patch_hash=fdfee13625b106d658de40cceb9947a4a1f658e55faa4ad2192304763050dcb9)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-shiki-engine:
specifier: ^0.3.12
version: 0.3.12([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
@@ -16266,7 +16266,7 @@ snapshots:
react-native: 0.85.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
react-native-drawer-layout: 4.2.4(0e9729601f58a7a7ae26c76fe6017455)
react-native-safe-area-context: 5.7.0([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-screens: 4.25.2(patch_hash=9a555061147ecd74107ca21a77697a0515cd6a9359abbe4baf8b44295565e61b)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
react-native-screens: 4.25.2(patch_hash=fdfee13625b106d658de40cceb9947a4a1f658e55faa4ad2192304763050dcb9)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
server-only: 0.0.1
sf-symbols-typescript: 2.2.0
shallowequal: 1.1.0
@@ -18873,7 +18873,7 @@ snapshots:
react: 19.2.3
react-native: 0.85.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
[email protected](patch_hash=9a555061147ecd74107ca21a77697a0515cd6a9359abbe4baf8b44295565e61b)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
[email protected](patch_hash=fdfee13625b106d658de40cceb9947a4a1f658e55faa4ad2192304763050dcb9)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
dependencies:
react: 19.2.3
react-freeze: 1.0.4([email protected])