diff --git a/main.go b/main.go index 8ce69c7..e42839a 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,7 @@ func main() { } w = webview.New(debug) defer w.Destroy() - w.SetSize(540, 240, webview.HintNone) + w.SetSize(640, 320, webview.HintNone) w.SetTitle("Imprint " + version) // Bind a function to inject JavaScript and CSS via webview.Eval. @@ -113,9 +113,6 @@ func main() { } // Call setDevicesReact. w.Eval("setDevicesReact([" + strings.Join(jsonifiedDevices, ", ") + "])") - if len(jsonifiedDevices) >= 1 { - w.Eval("setSelectedDeviceReact(" + jsonifiedDevices[0] + ")") - } }) // Bind a function to prompt for file. diff --git a/package.json b/package.json index 59bd114..3726cde 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ }, "packageManager": "yarn@4.5.1", "dependencies": { + "@emotion/react": "^11.13.3", + "@emotion/styled": "^11.13.0", + "@mui/joy": "5.0.0-beta.48", "jsbi": "^4.3.0", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/renderer/App.module.scss b/renderer/App.module.scss index 16c63c4..3fcf4f6 100644 --- a/renderer/App.module.scss +++ b/renderer/App.module.scss @@ -1,16 +1,24 @@ -.container { - padding: 8px; +.root { + height: 100vh; + width: 100vw; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; } -.select-image-container { - display: flex; - padding-bottom: 0.4em; +.container { + width: 100%; + max-width: 540px; } -.select-device-container { +.select-container { display: flex; - padding-bottom: 0.4em; padding-top: 0.4em; + padding-bottom: 0.4em; + > :last-child { + margin-left: 0.4em; + } } .flash-progress-container { @@ -23,10 +31,6 @@ width: 100%; } -.refresh-button { - min-width: 69px; -} - .spacer { width: 5px; } diff --git a/renderer/App.tsx b/renderer/App.tsx index acb3946..70ddec4 100644 --- a/renderer/App.tsx +++ b/renderer/App.tsx @@ -2,26 +2,29 @@ import { useEffect, useState } from 'react' import JSBI from 'jsbi' import Dialog from './Dialog' import * as styles from './App.module.scss' +import { Button, Option, Select, Textarea, Typography, useColorScheme } from '@mui/joy' +// TODO: Experiment with lg size for the UI. const App = (): JSX.Element => { const [file, setFile] = useState('') const [speed, setSpeed] = useState('') const [dialog, setDialog] = useState('') const [confirm, setConfirm] = useState(false) - const [devices, setDevices] = useState(['N/A']) + const [devices, setDevices] = useState([]) const [fileSize, setFileSize] = useState(0) const [progress, setProgress] = useState(null) - const [selectedDevice, setSelectedDevice] = useState('N/A') + const [selectedDevice, setSelectedDevice] = useState(null) globalThis.setFileReact = setFile globalThis.setSpeedReact = setSpeed globalThis.setDialogReact = setDialog globalThis.setDevicesReact = setDevices globalThis.setProgressReact = setProgress globalThis.setFileSizeReact = setFileSize - globalThis.setSelectedDeviceReact = setSelectedDevice + useColorScheme().setMode('light') useEffect(() => { globalThis.refreshDevices() }, []) + useEffect(() => setSelectedDevice(null), [devices]) const inProgress = typeof progress === 'number' useEffect(() => setConfirm(false), [inProgress]) @@ -35,7 +38,7 @@ const App = (): JSX.Element => { return } setProgress(null) - if (selectedDevice === 'N/A') return setDialog('Error: Select a device to flash the ISO to!') + if (selectedDevice === null) return setDialog('Error: Select a device to flash the ISO to!') if (file === '') return setDialog('Error: Select an ISO to flash to a device!') if (JSBI.greaterThan(JSBI.BigInt(fileSize), JSBI.BigInt(selectedDevice.split(' ')[0]))) { return setDialog('Error: The ISO file is too big to fit on the selected drive!') @@ -51,52 +54,67 @@ const App = (): JSX.Element => { ? JSBI.divide(JSBI.multiply(JSBI.BigInt(progress), JSBI.BigInt(100)), JSBI.BigInt(fileSize)) : JSBI.BigInt(0) return ( - <> - {dialog !== '' && ( - setDialog('')} - message={dialog.startsWith('Error: ') ? dialog.substring(7) : dialog} - error={dialog.startsWith('Error: ')} - /> - )} +
+ setDialog('')} + message={dialog.startsWith('Error: ') ? dialog.substring(7) : dialog} + error={dialog.startsWith('Error: ')} + />
- Step 1: Enter the path to the file. -
-