import * as React from 'react'; import { useCallback, useState } from 'react'; import { View, Button } from 'react-native'; import { TextInput } from 'react-native-paper'; import { _ } from '@joplin/lib/locale'; import shim from '@joplin/lib/shim'; import exportProfile from './utils/exportProfile'; import { ConfigScreenStyles } from '../configScreenStyles'; import SettingsButton from '../SettingsButton'; interface Props { styles: ConfigScreenStyles; } export const exportProfileButtonTitle = () => _('Export profile'); const ExportProfileButton = (props: Props) => { const [profileExportStatus, setProfileExportStatus] = useState<'idle'|'prompt'|'exporting'>('idle'); const [profileExportPath, setProfileExportPath] = useState(''); const exportProfileButtonPress = useCallback(async () => { const externalDir = await shim.fsDriver().getExternalDirectoryPath(); if (!externalDir) { return; } const p = profileExportPath ? profileExportPath : `${externalDir}/JoplinProfileExport`; setProfileExportStatus('prompt'); setProfileExportPath(p); }, [profileExportPath]); const exportProfileButton = ( ); const exportProfileButtonPress2 = useCallback(async () => { setProfileExportStatus('exporting'); await exportProfile(profileExportPath); setProfileExportStatus('idle'); }, [profileExportPath]); const profileExportPrompt = ( setProfileExportPath(text)} value={profileExportPath} placeholder="/path/to/sdcard" keyboardAppearance={props.styles.keyboardAppearance} />