ほぼすべての駅名標機能で内部ブラウザを利用できるように変更

This commit is contained in:
harukin-OneMix4 2023-06-18 03:08:13 +09:00
parent 320a94565d
commit a83bb27f60
3 changed files with 51 additions and 9 deletions

View File

@ -43,7 +43,13 @@ export const StationDeteilView = (props) => {
} }
setTrainBus(data[0]); setTrainBus(data[0]);
}, [currentStation]); }, [currentStation]);
const info =
currentStation &&
(currentStation[0].StationTimeTable.match(".pdf")
? `https://docs.google.com/viewer?url=${encodeURI(
currentStation[0].StationTimeTable
)}&embedded=true`
: currentStation[0].StationTimeTable);
return ( return (
<ActionSheet <ActionSheet
ref={StationBoardAcSR} ref={StationBoardAcSR}
@ -86,13 +92,12 @@ export const StationDeteilView = (props) => {
setFavoriteStation={setFavoriteStation} setFavoriteStation={setFavoriteStation}
oP={() => { oP={() => {
navigate("howto", { navigate("howto", {
info: `https://docs.google.com/viewer?url=${encodeURI( info,
currentStation[0].StationTimeTable
)}&embedded=true`,
onExit, onExit,
}); });
StationBoardAcSR.current?.hide(); StationBoardAcSR.current?.hide();
}} }}
oLP={() => Linking.openURL(currentStation[0].StationTimeTable)}
/> />
</View> </View>
)} )}
@ -118,6 +123,12 @@ export const StationDeteilView = (props) => {
}); });
StationBoardAcSR.current?.hide(); StationBoardAcSR.current?.hide();
}} }}
oLP={() => {
Linking.openURL(
currentStation[0].JrHpUrl.replace("/index.html", "/") +
"/kounai_map.html"
);
}}
uri={currentStation[0].JrHpUrl.replace("/index.html", "/")} uri={currentStation[0].JrHpUrl.replace("/index.html", "/")}
/> />
)} )}
@ -128,7 +139,14 @@ export const StationDeteilView = (props) => {
backgroundColor={"#AD7FA8"} backgroundColor={"#AD7FA8"}
icon={<Foundation name="web" color="white" size={50} />} icon={<Foundation name="web" color="white" size={50} />}
flex={1} flex={1}
onPressButton={() => onPressButton={() => {
navigate("howto", {
info: currentStation[0].JrHpUrl,
onExit,
});
StationBoardAcSR.current?.hide();
}}
onLongPressButton={() =>
Linking.openURL(currentStation[0].JrHpUrl) Linking.openURL(currentStation[0].JrHpUrl)
} }
> >
@ -140,7 +158,14 @@ export const StationDeteilView = (props) => {
backgroundColor={"#8F5902"} backgroundColor={"#8F5902"}
icon={<FontAwesome name="table" color="white" size={50} />} icon={<FontAwesome name="table" color="white" size={50} />}
flex={1} flex={1}
onPressButton={() => onPressButton={() => {
navigate("howto", {
info,
onExit,
});
StationBoardAcSR.current?.hide();
}}
onLongPressButton={() =>
Linking.openURL(currentStation[0].StationTimeTable) Linking.openURL(currentStation[0].StationTimeTable)
} }
> >
@ -164,7 +189,14 @@ export const StationDeteilView = (props) => {
backgroundColor={"#CE5C00"} backgroundColor={"#CE5C00"}
icon={<Ionicons name="bus" color="white" size={50} />} icon={<Ionicons name="bus" color="white" size={50} />}
flex={1} flex={1}
onPressButton={() => Linking.openURL(trainBus.address)} onPressButton={() => {
navigate("howto", {
info: trainBus.address,
onExit,
});
StationBoardAcSR.current?.hide();
}}
onLongPressButton={() => Linking.openURL(trainBus.address)}
> >
並行バス 並行バス
</TicketBox> </TicketBox>
@ -332,6 +364,7 @@ const 駅構内図 = (props) => {
margin: 2, margin: 2,
}} }}
onPress={props.oP} onPress={props.oP}
onLongPress={props.oLP}
//onPress={() => setOpen(!open)} //onPress={() => setOpen(!open)}
> >
<View style={{ flex: 1 }} /> <View style={{ flex: 1 }} />

View File

@ -1,7 +1,14 @@
import { TouchableOpacity, Text } from "react-native"; import { TouchableOpacity, Text } from "react-native";
export const TicketBox = (props) => { export const TicketBox = (props) => {
const { icon, backgroundColor, flex, onPressButton, children } = props; const {
icon,
backgroundColor,
flex,
onPressButton,
children,
onLongPressButton,
} = props;
return ( return (
<TouchableOpacity <TouchableOpacity
style={{ style={{
@ -14,6 +21,7 @@ export const TicketBox = (props) => {
alignItems: "center", alignItems: "center",
}} }}
onPress={onPressButton} onPress={onPressButton}
onLongPress={onLongPressButton}
> >
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}> <Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
{children} {children}

View File

@ -21,6 +21,7 @@ export default function Sign(props) {
currentStation, currentStation,
originalStationList, originalStationList,
oP, oP,
oLP,
favoriteStation, favoriteStation,
setFavoriteStation, setFavoriteStation,
} = props; } = props;
@ -91,7 +92,7 @@ export default function Sign(props) {
}; };
const lottieRef = useRef(); const lottieRef = useRef();
return ( return (
<TouchableOpacity style={styleSheet.外枠} onPress={oP}> <TouchableOpacity style={styleSheet.外枠} onPress={oP} onLongPress={oLP}>
<StationNumberMaker currentStation={currentStation} /> <StationNumberMaker currentStation={currentStation} />
<StationNameArea currentStation={currentStation} /> <StationNameArea currentStation={currentStation} />
<TouchableOpacity <TouchableOpacity