Add copy to generate address

This commit is contained in:
2026-05-11 02:52:52 +00:00
parent c2334b2cdd
commit ebe1d8acda
3 changed files with 20 additions and 4 deletions

View File

@@ -47,6 +47,8 @@ interface QRCodeProps {
dialogTitle?: string;
/** Whether to display the raw encoded value as copyable text above the QR code. */
showValue?: boolean;
/** Optional subtitle to display below the QR code. */
subtitle?: React.ReactNode;
}
/**
@@ -155,6 +157,7 @@ export function QRCode({
dialog = false,
dialogTitle = 'QR Code',
showValue = false,
subtitle = null,
}: QRCodeProps): React.ReactElement {
const { rows, moduleCount } = useMemo(() => {
const matrix = generateMatrix(value);
@@ -190,6 +193,7 @@ export function QRCode({
return (
<DialogWrapper title={dialogTitle} borderColor={colors.primary} width={dialogWidth}>
{qrContent}
{subtitle}
</DialogWrapper>
);
}

View File

@@ -29,6 +29,7 @@ import {
type HistoryDisplayRow,
type HistoryColorName,
} from '../../utils/history-utils.js';
import { copyToClipboard } from '../utils/clipboard.js';
/**
* Map history color name to theme color.
@@ -75,7 +76,10 @@ type HistoryListItem = ListItemData<HistoryDisplayRow>;
function QRDialogOverlay({ address, onClose }: { address: string; onClose: () => void }): React.ReactElement {
useInputLayer('qr-dialog');
useLayeredInput('qr-dialog', (_input, key) => {
useLayeredInput('qr-dialog', (input, key) => {
if (input === 'c' || input === 'C') {
copyToClipboard(address);
}
if (key.escape || key.return) {
onClose();
}
@@ -93,10 +97,13 @@ function QRDialogOverlay({ address, onClose }: { address: string; onClose: () =>
dialog
dialogTitle="Receive Address"
showValue
subtitle={
<Box flexDirection="column" justifyContent="center" marginTop={1}>
<Text color={colors.textMuted}>Press C to copy to clipboard</Text>
<Text color={colors.textMuted}>Press Enter or Esc to close</Text>
</Box>
}
/>
<Box justifyContent="center" marginTop={1}>
<Text color={colors.textMuted}>Press Enter or Esc to close</Text>
</Box>
</Box>
);
}