Browse Source

update scanner

feature/axios_provider
cyril.tsui 5 months ago
parent
commit
888f35073c
2 changed files with 12 additions and 9 deletions
  1. +6
    -5
      src/components/QrCodeScanner/QrCodeScanner.tsx
  2. +6
    -4
      src/components/QrCodeScanner/QrCodeScannerModal.tsx

+ 6
- 5
src/components/QrCodeScanner/QrCodeScanner.tsx View File

@@ -20,6 +20,7 @@ const scannerSx: React.CSSProperties = {


type QrCodeScannerProps = { type QrCodeScannerProps = {
title?: string, title?: string,
contents?: string[],
onScanSuccess: (result: string) => void, onScanSuccess: (result: string) => void,
onScanError?: (error: string) => void, onScanError?: (error: string) => void,
isOpen: boolean, isOpen: boolean,
@@ -28,6 +29,7 @@ type QrCodeScannerProps = {


const QrCodeScanner: React.FC<QrCodeScannerProps> = ({ const QrCodeScanner: React.FC<QrCodeScannerProps> = ({
title, title,
contents,
onScanSuccess, onScanSuccess,
onScanError, onScanError,
isOpen, isOpen,
@@ -160,14 +162,13 @@ const QrCodeScanner: React.FC<QrCodeScannerProps> = ({
{title ? <Typography variant="overline" display="block" marginBlockEnd={1} paddingLeft={2}> {title ? <Typography variant="overline" display="block" marginBlockEnd={1} paddingLeft={2}>
{"Title"} {"Title"}
</Typography> : null} </Typography> : null}
<Grid container alignItems="center" rowSpacing={2} columns={{ xs: 6, sm: 12 }}>
<Grid container alignItems="center" justifyContent="center" rowSpacing={2} columns={{ xs: 6, sm: 12 }}>
<Grid item xs={12}> <Grid item xs={12}>
<div style={{ textAlign: "center", margin: "auto", justifyContent: "center" }} id="qr-reader" hidden={isScanned} /> <div style={{ textAlign: "center", margin: "auto", justifyContent: "center" }} id="qr-reader" hidden={isScanned} />
</Grid> </Grid>
{cameraList.length > 0 ? <Grid item xs={6} > {cameraList.length > 0 ? <Grid item xs={6} >
<Autocomplete <Autocomplete
disableClearable disableClearable
disableCloseOnSelect
noOptionsText={t("No Options")} noOptionsText={t("No Options")}
options={cameraList} options={cameraList}
value={cameraList.find((camera) => camera.id === selectedCameraId)} value={cameraList.find((camera) => camera.id === selectedCameraId)}
@@ -184,9 +185,9 @@ const QrCodeScanner: React.FC<QrCodeScannerProps> = ({
/> />
</Grid> : null} </Grid> : null}
{ {
stringList.map((string) => {
return <Grid item xs={7}>{string}</Grid>
})
contents ? contents.map((string) => {
return <Grid item xs={8}>{string}</Grid>
}) : null
} }
</Grid> </Grid>
<Stack direction="row" justifyContent={"flex-end"} spacing={2} sx={{ margin: 2 }}> <Stack direction="row" justifyContent={"flex-end"} spacing={2} sx={{ margin: 2 }}>


+ 6
- 4
src/components/QrCodeScanner/QrCodeScannerModal.tsx View File

@@ -14,6 +14,7 @@ const modalSx: SxProps = {


type QrCodeScannerModalProps = { type QrCodeScannerModalProps = {
title?: string, title?: string,
contents?: string[],
isOpen: boolean, isOpen: boolean,
onClose: () => void, onClose: () => void,
onScanSuccess: (result: string) => void, onScanSuccess: (result: string) => void,
@@ -22,6 +23,7 @@ type QrCodeScannerModalProps = {


const QrCodeScannerModal: React.FC<QrCodeScannerModalProps> = ({ const QrCodeScannerModal: React.FC<QrCodeScannerModalProps> = ({
title, title,
contents,
isOpen, isOpen,
onClose, onClose,
onScanSuccess, onScanSuccess,
@@ -45,14 +47,14 @@ const QrCodeScannerModal: React.FC<QrCodeScannerModalProps> = ({
return ( return (
<Modal open={isOpen} onClose={onModalClose}> <Modal open={isOpen} onClose={onModalClose}>
<Card sx={modalSx}> <Card sx={modalSx}>
<CardContent>
<CardContent sx={{ overflow: "auto", maxHeight: "90vh" }} >
<Box <Box
sx={{ sx={{
marginInline: -3,
marginBlock: 4,
// marginInline: -1,
// marginBlock: 1,
}} }}
> >
<QrCodeScanner title={title} onScanSuccess={onScanSuccess} onScanError={onScanError} isOpen={modalOpen} onClose={onClose}/>
<QrCodeScanner title={title} contents={contents} onScanSuccess={onScanSuccess} onScanError={onScanError} isOpen={modalOpen} onClose={onClose} />
</Box> </Box>
</CardContent> </CardContent>
</Card> </Card>


Loading…
Cancel
Save