-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (smpl) [DSDK-205]: Implement Send APDU UI (#49)
- Loading branch information
Showing
9 changed files
with
321 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use client"; | ||
import React from "react"; | ||
|
||
import { ApduView } from "@/components/ApduView"; | ||
|
||
const Apdu: React.FC = () => { | ||
return <ApduView />; | ||
}; | ||
|
||
export default Apdu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { Button, Divider, Flex, Grid, Input, Text } from "@ledgerhq/react-ui"; | ||
import styled, { DefaultTheme } from "styled-components"; | ||
|
||
import { useApduForm } from "@/hooks/useApduForm"; | ||
|
||
const Root = styled(Flex).attrs({ mx: 15, mt: 10, mb: 5 })` | ||
flex-direction: column; | ||
flex: 1; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
const Title = styled(Text).attrs({ | ||
variant: "large", | ||
fontSize: 18, | ||
mt: 8, | ||
})``; | ||
|
||
const FormContainer = styled(Flex)` | ||
background-color: ${({ theme }: { theme: DefaultTheme }) => | ||
theme.colors.neutral.c30}; | ||
height: 100%; | ||
width: 100%; | ||
flex-direction: column; | ||
border-radius: 12px; | ||
`; | ||
|
||
const FormHeader = styled(Flex).attrs({ px: 8, py: 6 })``; | ||
|
||
const Form = styled(Flex).attrs({ my: 6, px: 10 })` | ||
flex: 1; | ||
flex-direction: column; | ||
justify-content: center; | ||
`; | ||
|
||
const FormFooter = styled(Flex).attrs({ my: 8, px: 8 })` | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
align-self: flex-end; | ||
align-items: flex-end; | ||
`; | ||
|
||
const FormFooterButton = styled(Button).attrs({ | ||
variant: "main", | ||
size: "large", | ||
color: "neutral.c00", | ||
})``; | ||
|
||
const InputContainer = styled(Flex).attrs({ mx: 8, mb: 4 })` | ||
flex-direction: column; | ||
min-width: 150px; | ||
`; | ||
|
||
const inputContainerProps = { style: { borderRadius: 4 } }; | ||
|
||
export const ApduView: React.FC = () => { | ||
const { apduFormValues, setApduFormValue, apdu } = useApduForm(); | ||
return ( | ||
<Root> | ||
<FormContainer> | ||
<FormHeader> | ||
<Title>APDU</Title> | ||
</FormHeader> | ||
<Divider my={4} /> | ||
<Form> | ||
<Grid columns={2}> | ||
<InputContainer> | ||
<Text variant="body" mb={4}> | ||
Class instruction | ||
</Text> | ||
<Input | ||
name="instruction" | ||
containerProps={inputContainerProps} | ||
value={apduFormValues.classInstruction} | ||
onChange={(value) => | ||
setApduFormValue("classInstruction", value) | ||
} | ||
/> | ||
</InputContainer> | ||
<InputContainer> | ||
<Text variant="body" mb={4}> | ||
Instruction method | ||
</Text> | ||
<Input | ||
name="instructionMethod" | ||
containerProps={inputContainerProps} | ||
value={apduFormValues.instructionMethod} | ||
onChange={(value) => | ||
setApduFormValue("instructionMethod", value) | ||
} | ||
/> | ||
</InputContainer> | ||
<InputContainer> | ||
<Text variant="body" mb={4}> | ||
Parameter 1 | ||
</Text> | ||
<Input | ||
name="firstParameter" | ||
containerProps={inputContainerProps} | ||
value={apduFormValues.firstParameter} | ||
onChange={(value) => setApduFormValue("firstParameter", value)} | ||
/> | ||
</InputContainer> | ||
<InputContainer> | ||
<Text variant="body" mb={4}> | ||
Parameter 2 | ||
</Text> | ||
<Input | ||
name="secondParameter" | ||
containerProps={inputContainerProps} | ||
value={apduFormValues.secondParameter} | ||
onChange={(value) => setApduFormValue("secondParameter", value)} | ||
/> | ||
</InputContainer> | ||
<InputContainer> | ||
<Text variant="body" mb={4}> | ||
Data | ||
</Text> | ||
<Input | ||
name="data" | ||
containerProps={inputContainerProps} | ||
value={apduFormValues.data} | ||
onChange={(value) => setApduFormValue("data", value)} | ||
/> | ||
</InputContainer> | ||
<InputContainer> | ||
<Text variant="body" mb={4}> | ||
Data length | ||
</Text> | ||
<Input | ||
name="dataLength" | ||
containerProps={inputContainerProps} | ||
value={apduFormValues.dataLength} | ||
onChange={(value) => setApduFormValue("dataLength", value)} | ||
/> | ||
</InputContainer> | ||
</Grid> | ||
</Form> | ||
<Divider my={4} /> | ||
<FormFooter my={8}> | ||
<FormFooterButton onClick={() => console.log(apdu)}> | ||
<Text color="neutral.c00">Send APDU</Text> | ||
</FormFooterButton> | ||
</FormFooter> | ||
</FormContainer> | ||
</Root> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from "react"; | ||
import { Flex, Icons } from "@ledgerhq/react-ui"; | ||
import styled, { DefaultTheme } from "styled-components"; | ||
|
||
const Root = styled(Flex).attrs({ py: 3, px: 10, gridGap: 8 })` | ||
color: ${({ theme }: { theme: DefaultTheme }) => theme.colors.neutral.c90}; | ||
justify-content: flex-end; | ||
align-items: center; | ||
`; | ||
|
||
const Actions = styled(Flex)` | ||
justify-content: flex-end; | ||
align-items: center; | ||
flex: 1 0 0; | ||
`; | ||
const IconBox = styled(Flex).attrs({ p: 3 })` | ||
cursor: pointer; | ||
align-items: center; | ||
opacity: 0.7; | ||
`; | ||
|
||
export const Header = () => ( | ||
<Root> | ||
<Actions> | ||
<IconBox> | ||
<Icons.Question size={"M"} /> | ||
</IconBox> | ||
<IconBox> | ||
<Icons.Settings size={"M"} /> | ||
</IconBox> | ||
</Actions> | ||
</Root> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.