From 67a3aa389a8b761c9fdf4129265d488a77db1ea9 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 26 Oct 2020 20:23:43 -0400 Subject: [TMA-305] Made things clickable (#67) * made links clickable * made handles clickable * made more links clickable --- src/components/taggs/TaggPost.tsx | 6 +++++- src/components/taggs/TwitterTaggPost.tsx | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/components/taggs/TaggPost.tsx b/src/components/taggs/TaggPost.tsx index 0d3aee50..07efd797 100644 --- a/src/components/taggs/TaggPost.tsx +++ b/src/components/taggs/TaggPost.tsx @@ -4,6 +4,7 @@ import {SimplePostType} from '../../types'; import {SCREEN_WIDTH} from '../../utils'; import {DateLabel} from '../common'; import TaggPostFooter from './TaggPostFooter'; +import Hyperlink from 'react-native-hyperlink'; interface TaggPostProps { post: SimplePostType; @@ -31,7 +32,9 @@ const TaggPost: React.FC = ({post}) => { // Post with large text return ( - {post.caption} + + {post.caption} + ); @@ -55,6 +58,7 @@ const styles = StyleSheet.create({ color: 'white', flexWrap: 'wrap', }, + linkColor: {color: '#2980b9'}, }); export default TaggPost; diff --git a/src/components/taggs/TwitterTaggPost.tsx b/src/components/taggs/TwitterTaggPost.tsx index 2cc23bcf..c72b4fa8 100644 --- a/src/components/taggs/TwitterTaggPost.tsx +++ b/src/components/taggs/TwitterTaggPost.tsx @@ -1,6 +1,7 @@ import React from 'react'; import {Image, Linking, StyleSheet, View} from 'react-native'; import {Text} from 'react-native-animatable'; +import Hyperlink from 'react-native-hyperlink'; import LinearGradient from 'react-native-linear-gradient'; import {AVATAR_DIM, TAGGS_GRADIENT} from '../../constants'; import {TwitterPostType} from '../../types'; @@ -15,6 +16,11 @@ const TwitterTaggPost: React.FC = ({ ownerHandle, post, }) => { + const openTwitterProfileLink = (handle?: string) => { + if (handle) { + Linking.openURL(`https://twitter.com/${handle}`); + } + }; return ( {/* Retweeted? */} @@ -33,13 +39,19 @@ const TwitterTaggPost: React.FC = ({ : require('../../assets/images/avatar-placeholder.png') } /> - @{post.handle} + openTwitterProfileLink(post.handle)}> + @{post.handle} + {/* Tweet/Reply/Retweet Content */} {/* First part of content is text or empty */} {post.text ? ( - {post.text} + + {post.text} + ) : ( )} @@ -70,7 +82,11 @@ const TwitterTaggPost: React.FC = ({ : require('../../assets/images/avatar-placeholder.png') } /> - + + openTwitterProfileLink(post.in_reply_to?.handle) + }> @{post.in_reply_to.handle}