|
1 | | -import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; |
| 1 | +import { View, Text, TouchableOpacity, StyleSheet, Share } from 'react-native'; |
2 | 2 | import type { RecordedHaptic } from '../types/recording'; |
3 | 3 |
|
4 | 4 | interface RecordingItemProps { |
@@ -42,6 +42,19 @@ export default function RecordingItem({ |
42 | 42 | } |
43 | 43 | }; |
44 | 44 |
|
| 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 | + |
45 | 58 | return ( |
46 | 59 | <TouchableOpacity |
47 | 60 | onPress={() => onSelect(recording.id)} |
@@ -82,6 +95,13 @@ export default function RecordingItem({ |
82 | 95 | )} |
83 | 96 | </TouchableOpacity> |
84 | 97 |
|
| 98 | + <TouchableOpacity |
| 99 | + style={[styles.button, styles.exportButton]} |
| 100 | + onPress={handleExport} |
| 101 | + > |
| 102 | + <Text style={styles.buttonText}>↗</Text> |
| 103 | + </TouchableOpacity> |
| 104 | + |
85 | 105 | <TouchableOpacity |
86 | 106 | style={[styles.button, styles.deleteButton]} |
87 | 107 | onPress={() => onDelete(recording.id)} |
@@ -147,6 +167,9 @@ const styles = StyleSheet.create({ |
147 | 167 | playButton: { |
148 | 168 | backgroundColor: '#007AFF', |
149 | 169 | }, |
| 170 | + exportButton: { |
| 171 | + backgroundColor: '#34C759', |
| 172 | + }, |
150 | 173 | deleteButton: { |
151 | 174 | backgroundColor: '#FF3B30', |
152 | 175 | }, |
|
0 commit comments