import * as React from 'react'; import { useMemo } from 'react'; import { View, StyleSheet, ViewStyle, Platform } from 'react-native'; import IconButton from '../IconButton'; import { _ } from '@joplin/lib/locale'; import { CameraDirection } from '@joplin/lib/models/settings/builtInMetadata'; import { ActivityIndicator } from 'react-native-paper'; interface Props { themeId: number; onCameraReverse: ()=> void; cameraDirection: CameraDirection; onSetCameraRatio: ()=> void; cameraRatio: string; onCancelPhoto: ()=> void; onTakePicture: ()=> void; takingPicture: boolean; cameraReady: boolean; } const useStyles = () => { return useMemo(() => { const buttonContainer: ViewStyle = { borderRadius: 32, minWidth: 60, minHeight: 60, borderColor: '#00000040', borderWidth: 1, borderStyle: 'solid', backgroundColor: '#ffffff77', justifyContent: 'center', alignItems: 'center', alignSelf: 'flex-end', }; const buttonRowContainer: ViewStyle = { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', left: 20, right: 20, position: 'absolute', }; return StyleSheet.create({ buttonRowContainerTop: { ...buttonRowContainer, top: 20, }, buttonRowContainerBottom: { ...buttonRowContainer, bottom: 20, }, buttonContainer, buttonContent: { color: 'black', fontSize: 40, }, buttonPlaceHolder: { width: 60, }, qrCodeButtonDimmed: { ...buttonContainer, backgroundColor: '#ffffff44', borderWidth: 0, }, takePhotoButtonContainer: { ...buttonContainer, minWidth: 80, minHeight: 80, borderRadius: 80, }, takePhotoButtonContent: { color: 'black', fontSize: 60, }, ratioButtonContainer: { ...buttonContainer, aspectRatio: undefined, padding: 12, }, ratioButtonContent: { fontSize: 20, color: 'black', }, }); }, []); }; const ActionButtons: React.FC = props => { const styles = useStyles(); const reverseButton = ( ); const takePhotoButton = ( ); const ratioButton = ( ); const cameraActions = ( {reverseButton} {takePhotoButton} { // Changing ratio is only supported on Android: Platform.OS === 'android' ? ratioButton : } ); return <> {props.cameraReady ? cameraActions : } ; }; export default ActionButtons;