InitialCommit

This commit is contained in:
harukin/DeskMini 2021-04-02 18:38:05 +09:00
commit 9442a59feb
32 changed files with 24052 additions and 0 deletions

View File

7
.expo-shared/assets.json Normal file
View File

@ -0,0 +1,7 @@
{
"e982607dc7c471e1e6dd358ecab4ec93f2211576b8b232652ee6e255c3c5c33f": true,
"7adc6cdde1172c646f8dda7fcb1186d148e59e6d2a40774bd7e03281a653f19c": true,
"d64a5b98ad82d1490c6b4000a35d16df16172ebee8c51369a3e09f0e7b77c286": true,
"bd33a28432d03bcee909287ce4fe2cc43e2eda700d603ca00c4493272b82bdab": true,
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
}

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
node_modules/**/*
.expo/*
npm-debug.*
*.jks
*.p12
*.key
*.mobileprovision

1
.watchmanconfig Normal file
View File

@ -0,0 +1 @@
{}

49
App.js Normal file
View File

@ -0,0 +1,49 @@
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator,TransitionPresets ,} from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { AntDesign, Ionicons } from '@expo/vector-icons';
import {ToastAndroid, Platform, UIManager,} from 'react-native';
import { UpdateAsync } from './UpdateAsync.js';
import Apps from './Apps';
import tndView from './ndView';
import trainbase from './trainbaseview';
import howto from './howto';
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(
<NavigationContainer name= "Root" ref={navigationRef} style={{flex:1}}>
<Tab.Navigator>
<Stack.Screen name="login" component={top} options={{ tabBarLabel: '位置情報',headerTransparent:true,gestureEnabled:true,tabBarIcon: ({ color, size }) => (<AntDesign name="barchart" size={32} />),}}/>
<Stack.Screen name="menu" component={menu} options={{ tabBarLabel: 'リンク',headerTransparent:true,gestureEnabled:true,tabBarIcon: ({ color, size }) => (<Ionicons name="ios-radio" size={platform}/>),}}/>
<Stack.Screen name="home" component={tndView} options={{ tabBarLabel: '運行情報',headerTransparent:true,gestureEnabled:true,tabBarIcon: ({ color, size }) => (<Ionicons name="md-train" size={32}/>),}}/>
</Tab.Navigator>
</NavigationContainer>
)
}
}
function top(){
return(
<Stack.Navigator>
<Stack.Screen name="Apps" component={Apps} options={{headerShown: false,gestureEnabled:true,headerTransparent:true,}}/>
<Stack.Screen name="trainbase" component={trainbase} options={{ title: 'トレインビジョン',gestureEnabled:true,...TransitionPresets.SlideFromRightIOS}}/>
<Stack.Screen name="howto" component={howto} options={{ title: '使い方',gestureEnabled:true,...TransitionPresets.ModalPresentationIOS,cardOverlayEnabled:true,headerTransparent:true,headerShown:false}}/>
<Stack.Screen name="test" component={TestArea} options={{}}/>
</Stack.Navigator>
)
}

132
Apps.js Normal file
View File

@ -0,0 +1,132 @@
import React from 'react';
import {View, Platform} from 'react-native';
import {WebView} from 'react-native-webview';
import Constants from 'expo-constants';
import StatusbarDetect from './StatusbarDetect';
var Status = StatusbarDetect();
export var webview = null;
export default function Apps ({ navigation: { navigate } }) {
var urlcache="";
return (
<View style={{height:"100%",paddingTop: Constants.statusBarHeight,}}>
{Status}
<WebView
useWebKit={true}
ref={ref => (this.webview = ref)}
source={{uri: 'https://train.jr-shikoku.co.jp/sp.html'}}
originWhitelist={['https://train.jr-shikoku.co.jp','https://train.jr-shikoku.co.jp/sp.html']}
mixedContentMode={'compatibility'}
javaScriptEnabled={true}
allowsBackForwardNavigationGestures={true}
onNavigationStateChange={
event =>{
console.log(event);
if(event.url != urlcache){//URL二重判定回避
urlcache = event.url;
if (event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")) {
if(Platform.OS==="android")navigate('howto');
this.webview.goBack();
//Actions.howto();
}
else if (event.url.includes("https://train.jr-shikoku.co.jp/train.html")) {
//Actions.trainbase({info: event.url});
if(Platform.OS==="android")navigate('trainbase', {info: event.url});
this.webview.goBack();
}
}
}
}
injectedJavaScript={js}/>
</View>
);
}
const js = `
var observer = new MutationObserver(function(){
console.log(elem);
});
const elem = document.querySelector('#modal_content');
console.log(elem);
const config = {
attributes: true,
childList: true,
characterData: true
};
observer.observe(elem, config);
document.getElementById('headerStr').style.display = 'none';
document.getElementById('modal_info').style.display = 'none';
document.getElementById('header').style.height = '50px';
document.getElementById('main').style.paddingTop = '54px';
document.querySelector('#header a').style.display = 'none';
after();
function after(){
try {
document.getElementById('refreshIcon').click();
var elements = document.querySelectorAll('[onclick]');
for (var index = 0; index < elements.length; index++) {
var element = elements[index];
if(element.getAttribute('onclick').indexOf('ShowTrainTimeInfo') != -1){
var test = element.getElementsByTagName("p");
var test3 = element.getAttribute('onclick').split('"');
var HTrain = "\\n試運転";
var RTrain = "\\n回送";
var STrain = "\\n臨時列車";
var WTrain = "ワンマン\\n";
var = "(海経由)";
var = "(内子経由)";
var reg1 = new RegExp(/^4[1-9]\\d\\d[DM]$/);
var reg2 = new RegExp(/^5[1-9]\\d\\d[DM]$/);
var 海1 = new RegExp(/^49[0-4]\\dD$/);
var 海2 = new RegExp(/^9[0-4]\\dD$/);
var 内1 = new RegExp(/^46\\d\\dD$/);
var 内2 = new RegExp(/^6\\d\\dD$/);
var flag=false;
test[0].innerText = test[0].innerText+test3[1];
if(reg1.test(test3[1]) || reg2.test(test3[1])){
test[0].innerText = WTrain+test[0].innerText;
flag=true;
}
if(海1.test(test3[1]) || 海2.test(test3[1])){
test[0].innerText = +(flag ? "" : "\\n")+test[0].innerText;
}
if(内1.test(test3[1]) || 内2.test(test3[1])){
test[0].innerText = +(flag ? "" : "\\n")+test[0].innerText;
}
if(test3[1].indexOf("H") != -1){
test[0].innerText = test[0].innerText+HTrain;
}
else if(test3[1].indexOf("R") != -1){
test[0].innerText = test[0].innerText+RTrain;
}
else if(test3[1].indexOf("S") != -1){
test[0].innerText = test[0].innerText+STrain;
}
}
}
try{
document.querySelector('#pMENU_2').style.borderStyle='solid';
document.querySelector('#pMENU_2').style.borderColor='#00d3e8';
document.querySelector('#pMENU_2').style.borderWidth='2px';
document.querySelector('#pMENU_2').style.borderRadius='10%';
document.querySelector('#pMENU_3').style.borderStyle='solid';
document.querySelector('#pMENU_3').style.borderColor='#00d3e8';
document.querySelector('#pMENU_3').style.borderWidth='2px';
document.querySelector('#pMENU_3').style.borderRadius='10%';
document.querySelectorAll('#pMENU_2 div').forEach((d)=>{
d.style.padding = '10px';
});
document.querySelectorAll('#pMENU_3 div').forEach((d)=>{
d.style.padding = '10px';
});
}catch(e){
alert("にゃー");
}
} catch (e) {
}
setTimeout(after, 10000);
}
`;

16
StatusbarDetect.js Normal file
View File

@ -0,0 +1,16 @@
import React from 'react';
import {Platform, StatusBar, View} from 'react-native';
export default function StatusbarDetect() {
if(Platform.OS == "ios"){
return (
<StatusBar barStyle="dark-content"/>
);
}
else if(Platform.OS == "android"){
return (
<View/>
);
}
}

49
TestArea.js Normal file
View File

@ -0,0 +1,49 @@
import React, { Component, useEffect, useState } from 'react';
import {StatusBar,View,ScrollView,Linking,Text } from 'react-native';
import Constants from 'expo-constants';
import { ListItem } from 'react-native-elements';
import Icon from 'react-native-vector-icons/Entypo';
import StatusbarDetect from './StatusbarDetect';
var Status = StatusbarDetect();
let a=[];
export default function TestArea(props) {
const [data,setdata] = useState(null);
useEffect(()=>{
data==null ? test().then(res=>{
//console.log(res);
setdata(res);
}):null
},[data])
return (
<View style={{height:"100%",paddingTop: Constants.statusBarHeight,}}>
{Status}
<ScrollView>
<Text>TEST AREA!!</Text>
{data}
</ScrollView>
</View>
);
}
async function test(){
return fetch('https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train', {
headers: {
'authority': 'train.jr-shikoku.co.jp',
'cache-control': 'no-cache',
'pragma': 'no-cache',
'if-modified-since': 'Thu, 01 Jun 1970 00:00:00 GMT',
'accept': '*/*',
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'cors',
'referer': 'https://train.jr-shikoku.co.jp/sp.html'
}
}).then(res=>res.json()).then(D=>{
let d =[];
D.forEach(element => {
console.log(element)
d.push(<ListItem title={"Direction:"+element.Direction+" Index:"+element.Index+" Line:"+element.Line+" Pos:"+element.Pos+" PosNum:"+element.PosNum+" TrainNum:"+element.TrainNum+" Type:"+element.Type+" Delay:"+element.delay}/>);
});
a=d;
return d;
});
}

