Activity View

Often called a share sheet, an activity view presents a range of tasks that people can perform in the current context.

Usage

index.tsx
import { Alert, Button as RNButton, ButtonProps, Share, View } from 'react-native';

function DefaultButton({ color, ...props }: ButtonProps) {
  const { colors } = useColorScheme();
  return <RNButton color={color ?? colors.primary} {...props} />;
}

function ActivityViewExample() {
  return (
    <View className="items-center">
      <DefaultButton
        onPress={async () => {
          try {
            const result = await Share.share({
              message: 'NativeWindUI | Familiar interface, native feel.',
            });
            if (result.action === Share.sharedAction) {
              if (result.activityType) {
                // shared with activity type of result.activityType
              } else {
                // shared
              }
            } else if (result.action === Share.dismissedAction) {
              // dismissed
            }
          } catch (error: any) {
            Alert.alert(error.message);
          }
        }}
        title="Share a message"
      />
    </View>
  );
}
© Ronin Technologies LLC 2024