diff options
author | Ivan Chen <ivan@tagg.id> | 2021-05-25 16:37:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 16:37:04 -0400 |
commit | 784258a8cd2899302aa945f2d6aae5c8a3090db0 (patch) | |
tree | 6e9ab5ac7fe0d5fa4fc4a65e91a5f9dfd4ff664b | |
parent | 7f991eef32475165f819dc8b666c5763f0021696 (diff) | |
parent | 35bbe51f8c7d6e4abcda13ce2d68f942107552b7 (diff) |
Merge pull request #446 from grusuTagg/tma890-tap-to-show-moment-tags
TMA-890] Fade tags in/out on image click
-rw-r--r-- | src/components/moments/MomentPostContent.tsx | 45 | ||||
-rw-r--r-- | src/components/taggs/TaggDraggable.tsx | 2 |
2 files changed, 39 insertions, 8 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index e702cb68..6953dca4 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -1,6 +1,8 @@ import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useRef, useState} from 'react'; import {Image, StyleSheet, Text, View, ViewProps} from 'react-native'; +import {TouchableWithoutFeedback} from 'react-native-gesture-handler'; +import Animated, {Easing} from 'react-native-reanimated'; import {useDispatch, useStore} from 'react-redux'; import {getCommentsCount, loadMomentTags} from '../../services'; import {RootState} from '../../store/rootReducer'; @@ -34,11 +36,16 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ const [elapsedTime, setElapsedTime] = useState(''); const [comments_count, setCommentsCount] = useState(''); const [tags, setTags] = useState<MomentTagType[]>([]); + const [visible, setVisible] = useState(false); const state: RootState = useStore().getState(); const navigation = useNavigation(); const dispatch = useDispatch(); const imageRef = useRef(null); + const [fadeValue, setFadeValue] = useState<Animated.Value<number>>( + new Animated.Value(0), + ); + useEffect(() => { const loadTags = async () => { const response = await loadMomentTags(momentId); @@ -58,15 +65,36 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ fetchCommentsCount(); }, [dateTime, momentId]); + useEffect(() => { + const fade = async () => { + Animated.timing(fadeValue, { + toValue: 1, + duration: 250, + easing: Easing.linear, + }).start(); + }; + fade(); + }, [fadeValue]); + return ( <View style={[styles.container, style]}> - <Image - ref={imageRef} - style={styles.image} - source={{uri: pathHash}} - resizeMode={'cover'} - /> - <MomentTags editing={false} tags={tags} imageRef={imageRef} /> + <TouchableWithoutFeedback + onPress={() => { + setVisible(!visible); + setFadeValue(new Animated.Value(0)); + }}> + <Image + ref={imageRef} + style={styles.image} + source={{uri: pathHash}} + resizeMode={'cover'} + /> + </TouchableWithoutFeedback> + {visible && ( + <Animated.View style={[styles.tapTag, {opacity: fadeValue}]}> + <MomentTags editing={false} tags={tags} imageRef={imageRef} /> + </Animated.View> + )} <View style={styles.footerContainer}> <CommentsCount commentsCount={comments_count} @@ -95,6 +123,9 @@ const styles = StyleSheet.create({ aspectRatio: 1, marginBottom: '3%', }, + tapTag: { + position: 'absolute', + }, footerContainer: { flexDirection: 'row', justifyContent: 'space-between', diff --git a/src/components/taggs/TaggDraggable.tsx b/src/components/taggs/TaggDraggable.tsx index 55f8162b..12e8e1e1 100644 --- a/src/components/taggs/TaggDraggable.tsx +++ b/src/components/taggs/TaggDraggable.tsx @@ -81,7 +81,7 @@ const TaggDraggable: React.FC<TaggDraggableProps> = ( const styles = StyleSheet.create({ imageTip: { - height: normalize(12), + height: 12, aspectRatio: 12 / 8, }, container: { |