File tree Expand file tree Collapse file tree 3 files changed +39
-12
lines changed
sample-apps/react-native/ExpoTikTokApp/components Expand file tree Collapse file tree 3 files changed +39
-12
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import type { ActivityResponse } from '@stream-io/feeds-react-native-sdk';
22import { useFeedContext } from '@stream-io/feeds-react-native-sdk' ;
33import React , { useMemo } from 'react' ;
44import {
5- Alert ,
65 Dimensions ,
76 StyleSheet ,
87 Text ,
@@ -18,6 +17,7 @@ import { Bookmark } from '@/components/Bookmark';
1817import { useRouter } from 'expo-router' ;
1918import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
2019import { LocationPreview } from '@/components/LocationPreview' ;
20+ import { ShareButton } from '@/components/Share' ;
2121
2222const { height : SCREEN_HEIGHT } = Dimensions . get ( 'window' ) ;
2323
@@ -95,16 +95,9 @@ const UnmemoizedPagerItem = ({
9595 < Text style = { styles . iconLabel } > { activity . bookmark_count ?? 0 } </ Text >
9696 </ TouchableOpacity >
9797
98- < TouchableOpacity
99- onPress = { ( ) =>
100- Alert . alert (
101- 'Sharing was captured successfully, but is not implemented yet !' ,
102- )
103- }
104- style = { styles . iconContainer }
105- >
106- < Ionicons name = "arrow-redo-outline" size = { 28 } color = "white" />
107- </ TouchableOpacity >
98+ < View style = { styles . iconContainer } >
99+ < ShareButton attachment = { videoAttachment } />
100+ </ View >
108101 </ View >
109102 </ View >
110103 ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { Place } from '@/components/PlaceSearchDropdown';
55import { useRouter } from 'expo-router' ;
66
77type LocationPreviewProps = {
8- location : Omit < Place , 'id' > ;
8+ location : Omit < Place , 'id' | 'address' > ;
99} ;
1010
1111export const LocationPreview = ( { location } : LocationPreviewProps ) => {
Original file line number Diff line number Diff line change 1+ import { Ionicons } from '@expo/vector-icons' ;
2+ import { Share , TouchableOpacity } from 'react-native' ;
3+ import React from 'react' ;
4+ import {
5+ Attachment ,
6+ isImageFile ,
7+ isVideoFile ,
8+ } from '@stream-io/feeds-react-native-sdk' ;
9+ import { useStableCallback } from '@/hooks/useStableCallback' ;
10+
11+ const pretext = 'Check out this cool' ;
12+
13+ export const ShareButton = ( { attachment } : { attachment : Attachment } ) => {
14+ const shareText = attachment . image_url
15+ ? `${ pretext } image ! ${ attachment . image_url } `
16+ : `${ pretext } video ! ${ attachment . asset_url } ` ;
17+
18+ const shareContent = useStableCallback ( async ( ) => {
19+ try {
20+ await Share . share ( {
21+ message : shareText ,
22+ title : 'ExpoTikTokApp' ,
23+ } ) ;
24+ } catch ( error ) {
25+ console . error ( 'Error sharing:' , error ) ;
26+ }
27+ } ) ;
28+
29+ return (
30+ < TouchableOpacity onPress = { shareContent } >
31+ < Ionicons name = "arrow-redo-outline" size = { 28 } color = "white" />
32+ </ TouchableOpacity >
33+ ) ;
34+ } ;
You can’t perform that action at this time.
0 commit comments