Skip to content

Commit d0f27ba

Browse files
refactor: ui changes
1 parent be27ffe commit d0f27ba

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

example/src/App.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default function App() {
5555

5656
const handleSetValue = (text = 'default value') => {
5757
textRef.current = text;
58-
inputRef.current?.setText(value);
58+
inputRef.current?.setText(text);
5959
inputRef.current?.setSelection(text.length, text.length);
6060
};
6161

@@ -295,7 +295,23 @@ export default function App() {
295295
);
296296
}
297297

298-
const ImageInfo = ({ image }: { image: any }) => {
298+
const ImageInfo = ({ image }: { image: onPasteImageEventData }) => {
299+
function formatFileSize(bytes: number): string {
300+
if (bytes <= 0) return '0 KB';
301+
302+
const KB = 1024;
303+
const MB = KB * KB;
304+
305+
const sizeInMB = bytes / MB;
306+
307+
if (sizeInMB < 0.9) {
308+
const sizeInKB = bytes / KB;
309+
return `${sizeInKB.toFixed(1)} KB`;
310+
}
311+
312+
return `${sizeInMB.toFixed(2)} MB`;
313+
}
314+
299315
return (
300316
<View>
301317
<Text style={{ color: 'red', fontWeight: 'bold' }}>
@@ -319,7 +335,7 @@ const ImageInfo = ({ image }: { image: any }) => {
319335
fontWeight: 'regular',
320336
}}
321337
>
322-
{image.fileSize}
338+
{image.fileSize} ({formatFileSize(image.fileSize)})
323339
</Text>
324340
</Text>
325341
<Text style={{ color: 'red', fontWeight: 'bold' }}>

0 commit comments

Comments
 (0)