@@ -8,25 +8,17 @@ import {
88} from "@t3tools/contracts" ;
99import * as Option from "effect/Option" ;
1010import { AsyncResult , Atom } from "effect/reactivity" ;
11- import { useRef , useState } from "react" ;
12- import { FlatList , Platform , View , type TextInputInstance } from "react-native" ;
11+ import { useState } from "react" ;
12+ import { FlatList , Platform } from "react-native" ;
1313
14- import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader" ;
1514import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator" ;
1615import { EmptyState } from "../../components/ui/EmptyState" ;
17- import { SearchField } from "../../components/ui/SearchField" ;
1816import { SelectionRow } from "../../components/ui/SelectionRow" ;
19- import { SheetHeader } from "../../components/ui/SheetHeader" ;
20- import { Toolbar } from "../../components/ui/Toolbar" ;
21- import { NativeStackScreenOptions } from "../../native/StackHeader" ;
22- import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar" ;
2317import { composerPullRequests } from "../../state/pull-requests" ;
2418import { useDebouncedValue } from "../../state/queries" ;
25- import {
26- createNativeMailSearchToolbarItem ,
27- NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET ,
28- } from "../layout/native-mail-search-toolbar" ;
2919import { pullRequestFilterChoices , pullRequestLabelColors } from "./pullRequestList" ;
20+ import { PullRequestLabelDot } from "./PullRequestLabelDot" ;
21+ import { PullRequestSearchSheet } from "./PullRequestSearchSheet" ;
3022import { usePullRequestListControls } from "./usePullRequestListControls" ;
3123
3224export type PullRequestFilterSearchParams = {
@@ -63,8 +55,6 @@ export function PullRequestFilterSearchScreen({
6355 const { kind, environmentId, environmentIds, suggestions, labelColors } = route . params ;
6456 const listControls = usePullRequestListControls ( ) ;
6557 const controls = listControls . controlsFor ( environmentId ) ;
66- const integratedSearch = useNativeMailSearchToolbar ( ) ;
67- const searchRef = useRef < TextInputInstance > ( null ) ;
6858 const [ query , setQuery ] = useState ( "" ) ;
6959 const typed = query . trim ( ) . slice ( 0 , 100 ) ;
7060 const sent = useDebouncedValue ( typed , 250 ) ;
@@ -121,124 +111,67 @@ export function PullRequestFilterSearchScreen({
121111 } ) ;
122112 } ;
123113 const placeholder = kind === "labels" ? "Search labels" : "Search authors" ;
124- const list = (
125- < FlatList
126- data = { rows }
127- keyExtractor = { ( value ) => value . toLowerCase ( ) }
128- className = "flex-1"
129- contentInsetAdjustmentBehavior = "automatic"
130- automaticallyAdjustKeyboardInsets = { Platform . OS === "ios" }
131- keyboardDismissMode = { Platform . OS === "ios" ? "interactive" : "on-drag" }
132- keyboardShouldPersistTaps = "handled"
133- showsVerticalScrollIndicator = { false }
134- contentContainerStyle = { {
135- paddingHorizontal : 16 ,
136- paddingTop : 16 ,
137- paddingBottom : integratedSearch ? NATIVE_MAIL_SEARCH_TOOLBAR_CONTENT_INSET + 16 : 16 ,
138- } }
139- renderItem = { ( { item, index } ) => (
140- < SelectionRow
141- title = { item }
142- role = { kind === "labels" ? "checkbox" : "radio" }
143- selected = { isSelected ( item ) }
144- isFirst = { index === 0 }
145- isLast = { index === rows . length - 1 }
146- leading = {
147- kind === "labels" ? (
148- // Uncolored labels keep the dot's room so every name starts at the same edge.
149- < View
150- className = "size-2.5 rounded-full"
151- style = { { backgroundColor : colors [ item . toLowerCase ( ) ] ?? "transparent" } }
114+ return (
115+ < PullRequestSearchSheet
116+ title = { kind === "labels" ? "Filter by label" : "Filter by author" }
117+ placeholder = { placeholder }
118+ closeAccessibilityLabel = { kind === "labels" ? "Close label filter" : "Close author filter" }
119+ clearAccessibilityLabel = { kind === "labels" ? "Clear label search" : "Clear author search" }
120+ searchTextChangeId = "pr-filter-option-search"
121+ query = { query }
122+ onQueryChange = { setQuery }
123+ >
124+ { ( { paddingBottom } ) => (
125+ < FlatList
126+ data = { rows }
127+ keyExtractor = { ( value ) => value . toLowerCase ( ) }
128+ className = "flex-1"
129+ contentInsetAdjustmentBehavior = "automatic"
130+ automaticallyAdjustKeyboardInsets = { Platform . OS === "ios" }
131+ keyboardDismissMode = { Platform . OS === "ios" ? "interactive" : "on-drag" }
132+ keyboardShouldPersistTaps = "handled"
133+ showsVerticalScrollIndicator = { false }
134+ contentContainerStyle = { { paddingHorizontal : 16 , paddingTop : 16 , paddingBottom } }
135+ renderItem = { ( { item, index } ) => (
136+ < SelectionRow
137+ title = { item }
138+ role = { kind === "labels" ? "checkbox" : "radio" }
139+ selected = { isSelected ( item ) }
140+ isFirst = { index === 0 }
141+ isLast = { index === rows . length - 1 }
142+ leading = {
143+ kind === "labels" ? (
144+ < PullRequestLabelDot color = { colors [ item . toLowerCase ( ) ] ?? null } />
145+ ) : undefined
146+ }
147+ onPress = { ( ) => choose ( item ) }
148+ />
149+ ) }
150+ ListEmptyComponent = {
151+ hosted . waiting || ! settled ? (
152+ < AppActivityIndicator className = "my-8" />
153+ ) : (
154+ < EmptyState
155+ title = {
156+ hosted . failed
157+ ? "Couldn't search the host"
158+ : kind === "labels"
159+ ? "No matching labels"
160+ : "No matching authors"
161+ }
162+ detail = {
163+ hosted . failed
164+ ? "The host didn't answer. Try again in a moment."
165+ : kind === "labels"
166+ ? "Search the labels of the repositories this list covers."
167+ : "Search people by name or handle on the repositories' hosts."
168+ }
169+ variant = "plain"
152170 />
153- ) : undefined
171+ )
154172 }
155- onPress = { ( ) => choose ( item ) }
156173 />
157174 ) }
158- ListEmptyComponent = {
159- hosted . waiting || ! settled ? (
160- < AppActivityIndicator className = "my-8" />
161- ) : (
162- < EmptyState
163- title = {
164- hosted . failed
165- ? "Couldn't search the host"
166- : kind === "labels"
167- ? "No matching labels"
168- : "No matching authors"
169- }
170- detail = {
171- hosted . failed
172- ? "The host didn't answer. Try again in a moment."
173- : kind === "labels"
174- ? "Search the labels of the repositories this list covers."
175- : "Search people by name or handle on the repositories' hosts."
176- }
177- variant = "plain"
178- />
179- )
180- }
181- />
182- ) ;
183- const title = kind === "labels" ? "Filter by label" : "Filter by author" ;
184- if ( Platform . OS === "android" ) {
185- return (
186- < View className = "flex-1 bg-sheet" collapsable = { false } >
187- < AndroidScreenHeader title = { title } hideBottomBorder onBack = { ( ) => navigation . goBack ( ) } />
188- < View className = "bg-header px-4 pb-3 pt-1" >
189- < SearchField
190- inputRef = { searchRef }
191- accessibilityLabel = { placeholder }
192- clearAccessibilityLabel = {
193- kind === "labels" ? "Clear label search" : "Clear author search"
194- }
195- onChangeText = { setQuery }
196- placeholder = { placeholder }
197- value = { query }
198- />
199- </ View >
200- { list }
201- </ View >
202- ) ;
203- }
204- return (
205- < View className = "flex-1 bg-sheet" >
206- < SheetHeader
207- title = { title }
208- onClose = { ( ) => navigation . goBack ( ) }
209- accessibilityLabel = { kind === "labels" ? "Close label filter" : "Close author filter" }
210- />
211- < NativeStackScreenOptions
212- options = { {
213- unstable_headerToolbarItems : integratedSearch
214- ? ( ) => [
215- createNativeMailSearchToolbarItem ( {
216- placeholder,
217- onSearchTextChange : setQuery ,
218- showsSearchDismissButton : true ,
219- searchTextChangeId : "pr-filter-option-search" ,
220- } ) ,
221- ]
222- : undefined ,
223- headerSearchBarOptions : integratedSearch
224- ? undefined
225- : {
226- placeholder,
227- allowToolbarIntegration : true ,
228- autoCapitalize : "none" ,
229- hideNavigationBar : false ,
230- obscureBackground : false ,
231- onChangeText : ( event ) => setQuery ( event . nativeEvent . text ) ,
232- onCancelButtonPress : ( ) => setQuery ( "" ) ,
233- } ,
234- } }
235- />
236- { integratedSearch ? null : (
237- < Toolbar placement = "bottom" >
238- < Toolbar . SearchBarSlot />
239- </ Toolbar >
240- ) }
241- { list }
242- </ View >
175+ </ PullRequestSearchSheet >
243176 ) ;
244177}
0 commit comments