コンポーネント整理
This commit is contained in:
parent
de37b3698c
commit
45b64f28cb
22
app.json
22
app.json
@ -3,10 +3,7 @@
|
|||||||
"name": "JR四国運行状況",
|
"name": "JR四国運行状況",
|
||||||
"slug": "jrshikoku",
|
"slug": "jrshikoku",
|
||||||
"privacy": "public",
|
"privacy": "public",
|
||||||
"platforms": [
|
"platforms": ["ios", "android"],
|
||||||
"ios",
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
[
|
||||||
"react-native-android-widget",
|
"react-native-android-widget",
|
||||||
@ -15,8 +12,8 @@
|
|||||||
{
|
{
|
||||||
"name": "JR_shikoku_train_info",
|
"name": "JR_shikoku_train_info",
|
||||||
"label": "JR四国列車遅延速報EX",
|
"label": "JR四国列車遅延速報EX",
|
||||||
"minWidth": "320dp",
|
"minWidth": "70dp",
|
||||||
"minHeight": "120dp",
|
"minHeight": "50dp",
|
||||||
"description": "JR四国列車遅延速報EXのウィジェットです。30分ごとに自動更新します。タッチすると強制更新します。",
|
"description": "JR四国列車遅延速報EXのウィジェットです。30分ごとに自動更新します。タッチすると強制更新します。",
|
||||||
"previewImage": "./assets/icon.png",
|
"previewImage": "./assets/icon.png",
|
||||||
"updatePeriodMillis": 1800000,
|
"updatePeriodMillis": 1800000,
|
||||||
@ -39,9 +36,7 @@
|
|||||||
"fallbackToCacheTimeout": 0,
|
"fallbackToCacheTimeout": 0,
|
||||||
"url": "https://u.expo.dev/398abf60-57a7-11e9-970c-8f04356d08bf"
|
"url": "https://u.expo.dev/398abf60-57a7-11e9-970c-8f04356d08bf"
|
||||||
},
|
},
|
||||||
"assetBundlePatterns": [
|
"assetBundlePatterns": ["**/*"],
|
||||||
"**/*"
|
|
||||||
],
|
|
||||||
"ios": {
|
"ios": {
|
||||||
"buildNumber": "31",
|
"buildNumber": "31",
|
||||||
"supportsTablet": true,
|
"supportsTablet": true,
|
||||||
@ -57,18 +52,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"com.apple.developer.nfc.readersession.formats": [
|
"com.apple.developer.nfc.readersession.formats": ["TAG"]
|
||||||
"TAG"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"android": {
|
"android": {
|
||||||
"package": "jrshikokuinfo.xprocess.hrkn",
|
"package": "jrshikokuinfo.xprocess.hrkn",
|
||||||
"versionCode": 20,
|
"versionCode": 20,
|
||||||
"permissions": [
|
"permissions": ["ACCESS_FINE_LOCATION", "NFC"],
|
||||||
"ACCESS_FINE_LOCATION",
|
|
||||||
"NFC"
|
|
||||||
],
|
|
||||||
"googleServicesFile": "./google-services.json",
|
"googleServicesFile": "./google-services.json",
|
||||||
"config": {
|
"config": {
|
||||||
"googleMaps": {
|
"googleMaps": {
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
ListWidget,
|
ListWidget,
|
||||||
} from "react-native-android-widget";
|
} from "react-native-android-widget";
|
||||||
|
|
||||||
export function HelloWidget({ time, delayString }) {
|
export function TraInfoEXWidget({ time, delayString }) {
|
||||||
return (
|
return (
|
||||||
<FlexWidget
|
<FlexWidget
|
||||||
style={{
|
style={{
|
@ -1,11 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { HelloWidget } from "./HelloWidget";
|
import { TraInfoEXWidget } from "./TraInfoEXWidget";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { ToastAndroid } from "react-native";
|
import { ToastAndroid } from "react-native";
|
||||||
|
|
||||||
const nameToWidget = {
|
const nameToWidget = {
|
||||||
// Hello will be the **name** with which we will reference our widget.
|
// Hello will be the **name** with which we will reference our widget.
|
||||||
JR_shikoku_train_info: HelloWidget,
|
JR_shikoku_train_info: TraInfoEXWidget,
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function widgetTaskHandler(props) {
|
export async function widgetTaskHandler(props) {
|
||||||
@ -30,25 +30,16 @@ export async function widgetTaskHandler(props) {
|
|||||||
switch (props.widgetAction) {
|
switch (props.widgetAction) {
|
||||||
case "WIDGET_ADDED":
|
case "WIDGET_ADDED":
|
||||||
case "WIDGET_UPDATE":
|
case "WIDGET_UPDATE":
|
||||||
// Not needed for now
|
|
||||||
case "WIDGET_CLICK":
|
case "WIDGET_CLICK":
|
||||||
// Not needed for now
|
|
||||||
case "WIDGET_RESIZED":
|
case "WIDGET_RESIZED":
|
||||||
// Not needed for now
|
// Not needed for now
|
||||||
props.renderWidget(<Widget time={time} delayString={delayString} />);
|
props.renderWidget(<Widget time={time} delayString={delayString} />);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "WIDGET_DELETED":
|
case "WIDGET_DELETED":
|
||||||
// Not needed for now
|
// Not needed for now
|
||||||
break;
|
break;
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect, useLayoutEffect } from "react";
|
||||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
||||||
import * as ExpoFelicaReader from "../modules/expo-felica-reader/src";
|
import * as ExpoFelicaReader from "../modules/expo-felica-reader/src";
|
||||||
import * as Updates from "expo-updates";
|
import * as Updates from "expo-updates";
|
||||||
@ -17,11 +17,7 @@ export default function Setting(props) {
|
|||||||
const [usePDFView, setUsePDFView] = useState(false);
|
const [usePDFView, setUsePDFView] = useState(false);
|
||||||
const [trainMenu, setTrainMenu] = useState(false);
|
const [trainMenu, setTrainMenu] = useState(false);
|
||||||
const [trainPosition, setTrainPosition] = useState(false);
|
const [trainPosition, setTrainPosition] = useState(false);
|
||||||
const testNFC = async () => {
|
useLayoutEffect(() => {
|
||||||
const resulit = await ExpoFelicaReader.scan();
|
|
||||||
alert(resulit);
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
|
||||||
AS.getItem("iconSwitch").then(setIconSetting);
|
AS.getItem("iconSwitch").then(setIconSetting);
|
||||||
AS.getItem("mapSwitch").then(setMapSwitch);
|
AS.getItem("mapSwitch").then(setMapSwitch);
|
||||||
AS.getItem("stationSwitch").then(setStationMenu);
|
AS.getItem("stationSwitch").then(setStationMenu);
|
||||||
@ -29,6 +25,22 @@ export default function Setting(props) {
|
|||||||
AS.getItem("trainSwitch").then(setTrainMenu);
|
AS.getItem("trainSwitch").then(setTrainMenu);
|
||||||
AS.getItem("trainPositionSwitch").then(setTrainPosition);
|
AS.getItem("trainPositionSwitch").then(setTrainPosition);
|
||||||
}, []);
|
}, []);
|
||||||
|
const testNFC = async () => {
|
||||||
|
const resulit = await ExpoFelicaReader.scan();
|
||||||
|
alert(resulit);
|
||||||
|
};
|
||||||
|
const updateAndReload = () => {
|
||||||
|
Promise.all([
|
||||||
|
AS.setItem("iconSwitch", iconSetting.toString()),
|
||||||
|
AS.setItem("mapSwitch", mapSwitch.toString()),
|
||||||
|
AS.setItem("stationSwitch", stationMenu.toString()),
|
||||||
|
AS.setItem("usePDFView", usePDFView.toString()),
|
||||||
|
AS.setItem("trainSwitch", trainMenu.toString()),
|
||||||
|
AS.setItem("trainPositionSwitch", trainPosition.toString()),
|
||||||
|
]).then(() => {
|
||||||
|
Updates.reloadAsync();
|
||||||
|
});
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||||
<View style={{ flex: 1, backgroundColor: "white" }}>
|
<View style={{ flex: 1, backgroundColor: "white" }}>
|
||||||
@ -59,10 +71,10 @@ export default function Setting(props) {
|
|||||||
列車アイコンを表示する
|
列車アイコンを表示する
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Switch
|
<SimpleSwitch
|
||||||
value={iconSetting == "true" ? true : false}
|
bool={iconSetting}
|
||||||
color={iconSetting == "true" ? "red" : null}
|
setBool={setIconSetting}
|
||||||
onValueChange={(value) => setIconSetting(value.toString())}
|
color="red"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
@ -78,11 +90,7 @@ export default function Setting(props) {
|
|||||||
マップを表示する(beta)
|
マップを表示する(beta)
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Switch
|
<SimpleSwitch bool={mapSwitch} setBool={setMapSwitch} color="red" />
|
||||||
value={mapSwitch == "true" ? true : false}
|
|
||||||
color={mapSwitch == "true" ? "red" : null}
|
|
||||||
onValueChange={(value) => setMapSwitch(value.toString())}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
<Text
|
<Text
|
||||||
@ -97,10 +105,10 @@ export default function Setting(props) {
|
|||||||
駅メニューを表示
|
駅メニューを表示
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Switch
|
<SimpleSwitch
|
||||||
value={stationMenu == "true" ? true : false}
|
bool={stationMenu}
|
||||||
color={stationMenu == "true" ? "red" : null}
|
setBool={setStationMenu}
|
||||||
onValueChange={(value) => setStationMenu(value.toString())}
|
color="red"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
@ -116,10 +124,10 @@ export default function Setting(props) {
|
|||||||
時刻表PDFをアプリ外で表示
|
時刻表PDFをアプリ外で表示
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Switch
|
<SimpleSwitch
|
||||||
value={usePDFView == "true" ? true : false}
|
bool={usePDFView}
|
||||||
color={usePDFView == "true" ? "red" : null}
|
setBool={setUsePDFView}
|
||||||
onValueChange={(value) => setUsePDFView(value.toString())}
|
color="red"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
@ -135,11 +143,7 @@ export default function Setting(props) {
|
|||||||
列車メニュー
|
列車メニュー
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Switch
|
<SimpleSwitch bool={trainMenu} setBool={setTrainMenu} color="red" />
|
||||||
value={trainMenu == "true" ? true : false}
|
|
||||||
color={trainMenu == "true" ? "red" : null}
|
|
||||||
onValueChange={(value) => setTrainMenu(value.toString())}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
<Text
|
<Text
|
||||||
@ -154,10 +158,10 @@ export default function Setting(props) {
|
|||||||
→列車現在位置表示(alpha)
|
→列車現在位置表示(alpha)
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Switch
|
<SimpleSwitch
|
||||||
value={trainPosition == "true" ? true : false}
|
bool={trainPosition}
|
||||||
color={trainPosition == "true" ? "red" : null}
|
setBool={setTrainPosition}
|
||||||
onValueChange={(value) => setTrainPosition(value.toString())}
|
color="red"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
@ -176,7 +180,7 @@ export default function Setting(props) {
|
|||||||
</View>
|
</View>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{ flexDirection: "row", padding: 10 }}
|
style={{ flexDirection: "row", padding: 10 }}
|
||||||
onPress={() => testNFC()}
|
onPress={testNFC}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@ -224,18 +228,7 @@ export default function Setting(props) {
|
|||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={updateAndReload}
|
||||||
Promise.all([
|
|
||||||
AS.setItem("iconSwitch", iconSetting.toString()),
|
|
||||||
AS.setItem("mapSwitch", mapSwitch.toString()),
|
|
||||||
AS.setItem("stationSwitch", stationMenu.toString()),
|
|
||||||
AS.setItem("usePDFView", usePDFView.toString()),
|
|
||||||
AS.setItem("trainSwitch", trainMenu.toString()),
|
|
||||||
AS.setItem("trainPositionSwitch", trainPosition.toString()),
|
|
||||||
]).then(() => {
|
|
||||||
Updates.reloadAsync();
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||||
@ -246,3 +239,10 @@ export default function Setting(props) {
|
|||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const SimpleSwitch = ({ bool, setBool, color }) => (
|
||||||
|
<Switch
|
||||||
|
value={bool == "true" ? true : false}
|
||||||
|
color={bool == "true" ? color : null}
|
||||||
|
onValueChange={(value) => setBool(value.toString())}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user