Merge commit '81dd57ba14ee9883ec1ea91c8647f0129c11b2dd' into feature/anpanman-status-icon

This commit is contained in:
harukin-expo-dev-env 2024-09-04 15:42:31 +00:00
commit 29ea98e29b
16 changed files with 16432 additions and 37659 deletions

2
App.js
View File

@ -16,6 +16,7 @@ import { SafeAreaProvider } from "react-native-safe-area-context";
import { DeviceOrientationChangeProvider } from "./stateBox/useDeviceOrientationChange";
import { TrainMenuProvider } from "./stateBox/useTrainMenu";
import { buildProvidersTree } from "./lib/providerTreeProvider";
import { StationListProvider } from "./stateBox/useStationList";
LogBox.ignoreLogs([
"ViewPropTypes will be removed",
@ -32,6 +33,7 @@ export default function App() {
useEffect(() => UpdateAsync(), []);
const ProviderTree = buildProvidersTree([
StationListProvider,
FavoriteStationProvider,
TrainDelayDataProvider,
CurrentTrainProvider,

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,224 @@
{"type":"FeatureCollection","features":[{"properties":{"name":"五十崎","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/五十崎","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.63672,33.53833],[132.63599,33.53782]]}},{"properties":{"name":"五十崎","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/五十崎"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.63599,33.53782]}},{"properties":{"name":"内子","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/内子","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.64634,33.55023],[132.64618,33.54873]]}},{"properties":{"name":"内子","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/内子"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.64634,33.55023]}},{"properties":{"name":"喜多山","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/喜多山","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.61103,33.53326],[132.61184,33.53359]]}},{"properties":{"name":"喜多山","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/喜多山"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.61103,33.53326]}},{"properties":{"name":"新谷","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/新谷","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.59812,33.53417],[132.59894,33.53414]]}},{"properties":{"name":"新谷","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/新谷"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.59812,33.53417]}},{"properties":{"name":"内子線","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線","color":"FBAF18"},"type":"Feature","geometry":{"type":"MultiLineString","coordinates":[[[132.61103,33.53326],[132.61184,33.53359]],[[132.63672,33.53833],[132.63599,33.53782]],[[132.59894,33.53414],[132.60008,33.53411],[132.60062,33.5341],[132.60165,33.53407],[132.60238,33.53402],[132.603,33.53393],[132.60436,33.53374],[132.60653,33.53343],[132.60837,33.53317],[132.60913,33.53306],[132.60942,33.53306],[132.60975,33.53306],[132.6103,33.53312],[132.61055,33.53315],[132.61086,33.53321],[132.61103,33.53326]],[[132.64634,33.55023],[132.64618,33.54873]],[[132.59812,33.53417],[132.59894,33.53414]],[[132.64618,33.54873],[132.64615,33.54836],[132.64606,33.5477],[132.64603,33.54735],[132.64593,33.54665],[132.64581,33.54616],[132.64569,33.54575],[132.64547,33.54524],[132.64527,33.54496],[132.64488,33.54449],[132.64463,33.54425],[132.64453,33.54415],[132.64379,33.54359],[132.64294,33.54293],[132.64204,33.54222],[132.64181,33.54204],[132.64106,33.54147],[132.63989,33.54055],[132.63898,33.53985],[132.63788,33.53906],[132.63691,33.53844],[132.6368,33.53838],[132.63672,33.53833]],[[132.63599,33.53782],[132.63492,33.53712],[132.63383,33.53646],[132.63354,33.53631],[132.63319,33.53621],[132.6323,33.53609],[132.63157,33.53597],[132.63102,33.53585],[132.63058,33.53569],[132.63016,33.53549],[132.62986,33.53527],[132.6297,33.53515],[132.62939,33.5348],[132.62913,33.53449],[132.62893,33.5343],[132.62862,33.53407],[132.62839,33.53393],[132.62791,33.53379],[132.62699,33.53356],[132.62575,33.53327],[132.62491,33.53313],[132.62449,33.53306],[132.62386,33.53307],[132.62341,33.53308],[132.6231,33.53306],[132.62248,33.53291],[132.62207,33.5328],[132.62171,33.53272],[132.62149,33.53271],[132.62126,33.53273],[132.62069,33.53283],[132.6203,33.53286],[132.61996,33.53288],[132.61954,33.5329],[132.61937,33.53292],[132.61913,33.53298],[132.6187,33.53311],[132.61841,33.53319],[132.61808,33.53329],[132.61675,33.53368],[132.6161,33.53387],[132.61546,33.53407],[132.615,33.53419],[132.61486,33.53421],[132.61474,33.53419],[132.61458,33.53417],[132.61428,33.5341],[132.61409,33.53407],[132.61341,33.53401],[132.6131,33.53397],[132.61285,33.5339],[132.61221,33.53373],[132.61184,33.53359]]]}}]}
{
"type": "FeatureCollection",
"features": [
{
"properties": {
"name": "新谷",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/新谷",
"color": "FBAF18"
},
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[132.59812, 33.53417],
[132.59894, 33.53414]
]
}
},
{
"properties": {
"name": "新谷",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/新谷"
},
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [132.59812, 33.53417] }
},
{
"properties": {
"name": "喜多山",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/喜多山",
"color": "FBAF18"
},
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[132.61103, 33.53326],
[132.61184, 33.53359]
]
}
},
{
"properties": {
"name": "喜多山",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/喜多山"
},
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [132.61103, 33.53326] }
},
{
"properties": {
"name": "五十崎",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/五十崎",
"color": "FBAF18"
},
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[132.63672, 33.53833],
[132.63599, 33.53782]
]
}
},
{
"properties": {
"name": "五十崎",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/五十崎"
},
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [132.63599, 33.53782] }
},
{
"properties": {
"name": "内子",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/内子",
"color": "FBAF18"
},
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[132.64634, 33.55023],
[132.64618, 33.54873]
]
}
},
{
"properties": {
"name": "内子",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線/内子"
},
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [132.64634, 33.55023] }
},
{
"properties": {
"name": "内子線",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/内子線",
"color": "FBAF18"
},
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[132.61103, 33.53326],
[132.61184, 33.53359]
],
[
[132.63672, 33.53833],
[132.63599, 33.53782]
],
[
[132.59894, 33.53414],
[132.60008, 33.53411],
[132.60062, 33.5341],
[132.60165, 33.53407],
[132.60238, 33.53402],
[132.603, 33.53393],
[132.60436, 33.53374],
[132.60653, 33.53343],
[132.60837, 33.53317],
[132.60913, 33.53306],
[132.60942, 33.53306],
[132.60975, 33.53306],
[132.6103, 33.53312],
[132.61055, 33.53315],
[132.61086, 33.53321],
[132.61103, 33.53326]
],
[
[132.64634, 33.55023],
[132.64618, 33.54873]
],
[
[132.59812, 33.53417],
[132.59894, 33.53414]
],
[
[132.64618, 33.54873],
[132.64615, 33.54836],
[132.64606, 33.5477],
[132.64603, 33.54735],
[132.64593, 33.54665],
[132.64581, 33.54616],
[132.64569, 33.54575],
[132.64547, 33.54524],
[132.64527, 33.54496],
[132.64488, 33.54449],
[132.64463, 33.54425],
[132.64453, 33.54415],
[132.64379, 33.54359],
[132.64294, 33.54293],
[132.64204, 33.54222],
[132.64181, 33.54204],
[132.64106, 33.54147],
[132.63989, 33.54055],
[132.63898, 33.53985],
[132.63788, 33.53906],
[132.63691, 33.53844],
[132.6368, 33.53838],
[132.63672, 33.53833]
],
[
[132.63599, 33.53782],
[132.63492, 33.53712],
[132.63383, 33.53646],
[132.63354, 33.53631],
[132.63319, 33.53621],
[132.6323, 33.53609],
[132.63157, 33.53597],
[132.63102, 33.53585],
[132.63058, 33.53569],
[132.63016, 33.53549],
[132.62986, 33.53527],
[132.6297, 33.53515],
[132.62939, 33.5348],
[132.62913, 33.53449],
[132.62893, 33.5343],
[132.62862, 33.53407],
[132.62839, 33.53393],
[132.62791, 33.53379],
[132.62699, 33.53356],
[132.62575, 33.53327],
[132.62491, 33.53313],
[132.62449, 33.53306],
[132.62386, 33.53307],
[132.62341, 33.53308],
[132.6231, 33.53306],
[132.62248, 33.53291],
[132.62207, 33.5328],
[132.62171, 33.53272],
[132.62149, 33.53271],
[132.62126, 33.53273],
[132.62069, 33.53283],
[132.6203, 33.53286],
[132.61996, 33.53288],
[132.61954, 33.5329],
[132.61937, 33.53292],
[132.61913, 33.53298],
[132.6187, 33.53311],
[132.61841, 33.53319],
[132.61808, 33.53329],
[132.61675, 33.53368],
[132.6161, 33.53387],
[132.61546, 33.53407],
[132.615, 33.53419],
[132.61486, 33.53421],
[132.61474, 33.53419],
[132.61458, 33.53417],
[132.61428, 33.5341],
[132.61409, 33.53407],
[132.61341, 33.53401],
[132.6131, 33.53397],
[132.61285, 33.5339],
[132.61221, 33.53373],
[132.61184, 33.53359]
]
]
}
}
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,256 @@
{
"type": "FeatureCollection",
"features": [
{
"properties": {
"name": "児島",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/児島",
"color": "0073BC"
},
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[133.80748, 34.46183],
[133.8079, 34.4638]
]
}
},
{
"properties": {
"name": "児島",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/児島"
},
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [133.80748, 34.46183] }
},
{
"properties": {
"name": "宇多津",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/宇多津",
"color": "0073BC"
},
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[133.81324, 34.30552],
[133.81426, 34.30712]
]
}
},
{
"properties": {
"name": "宇多津",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/宇多津"
},
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [133.81324, 34.30552] }
},
{
"properties": {
"name": "本四備讃線",
"uri": "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線",
"color": "0073BC"
},
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[133.81426, 34.30712],
[133.81504, 34.30838],
[133.81622, 34.31028],
[133.81778, 34.31274]
],
[
[133.81324, 34.30552],
[133.81426, 34.30712]
],
[
[133.80748, 34.46183],
[133.8079, 34.4638]
],
[
[133.80745, 34.46169],
[133.80748, 34.46183]
],
[
[133.80745, 34.46169],
[133.80735, 34.46116],
[133.80723, 34.46026],
[133.80714, 34.45964],
[133.807, 34.45809],
[133.80697, 34.45769],
[133.80697, 34.45753],
[133.80693, 34.45694],
[133.80691, 34.4557],
[133.80692, 34.45548],
[133.80691, 34.45543],
[133.80693, 34.45494],
[133.80696, 34.45464],
[133.80704, 34.45385],
[133.80714, 34.45314],
[133.8072, 34.45271],
[133.80727, 34.45221],
[133.80737, 34.45148],
[133.80742, 34.45102],
[133.80745, 34.45087],
[133.80762, 34.44957],
[133.80765, 34.4494],
[133.80779, 34.44837],
[133.80789, 34.44765],
[133.80793, 34.44736],
[133.80804, 34.4467],
[133.80813, 34.44589],
[133.80828, 34.4445],
[133.80825, 34.4442],
[133.80833, 34.44366],
[133.80837, 34.44336],
[133.8084, 34.44309],
[133.80842, 34.44263],
[133.80842, 34.44233],
[133.80842, 34.44203],
[133.8084, 34.44183],
[133.8083, 34.44071],
[133.80828, 34.44059],
[133.80819, 34.4399],
[133.80807, 34.43932],
[133.80763, 34.43745],
[133.80731, 34.4362],
[133.80714, 34.43555],
[133.80706, 34.43527],
[133.80691, 34.4346],
[133.80643, 34.43278],
[133.80594, 34.43084],
[133.8057, 34.42991],
[133.80545, 34.42891],
[133.8054, 34.42866],
[133.805, 34.42706],
[133.80491, 34.42672],
[133.80491, 34.4267],
[133.80463, 34.42556],
[133.80445, 34.42488],
[133.80435, 34.42447],
[133.8043, 34.4243],
[133.80403, 34.42323],
[133.804, 34.4231],
[133.8039, 34.42246],
[133.80386, 34.42206],
[133.80385, 34.42197],
[133.80384, 34.42187],
[133.80382, 34.42161],
[133.80383, 34.42155],
[133.80383, 34.42146],
[133.80382, 34.4212],
[133.80383, 34.42093],
[133.80384, 34.42074],
[133.8039, 34.42026],
[133.80393, 34.41992],
[133.80403, 34.41939],
[133.80425, 34.41856],
[133.80446, 34.41786],
[133.80506, 34.41631],
[133.80553, 34.41514],
[133.80581, 34.41441],
[133.80615, 34.41329],
[133.80657, 34.41181],
[133.80675, 34.41122],
[133.8068, 34.41106],
[133.80715, 34.40959],
[133.80768, 34.40746],
[133.8082, 34.40555],
[133.80908, 34.4024],
[133.80918, 34.40207],
[133.80999, 34.39922],
[133.81061, 34.39702],
[133.81079, 34.39659],
[133.8111, 34.39597],
[133.8114, 34.39544],
[133.81192, 34.39468],
[133.81254, 34.39392],
[133.8126, 34.39384],
[133.81397, 34.39239],
[133.81532, 34.39103],
[133.81581, 34.39044],
[133.81636, 34.38977],
[133.81687, 34.38902],
[133.81732, 34.38818],
[133.81775, 34.38715],
[133.81804, 34.38621],
[133.81811, 34.386],
[133.81902, 34.38312],
[133.81974, 34.38088],
[133.8208, 34.37748],
[133.82082, 34.37741],
[133.82236, 34.3725],
[133.8236, 34.36876],
[133.82361, 34.36872],
[133.82487, 34.365],
[133.82609, 34.3614],
[133.82654, 34.36006],
[133.82729, 34.35785],
[133.82828, 34.35487],
[133.82839, 34.35449],
[133.82854, 34.35392],
[133.82861, 34.35335],
[133.82865, 34.35271],
[133.8286, 34.35153],
[133.82857, 34.35127],
[133.82854, 34.35097],
[133.82835, 34.34966],
[133.82809, 34.34812],
[133.8277, 34.34593],
[133.82715, 34.34275],
[133.82707, 34.34234],
[133.82665, 34.33997],
[133.82636, 34.33823],
[133.82627, 34.33756],
[133.82627, 34.33706],
[133.82626, 34.3366],
[133.82642, 34.33542],
[133.82657, 34.33461],
[133.82678, 34.33343],
[133.82688, 34.33296],
[133.82703, 34.33215],
[133.82724, 34.33088],
[133.82714, 34.33036],
[133.8271, 34.33009],
[133.82706, 34.3297],
[133.82702, 34.32933],
[133.8268, 34.3284],
[133.82653, 34.32749],
[133.82626, 34.32674],
[133.82574, 34.32565],
[133.82473, 34.32388],
[133.82344, 34.32159],
[133.82326, 34.32129],
[133.82235, 34.31973],
[133.82224, 34.31954]
],
[
[133.81778, 34.31274],
[133.81853, 34.31395],
[133.82015, 34.31632],
[133.82147, 34.31828],
[133.82224, 34.31954]
],
[
[133.82224, 34.31954],
[133.82207, 34.31872],
[133.82199, 34.31824],
[133.82198, 34.31764],
[133.82204, 34.31701],
[133.82219, 34.31661],
[133.8226, 34.31597],
[133.82315, 34.31523],
[133.8237, 34.31472],
[133.8241, 34.3144],
[133.82457, 34.31411],
[133.82565, 34.31357]
]
]
}
}
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
import React, { FC, useEffect } from "react";
import { Platform, Text } from "react-native";
import { useFavoriteStation } from "../../stateBox/useFavoriteStation";
type Props = {
currentStation: any[];
isMatsuyama: boolean;
};
export const AddressText: FC<Props> = (props) => {
const { currentStation, isMatsuyama } = props;
const {lodAddMigration} = useFavoriteStation();
const [stationAddress, setStationAddress] = React.useState("");
useEffect(() => {
if (!!currentStation[0].jslodApi) {
fetch(`${currentStation[0].jslodApi}.json`)
.then((response) => response.json())
.then((data) => {
const c =
data[currentStation[0].jslodApi][
"http://dbpedia.org/ontology/address"
][0]["value"];
setStationAddress(c);
});
}else{
lodAddMigration();
}
}, [currentStation]);
return (
<Text
style={{
fontSize: parseInt("10%"),
color: isMatsuyama ? "white" : "#005170",
position: "absolute",
bottom: isMatsuyama ? Platform.OS === "ios"?"25.5%":"26.5%" : "0%",
textAlign: "center",
width: "100%",
fontWeight: "bold",
}}
>
{stationAddress}
</Text>
);
};

