Skip to content

Commit

Permalink
feat: home native handler 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sikkzz committed Feb 5, 2025
1 parent 6bd3412 commit c841c1e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import styles from "@/components/Home/Home.module.scss";
import { AppBridgeMessageType } from "@/components/provider/AppBridgeProvider/AppBridgeMessage.types";
import { useAppBridge } from "@/components/provider/AppBridgeProvider/AppBridgeProvider";
import IconButton from "@/components/ui/IconButton/IconButton";
import Text from "@/components/ui/Text/Text";

import { useRoute } from "@/hooks/common/useRoute";

const Home = () => {
// 이후 네이티브 라우팅으로 변경
const { navigateToReceiptEdit, navigateToRecognitionFail } = useRoute();
const { send } = useAppBridge();

return (
<div className={styles.Home}>
Expand All @@ -22,8 +21,16 @@ const Home = () => {
<img src="/assets/img/img-graphic-logo.png" alt="mainLogo" />
</div>
<div className={styles.HomeBottom}>
<IconButton text="갤러리" iconName="gallery" onClick={navigateToRecognitionFail} />
<IconButton text="카메라" iconName="camera" onClick={navigateToReceiptEdit} />
<IconButton
text="갤러리"
iconName="gallery"
onClick={() => send({ type: AppBridgeMessageType.OPEN_GALLERY })}
/>
<IconButton
text="카메라"
iconName="camera"
onClick={() => send({ type: AppBridgeMessageType.OPEN_CAMERA })}
/>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const androidHandlers = {

export function convertToIOSAppBridge(message: AppBridgeMessage) {
const handler = iosHandlers[message.type];

if (handler) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handler(message as any);
Expand All @@ -34,6 +35,7 @@ export function convertToIOSAppBridge(message: AppBridgeMessage) {

export function convertToAndroidAppBridge(message: AppBridgeMessage) {
const handler = androidHandlers[message.type];

if (handler) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handler(message as any);
Expand Down
10 changes: 8 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

import AppRouter from "@/router/AppRouter";

import { AppBridgeProvider } from "@/components/provider/AppBridgeProvider/AppBridgeProvider";
import ReactQueryClientProvider from "@/components/provider/ReactQueryClientProvider";
import { UserAgentProvider } from "@/components/provider/UserAgentProvider";

import "@/styles/reset.scss";
import "@/styles/global.scss";

ReactDom.createRoot(document.getElementById("root")!).render(
<StrictMode>
<ReactQueryClientProvider>
<AppRouter />
<ReactQueryDevtools initialIsOpen={false} />
<UserAgentProvider>
<AppBridgeProvider>
<AppRouter />
<ReactQueryDevtools initialIsOpen={false} />
</AppBridgeProvider>
</UserAgentProvider>
</ReactQueryClientProvider>
</StrictMode>,
);

0 comments on commit c841c1e

Please sign in to comment.