diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-26 18:32:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 18:32:28 -0400 |
commit | caac607ed90c35ad8d4b2787b170e1fd1f165333 (patch) | |
tree | 98d5733a6f98a89e293bd0cf2f0c4fe566d15315 /src/screens/chat/NewChatModal.tsx | |
parent | 27fdbf976907be00afdd10b0e545d0a429e27443 (diff) | |
parent | 8253184aef6051f053cc40e95e9c3433fae591ed (diff) |
Merge pull request #389 from IvanIFChen/tma819-new-message-cancel-button
[TMA-819] New message cancel button
Diffstat (limited to 'src/screens/chat/NewChatModal.tsx')
-rw-r--r-- | src/screens/chat/NewChatModal.tsx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/screens/chat/NewChatModal.tsx b/src/screens/chat/NewChatModal.tsx index 95e46ecd..9872dd6f 100644 --- a/src/screens/chat/NewChatModal.tsx +++ b/src/screens/chat/NewChatModal.tsx @@ -7,7 +7,6 @@ import { Text, View, } from 'react-native'; -import {useSharedValue} from 'react-native-reanimated'; import {BottomDrawer} from '../../components'; import { SEARCH_ENDPOINT_MESSAGES, @@ -27,10 +26,6 @@ const NewChatModal: React.FC<NewChatModalProps> = ({ setChatModalVisible, }) => { const [searching, setSearching] = useState(false); - /* - * Animated value - */ - const animationProgress = useSharedValue<number>(0); const [results, setResults] = useState<SectionListData<any>[]>([]); const [query, setQuery] = useState<string>(''); const handleFocus = () => { @@ -40,21 +35,20 @@ const NewChatModal: React.FC<NewChatModalProps> = ({ Keyboard.dismiss(); }; const handleCancel = () => { - setSearching(false); + setQuery(''); + setChatModalVisible(false); }; const getDefaultSuggested = async () => { const searchResults = await loadSearchResults( `${SEARCH_ENDPOINT_SUGGESTED}`, ); - console.log(searchResults); const sanitizedResult = [ { title: 'users', data: searchResults?.users, }, ]; - console.log(searchResults, sanitizedResult); setResults(sanitizedResult); }; @@ -102,7 +96,7 @@ const NewChatModal: React.FC<NewChatModalProps> = ({ onBlur={handleBlur} onFocus={handleFocus} value={query} - {...{animationProgress, searching}} + searching={searching} placeholder={''} /> {results.length > 0 && ( @@ -125,7 +119,12 @@ const NewChatModal: React.FC<NewChatModalProps> = ({ <BottomDrawer initialSnapPosition={'90%'} isOpen={modalVisible} - setIsOpen={setChatModalVisible} + setIsOpen={(open) => { + if (!open) { + setQuery(''); + } + setChatModalVisible(open); + }} showHeader={false}> {_modalContent()} </BottomDrawer> |