-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native] Introduce naive
ChatThreadListSearch
component
Summary: This diff starts moving things from `ChatThreadList` to `ChatThreadListSearch` in a pretty naive/cut-and-paste way. Breaking into steps so I can make sure that things continue to work as expected after each change. Originally made all the changes at once and ran into weird issues I couldn't troubleshoot, so hopefully doing this incrementally will make it easier to narrow down. This diff involves moving JUST the `Search` component to `ChatThreadListSearch` and ensuring that `onChangeText`, `onBlur`, and `additionalProps` get passed in and work as expected. Test Plan: Search experience continues to work as expected. Reviewers: ginsu, rohan, tomek Reviewed By: ginsu Subscribers: ashoat Differential Revision: https://phab.comm.dev/D9205
- Loading branch information
1 parent
5e8672d
commit aa58fb3
Showing
2 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// @flow | ||
|
||
import * as React from 'react'; | ||
|
||
import Search from '../components/search.react.js'; | ||
import { useStyles } from '../themes/colors.js'; | ||
|
||
type Props = { | ||
+searchText: string, | ||
+onChangeText: (updatedSearchText: string) => mixed, | ||
+onBlur: () => mixed, | ||
+additionalProps?: $Shape<React.ElementConfig<typeof Search>>, | ||
}; | ||
function ChatThreadListSearch(props: Props): React.Node { | ||
const { searchText, onChangeText, onBlur, additionalProps } = props; | ||
const styles = useStyles(unboundStyles); | ||
|
||
const searchInputRef = React.useRef(); | ||
return ( | ||
<Search | ||
searchText={searchText} | ||
onChangeText={onChangeText} | ||
containerStyle={styles.search} | ||
onBlur={onBlur} | ||
placeholder="Search chats" | ||
ref={searchInputRef} | ||
{...additionalProps} | ||
/> | ||
); | ||
} | ||
|
||
const unboundStyles = { | ||
icon: { | ||
fontSize: 28, | ||
}, | ||
container: { | ||
flex: 1, | ||
}, | ||
searchContainer: { | ||
backgroundColor: 'listBackground', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
flexDirection: 'row', | ||
}, | ||
searchBox: { | ||
flex: 1, | ||
}, | ||
search: { | ||
marginBottom: 8, | ||
marginHorizontal: 18, | ||
marginTop: 16, | ||
}, | ||
cancelSearchButton: { | ||
position: 'absolute', | ||
right: 0, | ||
top: 0, | ||
bottom: 0, | ||
display: 'flex', | ||
justifyContent: 'center', | ||
}, | ||
cancelSearchButtonText: { | ||
color: 'link', | ||
fontSize: 16, | ||
paddingHorizontal: 16, | ||
paddingTop: 8, | ||
}, | ||
flatList: { | ||
flex: 1, | ||
backgroundColor: 'listBackground', | ||
}, | ||
}; | ||
export default ChatThreadListSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters