diff --git a/public b/public index bc0689d..c1e34e9 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit bc0689d0d57c0adf9575c02e21695e0ffdc0e3a0 +Subproject commit c1e34e99282ba4d2593c77b8ef20c466ad494b14 diff --git a/src/assist/buttonwrapper/AppleLoginButtonWrapper.tsx b/src/assist/buttonwrapper/AppleLoginButtonWrapper.tsx new file mode 100644 index 0000000..e88fc31 --- /dev/null +++ b/src/assist/buttonwrapper/AppleLoginButtonWrapper.tsx @@ -0,0 +1,23 @@ +import { platformAtom } from "@/data/platform"; +import { postAppleLogin } from "@/libs/reactNative/sender"; +import LoginButton from "@modules/components/button/LoginButton"; +import FlexBox from "@modules/layout/FlexBox"; +import { useAtom } from "jotai"; + +function AppleLoginButtonWrapper() { + const [platform] = useAtom(platformAtom); + const appleLogin = () => { + postAppleLogin(); + }; + return ( + + {platform?.OS === "ios" && ( +
+ +
+ )} +
+ ); +} + +export default AppleLoginButtonWrapper; diff --git a/src/assist/KakaoLoginButtonWrapper.tsx b/src/assist/buttonwrapper/KakaoLoginButtonWrapper.tsx similarity index 79% rename from src/assist/KakaoLoginButtonWrapper.tsx rename to src/assist/buttonwrapper/KakaoLoginButtonWrapper.tsx index 69f9e17..4c009bb 100644 --- a/src/assist/KakaoLoginButtonWrapper.tsx +++ b/src/assist/buttonwrapper/KakaoLoginButtonWrapper.tsx @@ -1,5 +1,6 @@ import { eollugageUrl } from "@/apis/network"; import LoginButton from "@modules/components/button/LoginButton"; +import FlexBox from "@modules/layout/FlexBox"; import { useRouter } from "next/router"; function KakaoLoginButtonWrapper() { @@ -28,9 +29,11 @@ function KakaoLoginButtonWrapper() { }, []); */ return ( -
- -
+ +
+ +
+
); } diff --git a/src/assist/StateButtonWrapper.tsx b/src/assist/buttonwrapper/StateButtonWrapper.tsx similarity index 100% rename from src/assist/StateButtonWrapper.tsx rename to src/assist/buttonwrapper/StateButtonWrapper.tsx diff --git a/src/data/platform.ts b/src/data/platform.ts new file mode 100644 index 0000000..2f9314b --- /dev/null +++ b/src/data/platform.ts @@ -0,0 +1,93 @@ +import { atom } from "jotai"; + +export type PlatformOSType = + | "ios" + | "android" + | "macos" + | "windows" + | "web" + | "native"; +type PlatformConstants = { + isTesting: boolean; + reactNativeVersion: { + major: number; + minor: number; + patch: number; + prerelease?: number | null | undefined; + }; +}; +interface PlatformStatic { + isTV: boolean; + isTesting: boolean; + Version: number | string; + constants: PlatformConstants; + + /** + * @see https://reactnative.dev/docs/platform-specific-code#content + */ + select( + specifics: + | ({ [platform in PlatformOSType]?: T } & { default: T }) + | { [platform in PlatformOSType]: T }, + ): T; + select(specifics: { [platform in PlatformOSType]?: T }): T | undefined; +} + +interface PlatformIOSStatic extends PlatformStatic { + constants: PlatformConstants & { + forceTouchAvailable: boolean; + interfaceIdiom: string; + osVersion: string; + systemName: string; + }; + OS: "ios"; + isPad: boolean; + isTV: boolean; + Version: string; +} + +interface PlatformAndroidStatic extends PlatformStatic { + constants: PlatformConstants & { + Version: number; + Release: string; + Serial: string; + Fingerprint: string; + Model: string; + Brand: string; + Manufacturer: string; + ServerHost?: string | undefined; + uiMode: "car" | "desk" | "normal" | "tv" | "watch" | "unknown"; + }; + OS: "android"; + Version: number; +} + +interface PlatformMacOSStatic extends PlatformStatic { + OS: "macos"; + Version: string; + constants: PlatformConstants & { + osVersion: string; + }; +} + +interface PlatformWindowsOSStatic extends PlatformStatic { + OS: "windows"; + Version: number; + constants: PlatformConstants & { + osVersion: number; + }; +} + +interface PlatformWebStatic extends PlatformStatic { + OS: "web"; +} + +export type Platform = + | PlatformIOSStatic + | PlatformAndroidStatic + | PlatformWindowsOSStatic + | PlatformMacOSStatic + | PlatformWebStatic; + +export const platformAtom = atom(null); +platformAtom.debugLabel = "platformAtom"; diff --git a/src/libs/reactNative/RNListener.tsx b/src/libs/reactNative/RNListener.tsx index d5f6b73..646fbd3 100644 --- a/src/libs/reactNative/RNListener.tsx +++ b/src/libs/reactNative/RNListener.tsx @@ -1,14 +1,21 @@ +import { Platform, platformAtom } from "@/data/platform"; import { usePostFcmToken } from "@/hooks/query/fcmtoken"; +import { useAtom } from "jotai"; import { useEffect } from "react"; function RNListener() { const { mutate: postHistoryStatusMutate } = usePostFcmToken(); + const [, setPlatform] = useAtom(platformAtom); const onMessageEvent = (e: MessageEvent) => { e.stopPropagation(); - const message: { type: string; data: string } = JSON.parse(String(e.data)); + const message: { type: string; data: number | string | object } = + JSON.parse(String(e.data)); if (message.type === "getFcmTokenResponse") { - postHistoryStatusMutate({ token: message.data }); + postHistoryStatusMutate({ token: message.data as string }); + } + if (message.type === "getPlatform") { + setPlatform(message.data as Platform); } }; diff --git a/src/libs/reactNative/sender.ts b/src/libs/reactNative/sender.ts index def5af4..7f47ced 100644 --- a/src/libs/reactNative/sender.ts +++ b/src/libs/reactNative/sender.ts @@ -5,3 +5,19 @@ export function getFcmTokenRN() { ReactNativeWebView.postMessage(JSON.stringify({ type: "getFcmToken" })); } } + +export function getPlatform() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const { ReactNativeWebView } = window as any; + if (ReactNativeWebView) { + ReactNativeWebView.postMessage(JSON.stringify({ type: "getPlatform" })); + } +} + +export function postAppleLogin() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const { ReactNativeWebView } = window as any; + if (ReactNativeWebView) { + ReactNativeWebView.postMessage(JSON.stringify({ type: "postAppleLogin" })); + } +} diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 54a2405..ecf9e1e 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,7 +1,7 @@ import { myMemberIdAtom, storeIdAtom } from "@/data/global"; import { useGetMy } from "@/hooks/query/my"; import RNListener from "@/libs/reactNative/RNListener"; -import { getFcmTokenRN } from "@/libs/reactNative/sender"; +import { getFcmTokenRN, getPlatform } from "@/libs/reactNative/sender"; import "@/styles/fonts/fonts.css"; import "@/styles/globals.scss"; import "@/styles/scroll.scss"; @@ -48,6 +48,10 @@ export default function App({ Component, pageProps }: AppProps) { if (storeId !== "") setRendor(true); }, [storeId, pathname]); + useEffect(() => { + getPlatform(); + }, []); + return ( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index a26fb02..7ddffaa 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,4 +1,5 @@ -import KakaoLoginButtonWrapper from "@/assist/KakaoLoginButtonWrapper"; +import AppleLoginButtonWrapper from "@/assist/buttonwrapper/AppleLoginButtonWrapper"; +import KakaoLoginButtonWrapper from "@/assist/buttonwrapper/KakaoLoginButtonWrapper"; import FlexBox from "@modules/layout/FlexBox"; import Image from "next/image"; import { useRouter } from "next/router"; @@ -37,7 +38,10 @@ export default function Home() { 간편하게 일하는 법
- + + + + diff --git a/src/pages/manage/attendance.tsx b/src/pages/manage/attendance.tsx index c03fb68..a357ec8 100644 --- a/src/pages/manage/attendance.tsx +++ b/src/pages/manage/attendance.tsx @@ -1,6 +1,6 @@ import { AllHistory } from "@/apis/history"; import ProfileDiscription from "@/assist/ProfileDiscription"; -import StateButtonWrapper from "@/assist/StateButtonWrapper"; +import StateButtonWrapper from "@/assist/buttonwrapper/StateButtonWrapper"; import TimeBanner from "@/assist/banner/TimeBanner"; import { useGetAllMemeberHistory,