components/CameraButton.js
import React, {useState} from 'react'; import { View, Pressable, StyleSheet, Platform, ActionSheetIOS, } from 'react-native'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; import Icon from 'react-native-vector-icons/MaterialIcons'; import UploadModeModal from './UploadModeModal'; const TABBAR_HEIGHT 49; function () { const insets (); const [modalVisible, setModalVisible] (false); const bottom Platform. ({ android: TABBAR_HEIGHT 2, ios: TABBAR_HEIGHT 2 insets.bottom 4, }); const onPress = () => { if (Platform.OS === 'android') { setModalVisible(true); return; } ActionSheetIOS.showActionSheetWithOptions( { options: ['카메라로 촬영하기', '사진 선택하기', '취소'], cancelButtonIndex: 2, }, (buttonIndex) => { if (buttonIndex === 0) { console.log('카메라 촬영'); } else if (buttonIndex === 1) { console.log('사진 선택'); } }, ); }; return ( <> <View style={[styles.wrapper, {bottom}]}> <Pressable android_ripple={{ color '#ffffff', }} style={styles.circle} onPress={onPress}> <Icon name="camera-alt" color="white" size={24} /> </Pressable> </View> <UploadModeModal visible={modalVisible} onClose={() => (false)} /> </> ); } ( )