-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/#111 맛집 상세 페이지에 네이버 지도 및 카카오택시 딥링크 기능 추가 #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2d8dd0a
feat: 맛집 상세 페이지에 네이버 지도 딥링크 기능 추가
leeleeleeleejun 44a1ef3
feat: 맛집 상세 페이지에 카카오택시 딥링크 기능 추가
leeleeleeleejun bab77cc
feat: MapButton 컴포넌트의 이미지에 rounded-sm 클래스 추가
leeleeleeleejun e5b6df0
feat: 네이버 지도 딥링크에서 앱 스킴 수정 및 웹 폴백 타임아웃 제거
leeleeleeleejun e0313f5
refactor: 딥링크 공통 로직을 openDeepLink 유틸 함수로 분리
leeleeleeleejun 6cf0c63
feat: PlacePreview에서 사용하는 Location컴포너트 따로 생성
leeleeleeleejun 877eb01
refactor: 딥링크 유틸 함수 리팩토링 및 디바이스 감지 로직 분리
leeleeleeleejun a3636f7
fix: Location 컴포넌트의 지도 버튼 표시 개선
leeleeleeleejun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,16 @@ | ||
| /** | ||
| * 모바일 디바이스 감지 정규식 | ||
| */ | ||
| const MOBILE_REGEX = /iPhone|iPad|iPod|Android/i | ||
| const IOS_REGEX = /iPhone|iPad|iPod/i | ||
|
|
||
| /** | ||
| * 현재 디바이스가 모바일인지 확인 | ||
| */ | ||
| export const isMobileDevice = (): boolean => | ||
| MOBILE_REGEX.test(navigator.userAgent) | ||
|
|
||
| /** | ||
| * 현재 디바이스가 iOS인지 확인 | ||
| */ | ||
| export const isIOSDevice = (): boolean => IOS_REGEX.test(navigator.userAgent) |
This file contains hidden or 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 @@ | ||
| export { isMobileDevice, isIOSDevice } from './device' |
This file contains hidden or 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 @@ | ||
| export { openDeepLink } from './openDeepLink' |
This file contains hidden or 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,43 @@ | ||
| interface OpenDeepLinkParams { | ||
| appScheme: string | ||
| fallbackUrl: string | ||
| timeout?: number | ||
| } | ||
|
|
||
| const DEEPLINK_TIMEOUT = 2500 | ||
|
|
||
| /** | ||
| * 딥링크 실행 유틸 함수 | ||
| * - 앱이 설치되어 있으면 앱 실행 | ||
| * - 앱이 없으면 timeout 이후 fallbackUrl로 이동 | ||
| * - 앱 실행 시 페이지가 백그라운드로 가면 fallback 취소 | ||
| */ | ||
| export const openDeepLink = ({ | ||
| appScheme, | ||
| fallbackUrl, | ||
| timeout = DEEPLINK_TIMEOUT, | ||
| }: OpenDeepLinkParams): void => { | ||
| const startTime = Date.now() | ||
|
|
||
| // 페이지가 백그라운드로 가면 앱이 실행된 것으로 간주 | ||
| const handleVisibilityChange = () => { | ||
| if (document.hidden) { | ||
| // 앱이 실행되어 페이지가 숨겨짐 | ||
| clearTimeout(fallbackTimeout) | ||
| document.removeEventListener('visibilitychange', handleVisibilityChange) | ||
| } | ||
| } | ||
|
|
||
| document.addEventListener('visibilitychange', handleVisibilityChange) | ||
|
|
||
| // 앱이 설치되지 않은 경우를 대비한 타임아웃 | ||
| const fallbackTimeout = setTimeout(() => { | ||
| document.removeEventListener('visibilitychange', handleVisibilityChange) | ||
| // 페이지가 포그라운드 상태로 유지되었다면 앱이 없는 것으로 간주 | ||
| if (!document.hidden && Date.now() - startTime >= timeout) { | ||
| window.location.href = fallbackUrl | ||
| } | ||
| }, timeout) | ||
|
|
||
| window.location.href = appScheme | ||
| } |
This file contains hidden or 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 @@ | ||
| export { openKakaoTaxi } from './openKakaoTaxi' |
This file contains hidden or 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,35 @@ | ||
| import { addToast } from '@heroui/react' | ||
| import { openDeepLink } from '../openDeepLink' | ||
| import { isMobileDevice, isIOSDevice } from '../device' | ||
| import { Coord } from '@/map/_utils/toLatLng' | ||
|
|
||
| interface OpenKakaoTaxiParams extends Coord { | ||
| placeName?: string | ||
| } | ||
|
|
||
| /** | ||
| * 카카오택시 앱으로 특정 목적지를 설정하는 딥링크 함수 | ||
| * - 모바일: 카카오택시 앱이 설치되어 있으면 앱 실행, 없으면 앱스토어로 이동 | ||
| * - 데스크톱: 카카오택시 앱은 모바일 전용이므로 토스트 메시지로 안내 | ||
| */ | ||
| export const openKakaoTaxi = ({ | ||
| latitude, | ||
| longitude, | ||
| placeName = '목적지', | ||
| }: OpenKakaoTaxiParams): void => { | ||
| if (isMobileDevice()) { | ||
| const urls = buildKakaoTaxiUrls({ latitude, longitude }, placeName) | ||
| openDeepLink({ appScheme: urls.app, fallbackUrl: urls.store }) | ||
| } else { | ||
| addToast({ | ||
| title: '카카오택시 앱은 모바일에서만 이용 가능합니다.', | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| const buildKakaoTaxiUrls = (coords: Coord, placeName: string) => ({ | ||
| app: `kakaot://taxi?dest_lat=${coords.latitude}&dest_lng=${coords.longitude}&end_name=${encodeURIComponent(placeName)}`, | ||
| store: isIOSDevice() | ||
| ? 'https://apps.apple.com/kr/app/kakaotaxi/id981110422' | ||
| : 'https://play.google.com/store/apps/details?id=com.kakao.taxi', | ||
| }) |
This file contains hidden or 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 @@ | ||
| export { openNaverMap } from './openNaverMap' |
This file contains hidden or 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,32 @@ | ||
| import { openDeepLink } from '../openDeepLink' | ||
| import { isMobileDevice } from '../device' | ||
| import { Coord } from '@/map/_utils/toLatLng' | ||
|
|
||
| interface OpenNaverMapParams extends Coord { | ||
| placeName?: string | ||
| } | ||
|
|
||
| /** | ||
| * 네이버 지도 앱으로 특정 위치를 여는 딥링크 함수 | ||
| * - 모바일: 네이버 지도 앱이 설치되어 있으면 앱 실행, 없으면 웹으로 이동 | ||
| * - 데스크톱: 네이버 지도 웹 페이지로 이동 | ||
| */ | ||
| export const openNaverMap = ({ | ||
| latitude, | ||
| longitude, | ||
| placeName = '공주대학교', | ||
| }: OpenNaverMapParams): void => { | ||
| const urls = buildNaverMapUrls({ latitude, longitude }, placeName) | ||
|
|
||
| if (isMobileDevice()) { | ||
| openDeepLink({ appScheme: urls.app, fallbackUrl: urls.web }) | ||
| } else { | ||
| // 데스크톱: 웹 페이지로 바로 이동 | ||
| window.open(urls.web, '_blank') | ||
| } | ||
| } | ||
|
|
||
| const buildNaverMapUrls = (coords: Coord, placeName: string) => ({ | ||
| app: `nmap://place?lat=${coords.latitude}&lng=${coords.longitude}&name=${encodeURIComponent(placeName)}&appname=com.matzip`, | ||
| web: `https://map.naver.com/p/search/${encodeURIComponent(placeName)}?c=${coords.longitude},${coords.latitude},18,0,0,0,dh`, | ||
| }) |
This file contains hidden or 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 hidden or 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
28 changes: 28 additions & 0 deletions
28
apps/web/app/places/new/_components/Step/PlacePreview/Location.tsx
This file contains hidden or 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,28 @@ | ||
| import { useState } from 'react' | ||
| import { Container, NaverMap } from 'react-naver-maps' | ||
| import { type Coord, toLatLng } from '@/map/_utils/toLatLng' | ||
| import { PlaceMarker } from '@/map/_components/Marker' | ||
| import { Column } from '@repo/ui/components/Layout' | ||
|
|
||
| interface LocationProps { | ||
| location: Coord | ||
| } | ||
|
|
||
| export const Location = ({ location }: LocationProps) => { | ||
| const [, setMap] = useState<naver.maps.Map | null>(null) | ||
|
|
||
| return ( | ||
| <Column className={'gap-3'}> | ||
| <Container className={'h-[150px] overflow-hidden rounded-xl'}> | ||
| <NaverMap | ||
| defaultZoom={18} | ||
| minZoom={15} | ||
| ref={setMap} | ||
| defaultCenter={toLatLng(location)} | ||
| > | ||
| <PlaceMarker position={location} icon={'logo'} /> | ||
| </NaverMap> | ||
| </Container> | ||
| </Column> | ||
| ) | ||
| } |
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
border-1은 표준 Tailwind 유틸리티 클래스가 아닐 수 있습니다공식 Tailwind 문서의 border-width 예시는
border,border-2,border-4,border-8만 나열하며border-1은 포함되지 않습니다. 이 클래스가 인식되지 않으면 버튼 테두리가 렌더링되지 않습니다. 1px 테두리에는border를 사용해야 합니다.🐛 제안 수정
프로젝트의 Tailwind 버전에서
border-1이 유효한지 확인하려면 아래 스크립트를 실행하세요:🤖 Prompt for AI Agents