From a251651e105c484f7b6cace96c616f537e7a7f75 Mon Sep 17 00:00:00 2001 From: harukin-DeskMini Date: Mon, 28 Mar 2022 03:58:14 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E9=83=A8=E7=8F=BE=E4=BB=A3=E7=9A=84?= =?UTF-8?q?=E3=81=AA=E3=82=B3=E3=83=BC=E3=83=89=E3=81=B8=E3=81=AE=E6=9B=B8?= =?UTF-8?q?=E3=81=8D=E6=8F=9B=E3=81=88&=E3=81=93=E3=82=8C=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=81=B8=E3=81=AE=E6=BA=96=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 35 ++++--- Apps.js | 9 +- UpdateAsync.js | 25 ++--- menu.js | 253 ++++++++++++++++++++++++++++++------------------- 4 files changed, 182 insertions(+), 140 deletions(-) diff --git a/App.js b/App.js index 17ceccc..987ce0f 100644 --- a/App.js +++ b/App.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useRef } from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator,TransitionPresets ,} from '@react-navigation/stack'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; @@ -13,30 +13,27 @@ import menu from './menu'; import TestArea from './TestArea.js'; const Stack = createStackNavigator(); const Tab = createBottomTabNavigator(); -const navigationRef = React.createRef(); if (Platform.OS === 'android') { if (UIManager.setLayoutAnimationEnabledExperimental) { UIManager.setLayoutAnimationEnabledExperimental(true); } } -export default class App extends React.Component{ - render(){ - UpdateAsync(); - var platform = Platform.OS === "android" ? 70 : 50; - return( - - - (),}}/> - (),}}/> - (),}}/> - - - - - ) - } +export default function App(){ + const navigationRef = useRef(); + var platform = Platform.OS === "android" ? 70 : 50; + useEffect(()=>UpdateAsync(),[]) + return( + + + (),}}/> + (),}}/> + (),}}/> + + + + + ) } - function top(){ return( diff --git a/Apps.js b/Apps.js index 6c2ecf3..4ef559b 100644 --- a/Apps.js +++ b/Apps.js @@ -1,16 +1,17 @@ import React, { useRef } from 'react'; import {View, Platform} from 'react-native'; import {WebView} from 'react-native-webview'; -import Constants from 'expo-constants'; +import Constants from 'expo-constants';/* import StatusbarDetect from './StatusbarDetect'; -var Status = StatusbarDetect(); +var Status = StatusbarDetect(); */ export var webview = null; -export default function Apps ({ navigation: { navigate } }) { +export default function Apps (props) { + const { navigation: { navigate } } = props; var urlcache=""; const webview = useRef(); return ( - {Status} + {/* {Status} */} { + if (update.isAvailable) { + ToastAndroid.showWithGravityAndOffset('アプリのデータを更新しています。',ToastAndroid.LONG,ToastAndroid.BOTTOM,25,50,); + Updates.fetchUpdateAsync().then(()=>Updates.reloadAsync()); + } + }).catch(e=>ToastAndroid.showWithGravityAndOffset(e.toString(),ToastAndroid.LONG,ToastAndroid.BOTTOM,25,50,)) } \ No newline at end of file diff --git a/menu.js b/menu.js index 4f8c78e..8449a63 100644 --- a/menu.js +++ b/menu.js @@ -45,16 +45,43 @@ const UchikoLineStation = makeLineStationListValiable(内子線,"(予讃)内子 const TokushimaLineStation = makeLineStationListValiable(徳島線,"徳島線"); const NarutoLineStation = makeLineStationListValiable(鳴門線,"鳴門線"); const stationList = {}; -export default function(props) { - const navigation = useNavigation(); - return ; + + +const UsefulBox = (props) =>{ + const { icon, backgroundColor, flex, onPressButton, children } = props; + return( + + + {children} + + ) } -export function Menu(props) { - const actionSheetRef = useRef(null); - const _handlePressButtonAsync = async (link) => { - let result = await WebBrowser.openBrowserAsync(link); - }; +const TicketBox = (props) =>{ + const { icon, backgroundColor, flex, onPressButton, children } = props; + return( + + {children} + {icon} + + ) +} + +const TextBox = (props) =>{ + const { backgroundColor, flex, onPressButton, children } = props; + return( + + + {children} + + + ) +} + +export default function Menu(props) { + const JRSTraInfoEXAcSR = useRef(null); + const StationBoardAcSR = useRef(null); + const navigation = useNavigation(); const [stationName,setStationName] = useState(undefined); @@ -219,30 +246,19 @@ export function Menu(props) { const [location, setLocation] = useState(null); const [errorMsg, setErrorMsg] = useState(null); - useEffect(() => { - (async () => { - let { status } = await Location.requestForegroundPermissionsAsync(); - if (status !== 'granted') { - setErrorMsg('Permission to access location was denied'); - return; - } - - let location = await Location.getCurrentPositionAsync({}); + useEffect(async() => { + let { status } = await Location.requestForegroundPermissionsAsync(); + if (status !== 'granted') { + setErrorMsg('Permission to access location was denied'); + return; + } + Location.getCurrentPositionAsync({}).then(location=>{ console.log(location); setLocation(location); loadOfficialStationList().then(()=>getCurrentStation(location.coords)); - - })(); + }) }, []); - let text = 'Waiting..'; - if (errorMsg) { - text = errorMsg; - } else if (location) { - text = JSON.stringify(location); - } - - const LottieRef = useRef(null); const LottieRef2 = useRef(null); @@ -250,15 +266,16 @@ export function Menu(props) { const [delayData,setDelayData] = useState(undefined); const [getTime,setGetTime] = useState(new Date()); const [loadingDelayData,setLoadingDelayData] = useState(true); - delayData === undefined ? doFetch() : null; - function doFetch(){ + + useEffect(()=>{ fetch("https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec") .then(response => response.text()) .then(data => {if(data != ""){setDelayData(data.split("^"))}else setDelayData(null)}) .then(data => LayoutAnimation.easeInEaseOut()) .then(()=>setGetTime(new Date())) .finally(()=>setLoadingDelayData(false)); - } + },[loadingDelayData]) + useEffect(()=>{ try{ LottieRef?.current.play(); @@ -266,7 +283,6 @@ export function Menu(props) { }catch(e){} }) - const { navigation } = props; return ( {Status} @@ -277,27 +293,16 @@ export function Menu(props) { - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/01_trainbus/sp/")}> - - 駅・鉄道情報 - - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box")}> - - 運賃表 - - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/e5489/")}> - - 予約(e5489) - + Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/")}>駅・鉄道情報 + Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box")}>運賃表 + Linking.openURL("https://www.jr-shikoku.co.jp/e5489/")}>予約 - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/02_information/suspension/sp/")}> - - 新型コロナウイルスに関するお知らせ - 列車の運行計画・混雑状況・感染症対策への取り組み - - + Linking.openURL("https://www.jr-shikoku.co.jp/02_information/suspension/sp/")}> + 新型コロナウイルスに関するお知らせ + 列車の運行計画・混雑状況・感染症対策への取り組み + {stationName ? stationName.今 ? - !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)}> + !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)} */onPress={() => {StationBoardAcSR.current?.setModalVisible()}}> JR @@ -327,7 +332,7 @@ export function Menu(props) { {stationName.前.name} {stationName.前.en} - _handlePressButtonAsync(stationName.今.StationTimeTable)}> + Linking.openURL(stationName.今.StationTimeTable)}> 時刻表 @@ -347,7 +352,7 @@ export function Menu(props) { {stationName ? stationName.今 ? : null : null} - {actionSheetRef.current?.setModalVisible()}}> + {JRSTraInfoEXAcSR.current?.setModalVisible()}}> @@ -357,7 +362,7 @@ export function Menu(props) { 最新の情報へ更新 */} {getTime ? getTime.toLocaleTimeString('ja-JP').split(":")[0]+":"+getTime.toLocaleTimeString('ja-JP').split(":")[1]: NaN} - {LayoutAnimation.easeInEaseOut(),setLoadingDelayData(true),doFetch()}}/> + {LayoutAnimation.easeInEaseOut(),setLoadingDelayData(true)}}/> {loadingDelayData ? @@ -392,45 +397,28 @@ export function Menu(props) { - _handlePressButtonAsync("https://www.jr-eki.com/ticket/brand")}> - トクトク切符 - - - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/01_trainbus/event_train/sp/")}> - 観光列車 - - - _handlePressButtonAsync("https://www.jr-eki.com/tour/brand")}> - 旅行ツアー - - + } flex={1} onPressButton={()=>Linking.openURL("https://www.jr-eki.com/ticket/brand")}>トクトク切符 + } flex={1} onPressButton={()=>Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/event_train/sp/")}>観光列車 + } flex={1} onPressButton={()=>Linking.openURL("https://www.jr-eki.com/tour/brand")}>旅行ツアー - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/sp/index.html#menu-box")}> - - 臨時列車などのお知らせ - 区間縮小・計画運休・イベント・季節臨時列車など - - - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/03_news/press/")}> - - ニュースリリース - 公式プレス記事はこちら - - - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/teiki/")}> - - 定期運賃計算 - 通常/学生/快て〜き等はこちら - - - _handlePressButtonAsync("https://www.jr-shikoku.co.jp/04_company/group/sp/")}> - - JR四国のお店・サービス - JR四国グループの施設をご案内 - - + Linking.openURL("https://www.jr-shikoku.co.jp/sp/index.html#menu-box")}> + 臨時列車などのお知らせ + 区間縮小・計画運休・イベント・季節臨時列車など + + Linking.openURL("https://www.jr-shikoku.co.jp/03_news/press/")}> + ニュースリリース + 公式プレス記事はこちら + + Linking.openURL("https://www.jr-shikoku.co.jp/teiki/")}> + 定期運賃計算 + 通常/学生/快て〜き等はこちら + + Linking.openURL("https://www.jr-shikoku.co.jp/04_company/group/sp/")}> + JR四国のお店・サービス + JR四国グループの施設をご案内 + - _handlePressButtonAsync("https://www.jr-odekake.net/smt/")}> + Linking.openURL("https://www.jr-odekake.net/smt/")}> 時刻・運賃計算 (マイ・ダイヤ) @@ -490,15 +478,13 @@ export function Menu(props) { このアプリについて このアプリはXprocess(HARUKIN)が製作しているJR四国の完全非公式アシストアプリケーションです。このアプリに関することでのJR四国公式へ問合せすることはお控えください。以下のTwitterよりお願いします。 2021/6/23 4.0公開!ホーム画面を大改造しました。 - {count < 10 ? (Linking.openURL("https://twitter.com/Xprocess_main"),setCount(count+1)):navigation.navigate("test")}}> - - XprocessのTwitter - 制作運営のTwitterです。 - - + Linking.openURL("https://twitter.com/Xprocess_main")}> + XprocessのTwitter + 制作運営のTwitterです。 + - {}}> + {}}> @@ -510,7 +496,7 @@ export function Menu(props) { 最新の情報へ更新 */} {getTime ? getTime.toLocaleTimeString('ja-JP').split(":")[0]+":"+getTime.toLocaleTimeString('ja-JP').split(":")[1]: NaN} - {LayoutAnimation.easeInEaseOut(),setLoadingDelayData(true),doFetch()}}/> + {LayoutAnimation.easeInEaseOut(),setLoadingDelayData(true)}}/> @@ -547,6 +533,77 @@ export function Menu(props) { + {}}> + + + + + + にゃー + + {/* {doFetch()}}> + 最新の情報へ更新 + */} + {getTime ? getTime.toLocaleTimeString('ja-JP').split(":")[0]+":"+getTime.toLocaleTimeString('ja-JP').split(":")[1]: NaN} + {LayoutAnimation.easeInEaseOut(),setLoadingDelayData(true)}}/> + + + {stationName ? stationName.今 ? + + : null : null} + {stationName ? stationName.今 ? + !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)} /* onPress={() => {StationBoardAcSR.current?.setModalVisible()}}*/> + + JR + + + {stationName.今.StationNumber} + + + + + + {stationName.今.LineName} + {stationName.今.name} + {stationName.今.en} + + + + + {stationName.前 ? : null} + + {stationName.前 ? + + + {stationName.前.StationNumber} + + : null} + + {stationName.前.name} + {stationName.前.en} + + Linking.openURL(stationName.今.StationTimeTable)}> + 時刻表 + + + {stationName.次.name} + {stationName.次.en} + + {stationName.次.name != null ? + + + {stationName.次.StationNumber} + + : null} + {stationName.次.name != null ? : null} + + + : null : null} + + + + + ); }