import * as React from 'react'; import { Dialog, Surface, Text } from 'react-native-paper'; import { TextInputDialogData } from './types'; import { StyleSheet, ViewStyle } from 'react-native'; import { useId, useMemo, useState } from 'react'; import PromptButton from './PromptButton'; import { _ } from '@joplin/lib/locale'; import TextInput from '../TextInput'; import { themeStyle } from '../global-style'; interface Props { dialog: TextInputDialogData; containerStyle: ViewStyle; themeId: number; } const useStyles = (themeId: number) => { return useMemo(() => { const theme = themeStyle(themeId); return StyleSheet.create({ dialogContent: { paddingBottom: theme.margin, paddingHorizontal: theme.margin, }, dialogActions: { paddingBottom: theme.margin, paddingTop: 4, paddingHorizontal: theme.margin, gap: theme.marginMedium, }, textInput: { borderBottomColor: theme.dividerColor, borderBottomWidth: 1, paddingLeft: 6, paddingBottom: 8, }, }); }, [themeId]); }; const TextInputDialog: React.FC = ({ dialog, containerStyle, themeId }) => { const styles = useStyles(themeId); const [text, setText] = useState(dialog.initialValue ?? ''); const labelId = useId(); return ( {dialog.message} dialog.onSubmit(text), }} isMenu={false} themeId={themeId} /> ); }; export default TextInputDialog;