24
UpdateAsync.js Normal file
View File

@ -0,0 +1,24 @@
import { ToastAndroid, } from 'react-native';
import * as Updates from 'expo-updates';
export function UpdateAsync(){
try {
async function test(){
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
ToastAndroid.showWithGravityAndOffset('アプリのデータを更新しています。',ToastAndroid.LONG,ToastAndroid.BOTTOM,25,50,);
await Updates.fetchUpdateAsync().then(function(){
Updates.reloadAsync();
});
}
else{}
}
test();
}catch(e){
ToastAndroid.showWithGravityAndOffset(e,ToastAndroid.LONG,ToastAndroid.BOTTOM,25,50,);
}
}

36
app.json Normal file
View File

@ -0,0 +1,36 @@
{
"expo": {
"name": "JR四国運行状況",
"slug": "jrshikoku",
"privacy": "public",
"platforms": [
"ios",
"android"
],
"version": "3.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#00b8ff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"buildNumber": "13",
"supportsTablet": true,
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn"
},
"android": {
"package": "jrshikokuinfo.xprocess.hrkn",
"versionCode": 10,
"permissions": [],
"googleServicesFile": "./google-services.json"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
assets/icons.orig.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
assets/icons.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

BIN
assets/splash2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
assets/splashs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
assets/名称未設定.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

BIN
assets/名称未設定.xcf Normal file

Binary file not shown.

6
babel.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};

40
google-services.json Normal file
View File

@ -0,0 +1,40 @@
{
"project_info": {
"project_number": "407139691461",
"firebase_url": "https://trainfo-shikoku.firebaseio.com",
"project_id": "trainfo-shikoku",
"storage_bucket": "trainfo-shikoku.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:407139691461:android:b6824b1f6c962d4d",
"android_client_info": {
"package_name": "jrshikokuinfo.xprocess.hrkn"
}
},
"oauth_client": [
{
"client_id": "407139691461-jo0nh70n7m93p049rkak2sjamb5uti6p.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDnUf3CaZXyuJe_EkGK-UV3zRoBEPCcSWA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "407139691461-jo0nh70n7m93p049rkak2sjamb5uti6p.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

16
howto.js Normal file
View File

@ -0,0 +1,16 @@
const WEBVIEW = "WEBVIEW";
import React, { Component } from 'react';
import { StatusBar,View} from 'react-native';
import {WebView} from 'react-native-webview';
export default class howto extends Component {
render() {
return (
<View style={{height:"100%"}}>
<View style={{alignItems:"center"}}>
<View style={{ width:60,height:8,marginTop:15,marginBottom:10, backgroundColor: "gray", padding: 0, borderRadius: 20, borderWidth: 1, borderColor: "gray", overflow: "hidden"}}/>
</View>
<WebView useWebKit={true} source={{uri: 'https://train.jr-shikoku.co.jp/usage.htm'}}/>
</View>
);
}
}

49
menu.js Normal file
View File

@ -0,0 +1,49 @@
import React, { Component } from 'react';
import {StatusBar,View,ScrollView,Linking,Text } from 'react-native';
import Constants from 'expo-constants';
import { ListItem } from 'react-native-elements';
import Icon from 'react-native-vector-icons/Entypo';
import StatusbarDetect from './StatusbarDetect';
var Status = StatusbarDetect();
import { useNavigation } from '@react-navigation/native';
export default function(props) {
const navigation = useNavigation();
return <Menu {...props} navigation={navigation} />;
}
export class Menu extends React.Component {
constructor(props){
super(props);
this.state={
count:0,
}
}
render() {
const { navigation } = this.props;
return (
<View style={{height:"100%",paddingTop: Constants.statusBarHeight,}}>
{Status}
<ScrollView>
<Text>JR四国</Text>
<ListItem title={"JR四国サイトトップ"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="globe" size={20} />} onPress={()=>Linking.openURL("https://www.jr-shikoku.co.jp")}/>
<ListItem title={"コロナウイルスに関するお知らせ"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="new" size={20} />} onPress={()=>Linking.openURL("http://www.jr-shikoku.co.jp/02_information/suspension/index.html")}/>
<ListItem title={"駅/鉄道情報"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="map" size={20} />} onPress={()=>Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/")}/>
<ListItem title={"列車空席案内(サイバーステーション)"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="browser" size={20} />} onPress={()=>Linking.openURL("http://www.jr.cyberstation.ne.jp/")}/>
<ListItem title={"JR四国 東京営業情報【公式】"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="twitter" size={20} />} onPress={()=>Linking.openURL("https://twitter.com/JRshikoku_tokyo")}/>
<ListItem title={"JR四国運行情報Twitter"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="twitter" size={20} />} onPress={()=>Linking.openURL("https://twitter.com/jr_shikoku_info")}/>
<ListItem title={"JR四国いそうろう妖精 すまいるえきちゃん♡【公式】"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="twitter" size={20} />} onPress={()=>Linking.openURL("https://twitter.com/Smile_Eki_Chan")}/>
<ListItem title={"JR四国デザインPT♡"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="twitter" size={20} />} onPress={()=>Linking.openURL("https://twitter.com/JR_Shikoku_DPT")}/>
<ListItem title={"JR四国デザインPT弐号◇"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="twitter" size={20} />} onPress={()=>Linking.openURL("https://twitter.com/PT2nd_Yuki")}/>
<Text>このアプリについて</Text>
<ListItem title={"広報Twitter"} roundAvatar rightIcon={<Icon name="chevron-right" size={20}/>} leftIcon={<Icon name="twitter" size={20} />} onPress={()=>{this.state.count < 10 ? (Linking.openURL("https://twitter.com/Xprocess_main"),this.setState({count: this.state.count+1})):navigation.navigate("test")}}/>
</ScrollView>
<Text>2021/4/1 >> ボタン押しにくくねと思った箇所を改善しました</Text>
<Text>バージョン3.2 最終データ更新:2021/4/1</Text>
</View>
);
}
}

23
ndView.js Normal file
View File

@ -0,0 +1,23 @@
import React, { Component } from 'react';
import { StatusBar,View,Linking,Text} from 'react-native';
import {WebView} from 'react-native-webview';
import Constants from 'expo-constants';
import { TouchableOpacity } from 'react-native-gesture-handler';
export default function tndView () {
return (
<View style={{backgroundColor: '#309AC3', height:"100%",paddingTop: Constants.statusBarHeight,}}>
<WebView
useWebKit={true}
source={{uri: 'https://www.jr-shikoku.co.jp/info/'}}
originWhitelist={['https://www.jr-shikoku.co.jp']}
mixedContentMode={'compatibility'}
javaScriptEnabled={true}
injectedJavaScript={jsa}/>
</View>
);
}
const jsa = `
document.querySelector('.sitettl').style.display = 'none';
document.querySelector('.attention').style.display = 'none';
`;

12485
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

38
package.json Normal file
View File

@ -0,0 +1,38 @@
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject"
},
"dependencies": {
"@expo/vector-icons": "^10.2.1",
"@react-native-community/masked-view": "0.1.6",
"@react-navigation/bottom-tabs": "^5.9.2",
"@react-navigation/native": "^5.7.6",
"@react-navigation/stack": "^5.9.3",
"expo": "^37.0.12",
"expo-font": "~8.1.0",
"expo-updates": "~0.2.1",
"firebase": "7.9.0",
"native-base": "^2.13.14",
"npm": "^6.14.8",
"pushy-react-native": "^1.0.15",
"react": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz",
"react-native-elements": "^1.2.7",
"react-native-gesture-handler": "~1.6.0",
"react-native-reanimated": "~1.7.0",
"react-native-responsive-screen": "^1.4.1",
"react-native-router-flux": "^4.0.6",
"react-native-safe-area-context": "0.7.3",
"react-native-screens": "~2.2.0",
"react-native-vector-icons": "^6.7.0",
"react-native-webview": "8.1.1"
},
"devDependencies": {
"babel-preset-expo": "^8.3.0"
},
"private": true
}

View File

@ -0,0 +1,14 @@
/* eslint-env browser */
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker
.register('/expo-service-worker.js', { scope: '/' })
.then(function(info) {
// console.info('Registered service-worker', info);
})
.catch(function(error) {
console.info('Failed to register service-worker', error);
});
});
}

14
trainbaseview.js Normal file
View File

@ -0,0 +1,14 @@
const WEBVIEW = "WEBVIEW";
import React, { Component } from 'react';
import { StatusBar,View} from 'react-native';
import {WebView} from 'react-native-webview';
export default function trainbase({route, navigation}) {
const { info } = route.params;
return (
<View style={{height:"100%"}}>
<WebView source={{uri: info}} useWebKit={true} originWhitelist={['https://train.jr-shikoku.co.jp']}injectedJavaScript={jss}/>
</View>
);
}
const jss = `document.getElementById('Footer').style.display = 'none';`;

View File

@ -0,0 +1,14 @@
/* eslint-env browser */
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker
.register('/expo-service-worker.js', { scope: '/' })
.then(function(info) {
// console.info('Registered service-worker', info);
})
.catch(function(error) {
console.info('Failed to register service-worker', error);
});
});
}

11032
yarn.lock Normal file

File diff suppressed because it is too large Load Diff