Skip to content

Commit

Permalink
Merge pull request #5 from Booda-YAMYAM/feature/sw/makeDynamicRouter
Browse files Browse the repository at this point in the history
Feature/sw/make dynamic router
  • Loading branch information
IGhost-P authored Jun 23, 2022
2 parents 75b9963 + e94602b commit 723cfa5
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 28 deletions.
28 changes: 0 additions & 28 deletions yam-view/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,6 @@ import axios from "axios";
//axios.defaults.withCredentials = true;

function App() {
// 받아오는 값에 따라 달라지는 tag 값
const [textValue, setTextValue] = useState("");

/** react native 환경에서만 가능 */
const onMessageHandler = (e) => {
const event = JSON.parse(e.data);
window.ReactNativeWebView.postMessage(JSON.stringify({ event: event }));
if (event.changeText) {
console.log(event.changeText);
setTextValue(event.changeText);
}
};

// tagChange
useEffect(() => {
const isUIWebView = () => {
return navigator.userAgent
.toLowerCase()
.match(/\(ip.*applewebkit(?!.*(version|crios))/);
};

const receiver = isUIWebView() ? window : document;

receiver.addEventListener("message", onMessageHandler);
return () => {
receiver.removeEventListener("message", onMessageHandler);
};
});
return (
<Router>
<Switch>
Expand Down
103 changes: 103 additions & 0 deletions yam-view/src/components/Data/markerData.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,109 @@
// latitude : y축
// longitude : x축

//template
// restaurantId: 1,
// restaurantName: "콜드스퀘어", // 이름
// restaurantNumber: "010-1111-1111", // 전화번호
// y_coordinate: 37.62197524055062, // 위도
// x_coordinate: 127.16017523675508, // 경도
// address: "대전광역시 00구 00동",
// heart: 3,
// category: "korea",
// menus: [
// {
// menuId: 1,
// menuName: "비빔밥",
// price: 10000,
// category: "korea",
// menuNum: 0,
// },
// ],
// OPEN_TIME: "오전 11:00 ~ 오후 11:00",
// SECTOR: "분식",
// MAIN_MENU: "돼지국밥, 돼지찜, 돼지전골",
// LAST_UPDATED: Date(),
// DATE_CREATED: Date(),
//
export const dummyData = [
{
restaurantId: 1,
restaurantName: "한국집", // 이름
restaurantNumber: "010-1111-1111", // 전화번호
y_coordinate: 37.62197524055062, // 위도
x_coordinate: 127.16017523675508, // 경도
address: "대전광역시 00구 00동",
heart: 3,
category: "korea",
menus: [
{
menuId: 1,
menuName: "비빔밥",
price: 10000,
category: "korea",
menuNum: 0,
},
],
},
{
restaurantId: 1,
restaurantName: "카페", // 이름
restaurantNumber: "010-1111-1111", // 전화번호
y_coordinate: 37.62197524055062, // 위도
x_coordinate: 127.16017523675508, // 경도
address: "대전광역시 00구 00동",
heart: 3,
category: "cafe",
menus: [
{
menuId: 1,
menuName: "비빔밥",
price: 10000,
category: "korea",
menuNum: 0,
},
],
},
{
restaurantId: 1,
restaurantName: "일본집", // 이름
restaurantNumber: "010-1111-1111", // 전화번호
y_coordinate: 37.62197524055062, // 위도
x_coordinate: 127.16017523675508, // 경도
address: "대전광역시 00구 00동",
heart: 3,
category: "japan",
menus: [
{
menuId: 1,
menuName: "비빔밥",
price: 10000,
category: "korea",
menuNum: 0,
},
],
},
{
restaurantId: 1,
restaurantName: "중국집", // 이름
restaurantNumber: "010-1111-1111", // 전화번호
y_coordinate: 37.62197524055062, // 위도
x_coordinate: 127.16017523675508, // 경도
address: "대전광역시 00구 00동",
heart: 3,
category: "china",
menus: [
{
menuId: 1,
menuName: "비빔밥",
price: 10000,
category: "korea",
menuNum: 0,
},
],
},
];

export const markerdata = [
{
RESTARANT_ID: 1,
Expand Down
25 changes: 25 additions & 0 deletions yam-view/src/pages/WebView.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,33 @@ const requestPermission = () => {
DATE_CREATED: Date(), */

const WebView = () => {
const [category, setCategory] = useState("전체");

/** react native 환경에서만 가능 */
const onMessageHandler = (e) => {
const event = JSON.parse(e.data);
window.ReactNativeWebView.postMessage(JSON.stringify({ event: event }));
if (event.changeText) {
setCategory(event.changeText);
alert(event.changeText);
}
};

useEffect(() => {
mapscript();

const isUIWebView = () => {
return navigator.userAgent
.toLowerCase()
.match(/\(ip.*applewebkit(?!.*(version|crios))/);
};

const receiver = isUIWebView() ? window : document;

receiver.addEventListener("message", onMessageHandler);
return () => {
receiver.removeEventListener("message", onMessageHandler);
};
}, []);

const mapscript = () => {
Expand Down
3 changes: 3 additions & 0 deletions yam-view/src/utils/filterTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const filterTag = (arr, tagList) => {
return arr.filter((item) => tagList.includes(item.tag));
};
26 changes: 26 additions & 0 deletions yam-view/src/utils/findCategory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const findCategory = (category) => {
switch (category) {
case "korea":
return "한식";
case "japan":
return "일식";
case "china":
return "중식";
case "western":
return "양식";
case "snack":
return "분식";
case "fastfood":
return "패스트푸드";
case "bakery":
return "베이커리";
case "cafe":
return "카페";
case "restaurant":
return "레스토랑";
case "bar":
return "바";
default:
return "기타";
}
};
28 changes: 28 additions & 0 deletions yam-view/src/utils/localMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const getLocalStorage = (key) => {
try {
return JSON.parse(localStorage.getItem(key));
} catch (e) {
return null;
}
};
export const setLocalStorage = (key, value) => {
try {
localStorage.setItem(key, JSON.stringify(value));
} catch (e) {
return null;
}
};
export const removeLocalStorage = (key) => {
try {
localStorage.removeItem(key);
} catch (e) {
return null;
}
};
export const clearLocalStorage = () => {
try {
localStorage.clear();
} catch (e) {
return null;
}
};

2 comments on commit 723cfa5

@vercel
Copy link

@vercel vercel bot commented on 723cfa5 Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yamyma-webview – ./yam-view/public

yamyma-webview-booda.vercel.app
yamyma-webview-gamma.vercel.app
yamyma-webview-git-main-booda.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 723cfa5 Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yamyma-webview2 – ./yam-view

yamyma-webview2-git-main-booda.vercel.app
yamyma-webview2.vercel.app
yamyma-webview2-booda.vercel.app

Please sign in to comment.