View File

@ -88,7 +88,7 @@ const 下枠左右マーク: TextStyle = {
fontWeight: "bold",
fontSize: parseInt("20%"),
color: "white",
paddingHorizontal: 10,
paddingHorizontal: 5,
textAlignVertical: "center",
};
const 下枠駅ナンバー: ViewStyle = {

View File

@ -11,6 +11,7 @@ import { StationNameArea } from "./StationNameArea";
import { StationNumberMaker } from "./StationNumberMaker";
import { NextPreStationLine } from "./NextPreStationLine";
import { LottieDelayView } from "./LottieDelayView";
import { AddressText } from "./AddressText";
import { useTrainMenu } from "../../stateBox/useTrainMenu";
export default function Sign(props) {
@ -162,6 +163,7 @@ export default function Sign(props) {
<View style={styleSheet[isMatsuyama ? "下帯内容B" : "下帯内容"]}>
<NextPreStationLine {...{ nexStation, preStation, isMatsuyama }} />
</View>
<AddressText {...{ currentStation, isMatsuyama }} />
</TouchableOpacity>
);
}
@ -181,10 +183,10 @@ const styleSheet = {
},
下帯: {
position: "absolute",
bottom: "0%",
bottom: "8%",
left: "0%",
width: "100%",
height: "30%",
height: "27%",
backgroundColor: "#0099CC",
},
下帯B: {
@ -192,7 +194,7 @@ const styleSheet = {
bottom: "0%",
left: "0%",
width: "100%",
height: "25%",
height: "26%",
backgroundColor: "#454545",
},
JRStyle: {
@ -205,8 +207,8 @@ const styleSheet = {
},
下帯内容: {
position: "absolute",
bottom: "0%",
height: "30%",
bottom: "8%",
height: "27%",
width: "100%",
alignItems: "center",
flexDirection: "column",
@ -214,7 +216,7 @@ const styleSheet = {
下帯内容B: {
position: "absolute",
bottom: "0%",
height: "25%",
height: "26%",
width: "100%",
alignItems: "center",
flexDirection: "column",

View File

@ -1,5 +1,5 @@
import React, { FC } from "react";
import { Text, TextStyle, View } from "react-native";
import { Platform, Text, TextStyle, View } from "react-native";
export const StationName: FC<{
stringData: { Station_JP: string; Station_EN: string };
ss: TextStyle;
@ -15,7 +15,7 @@ export const StationName: FC<{
const styleSheet: TextStyle = {
fontWeight: "bold",
fontSize: parseInt("15%"),
fontSize: Platform.OS === "ios" ? parseInt("14%") : parseInt("15%"),
color: "white",
flex: 1,
textAlignVertical: "center",

View File

@ -1,5 +1,5 @@
import React, { CSSProperties } from "react";
import { Text, TextStyle, View, ViewStyle } from "react-native";
import { Platform, Text, TextStyle, View, ViewStyle } from "react-native";
export const StationNameArea = (props) => {
const { currentStation, isMatsuyama } = props;
@ -14,6 +14,8 @@ export const StationNameArea = (props) => {
};
const Station_JP: TextStyle = {
letterSpacing: currentStation[0].Station_JP.length < 4 ? 15 : 0,
// iOSの場合、letterSPacingで末尾の文字の後ろにもpaddingが入るため、paddingLeftを設定
paddingLeft: currentStation[0].Station_JP.length < 4 &&Platform.OS === "ios" ? 15 : 0,
fontWeight: "bold",
fontSize: parseInt(currentStation[0].Station_JP.length < 6 ? "40%" : "25%"),

View File

@ -116,6 +116,7 @@ export const getStationList = async (props) => {
if (element.properties.name == stationName) {
data.lat = element.geometry.coordinates[1];
data.lng = element.geometry.coordinates[0];
data.jslodApi = element.properties.uri;
}
});
return data;
@ -182,6 +183,7 @@ export const getStationList = async (props) => {
JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/sakaide/",
lat: 34.313222,
lng: 133.856325,
jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/予讃線/坂出",
},
{
@ -196,6 +198,7 @@ export const getStationList = async (props) => {
JrHpUrl: "http://www.jr-odekake.net/eki/top.php?id=0651304",
lat: 34.462562,
lng: 133.807809,
jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/児島",
},
{
Station_JP: "宇多津",
@ -209,6 +212,7 @@ export const getStationList = async (props) => {
JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/utazu/",
lat: 34.306379,
lng: 133.813784,
jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/宇多津",
},
];
status = stationList;

View File

@ -6,9 +6,11 @@ import React, {
useLayoutEffect,
} from "react";
import { AS } from "../storageControl";
import { useStationList } from "./useStationList";
const initialState = {
favoriteStation: [],
setFavoriteStation: () => {},
lodAddMigration: () => {},
};
const FavoriteStationContext = createContext(initialState);
@ -19,6 +21,13 @@ export const useFavoriteStation = () => {
export const FavoriteStationProvider = ({ children }) => {
const [favoriteStation, setFavoriteStation] = useState([]);
const { getStationData } = useStationList();
const lodAddMigration = () => {
const migration = favoriteStation.map((d) => {
return getStationData(d[0].Station_JP);
});
setFavoriteStation(migration);
};
useEffect(() => {
AS.getItem("favoriteStation")
.then((d) => {
@ -29,7 +38,7 @@ export const FavoriteStationProvider = ({ children }) => {
}, []);
return (
<FavoriteStationContext.Provider
value={{ favoriteStation, setFavoriteStation }}
value={{ favoriteStation, setFavoriteStation, lodAddMigration }}
>
{children}
</FavoriteStationContext.Provider>

View File

@ -0,0 +1,56 @@
import React, {
createContext,
useContext,
useState,
useEffect,
useLayoutEffect,
FC,
} from "react";
import { AS } from "../storageControl";
import { getStationList } from "../lib/getStationList";
type initialStateType = {
originalStationList: any[];
setOriginalStationList: React.Dispatch<React.SetStateAction<any[]>>;
getStationData: (id: string) => void;
};
const initialState = {
originalStationList: [],
setOriginalStationList: () => {},
getStationData: () => {},
};
const StationListContext = createContext<initialStateType>(initialState);
type Props = {
children: React.ReactNode;
};
export const useStationList = () => {
return useContext(StationListContext);
};
export const StationListProvider: FC<Props> = ({ children }) => {
const [originalStationList, setOriginalStationList] = useState<any[]>([]);
useEffect(() => {
getStationList().then(setOriginalStationList);
}, []);
const getStationData: (name: string) => void = (name) => {
const returnArray = [];
Object.keys(originalStationList).forEach((key) => {
originalStationList[key].forEach((station) => {
if (station.Station_JP === name) {
if(!!station.jslodApi)returnArray.push(station);
}
});
});
return returnArray;
};
return (
<StationListContext.Provider
value={{ originalStationList, setOriginalStationList, getStationData }}
>
{children}
</StationListContext.Provider>
);
};