1import { useExpoTheme } from 'expo-dev-client-components';
2import * as React from 'react';
3import { Share, StyleSheet, TouchableOpacity } from 'react-native';
4
5import * as Icons from './Icons';
6import Config from '../api/Config';
7import * as UrlUtils from '../utils/UrlUtils';
8
9export default function ShareProjectButton(
10  props: Partial<React.ComponentProps<typeof TouchableOpacity>> & {
11    fullName: string;
12  }
13) {
14  const theme = useExpoTheme();
15  const onPress = React.useCallback(() => {
16    const url = `exp://${Config.api.host}/${props.fullName}`;
17    const message = UrlUtils.normalizeUrl(url);
18    Share.share({
19      title: url,
20      message,
21      url: message,
22    });
23  }, [props.fullName]);
24
25  return (
26    <TouchableOpacity style={[styles.container, props.style]} onPress={onPress}>
27      <Icons.Share size={24} color={theme.icon.default} />
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