Merge commit 'c09c8c65532c05dba3379261aae424ed9bcbb31c' into develop
This commit is contained in:
commit
682944fb5a
@ -21,9 +21,10 @@ import { BigButton } from "./atom/BigButton";
|
|||||||
import { Switch } from "react-native-elements";
|
import { Switch } from "react-native-elements";
|
||||||
export default function AllTrainDiagramView() {
|
export default function AllTrainDiagramView() {
|
||||||
const { navigate } = useNavigation();
|
const { navigate } = useNavigation();
|
||||||
const { keyList } = useAllTrainDiagram();
|
const { keyList, allTrainDiagram } = useAllTrainDiagram();
|
||||||
const [input, setInput] = useState(""); // 文字入力
|
const [input, setInput] = useState(""); // 文字入力
|
||||||
const [keyBoardVisible, setKeyBoardVisible] = useState(false);
|
const [keyBoardVisible, setKeyBoardVisible] = useState(false);
|
||||||
|
const [useStationName, setUseStationName] = useState(false);
|
||||||
const [useRegex, setUseRegex] = useState(false);
|
const [useRegex, setUseRegex] = useState(false);
|
||||||
const regexTextStyle = {
|
const regexTextStyle = {
|
||||||
color: "white",
|
color: "white",
|
||||||
@ -75,7 +76,12 @@ export default function AllTrainDiagramView() {
|
|||||||
<FlatList
|
<FlatList
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
data={keyList?.filter((d) => {
|
data={keyList?.filter((d) => {
|
||||||
console.log(d);
|
if (useStationName) {
|
||||||
|
const ls = input.split(",").map((stationName) => {
|
||||||
|
return allTrainDiagram[d].includes(stationName);
|
||||||
|
});
|
||||||
|
return !ls.includes(false);
|
||||||
|
}
|
||||||
if (useRegex) {
|
if (useRegex) {
|
||||||
try {
|
try {
|
||||||
const regex = new RegExp(input);
|
const regex = new RegExp(input);
|
||||||
@ -100,6 +106,7 @@ export default function AllTrainDiagramView() {
|
|||||||
value={useRegex}
|
value={useRegex}
|
||||||
onValueChange={() => {
|
onValueChange={() => {
|
||||||
setUseRegex(!useRegex);
|
setUseRegex(!useRegex);
|
||||||
|
setUseStationName(false);
|
||||||
}}
|
}}
|
||||||
color="red"
|
color="red"
|
||||||
style={{ margin: 5 }}
|
style={{ margin: 5 }}
|
||||||
@ -107,6 +114,18 @@ export default function AllTrainDiagramView() {
|
|||||||
<Text style={{ color: "white", fontSize: 20, margin: 5 }}>
|
<Text style={{ color: "white", fontSize: 20, margin: 5 }}>
|
||||||
正規表現を使用
|
正規表現を使用
|
||||||
</Text>
|
</Text>
|
||||||
|
<Switch
|
||||||
|
value={useStationName}
|
||||||
|
onValueChange={() => {
|
||||||
|
setUseRegex(false);
|
||||||
|
setUseStationName(!useStationName);
|
||||||
|
}}
|
||||||
|
color="red"
|
||||||
|
style={{ margin: 5 }}
|
||||||
|
/>
|
||||||
|
<Text style={{ color: "white", fontSize: 20, margin: 5 }}>
|
||||||
|
駅名で検索
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
style={{
|
style={{
|
||||||
@ -119,13 +138,49 @@ export default function AllTrainDiagramView() {
|
|||||||
horizontal={true}
|
horizontal={true}
|
||||||
>
|
>
|
||||||
<Text style={regexTextStyle}>正規表現のサンプル:</Text>
|
<Text style={regexTextStyle}>正規表現のサンプル:</Text>
|
||||||
<Text style={regexTextButtonStyle} onPress={() => setInput("D")}>気動車を選択</Text>
|
<Text style={regexTextButtonStyle} onPress={() => setInput("D")}>
|
||||||
<Text style={regexTextButtonStyle} onPress={()=>setInput("3\\d\\d\\dM")}>マリンライナーを選択</Text>
|
気動車を選択
|
||||||
<Text style={regexTextButtonStyle} onPress={()=>setInput("[4,5]\\d\\d\\d[D,M]")}>ワンマン列車を選択</Text>
|
</Text>
|
||||||
<Text style={regexTextButtonStyle} onPress={()=>setInput("^\\d?\\dM")}>しおかぜを選択</Text>
|
<Text
|
||||||
<Text style={regexTextButtonStyle} onPress={()=>setInput("^\\d?[0,2,4,6,8]D")}>下り南風を選択</Text>
|
style={regexTextButtonStyle}
|
||||||
<Text style={regexTextButtonStyle} onPress={()=>setInput("^([\\d])+\\1")}>数字が二桁揃っている列車を選択</Text>
|
onPress={() => setInput("3\\d\\d\\dM")}
|
||||||
<Text style={{...regexTextButtonStyle,backgroundColor:"green"}} onPress={()=>Linking.openURL("https://qiita.com/tossh/items/635aea9a529b9deb3038")}>参考資料(Qiita)</Text>
|
>
|
||||||
|
マリンライナーを選択
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={regexTextButtonStyle}
|
||||||
|
onPress={() => setInput("[4,5]\\d\\d\\d[D,M]")}
|
||||||
|
>
|
||||||
|
ワンマン列車を選択
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={regexTextButtonStyle}
|
||||||
|
onPress={() => setInput("^\\d?\\dM")}
|
||||||
|
>
|
||||||
|
しおかぜを選択
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={regexTextButtonStyle}
|
||||||
|
onPress={() => setInput("^\\d?[0,2,4,6,8]D")}
|
||||||
|
>
|
||||||
|
下り南風を選択
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={regexTextButtonStyle}
|
||||||
|
onPress={() => setInput("^([\\d])+\\1")}
|
||||||
|
>
|
||||||
|
数字が二桁揃っている列車を選択
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={{ ...regexTextButtonStyle, backgroundColor: "green" }}
|
||||||
|
onPress={() =>
|
||||||
|
Linking.openURL(
|
||||||
|
"https://qiita.com/tossh/items/635aea9a529b9deb3038"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
参考資料(Qiita)
|
||||||
|
</Text>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
Loading…
Reference in New Issue
Block a user