From 3ddf0550fd748bf7a79d69134fd1f90aa216b6f5 Mon Sep 17 00:00:00 2001 From: Username148576 Date: Fri, 27 Jan 2023 15:52:44 +0800 Subject: [PATCH] commit --- controller/Bus.js | 272 +++------------- package-lock.json | 59 ++-- package.json | 1 + screens/Map/BusScreen/132-2.jsx | 453 +++++++++++++++------------ screens/Map/BusScreen/133-2.jsx | 312 +++++++----------- screens/Map/BusScreen/172-2.jsx | 391 +++++++++++------------ screens/Map/BusScreen/173-2.jsx | 393 ++++++++++++----------- screens/Map/BusScreen/216-1.jsx | 134 ++++++++ screens/Map/BusScreen/216-2.jsx | 358 +++++++++++++++++++++ screens/Map/BusScreen/9025A-1.jsx | 6 +- screens/Map/BusScreen/9025A-2.jsx | 376 +++++++++++----------- screens/Map/BusScreen/UST.jsx | 105 +++++++ screens/Map/BusScreen/backdoor.jsx | 95 ------ screens/Map/BusScreen/firstpage.jsx | 202 ++++++------ screens/Map/BusScreen/frontdoor.jsx | 95 ------ screens/Map/BusScreen/gym.jsx | 95 ------ screens/Map/BusScreen/lake.jsx | 95 ------ screens/Map/BusScreen/library.jsx | 95 ------ screens/Map/BusScreen/second.jsx | 157 ---------- screens/Map/BusScreen/sg.jsx | 95 ------ screens/Map/BusScreen/sl.jsx | 95 ------ screens/Map/MapScreen.jsx | 4 +- screens/Map/components/BusButton.jsx | 2 +- screens/Map/index.jsx | 24 +- 24 files changed, 1708 insertions(+), 2206 deletions(-) create mode 100644 screens/Map/BusScreen/216-1.jsx create mode 100644 screens/Map/BusScreen/216-2.jsx create mode 100644 screens/Map/BusScreen/UST.jsx delete mode 100644 screens/Map/BusScreen/backdoor.jsx delete mode 100644 screens/Map/BusScreen/frontdoor.jsx delete mode 100644 screens/Map/BusScreen/gym.jsx delete mode 100644 screens/Map/BusScreen/lake.jsx delete mode 100644 screens/Map/BusScreen/library.jsx delete mode 100644 screens/Map/BusScreen/second.jsx delete mode 100644 screens/Map/BusScreen/sg.jsx delete mode 100644 screens/Map/BusScreen/sl.jsx diff --git a/controller/Bus.js b/controller/Bus.js index 6e1d24e..4ef838a 100644 --- a/controller/Bus.js +++ b/controller/Bus.js @@ -1,18 +1,30 @@ -import axios from 'axios'; -import jsSHA from 'jssha'; import url from 'url'; +import axios from 'axios'; +import qs from 'qs'; -const getAuthorizationHeader = function () { - const AppID = 'e05be185a29147f7b37c4343bedae576'; - const AppKey = '1BySzX0HVXNpZgE-4znpiKBW8TE'; - const GMTString = new Date().toGMTString(); - const ShaObj = new jsSHA('SHA-1', 'TEXT'); - ShaObj.setHMACKey(AppKey, 'TEXT'); - ShaObj.update(`x-date: ${GMTString}`); - const HMAC = ShaObj.getHMAC('B64'); - const Authorization = `hmac username=\"${AppID}\", algorithm=\"hmac-sha1\", headers=\"x-date\", signature=\"${HMAC}\"`; - return { Authorization, 'X-Date': GMTString }; -}; +async function getAuthorizationHeader() { + const parameter = { + grant_type: 'client_credentials', + client_id: '110502542-f4ef0225-f7f3-49d7', + client_secret: 'b8ba09f0-1be8-4a1f-abc3-f944c69b89ce', + }; + + const auth_url = 'https://tdx.transportdata.tw/auth/realms/TDXConnect/protocol/openid-connect/token'; + try { + const res = await axios({ + method: 'POST', + url: auth_url, + data: qs.stringify(parameter), + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + }); + const accesstoken = res.data; + return { + authorization: `Bearer ${accesstoken.access_token}`, + }; + } catch (err) { + return err; + } +} function get_busTime(data) { let busTime; @@ -47,7 +59,9 @@ function busTime_9025(StopSequence, Direction) { if (today === 0 || today === 6) { if (now >= 1080)busTime = '末班駛離'; else if (now >= 450)busTime = `${Math.floor((1080 + chart[0][StopSequence]) / 60).toString().padStart(2, '0')}:${((1080 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; - else busTime = `${Math.floor((450 + chart[0][StopSequence - 1]) / 60).toString().padStart(2, '0')}:${Math.floor((450 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; + else if (now >= 437)busTime = `${Math.floor((450 + chart[0][StopSequence - 1]) / 60).toString().padStart(2, '0')}:${Math.floor((450 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; + else if (now >= 420)busTime = `${Math.floor((437 + chart[0][StopSequence - 1]) / 60).toString().padStart(2, '0')}:${Math.floor((437 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; + else busTime = `${Math.floor((420 + chart[0][StopSequence - 1]) / 60).toString().padStart(2, '0')}:${Math.floor((420 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; } else if (now >= 1070)busTime = '末班駛離'; else if (now >= 1020)busTime = `${Math.floor((1070 + chart[0][StopSequence]) / 60).toString().padStart(2, '0')}:${Math.floor((1070 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; else if (now >= 960)busTime = `${Math.floor((1020 + chart[0][StopSequence]) / 60).toString().padStart(2, '0')}:${Math.floor((1020 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; @@ -55,7 +69,9 @@ function busTime_9025(StopSequence, Direction) { else busTime = `${Math.floor((720 + chart[0][StopSequence - 1]) / 60).toString().padStart(2, '0')}:${Math.floor((720 + chart[0][StopSequence]) % 60).toString().padStart(2, '0')}`; } else if (today === 0 || today === 6) { if (now >= 1140)busTime = '末班駛離'; - else if (now >= 450)busTime = `${Math.floor((1140 + chart[1][StopSequence]) / 60).toString().padStart(2, '0')}:${((1140 + chart[1][StopSequence]) % 60).toString().padStart(2, '0')}`; + else if (now >= 1090)busTime = `${Math.floor((1140 + chart[1][StopSequence]) / 60).toString().padStart(2, '0')}:${((1140 + chart[1][StopSequence]) % 60).toString().padStart(2, '0')}`; + else if (now >= 1020)busTime = `${Math.floor((1090 + chart[1][StopSequence]) / 60).toString().padStart(2, '0')}:${((1090 + chart[1][StopSequence]) % 60).toString().padStart(2, '0')}`; + else if (now >= 450)busTime = `${Math.floor((1020 + chart[1][StopSequence]) / 60).toString().padStart(2, '0')}:${((1020 + chart[1][StopSequence]) % 60).toString().padStart(2, '0')}`; else busTime = `${Math.floor((450 + chart[1][StopSequence]) / 60).toString().padStart(2, '0')}:${Math.floor((450 + chart[1][StopSequence]) % 60).toString().padStart(2, '0')}`; } else if (now >= 750)busTime = '末班駛離'; else if (now >= 470)busTime = `${Math.floor((750 + chart[1][StopSequence]) / 60).toString().padStart(2, '0')}:${Math.floor((750 + chart[1][StopSequence]) % 60).toString().padStart(2, '0')}`; @@ -92,7 +108,7 @@ function state_9025(StopSequence, Direction) { function fun9025(parame, response) { let i; let j; - const output = []; let output1; let output2; + const output = []; const now_h = new Date().getHours(); const now_m = new Date().getMinutes(); const now = now_h * 60 + now_m; @@ -103,21 +119,13 @@ function fun9025(parame, response) { for (j = departState + 1; j < num; j += 1) { if (departTime === -1) { busTime = busTime_9025(j, parame.dir); - if (j === parame.id) { - output1 = busTime; - output2 = (busTime[0] - '0') * 36000 + (busTime[1] - '0') * 3600 + (busTime[3] - '0') * 600 + (busTime[4] - '0') * 60; - } } else { - let time = chart[parame.dir][j] - chart[parame.dir][departState] - (now - ((response.data[i - 1].GPSTime[11] - '0') * 600 + (response.data[i - 1].GPSTime[12] - '0') * 60 + (response.data[i - 1].GPSTime[14] - '0') * 10 + (response.data[i - 1].GPSTime[15] - '0'))); + let time = chart[parame.dir][j] - chart[parame.dir][departState] - (now - ((departTime[11] - '0') * 600 + (departTime[12] - '0') * 60 + (departTime[14] - '0') * 10 + (departTime[15] - '0'))); if (time < chart[parame.dir][j] - chart[parame.dir][departState + 1]) { time = chart[parame.dir][j] - chart[parame.dir][departState + 1]; } if (time <= 2) busTime = '即將進站'; else busTime = `${time}分鐘後`; - if (j === parame.id) { - output1 = busTime; - output2 = time * 60; - } } output.push({ state: state_9025(j, parame.dir), @@ -127,27 +135,15 @@ function fun9025(parame, response) { const stay = (now - ((response.data[i].GPSTime[11] - '0') * 600 + (response.data[i].GPSTime[12] - '0') * 60 + (response.data[i].GPSTime[14] - '0') * 10 + (response.data[i].GPSTime[15] - '0'))); if (response.data[i].A2EventType === 1 && !(num === 10 && stay > 1)) { busTime = '進站中'; - if (num === parame.id) { - output1 = busTime; - output2 = 0; - } } else if (departTime === -1) { busTime = busTime_9025(num, parame.dir); - if (num === parame.id) { - output1 = busTime; - output2 = (busTime[0] - '0') * 36000 + (busTime[1] - '0') * 3600 + (busTime[3] - '0') * 600 + (busTime[4] - '0') * 60; - } } else { - let time = chart[parame.dir][num] - chart[parame.dir][departState] - (now - ((response.data[i - 1].GPSTime[11] - '0') * 600 + (response.data[i - 1].GPSTime[12] - '0') * 60 + (response.data[i - 1].GPSTime[14] - '0') * 10 + (response.data[i - 1].GPSTime[15] - '0'))); + let time = chart[parame.dir][num] - chart[parame.dir][departState] - (now - ((departTime[11] - '0') * 600 + (departTime[12] - '0') * 60 + (departTime[14] - '0') * 10 + (departTime[15] - '0'))); if (time < chart[parame.dir][num] - chart[parame.dir][departState + 1]) { time = chart[parame.dir][num] - chart[parame.dir][departState + 1]; } if (time <= 2) busTime = '即將進站'; else busTime = `${time}分鐘後`; - if (num === parame.id) { - output1 = busTime; - output2 = time * 60; - } } output.push({ state: state_9025(num, parame.dir), time: busTime, @@ -159,21 +155,13 @@ function fun9025(parame, response) { for (j = departState + 1; j <= 10; j += 1) { if (departTime === -1) { busTime = busTime_9025(j, parame.dir); - if (j === parame.id) { - output1 = busTime; - output2 = (busTime[0] - '0') * 36000 + (busTime[1] - '0') * 3600 + (busTime[3] - '0') * 600 + (busTime[4] - '0') * 60; - } } else { - let time = chart[parame.dir][j] - chart[parame.dir][departState] - (now - ((response.data[l - 1].GPSTime[11] - '0') * 600 + (response.data[l - 1].GPSTime[12] - '0') * 60 + (response.data[l - 1].GPSTime[14] - '0') * 10 + (response.data[l - 1].GPSTime[15] - '0'))); + let time = chart[parame.dir][j] - chart[parame.dir][departState] - (now - ((departTime[11] - '0') * 600 + (departTime[12] - '0') * 60 + (departTime[14] - '0') * 10 + (departTime[15] - '0'))); if (time < chart[parame.dir][j] - chart[parame.dir][departState + 1]) { time = chart[parame.dir][j] - chart[parame.dir][departState + 1]; } if (time <= 2) busTime = '即將進站'; else busTime = `${time}分鐘後`; - if (j === parame.id) { - output1 = busTime; - output2 = time * 60; - } }output.push({ state: state_9025(j, parame.dir), time: busTime, @@ -181,78 +169,22 @@ function fun9025(parame, response) { } // console.log(output2); - if (parame.type === 0) return output; - if (parame.type === 1) return output1; - if (parame.type === 2) return { output1, output2 }; + return output; } async function afun9025(parame) { let Url; - if (parame.dir === 0) Url = "https://ptx.transportdata.tw/MOTC/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%200%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON"; - else Url = "https://ptx.transportdata.tw/MOTC/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%201%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON"; + if (parame.dir === 0) Url = "https://tdx.transportdata.tw/api/basic/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%200%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON"; + else Url = "https://tdx.transportdata.tw/api/basic/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%201%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON"; const response = await axios.get(Url, { - headers: getAuthorizationHeader(), + headers: await getAuthorizationHeader(), }); return fun9025(parame, response); } -async function state(parame) { - const APIBASE = 'https://ptx.transportdata.tw/MOTC/v2/Bus/EstimatedTimeOfArrival/City/Taoyuan/PassThrough/Station'; - const data = { - $select: 'StopStatus,EstimateTime,RouteName,NextBusTime', - $filter: "(RouteUID eq 'TAO3220' or RouteUID eq 'TAO133') and Direction eq 1 or (RouteUID eq 'TAO3221' or RouteUID eq 'TAO1730') and Direction eq 0", - $orderby: 'RouteName/En', - $top: '4', - $format: 'JSON', - }; - const URL = url.parse(`${APIBASE}/${parame.id}`, true); - URL.query = data; - const Url = url.format(URL); - const output = []; - const response = await axios.get(Url, { - headers: getAuthorizationHeader(), - }); - response.data.forEach((doc) => { - const busTime = get_busTime(doc); - let way; - if (doc.RouteName.En === '132' || doc.RouteName.En === '133') way = '往中壢公車站'; - else if (doc.RouteName.En === '172' || doc.RouteName.En === '173') way = '往桃園高鐵站'; - output.push({ - route: doc.RouteName.Zh_tw, - time: busTime, - to: way, - }); - }); - let stopID; - if (parame.id === 205) stopID = 6; - else stopID = 5; - const par = { id: stopID, type: 1, dir: 0 }; - let res = await axios.get("https://ptx.transportdata.tw/MOTC/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%200%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON", { - headers: getAuthorizationHeader(), - }); - let busTime = fun9025(par, res); - output.push({ - route: '9025A', - time: busTime, - to: '往松山機場', - }); - const par1 = { id: stopID, type: 1, dir: 1 }; - res = await axios.get("https://ptx.transportdata.tw/MOTC/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%201%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON", { - headers: getAuthorizationHeader(), - }); - busTime = fun9025(par1, res); - output.push({ - route: '9025A', - time: busTime, - to: '往中壢公車站', - }); - // console.log(output); - return output; -} - async function route(parame) { + const APIBASE = 'https://tdx.transportdata.tw/api/basic/v2/Bus/EstimatedTimeOfArrival/City/Taoyuan'; const str = `Direction eq ${parame.dir}`; - const APIBASE = 'https://ptx.transportdata.tw/MOTC/v2/Bus/EstimatedTimeOfArrival/City/Taoyuan'; const data = { $select: 'StopStatus,EstimateTime,StopName,NextBusTime', $filter: str, @@ -260,131 +192,29 @@ async function route(parame) { $format: 'JSON', }; const URL = url.parse(`${APIBASE}/${parame.id}`, true); + console.log(URL); URL.query = data; + console.log(URL); const Url = url.format(URL); + console.log(Url); + const output = []; const response = await axios.get(Url, { - headers: getAuthorizationHeader(), + headers: await getAuthorizationHeader(), }); - let i; - for (i = 0; i < response.data.length; i += 1) { - const doc = response.data[i]; + console.log(response.data); + response.data.forEach((doc) => { const busTime = get_busTime(doc); output.push({ - state: doc.StopName.Zh_tw, - time: busTime, - }); - } - // console.log(output); - return output; -} - -async function second() { - const station_id = [235, 2393, 205, 236, 238, 1351];// 站位代號們,用於second.jsx - const APIBASE = 'https://ptx.transportdata.tw/MOTC/v2/Bus/EstimatedTimeOfArrival/City/Taoyuan/PassThrough/Station'; - const data = { - $select: 'StopStatus,EstimateTime,RouteName,NextBusTime,StopName', - $filter: "(RouteUID eq 'TAO3220' or RouteUID eq 'TAO133') and Direction eq 1 or (RouteUID eq 'TAO3221' or RouteUID eq 'TAO1730') and Direction eq 0", - $top: '4', - $orderby: 'NextBusTime', - $format: 'JSON', - }; - const output = []; - let i; let j; - for (i = 0; i < station_id.length; i += 1) { - const URL = url.parse(`${APIBASE}/${station_id[i]}`, true); - URL.query = data; - const Url = url.format(URL); - const response = await axios.get(Url, { - headers: getAuthorizationHeader(), - }); - - let min1 = 90000; let min2 = 90000; let tmp; let min1_index = 0; let min2_index = 1; - for (j = 0; j < response.data.length; j += 1) { - // console.log(response.data); - if (response.data[j].StopStatus !== 1 && response.data[j].StopStatus !== 0) continue; - if (response.data[j].EstimateTime === undefined) { - tmp = (response.data[j].NextBusTime[11] - '0') * 36000 + (response.data[j].NextBusTime[12] - '0') * 3600 + (response.data[j].NextBusTime[14] - '0') * 600 + (response.data[j].NextBusTime[15] - '0') * 60; - } else tmp = response.data[j].EstimateTime; - // console.log(tmp); - if (tmp < min1) { - min2 = min1; - min2_index = min1_index; - min1 = tmp; - min1_index = j; - } else if (tmp < min2) { - min2 = tmp; - min2_index = j; - } - } - let stopID; let tmp1; let tmp2; - if (station_id[i] === 205 || station_id[i] === 235) { - if (station_id[i] === 205) stopID = 6; - else stopID = 5; - const par = { id: stopID, type: 2, dir: 0 }; - let res = await axios.get("https://ptx.transportdata.tw/MOTC/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%200%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON", { - headers: getAuthorizationHeader(), - }); - tmp1 = fun9025(par, res); - tmp = tmp1.output2; - if (!isNaN(tmp) && tmp < min1) { - min2 = min1; - min2_index = min1_index; - min1 = tmp; - min1_index = -1; - } else if (!isNaN(tmp) && tmp < min2) { - min2 = tmp; - min2_index = -1; - } - par.dir = 1; - res = await axios.get("https://ptx.transportdata.tw/MOTC/v2/Bus/RealTimeNearStop/Streaming/InterCity/9025?%24select=GPSTime&%24filter=Direction%20eq%201%20and%20SubRouteName%2FEn%20eq%20'9025A'&%24orderby=StopSequence&%24top=30&%24format=JSON", { - headers: getAuthorizationHeader(), - }); - tmp2 = fun9025(par, res); - tmp = tmp2.output2; - if (!isNaN(tmp) && tmp < min1) { - min2 = min1; - min2_index = min1_index; - min1 = tmp; - min1_index = -2; - } else if (!isNaN(tmp) && tmp < min2) { - min2 = tmp; - min2_index = -2; - } - } - - let busTime1; let busTime2; let route1_output; let route2_output; - if (min1_index < 0) { - if (min1_index === -1)busTime1 = tmp1.output1; - else busTime1 = tmp2.output1; - route1_output = '9025A'; - } else { - busTime1 = get_busTime(response.data[min1_index]); - route1_output = response.data[min1_index].RouteName.Zh_tw; - } - if (min2_index < 0) { - if (min2_index === -1)busTime2 = tmp1.output1; - else busTime2 = tmp2.output1; - route2_output = '9025A'; - } else { - busTime2 = get_busTime(response.data[min2_index]); - route2_output = response.data[min2_index].RouteName.Zh_tw; - } - output.push({ - state: response.data[0].StopName.Zh_tw, - route1: route1_output, - time1: busTime1, - route2: route2_output, - time2: busTime2, + state: doc.StopName.Zh_tw, + time: busTime, }); - } - // console.log(output); + }); + console.log(output); return output; } export default { - state, route, - second, afun9025, }; diff --git a/package-lock.json b/package-lock.json index 529f027..47e2fa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "fuse.js": "^6.5.3", "jssha": "^2.3.1", "native-base": "^3.3.7", + "qs": "^6.11.0", "react": "18.0.0", "react-dom": "18.0.0", "react-native": "^0.69.5", @@ -7750,6 +7751,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/body-parser/node_modules/qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -10313,20 +10322,6 @@ "url-parse": "^1.5.9" } }, - "node_modules/expo-linking/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/expo-location": { "version": "14.3.0", "resolved": "https://registry.npmjs.org/expo-location/-/expo-location-14.3.0.tgz", @@ -15739,11 +15734,17 @@ } }, "node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, "engines": { "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/query-string": { @@ -24711,6 +24712,11 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" } } }, @@ -26716,16 +26722,6 @@ "invariant": "^2.2.4", "qs": "^6.9.1", "url-parse": "^1.5.9" - }, - "dependencies": { - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "requires": { - "side-channel": "^1.0.4" - } - } } }, "expo-location": { @@ -30818,9 +30814,12 @@ "integrity": "sha512-Uu7ii+FQy4Qf82G4xu7ShHhjhGahEpCWc3x8UavY3CTcWV+ufmmCtwkr7ZKsX42jdL0kr1B5FKUeqJvAn51jzQ==" }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { + "side-channel": "^1.0.4" + } }, "query-string": { "version": "7.1.1", diff --git a/package.json b/package.json index 1f69caf..db9c512 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "fuse.js": "^6.5.3", "jssha": "^2.3.1", "native-base": "^3.3.7", + "qs": "^6.11.0", "react": "18.0.0", "react-dom": "18.0.0", "react-native": "^0.69.5", diff --git a/screens/Map/BusScreen/132-2.jsx b/screens/Map/BusScreen/132-2.jsx index bdada11..f24380b 100644 --- a/screens/Map/BusScreen/132-2.jsx +++ b/screens/Map/BusScreen/132-2.jsx @@ -1,13 +1,16 @@ -import React from 'react'; +import React, { useState } from 'react'; + import { View, SafeAreaView, Text, + ScrollView, + TouchableOpacity, } from 'react-native'; import Styles from '../Styles'; -const Separator = () => ; function List132() { + const [workDay, setWorkDay] = useState(true); return ( @@ -18,211 +21,261 @@ function List132() { 132公車時刻表 - - 往中央大學 - - - - - 平日 - - - 假日 - - - - - - - - 06:30 - - - 06:20 - - - - - - 07:00 - - - 07:00 - - - - - - 08:00 - - - 07:20 - - - - - 08:30 - - - 08:00 - - - - - 09:00 - - - 08:20 - - - - - + { setWorkDay(true); }} + style={{ width: '50%', backgroundColor: 'white' }} > - 09:30 - - + 平日 + + + { setWorkDay(false); }} + style={{ width: '50%', backgroundColor: 'white' }} > - 09:00 - - - - - - 10:00 - - - 09:20 - - - - - - 10:30 - - - 10:00 - - - - - - 11:00 - - - 10:20 - - - - - - 11:30 - - - 11:00 - - - - - - 12:00 - - - 11:20 - - - - - - 12:25 - - - 12:00 - + + 假日 + + - - - 上次更新:2022/03/10 + + 往中央大學 + + {workDay + && ( + + + 06:30 + + + 07:00 + + + 07:30 + + + 08:00 + + + 08:30 + + + 09:00 + + + 09:30 + + + 10:00 + + + 11:00 + + + 12:00 + + + 13:00 + + + 14:00 + + + 15:00 + + + 15:30 + + + 16:00 + + + 16:30 + + + 17:00 + + + 17:40 + + + 18:00 + + + 18:40 + + + 19:00 + + + 20:00 + + + 21:00 + + + 22:00 + + + )} + {!workDay + && ( + + + 08:00 + + + 09:00 + + + 10:00 + + + 11:00 + + + 12:00 + + + 13:00 + + + 14:00 + + + 15:00 + + + 16:00 + + + 17:00 + + + 18:00 + + + )} + + 上次更新:2023/01/26 + + ); } diff --git a/screens/Map/BusScreen/133-2.jsx b/screens/Map/BusScreen/133-2.jsx index e55c36a..d216f66 100644 --- a/screens/Map/BusScreen/133-2.jsx +++ b/screens/Map/BusScreen/133-2.jsx @@ -1,13 +1,16 @@ -import React from 'react'; +import React, { useState } from 'react'; + import { View, SafeAreaView, Text, + ScrollView, + TouchableOpacity, } from 'react-native'; import Styles from '../Styles'; -const Separator = () => ; function List133() { + const [workDay, setWorkDay] = useState(true); return ( @@ -18,214 +21,111 @@ function List133() { 133公車時刻表 - - - 往中央大學 - - - - - 平日 - - - 假日 - - - - - - - - 06:30 - - - 06:20 - - - - - - 07:00 - - - 07:00 - - - - - - 08:00 - - - 07:20 - - - - - - 08:30 - - - 08:00 - - - - - - 09:00 - - - 08:20 - - - - - - 09:30 - - - 09:00 - - - - - - 10:00 - - - 09:20 - - - - - - 10:30 - - - 10:00 - - - - - - 11:00 - - - 10:20 - - - - - - 11:30 - - - 11:00 - - - - - - 12:00 - - - 11:20 - - - - - - 12:25 - - - 12:00 - + + { setWorkDay(true); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 平日 + + + { setWorkDay(false); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 假日 + + - - - 上次更新:2022/03/10 + + 往中央大學 - + + {workDay + && ( + + + 07:40 + + + 08:40 + + + 09:40 + + + 10:40 + + + 15:40 + + + 16:40 + + + )} + {!workDay + && ( + + + 10:30 + + + 11:30 + + + 14:30 + + + 15:30 + + + )} + + + 上次更新:2023/01/26 + + ); } diff --git a/screens/Map/BusScreen/172-2.jsx b/screens/Map/BusScreen/172-2.jsx index 2958ef9..d8dafc4 100644 --- a/screens/Map/BusScreen/172-2.jsx +++ b/screens/Map/BusScreen/172-2.jsx @@ -1,13 +1,17 @@ -import React from 'react'; +import React, { useState } from 'react'; + import { View, SafeAreaView, Text, + TouchableOpacity, } from 'react-native'; +import { ScrollView } from 'react-native-gesture-handler'; import Styles from '../Styles'; const Separator = () => ; function List172() { + const [workDay, setWorkDay] = useState(true); return ( @@ -18,212 +22,199 @@ function List172() { 172公車時刻表 - - - 往中央大學 - - - - - 平日 - - - 假日 - - - - - - - - 06:30 - - - 06:20 - - - - - - 07:00 - - - 07:00 - - - - - - 08:00 - - - 07:20 - - - - - - 08:30 - - - 08:00 - - - - - - 09:00 - - - 08:20 - - - - - - 09:30 - - - 09:00 - + + { setWorkDay(true); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 平日 + + + { setWorkDay(false); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 假日 + + - - - - 10:00 - - - 09:20 - - - - - - 10:30 - - - 10:00 - - - - - - 11:00 - - - 10:20 - - - - - - 11:30 - - - 11:00 - - - + + - - 12:00 - - - 11:20 - - - + + 往桃園高鐵站 + + + 往中央大學 + - - 12:25 - - - 12:00 - - + + {workDay + && ( + + + + + + 07:50 + + + 08:20 + + + + + + 09:50 + + + 10:20 + + + + + + 11:50 + + + 12:20 + + + + + + 14:30 + + + 15:00 + + + + + + 16:40 + + + 17:10 + + + + )} + {!workDay + && ( + + + + + 09:30 + + + 10:00 + + + + + + 11:30 + + + 12:00 + + + + + + 14:30 + + + 15:00 + + + + + + 16:40 + + + 17:10 + + + + )} + - 上次更新:2022/03/10 + 上次更新:2023/01/26 diff --git a/screens/Map/BusScreen/173-2.jsx b/screens/Map/BusScreen/173-2.jsx index 3b03a2e..b4241c8 100644 --- a/screens/Map/BusScreen/173-2.jsx +++ b/screens/Map/BusScreen/173-2.jsx @@ -1,13 +1,17 @@ -import React from 'react'; +import React, { useState } from 'react'; + import { View, SafeAreaView, Text, + TouchableOpacity, } from 'react-native'; +import { ScrollView } from 'react-native-gesture-handler'; import Styles from '../Styles'; const Separator = () => ; function List173() { + const [workDay, setWorkDay] = useState(true); return ( @@ -15,215 +19,202 @@ function List173() { textAlign: 'center', backgroundColor: '#28527A', color: 'white', height: 50, width: '100%', fontSize: 20, textAlignVertical: 'center', lineHeight: 50, }} > - 172公車時刻表 + 173公車時刻表 - - - 往中央大學 - - - - - 平日 - - - 假日 - - - - - - - - 06:30 - - - 06:20 - - - - - - 07:00 - - - 07:00 - - - - - - 08:00 - - - 07:20 - - - - - - 08:30 - - - 08:00 - - - - - - 09:00 - - - 08:20 - - - - - - 09:30 - - - 09:00 - + + { setWorkDay(true); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 平日 + + + { setWorkDay(false); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 假日 + + - - - - 10:00 - - - 09:20 - - - - - - 10:30 - - - 10:00 - - - - - - 11:00 - - - 10:20 - - - - - - 11:30 - - - 11:00 - - - + + - - 12:00 - - - 11:20 - - - + + 往桃園高鐵站 + + + 往中央大學 + - - 12:25 - - - 12:00 - - + + + {workDay + && ( + + + + + 08:50 + + + 09:20 + + + + + + 10:50 + + + 11:20 + + + + + + 13:30 + + + 14:00 + + + + + + 15:40 + + + 16:10 + + + + + + 17:50 + + + 18:20 + + + + )} + {!workDay + && ( + + + + + 10:30 + + + 11:00 + + + + + + 12:30 + + + 13:00 + + + + + + 15:40 + + + 16:10 + + + + + + 17:50 + + + 18:20 + + + + )} + - 上次更新:2022/03/10 + 上次更新:2023/01/26 diff --git a/screens/Map/BusScreen/216-1.jsx b/screens/Map/BusScreen/216-1.jsx new file mode 100644 index 0000000..ae68897 --- /dev/null +++ b/screens/Map/BusScreen/216-1.jsx @@ -0,0 +1,134 @@ +import React, { useState, useEffect } from 'react'; +import { + View, + SafeAreaView, + Text, + TouchableOpacity, + RefreshControl, + ScrollView, +} from 'react-native'; +import BusController from '../../../controller/Bus'; +import Styles from '../Styles'; + +const Separator = () => ; +function Bus216({ navigation }) { + const [item, setItems] = useState([]); + + const [start, setStart] = useState(true); + + const [direction, setDirection] = useState(1); + + const [refreshing, setRefreshing] = useState(false); + + const onRefresh = () => { + setRefreshing(true); + BusController.route({ id: 216, dir: 0 }).then((res) => { + setItems(res); + setRefreshing(false); + }); + }; + + const onRefresh1 = () => { + setRefreshing(true); + BusController.route({ id: 216, dir: 1 }).then((res) => { + setItems(res); + setRefreshing(false); + }); + }; + + useEffect(() => { + if (start) { + setStart(false); + if (direction === 1)onRefresh(); + else onRefresh1(); + } + let id; + if (direction === 1)id = setInterval(onRefresh, 10000); + else id = setInterval(onRefresh1, 10000); + return () => { + clearInterval(id); + }; + }, [start]); + + return ( + )} + > + + + 216 + + { navigation.navigate('List216'); }} + style={{ + width: '25%', + top: 15, + left: 280, + backgroundColor: '#FFE66F', + position: 'absolute', + right: 0, + }} + > + 發車時刻表 + + + + + + { setStart(true); setDirection(0); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 往八德區公所 + + + { setStart(true); setDirection(1); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 往平鎮區公所 + + + + + {'\n'} + + { item.map((data) => ( + + + + {data.time} + + + {data.state} + + + + + + + ))} + + + ); +} + +export default Bus216; diff --git a/screens/Map/BusScreen/216-2.jsx b/screens/Map/BusScreen/216-2.jsx new file mode 100644 index 0000000..9234148 --- /dev/null +++ b/screens/Map/BusScreen/216-2.jsx @@ -0,0 +1,358 @@ +import React, { useState } from 'react'; + +import { + View, + SafeAreaView, + Text, + TouchableOpacity, +} from 'react-native'; +import { ScrollView } from 'react-native-gesture-handler'; +import Styles from '../Styles'; + +const Separator = () => ; +function List216() { + const [workDay, setWorkDay] = useState(true); + return ( + + + + 216公車時刻表 + + + + + { setWorkDay(true); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 平日 + + + { setWorkDay(false); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 假日 + + + + + + + + 往中央大學 + + + 往八德區公所 + + + + + + {workDay + && ( + + + + + 06:10 + + + 06:10 + + + + + + 07:00 + + + 07:00 + + + + + + 08:00 + + + 08:10 + + + + + + 09:20 + + + 09:10 + + + + + + 10:00 + + + 10:10 + + + + + + 11:00 + + + 11:10 + + + + + + 12:00 + + + 12:10 + + + + + + 14:00 + + + 14:10 + + + + + + 15:00 + + + 15:10 + + + + + + 16:00 + + + 16:10 + + + + + + 17:00 + + + 17:10 + + + + + + 18:00 + + + 18:10 + + + + )} + {!workDay + && ( + + + + + 07:00 + + + 06:10 + + + + + + 09:20 + + + 08:10 + + + + + + 11:00 + + + 10:10 + + + + + + 14:00 + + + 12:10 + + + + + + 16:00 + + + 15:10 + + + + + + 18:10 + + + 17:10 + + + + )} + + + + 上次更新:2023/01/26 + + + + ); +} +export default List216; diff --git a/screens/Map/BusScreen/9025A-1.jsx b/screens/Map/BusScreen/9025A-1.jsx index a3f95ba..38cc6d5 100644 --- a/screens/Map/BusScreen/9025A-1.jsx +++ b/screens/Map/BusScreen/9025A-1.jsx @@ -22,7 +22,7 @@ function Bus9025A({ navigation }) { const onRefresh = () => { setRefreshing(true); - BusController.afun9025({type: 0, dir: 1 }).then((res) => { + BusController.afun9025({ dir: 1 }).then((res) => { setItems(res); setRefreshing(false); }); @@ -30,7 +30,7 @@ function Bus9025A({ navigation }) { const onRefresh1 = () => { setRefreshing(true); - BusController.afun9025({type: 0, dir: 0 }).then((res) => { + BusController.afun9025({ dir: 0 }).then((res) => { setItems(res); setRefreshing(false); }); @@ -60,7 +60,7 @@ function Bus9025A({ navigation }) { textAlign: 'center', backgroundColor: '#28527A', color: 'white', height: 50, width: '100%', fontSize: 20, textAlignVertical: 'center', lineHeight: 50, }} > - 9025 + 9025A { navigation.navigate('List9025A'); }} diff --git a/screens/Map/BusScreen/9025A-2.jsx b/screens/Map/BusScreen/9025A-2.jsx index 2c73292..fd76ab2 100644 --- a/screens/Map/BusScreen/9025A-2.jsx +++ b/screens/Map/BusScreen/9025A-2.jsx @@ -1,13 +1,17 @@ -import React from 'react'; +import React, { useState } from 'react'; + import { View, SafeAreaView, Text, + TouchableOpacity, } from 'react-native'; +import { ScrollView } from 'react-native-gesture-handler'; import Styles from '../Styles'; const Separator = () => ; function List9025A() { + const [workDay, setWorkDay] = useState(true); return ( @@ -18,212 +22,184 @@ function List9025A() { 9025A公車時刻表 - - - 往中央大學 - - - - - 平日 - - - 假日 - - - - - - - - 06:30 - - - 06:20 - - - - - - 07:00 - - - 07:00 - - - - - - 08:00 - - - 07:20 - - - - - - 08:30 - - - 08:00 - - - - - - 09:00 - - - 08:20 - - - - - - 09:30 - - - 09:00 - + + { setWorkDay(true); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 平日 + + + { setWorkDay(false); }} + style={{ width: '50%', backgroundColor: 'white' }} + > + + 假日 + + - - - - 10:00 - - - 09:20 - - - - - - 10:30 - - - 10:00 - - - - - - 11:00 - - - 10:20 - - - - - - 11:30 - - - 11:00 - - - + + - - 12:00 - - - 11:20 - - - + + 往松山 + + + 往中壢 + - - 12:25 - - - 12:00 - - + + + {workDay + && ( + + + + + 12:00 + + + 06:37 + + + + + + 16:00 + + + 07:10 + + + + + + 17:00 + + + 07:50 + + + + + + 17:50 + + + 12:30 + + + + )} + {!workDay + && ( + + + + + 07:00 + + + 07:30 + + + + + + 07:17 + + + 17:00 + + + + + + 07:30 + + + 18:10 + + + + + + 18:00 + + + 19:00 + + + + )} + - 上次更新:2022/03/10 + 上次更新:2023/01/26 diff --git a/screens/Map/BusScreen/UST.jsx b/screens/Map/BusScreen/UST.jsx new file mode 100644 index 0000000..832b901 --- /dev/null +++ b/screens/Map/BusScreen/UST.jsx @@ -0,0 +1,105 @@ +import React from 'react'; + +import { + View, + SafeAreaView, + Text, +} from 'react-native'; +import { ScrollView } from 'react-native-gesture-handler'; +import Styles from '../Styles'; + +function UST() { + return ( + + + + 台聯大專車時刻表 + + + + + + 僅平日行駛 + + + + + + + 往清大、交大 + + + 往政大 + + + + + + + + + 07:50 + + + 07:30 + + + + + + 12:10 + + + 11:30 + + + + + + 20:10 + + + 21:10 + + + + + + + 上次更新:2023/01/26 + + + + ); +} +export default UST; diff --git a/screens/Map/BusScreen/backdoor.jsx b/screens/Map/BusScreen/backdoor.jsx deleted file mode 100644 index ede124e..0000000 --- a/screens/Map/BusScreen/backdoor.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Backdoor() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 236 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 中央大學後門 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Backdoor; diff --git a/screens/Map/BusScreen/firstpage.jsx b/screens/Map/BusScreen/firstpage.jsx index 70318dc..95fa1cd 100644 --- a/screens/Map/BusScreen/firstpage.jsx +++ b/screens/Map/BusScreen/firstpage.jsx @@ -1,48 +1,19 @@ -import React, { useState, useEffect } from 'react'; +import React from 'react'; import { View, SafeAreaView, ScrollView, Text, - Alert, TouchableOpacity, - RefreshControl, } from 'react-native'; import { IconButton, } from 'react-native-paper'; -import BusController from '../../../controller/Bus'; import Styles from '../Styles'; function First({ navigation }) { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 235 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - const id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); return ( - )} - > + navigation.navigate('地圖')} - icon="times" + icon="close" size={20} style={{ left: 320, @@ -63,88 +34,113 @@ function First({ navigation }) { /> + {'\n'} - - navigation.navigate('依班次')} - style={{ width: '50%', backgroundColor: 'white' }} - > + navigation.navigate('Bus132')} + style={{ width: '100%', backgroundColor: 'white' }} + > + - 依班次 + {' '}132 - - navigation.navigate('依站牌')} - style={{ width: '50%', backgroundColor: 'white' }} - > + + {'\n'} + + {'\n'} + navigation.navigate('Bus133')} + style={{ width: '100%', backgroundColor: 'white' }} + > + - 依站牌 + {' '}133 - - - - {'\n'} - {item.map((res) => ( - - - navigation.navigate(`Bus${res.route}`)} - style={{ width: '100%', backgroundColor: 'white' }} + + {'\n'} + + {'\n'} + navigation.navigate('Bus172')} + style={{ width: '100%', backgroundColor: 'white' }} + > + + - - - - {res.route} - - - - - - 警衛室 | - {' '} - {res.time} - - - {res.to} - - - - Alert.alert('Left button pressed')} - size={20} - icon="heart" - style={{ - textAlign: 'center', - }} - /> - Alert.alert('Left button pressed')} - size={20} - icon="plus" - style={{ - textAlign: 'center', - }} - /> - - - - + {' '}172 + - {'\n'} - - ))} + {'\n'} + + {'\n'} + navigation.navigate('Bus173')} + style={{ width: '100%', backgroundColor: 'white' }} + > + + + {' '}173 + + + {'\n'} + + {'\n'} + navigation.navigate('Bus216')} + style={{ width: '100%', backgroundColor: 'white' }} + > + + + {' '}216 + + + {'\n'} + + {'\n'} + navigation.navigate('Bus9025A')} + style={{ width: '100%', backgroundColor: 'white' }} + > + + + {' '}9025A + + + {'\n'} + + {'\n'} + navigation.navigate('UST')} + style={{ width: '100%', backgroundColor: 'white' }} + > + + + {' '}台聯大專車 + + + {'\n'} + + ); diff --git a/screens/Map/BusScreen/frontdoor.jsx b/screens/Map/BusScreen/frontdoor.jsx deleted file mode 100644 index 42f9247..0000000 --- a/screens/Map/BusScreen/frontdoor.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Frontdoor() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 1351 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 中央大學正門 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Frontdoor; diff --git a/screens/Map/BusScreen/gym.jsx b/screens/Map/BusScreen/gym.jsx deleted file mode 100644 index 60e2bf5..0000000 --- a/screens/Map/BusScreen/gym.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Gym() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 205 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 中央大學依仁堂 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Gym; diff --git a/screens/Map/BusScreen/lake.jsx b/screens/Map/BusScreen/lake.jsx deleted file mode 100644 index 9e5c46a..0000000 --- a/screens/Map/BusScreen/lake.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Lake() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 2393 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 中大湖 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Lake; diff --git a/screens/Map/BusScreen/library.jsx b/screens/Map/BusScreen/library.jsx deleted file mode 100644 index aa33b8a..0000000 --- a/screens/Map/BusScreen/library.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Library() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 1351 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 國鼎圖書館 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Library; diff --git a/screens/Map/BusScreen/second.jsx b/screens/Map/BusScreen/second.jsx deleted file mode 100644 index 7e47350..0000000 --- a/screens/Map/BusScreen/second.jsx +++ /dev/null @@ -1,157 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - ScrollView, - Text, - Alert, - TouchableOpacity, - RefreshControl, -} from 'react-native'; -import { - IconButton, -} from 'react-native-paper'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -function Second({ navigation }) { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.second().then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - - 公車動態 - - navigation.navigate('地圖')} - icon="times" - size={20} - style={{ - left: 320, - top: 0, - position: 'absolute', - }} - /> - - - - - navigation.navigate('依班次')} - style={{ width: '50%', backgroundColor: 'white' }} - > - - 依班次 - - - navigation.navigate('依站牌')} - style={{ width: '50%', backgroundColor: 'white' }} - > - - 依站牌 - - - - - {'\n'} - {item.map((res) => ( - - - navigation.navigate(res.state)} - style={{ width: '100%', backgroundColor: 'white' }} - > - - - - {res.state} - - - - - {res.route1} - {' '} - | - {' '} - {res.time1} - - - {res.route2} - {' '} - | - {' '} - {res.time2} - - - - Alert.alert('Left button pressed')} - size={20} - icon="heart" - style={{ - textAlign: 'center', - }} - /> - Alert.alert('Left button pressed')} - size={20} - icon="plus" - style={{ - textAlign: 'center', - }} - /> - - - - - - {'\n'} - - ))} - - - ); -} - -export default Second; diff --git a/screens/Map/BusScreen/sg.jsx b/screens/Map/BusScreen/sg.jsx deleted file mode 100644 index d3df3d4..0000000 --- a/screens/Map/BusScreen/sg.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Sg() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 235 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 警衛室 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Sg; diff --git a/screens/Map/BusScreen/sl.jsx b/screens/Map/BusScreen/sl.jsx deleted file mode 100644 index 63445b4..0000000 --- a/screens/Map/BusScreen/sl.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { - View, - SafeAreaView, - Text, - RefreshControl, -} from 'react-native'; -import BusController from '../../../controller/Bus'; -import Styles from '../Styles'; - -const Separator = () => ; -function Sl() { - const [item, setItems] = useState([]); - - const [start, setStart] = useState(true); - - const [refreshing, setRefreshing] = useState(false); - - const onRefresh = () => { - setRefreshing(true); - BusController.state({ id: 238 }).then((res) => { - setItems(res); - setRefreshing(false); - }); - }; - - useEffect(() => { - if (start) { - setStart(false); - onRefresh(); - } - let id; - id = setInterval(onRefresh, 10000); - return () => { - clearInterval(id); - }; - }, [start]); - return ( - )} - > - - - 中央大學觀景台 - - - {'\n'} - - - - - 公車 - - - - 到站時間 - - - - - { item.map((data) => ( - - - - {data.route} - - - {data.time} - - - {data.to} - - - - - - ))} - - - ); -} -export default Sl; diff --git a/screens/Map/MapScreen.jsx b/screens/Map/MapScreen.jsx index 20d4eb2..37e7c8a 100644 --- a/screens/Map/MapScreen.jsx +++ b/screens/Map/MapScreen.jsx @@ -193,12 +193,12 @@ export default function MapScreen({ navigation }) { textInputValue={textInputValue} setTextInputValue={setTextInputValue} /> - + + - navigation.navigate('依班次')} + onPress={() => navigation.navigate('公車動態')} > diff --git a/screens/Map/index.jsx b/screens/Map/index.jsx index 55a4783..29d46da 100644 --- a/screens/Map/index.jsx +++ b/screens/Map/index.jsx @@ -10,16 +10,11 @@ import List172 from './BusScreen/172-2'; import Bus9025A from './BusScreen/9025A-1'; import List9025A from './BusScreen/9025A-2'; import First from './BusScreen/firstpage'; -import Second from './BusScreen/second'; -import Lake from './BusScreen/lake'; -import Gym from './BusScreen/gym'; -import Backdoor from './BusScreen/backdoor'; -import Library from './BusScreen/library'; -import Sg from './BusScreen/sg'; -import Frontdoor from './BusScreen/frontdoor'; -import Sl from './BusScreen/sl'; import Bus173 from './BusScreen/173-1'; import List173 from './BusScreen/173-2'; +import Bus216 from './BusScreen/216-1'; +import List216 from './BusScreen/216-2'; +import UST from './BusScreen/UST'; const Stack = createStackNavigator(); @@ -27,8 +22,7 @@ function MapStack() { return ( - - + @@ -37,15 +31,11 @@ function MapStack() { - - - - - - - + + + ); }