Skip to content

Commit

Permalink
fix interaction with android (#38)
Browse files Browse the repository at this point in the history
# Overview
  • Loading branch information
deli-ght authored Aug 7, 2023
2 parents d270a68 + 0c846f4 commit a5dd0b8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/onboarding/src/app/measure/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default function MeasurePage() {
bottom: 0;
background: url('/svgs/grainy.svg') repeat, #1f2229;
background-size: contain;
padding-top: 50px;
`}
>
<Box
Expand Down
1 change: 1 addition & 0 deletions apps/onboarding/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function Home() {
background: '#1f2229',
padding: '100px 0 32px',
textAlign: 'center',
minHeight: '100vh',
}}
>
<div
Expand Down
32 changes: 29 additions & 3 deletions apps/onboarding/src/app/result/components/ResultContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Button } from '@sulsul/ui';
import { DrinkReq, TitleDto, TitleDtoTitleEnum } from '~/api';
import { AlcoholDetails, AlcoholResultDetails } from '~/constants/alcohol';
import { ResultCard } from './ResultCard';
import { useSearchParams } from 'next/navigation';
import { useRouter, useSearchParams } from 'next/navigation';
import axios from 'axios';
import { css } from '@emotion/react';
import { shareResult } from '~/app/utils/share';
Expand Down Expand Up @@ -72,12 +72,14 @@ const Volumn = styled.p`
`;

export const ResultContents = () => {
const router = useRouter();
const searchParams = useSearchParams();
const drinkType = searchParams?.get('drinkType');
const glasses = Number(searchParams?.get('glasses'));
const baseY = useMotionValue(0);
const backgroundRef = useRef<HTMLDivElement>(null);
const scrollHeight = backgroundRef.current?.scrollHeight ?? 0;
const scrollHeight = backgroundRef.current?.scrollHeight ?? 200;

const opacityOfY = useTransform(
baseY,
(v) => `${Math.max((v / scrollHeight) * 100, 30)}`
Expand Down Expand Up @@ -106,6 +108,30 @@ export const ResultContents = () => {
const resultSubTitle = resultTitleData?.subTitle;
const { svg, mainColor, color1, color2 } = AlcoholResultDetails[resultTitle];

const measureInApp = () => {
if (globalThis?.window.sulsulBridge) {
globalThis.window.sulsulBridge.onStartMeasureDrink();
return;
}

const checkAndroid = () => {
const u = navigator.userAgent;
return !!u.match(/Android/i);
};

if (checkAndroid()) {
const deep_link =
'intent://measuring/#Intent;scheme=sulsul;package=com.mashup.alcoholfree;end';

router.push(deep_link);
return;
}

router.push(
'https://play.google.com/store/apps/details?id=com.mashup.alcoholfree&hl=en-KR'
);
};

return (
<Stack.Vertical
color="white"
Expand Down Expand Up @@ -257,7 +283,7 @@ export const ResultContents = () => {
<Button type="button" onClick={shareResult} size="lg">
내 주량 공유하기
</Button>
<Button type="button" appearance="primary" size="lg">
<Button type="button" appearance="primary" size="lg" onClick={measureInApp}>
술자리에서 측정하기
</Button>
</Stack.Vertical>
Expand Down

0 comments on commit a5dd0b8

Please sign in to comment.