diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-24 17:41:45 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-06-24 17:41:45 -0400 |
commit | b184179a8bff25ad018d02abc31acadc7b3f6a62 (patch) | |
tree | efd94448ee76860156d7622a61e6eb8785c10f10 /src/components/common | |
parent | 981051448fee6197544383e535fea7a72827d41d (diff) | |
parent | 53bdc94cf0491e348b7d4ad61e51ce1844423773 (diff) |
Merge branch 'master' into tma948-video-playback
# Conflicts:
# ios/Podfile.lock
# package.json
# src/components/moments/Moment.tsx
# src/routes/main/MainStackNavigator.tsx
# src/screens/moments/TagFriendsScreen.tsx
# src/screens/profile/CaptionScreen.tsx
# yarn.lock
Diffstat (limited to 'src/components/common')
-rw-r--r-- | src/components/common/MomentTags.tsx | 28 | ||||
-rw-r--r-- | src/components/common/TaggTypeahead.tsx | 74 |
2 files changed, 61 insertions, 41 deletions
diff --git a/src/components/common/MomentTags.tsx b/src/components/common/MomentTags.tsx index bdd1fbeb..4afacddb 100644 --- a/src/components/common/MomentTags.tsx +++ b/src/components/common/MomentTags.tsx @@ -66,19 +66,21 @@ const MomentTags: React.FC<MomentTagsProps> = ({ useEffect(() => { setTimeout( () => { - imageRef.current.measure( - ( - fx: number, // location of ref relative to parent element - fy: number, - width: number, - height: number, - _x: number, // location of ref relative to entire screen - _y: number, - ) => { - setOffset([fx, fy]); - setImageDimensions([width, height]); - }, - ); + if (imageRef && imageRef.current) { + imageRef.current.measure( + ( + fx: number, // location of ref relative to parent element + fy: number, + width: number, + height: number, + _x: number, // location of ref relative to entire screen + _y: number, + ) => { + setOffset([fx, fy]); + setImageDimensions([width, height]); + }, + ); + } }, editing ? 100 : 0, ); diff --git a/src/components/common/TaggTypeahead.tsx b/src/components/common/TaggTypeahead.tsx index 747e0bb5..7967fdbc 100644 --- a/src/components/common/TaggTypeahead.tsx +++ b/src/components/common/TaggTypeahead.tsx @@ -1,21 +1,29 @@ import React, {Fragment, useEffect, useState} from 'react'; -import {ScrollView, StyleSheet} from 'react-native'; -import {MentionSuggestionsProps} from 'react-native-controlled-mentions'; +import {ScrollView, StyleSheet, View} from 'react-native'; +import {Suggestion} from 'react-native-controlled-mentions'; import {useSelector} from 'react-redux'; import {SEARCH_ENDPOINT_MESSAGES} from '../../constants'; import {loadSearchResults} from '../../services'; import {RootState} from '../../store/rootReducer'; import {ProfilePreviewType} from '../../types'; -import {SCREEN_WIDTH, shuffle} from '../../utils'; +import {SCREEN_HEIGHT, SCREEN_WIDTH, shuffle} from '../../utils'; import TaggUserRowCell from './TaggUserRowCell'; -const TaggTypeahead: React.FC<MentionSuggestionsProps> = ({ +type TaggTypeaheadProps = { + keyword: string | undefined; + component: string | undefined; + onSuggestionPress: (suggestion: Suggestion) => void; +}; + +const TaggTypeahead: React.FC<TaggTypeaheadProps> = ({ keyword, + component, onSuggestionPress, }) => { const {friends} = useSelector((state: RootState) => state.friends); const [results, setResults] = useState<ProfilePreviewType[]>([]); const [height, setHeight] = useState(0); + const margin = component === 'comment' ? -10 : 0; useEffect(() => { if (keyword === '') { @@ -42,40 +50,50 @@ const TaggTypeahead: React.FC<MentionSuggestionsProps> = ({ } return ( - <ScrollView - style={[styles.container, {top: -(height + 30)}]} - showsVerticalScrollIndicator={false} - onLayout={(event) => { - setHeight(event.nativeEvent.layout.height); - }} - keyboardShouldPersistTaps={'always'}> - {results.map((user) => ( - <TaggUserRowCell - onPress={() => { - setResults([]); - onSuggestionPress({ - id: user.id, - name: user.username, - }); - }} - user={user} - /> - ))} - </ScrollView> + <View> + <View style={styles.overlay} /> + <ScrollView + style={[styles.container, {top: -height, margin: margin}]} + showsVerticalScrollIndicator={false} + onLayout={(event) => { + setHeight(event.nativeEvent.layout.height); + }} + keyboardShouldPersistTaps={'always'}> + {results.map((user) => ( + <TaggUserRowCell + onPress={() => { + setResults([]); + onSuggestionPress({ + id: user.id, + name: user.username, + }); + }} + user={user} + /> + ))} + </ScrollView> + </View> ); }; const styles = StyleSheet.create({ container: { - marginLeft: SCREEN_WIDTH * 0.05, - width: SCREEN_WIDTH * 0.9, + width: SCREEN_WIDTH, maxHeight: 264, - borderRadius: 10, backgroundColor: 'white', position: 'absolute', alignSelf: 'center', zIndex: 1, - borderWidth: 1, + }, + overlay: { + width: SCREEN_WIDTH, + height: SCREEN_HEIGHT, + backgroundColor: 'gray', + opacity: 0.4, + position: 'absolute', + alignSelf: 'center', + bottom: 10, + zIndex: -1, }, }); |