import * as React from 'react'; import { CameraResult } from './types'; import { View, StyleSheet } from 'react-native'; import CameraView from './CameraView'; import { useCallback, useMemo } from 'react'; import { themeStyle } from '../global-style'; import { Button } from 'react-native-paper'; import { _ } from '@joplin/lib/locale'; import PhotoPreview from './PhotoPreview'; export type OnPhotosChange = (photos: CameraResult[])=> void; export type OnComplete = ()=> void; interface Props { themeId: number; onCancel: ()=> void; onComplete: OnComplete; photos: CameraResult[]; onSetPhotos: OnPhotosChange; onInsertBarcode: (barcodeText: string)=> void; } const useStyle = (themeId: number) => { return useMemo(() => { const theme = themeStyle(themeId); return StyleSheet.create({ camera: { flex: 1, }, root: { flex: 1, backgroundColor: theme.backgroundColor, }, bottomRow: { flexDirection: 'row', alignItems: 'center', }, photoWrapper: { flexGrow: 1, minHeight: 82, flexDirection: 'row', justifyContent: 'center', }, imagePreview: { maxWidth: 70, }, imageCountText: { backgroundColor: theme.backgroundColor2, color: theme.color2, }, }); }, [themeId]); }; const CameraViewMultiPage: React.FC = ({ onInsertBarcode, onCancel, onComplete, themeId, photos, onSetPhotos, }) => { const onPhoto = useCallback((data: CameraResult) => { onSetPhotos([...photos, data]); }, [photos, onSetPhotos]); const styles = useStyle(themeId); const renderLastPhoto = () => { if (!photos.length) return null; return ; }; return {renderLastPhoto()} ; }; export default CameraViewMultiPage;