Skip to content

Commit 3b9ee38

Browse files
committed
feat: allow export
1 parent ddb2198 commit 3b9ee38

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

example/src/components/RecordingItem.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
1+
import { View, Text, TouchableOpacity, StyleSheet, Share } from 'react-native';
22
import type { RecordedHaptic } from '../types/recording';
33

44
interface RecordingItemProps {
@@ -42,6 +42,19 @@ export default function RecordingItem({
4242
}
4343
};
4444

45+
const handleExport = async () => {
46+
try {
47+
const jsonData = JSON.stringify(recording, null, 2);
48+
49+
await Share.share({
50+
message: jsonData,
51+
title: `Export ${recording.name}`,
52+
});
53+
} catch (error) {
54+
console.error('Error sharing recording:', error);
55+
}
56+
};
57+
4558
return (
4659
<TouchableOpacity
4760
onPress={() => onSelect(recording.id)}
@@ -82,6 +95,13 @@ export default function RecordingItem({
8295
)}
8396
</TouchableOpacity>
8497

98+
<TouchableOpacity
99+
style={[styles.button, styles.exportButton]}
100+
onPress={handleExport}
101+
>
102+
<Text style={styles.buttonText}></Text>
103+
</TouchableOpacity>
104+
85105
<TouchableOpacity
86106
style={[styles.button, styles.deleteButton]}
87107
onPress={() => onDelete(recording.id)}
@@ -147,6 +167,9 @@ const styles = StyleSheet.create({
147167
playButton: {
148168
backgroundColor: '#007AFF',
149169
},
170+
exportButton: {
171+
backgroundColor: '#34C759',
172+
},
150173
deleteButton: {
151174
backgroundColor: '#FF3B30',
152175
},

0 commit comments

Comments
 (0)