Skip to content

Commit

Permalink
Merge pull request #2383 from planetarium/fix/hide-qr
Browse files Browse the repository at this point in the history
Add Hide QR UI
  • Loading branch information
Akamig authored Nov 27, 2023
2 parents d8f012b + 2e4c38a commit ecbf958
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
60 changes: 51 additions & 9 deletions src/renderer/components/core/Layout/UserInfo/ExportOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { styled, Box } from "@material-ui/core";
import { styled, Box, Button, Backdrop } from "@material-ui/core";
import React, { useEffect, useState } from "react";
import DummyQR from "src/renderer/resources/dummyQR.png";
import writeQR from "@paulmillr/qr";
import { useStore } from "src/utils/useStore";
import OverlayBase, { CloseButton } from "../../OverlayBase";
Expand All @@ -12,17 +13,38 @@ const MainPageContainer = styled(OverlayBase)({
width: "420px",
height: "600px",
backgroundColor: "#1d1e1f",
padding: "48px 48px",
padding: "2rem",
display: "flex",
gap: "1rem",
gap: "0.5rem",
flexDirection: "column",
alignItems: "center",
color: "white",
},
});

const SquareBox = {
borderRadius: "1rem",
aspectRatio: "1/1",
minWidth: "100%",

display: "flex",
justifyContent: "center",
overflow: "hidden",
};

const imageBox = {
backgroundColor: "white",
padding: "1rem",
};

const hiddenBox = {
...imageBox,
filter: "blur(0.5rem) brightness(1.2)",
};

export function ExportOverlay({ isOpen, onClose }: OverlayProps) {
const [vector, setVector] = useState<string>("");
const [hidden, setHidden] = useState<boolean>(true);
const account = useStore("account");
useEffect(() => {
account.exportKeystore().then((key) => {
Expand All @@ -33,16 +55,36 @@ export function ExportOverlay({ isOpen, onClose }: OverlayProps) {

return (
<MainPageContainer isOpen={isOpen} onDismiss={onClose}>
<CloseButton onClick={() => onClose()} />
<H1 css={{ margin: 0 }}>Key Export</H1>
<img
style={{ backgroundColor: "white", padding: "1rem" }}
src={`data:image/svg+xml;utf8,${vector}`}
<CloseButton
onClick={() => {
setHidden(true);
onClose();
}}
/>
<Box>
<H1 css={{ margin: 0 }}>Key Export</H1>
<Box style={SquareBox}>
{hidden ? (
<img style={hiddenBox} src={DummyQR}></img>
) : (
<img style={imageBox} src={`data:image/svg+xml;utf8,${vector}`} />
)}
</Box>
<Box marginBottom={0}>
<Text>This is Encrypted Key.</Text>
<Text>Do Not Show Your Key to Others.</Text>
</Box>
<Button
onClick={() => setHidden(!hidden)}
variant={hidden ? "outlined" : "contained"}
style={{
marginLeft: "auto",
marginRight: "auto",
color: `${hidden ? "white" : "black"}`,
borderColor: `${hidden ? "white" : "black"}`,
}}
>
Show / Hide QR Code
</Button>
</MainPageContainer>
);
}
Binary file added src/renderer/resources/DummyQR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ecbf958

Please sign in to comment.