Skip to content

Commit

Permalink
Merge pull request #46 from etclabscore/fix/add-empty-card-loading-si…
Browse files Browse the repository at this point in the history
…gning

fix: add emptycard for loading and signing
  • Loading branch information
shanejonas authored Oct 1, 2020
2 parents d163b52 + 8f5e729 commit 2ec7c60
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 26 deletions.
57 changes: 57 additions & 0 deletions src/components/EmptyCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";
import { Card, CardContent, Grid, LinearProgress } from "@material-ui/core";
import { grey } from "@material-ui/core/colors";

const styles = {
card: {
minHeight: "150px",
width: "300px",
borderRadius: "10px",
background: grey[500],
opacity: 0.2,
margin: "0px",
display: "flex",
},
cardContent: {
flexGrow: 1,
padding: 0,
margin: "16px",
display: "flex",
},
cardItem: {
borderRadius: "10px",
width: "145px",
minHeight: "115px",
},
listItem: {
width: "145px",
minHeight: "115px",
borderRadius: "10px",
},
listItemIcon: {
minWidth: "auto",
},
};

interface IProps {
content?: JSX.Element;
}

const EmptyCard: React.FC<IProps> = (props) => {
return (
<Card style={styles.card}>
<CardContent style={styles.cardContent}>
<Grid container direction="column" justify="space-between" style={{ width: "265px" }}>
<Grid container justify="space-between">
<Grid container item justify="space-around" alignItems="center">
{props.content}
</Grid>
<LinearProgress style={{ width: "100%", height: "15px", marginTop: props.content ? "35px" : "105px" }} />
</Grid>
</Grid>
</CardContent>
</Card>
);
};

export default EmptyCard;
2 changes: 2 additions & 0 deletions src/containers/CardsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { ButtonBase } from "@material-ui/core";
import { ICard } from "../machines/appMachine";
import CardView from "./CardView";
import EmptyCard from "../components/EmptyCard";

interface IProps {
cards: ICard[];
Expand All @@ -13,6 +14,7 @@ const TAB_INDEX_START = 3;
const CardsList: React.FC<IProps> = ({ cards, onCardSelect }) => {
return (
<>
{cards.length === 0 && <EmptyCard />}
{cards.map((card, i) => (
<ButtonBase key={i}
onClick={() => onCardSelect && onCardSelect(card)}
Expand Down
8 changes: 3 additions & 5 deletions src/containers/FormPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ const FormPanel: React.FC<IProps> = (props) => {
}}
onClick={() => {
setOpen(false);
setTimeout(() => {
if (props.onCancel) {
props.onCancel();
}
}, 90);
if (props.onCancel) {
props.onCancel();
}
}}>
<Close />
</IconButton>
Expand Down
11 changes: 8 additions & 3 deletions src/containers/MyApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
MuiThemeProvider,
CssBaseline,
Paper,
CircularProgress,
Typography,
FormControlLabel,
Checkbox,
Expand All @@ -18,7 +17,7 @@ import {
import SignatoryOpenRPCDocument from "../openrpc.json";
import CardView from "./CardView";
import refParser, { JSONSchema } from "@apidevtools/json-schema-ref-parser";
import { ArrowBackIos, Close } from "@material-ui/icons";
import { ArrowBackIos, Close, ScreenLockPortrait } from "@material-ui/icons";
import CardsList from "./CardsList";
import { Flipper } from "react-flip-toolkit";
import AppBar from "./AppBar";
Expand All @@ -41,6 +40,7 @@ import { capabilities } from "../capabilities";
import { RpcCapDomainEntry } from "@xops.net/rpc-cap";
import AccountSelectList from "../components/AccountSelectList";
import { Account } from "@etclabscore/signatory-core";
import EmptyCard from "../components/EmptyCard";

export const matchesMachineState = (
states: string[],
Expand Down Expand Up @@ -412,7 +412,12 @@ const MyApp = () => {
state.matches("signingTransaction") ||
state.matches("signingTypedData")) &&
<Grid container justify="center" alignItems="center" style={{ paddingTop: "30px" }}>
<CircularProgress />
<EmptyCard content={
<Grid container direction="column" justify="center" alignItems="center">
<ScreenLockPortrait fontSize="large" />
<Typography color="textSecondary">{state.value.includes("signing") ? "Signing" : "Creating"}</Typography>
</Grid>
} />
</Grid>
}
{
Expand Down
10 changes: 5 additions & 5 deletions src/machines/appMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const rawAppMachine: any = {
const keyfile = await signatoryCore.exportAccount(e.address);
saveJSON(keyfile, `${e.address}-keyfile.json`);
resolve();
}, 200);
}, 300);
});
},
},
Expand Down Expand Up @@ -363,7 +363,7 @@ export const rawAppMachine: any = {
saveJSON(keyfile, `${r}-keyfile.json`);
resolve(r);
}).catch(reject);
}, 200);
}, 300);
});
},
onDone: {
Expand All @@ -389,7 +389,7 @@ export const rawAppMachine: any = {
return new Promise((resolve: any, reject: any) => {
setTimeout(() => {
signatoryCore.importMnemonic(event.importMnemonicOptions).then(resolve).catch(reject);
}, 200);
}, 300);
});
},
onDone: {
Expand Down Expand Up @@ -431,7 +431,7 @@ export const rawAppMachine: any = {
.signTransaction(event.transaction, event.passphrase, event.chainId)
.then(resolve)
.catch(reject);
}, 200);
}, 300);
});
},
onDone: {
Expand All @@ -452,7 +452,7 @@ export const rawAppMachine: any = {
setTimeout(() => {
signatoryCore
.sign(event.dataToSign, event.address, event.passphrase, event.chainId).then(resolve).catch(reject);
}, 200);
}, 300);
});
},
onDone: {
Expand Down
13 changes: 0 additions & 13 deletions src/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,6 @@
}
]
},
{
"name": "importKeyfile",
"summary": "Import an account from Keyfile",
"description": "Import a new account from an external keyfile. should comply with the [Web3 Secret Storage Definition](https://github.com/ethereumproject/wiki/wiki/Web3-Secret-Storage-Definition)",
"params": [
{
"$ref": "#/components/contentDescriptors/Keyfile"
}
],
"result": {
"$ref": "#/components/contentDescriptors/Address"
}
},
{
"name": "generateMnemonic",
"summary": "Generate a mnemonic phrase",
Expand Down

0 comments on commit 2ec7c60

Please sign in to comment.