-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from mym0404/web-navi
Web - Navi package
- Loading branch information
Showing
12 changed files
with
225 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,24 +1,25 @@ | ||
// import type { KakaoChannelAPI } from './index'; | ||
// | ||
// const KakaoChannel: KakaoChannelAPI = { | ||
// followChannel: (channelPublicId: string): Promise<boolean> => {}, | ||
// addChannel: (channelPublicId: string): Promise<void> => {}, | ||
// getAddChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// openAddChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// chatChannel: (channelPublicId: string): Promise<void> => {}, | ||
// getChatChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// openChatChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// channels: (params) => {}, | ||
// }; | ||
// | ||
// export const { | ||
// addChannel, | ||
// followChannel, | ||
// channels, | ||
// chatChannel, | ||
// getAddChannelUrl, | ||
// getChatChannelUrl, | ||
// openAddChannelUrl, | ||
// openChatChannelUrl, | ||
// } = KakaoChannel; | ||
// export default KakaoChannel; | ||
import type { KakaoChannelAPI } from './index'; | ||
|
||
// @ts-ignore | ||
const KakaoChannel: KakaoChannelAPI = { | ||
// followChannel: (channelPublicId: string): Promise<boolean> => {}, | ||
// addChannel: (channelPublicId: string): Promise<void> => {}, | ||
// getAddChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// openAddChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// chatChannel: (channelPublicId: string): Promise<void> => {}, | ||
// getChatChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// openChatChannelUrl: (channelPublicId: string): Promise<string> => {}, | ||
// channels: (params) => {}, | ||
}; | ||
|
||
export const { | ||
addChannel, | ||
followChannel, | ||
channels, | ||
chatChannel, | ||
getAddChannelUrl, | ||
getChatChannelUrl, | ||
openAddChannelUrl, | ||
openChatChannelUrl, | ||
} = KakaoChannel; | ||
export default KakaoChannel; |
This file contains 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 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 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,134 @@ | ||
import { filterNonNullishKeys } from '@mj-studio/js-util'; | ||
import { kAssert } from '@react-native-kakao/core'; | ||
|
||
import type { KakaoNaviAPI, KakaoNaviOption } from './index'; | ||
|
||
declare const Kakao: { | ||
Navi: { | ||
start: Function; | ||
share: Function; | ||
}; | ||
}; | ||
|
||
function getVehicleType(v: KakaoNaviOption['vehicleType']): number { | ||
if (v === 'First') { | ||
return 1; | ||
} | ||
|
||
if (v === 'Second') { | ||
return 2; | ||
} | ||
|
||
if (v === 'Third') { | ||
return 3; | ||
} | ||
|
||
if (v === 'Fourth') { | ||
return 4; | ||
} | ||
|
||
if (v === 'Fifth') { | ||
return 5; | ||
} | ||
|
||
if (v === 'Sixth') { | ||
return 6; | ||
} | ||
|
||
if (v === 'TwoWheel') { | ||
return 7; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
function getRpOption(v: KakaoNaviOption['rpOption']): number { | ||
if (v === 'Fast') { | ||
return 1; | ||
} | ||
|
||
if (v === 'Free') { | ||
return 2; | ||
} | ||
|
||
if (v === 'Shortest') { | ||
return 3; | ||
} | ||
|
||
if (v === 'NoAuto') { | ||
return 4; | ||
} | ||
|
||
if (v === 'Wide') { | ||
return 5; | ||
} | ||
|
||
if (v === 'Highway') { | ||
return 6; | ||
} | ||
|
||
if (v === 'Normal') { | ||
return 8; | ||
} | ||
|
||
if (v === 'Recommended') { | ||
return 100; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
const KakaoNavi: KakaoNaviAPI = { | ||
navigateTo: async ({ viaList, destination, option }) => { | ||
kAssert( | ||
viaList ? viaList.length <= 3 : true, | ||
'[navigateTo] viaList length should equal or less then 3.', | ||
); | ||
|
||
try { | ||
Kakao.Navi.start( | ||
filterNonNullishKeys({ | ||
name: destination.name, | ||
x: destination.x, | ||
y: destination.y, | ||
coordType: option?.coordType?.toLowerCase(), | ||
vehicleType: option?.vehicleType ? getVehicleType(option.vehicleType) : undefined, | ||
rpOption: option?.rpOption ? getRpOption(option.rpOption) : undefined, | ||
routeInfo: option?.routeInfo, | ||
sX: option?.startX, | ||
sY: option?.startY, | ||
sAngle: option?.startAngle, | ||
returnUri: option?.returnUri, | ||
viaPoints: viaList?.map((v) => ({ | ||
name: v.name, | ||
x: v.x, | ||
y: v.y, | ||
})), | ||
}), | ||
); | ||
|
||
return true; | ||
} catch (e: any) { | ||
return false; | ||
} | ||
}, | ||
shareTo: async ({ destination, option }) => { | ||
try { | ||
Kakao.Navi.share( | ||
filterNonNullishKeys({ | ||
name: destination.name, | ||
x: destination.x, | ||
y: destination.y, | ||
coordType: option?.coordType?.toLowerCase(), | ||
}), | ||
); | ||
|
||
return true; | ||
} catch (e: any) { | ||
return false; | ||
} | ||
}, | ||
}; | ||
|
||
export const { navigateTo, shareTo } = KakaoNavi; | ||
export default KakaoNavi; |
This file contains 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 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 type { KakaoShareAPI } from './index'; | ||
|
||
// @ts-ignore | ||
const KakaoShare: KakaoShareAPI = {}; | ||
export const { | ||
sendCalendarTemplateToFriends, | ||
sendCalendarTemplateToMe, | ||
sendCommerceTemplateToFriends, | ||
sendCommerceTemplateToMe, | ||
sendCustomTemplateToFriends, | ||
sendCustomTemplateToMe, | ||
sendFeedTemplateToFriends, | ||
sendFeedTemplateToMe, | ||
sendListTemplateToFriends, | ||
sendListTemplateToMe, | ||
sendLocationTemplateToFriends, | ||
sendLocationTemplateToMe, | ||
sendTextTemplateToFriends, | ||
sendTextTemplateToMe, | ||
shareCalendarTemplate, | ||
shareCommerceTemplate, | ||
shareCustomTemplate, | ||
shareFeedTemplate, | ||
shareListTemplate, | ||
shareLocationTemplate, | ||
shareTextTemplate, | ||
} = KakaoShare; | ||
export default KakaoShare; |
This file contains 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 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,7 @@ | ||
import type { KakaoSocialAPI } from './index'; | ||
|
||
// @ts-ignore | ||
const KakaoSocial: KakaoSocialAPI = {}; | ||
export const { getFriends, getTalkProfile, selectMultipleFriends, selectSingleFriend } = | ||
KakaoSocial; | ||
export default KakaoSocial; |
This file contains 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