Skip to content

Commit

Permalink
Feat: add native interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dannaward committed May 20, 2023
1 parent 8ac22f2 commit 642c3f1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
24 changes: 16 additions & 8 deletions src/components/CtaLargeBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { pageKey } from "@/types/pageKey";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useState } from "react";
import styled from "styled-components";
import Script from "next/script";

interface Props {
// key: pageKey;
Expand All @@ -13,15 +14,22 @@ interface Props {
const CtaLargeBtn = (props: Props) => {
const { title, key } = props;
const router = useRouter();

const [isClicked, setIsClicked] = useState(false);

return (
<Button
onClick={() => {
// TODO: 얼굴인식 화면으로
router.push(`/main`);
}}
>
<Title>{title}</Title>
</Button>
<>
<Button
onClick={() => {
// TODO: 얼굴인식 화면으로
// router.push(`/main`);
setIsClicked(!isClicked);
}}
>
<Title>{title}</Title>
</Button>
{ isClicked && <Script id="foo">{'window.webkit.messageHandlers.bridge.postMessage("onClickImportYourWallet");'}</Script> }
</>
);
};

Expand Down
26 changes: 18 additions & 8 deletions src/components/CtaSmallBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { colors } from "@/constant/colors";
import { useRouter } from "next/navigation";
import styled from "styled-components";
import {useState} from "react";
import Script from "next/script";

interface SmallProps {
key: string;
Expand All @@ -10,15 +12,23 @@ interface SmallProps {
const CtaSmallBtn = (props: SmallProps) => {
const { title, key } = props;
const router = useRouter();

const [isClicked, setIsClicked] = useState(false);

return (
<Button
onClick={() => {
// TODO: 얼굴인식 화면으로
router.push(`/send`);
}}
>
<Title>{title}</Title>
</Button>
<>
<Button
onClick={() => {
// TODO: 얼굴인식 화면으로
// router.push(`/send`);

setIsClicked(!isClicked);
}}
>
<Title>{title}</Title>
</Button>
{ isClicked && <Script id="foo">{'window.webkit.messageHandlers.bridge.postMessage("onClickSend");'}</Script> }
</>
);
};

Expand Down
4 changes: 4 additions & 0 deletions src/pages/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { colors } from "@/constant/colors";
import { GlobalStyle } from "@/styles/global.style";
import { useState } from "react";
import styled from "styled-components";
import Script from "next/script";

const Confirm = () => {
const [balance, setBalance] = useState(0);
const [isClicked, setIsClicked] = useState(false);

return (
<Container>
<GlobalStyle />
Expand All @@ -18,6 +21,7 @@ const Confirm = () => {
<ToAddressContainer>{"TO"}</ToAddressContainer>
<TotalFeeContainer>{"Total Gas Fee"}</TotalFeeContainer>
{/* <Footer /> */}
{ isClicked && <Script id="foo">{'window.webkit.messageHandlers.bridge.postMessage("onClickConfirm");'}</Script> }
</Container>
);
};
Expand Down
4 changes: 4 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { GlobalStyle } from "@/styles/global.style";
import { pageKey } from "@/types/pageKey";
import Link from "next/link";
import styled from "styled-components";
import Script from "next/script";
import {useEffect} from "react";

export default function Home() {
const SettingWalletTitle = "Setting Wallet";
const WalletTitle = "Import your wallet or create a new wallet";

return (
<>
<GlobalStyle />
Expand All @@ -23,6 +26,7 @@ export default function Home() {
<CtaLargeBtn key={"create"} title={"Create a new wallet"} />
</BtnContainer>
</Container>
<Script id="my-script">{`function test() { alert("오예"); }`}</Script>
</>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import MaticIcon from "../../public/svgs/Matic.svg";
import UpArrow from "../../public/svgs/UpArrow.svg";
import DownArrow from "../../public/svgs/DownArrow.svg";
import { useRouter } from "next/navigation";
import Script from "next/script";

const Send = () => {
const [value, setValue] = useState(0);
const [gasFee, setGasFee] = useState("");
const router = useRouter();

const [isClicked, setIsClicked] = useState(false);
// TODO: swap contract call
// const provider = new ethers.JsonRpcApiProvider("", 1);
// const signer = new ethers.Wallet("WALLET_PRIVATE_KEY", provider);
Expand Down Expand Up @@ -80,11 +83,14 @@ const Send = () => {
<SubmitBtn
onClick={() => {
router.push("/status");
setIsClicked(!isClicked);
}}

>
{"Next"}
</SubmitBtn>
{/* <Footer /> */}
{ isClicked && <Script id="foo">{'window.webkit.messageHandlers.bridge.postMessage("onClickNext");'}</Script> }
</Container>
);
};
Expand Down

0 comments on commit 642c3f1

Please sign in to comment.