1import { useRoute, useTheme } from '@react-navigation/native'; 2import * as React from 'react'; 3import { Share, StyleSheet, TouchableOpacity } from 'react-native'; 4 5import Config from '../api/Config'; 6import * as UrlUtils from '../utils/UrlUtils'; 7import * as Icons from './Icons'; 8 9export default function ShareProjectButton( 10 props: Partial<React.ComponentProps<typeof TouchableOpacity>> 11) { 12 const theme = useTheme(); 13 const route = useRoute(); 14 const onPress = React.useCallback(() => { 15 const { username, slug } = route.params as any; 16 const url = `exp://${Config.api.host}/@${username}/${slug}`; 17 const message = UrlUtils.normalizeUrl(url); 18 Share.share({ 19 title: url, 20 message, 21 url: message, 22 }); 23 }, [route.params]); 24 25 return ( 26 <TouchableOpacity style={[styles.container, props.style]} onPress={onPress}> 27 <Icons.Share size={24} color={theme.colors.primary} /> 28 </TouchableOpacity> 29 ); 30} 31 32const styles = StyleSheet.create({ 33 container: { 34 flexDirection: 'row', 35 alignItems: 'center', 36 justifyContent: 'center', 37 paddingRight: 15, 38 }, 39}); 40