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";
|
||||
export default function AllTrainDiagramView() {
|
||||
const { navigate } = useNavigation();
|
||||
const { keyList } = useAllTrainDiagram();
|
||||
const { keyList, allTrainDiagram } = useAllTrainDiagram();
|
||||
const [input, setInput] = useState(""); // 文字入力
|
||||
const [keyBoardVisible, setKeyBoardVisible] = useState(false);
|
||||
const [useStationName, setUseStationName] = useState(false);
|
||||
const [useRegex, setUseRegex] = useState(false);
|
||||
const regexTextStyle = {
|
||||
color: "white",
|
||||
@ -75,7 +76,12 @@ export default function AllTrainDiagramView() {
|
||||
<FlatList
|
||||
style={{ flex: 1 }}
|
||||
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) {
|
||||
try {
|
||||
const regex = new RegExp(input);
|
||||
@ -100,6 +106,7 @@ export default function AllTrainDiagramView() {
|
||||
value={useRegex}
|
||||
onValueChange={() => {
|
||||
setUseRegex(!useRegex);
|
||||
setUseStationName(false);
|
||||
}}
|
||||
color="red"
|
||||
style={{ margin: 5 }}
|
||||
@ -107,6 +114,18 @@ export default function AllTrainDiagramView() {
|
||||
<Text style={{ color: "white", fontSize: 20, margin: 5 }}>
|
||||
正規表現を使用
|
||||
</Text>
|
||||
<Switch
|
||||
value={useStationName}
|
||||
onValueChange={() => {
|
||||
setUseRegex(false);
|
||||
setUseStationName(!useStationName);
|
||||
}}
|
||||
color="red"
|
||||
style={{ margin: 5 }}
|
||||
/>
|
||||
<Text style={{ color: "white", fontSize: 20, margin: 5 }}>
|
||||
駅名で検索
|
||||
</Text>
|
||||
</View>
|
||||
<ScrollView
|
||||
style={{
|
||||
@ -119,13 +138,49 @@ export default function AllTrainDiagramView() {
|
||||
horizontal={true}
|
||||
>
|
||||
<Text style={regexTextStyle}>正規表現のサンプル:</Text>
|
||||
<Text style={regexTextButtonStyle} onPress={() => setInput("D")}>気動車を選択</Text>
|
||||
<Text style={regexTextButtonStyle} onPress={()=>setInput("3\\d\\d\\dM")}>マリンライナーを選択</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>
|
||||
<Text style={regexTextButtonStyle} onPress={() => setInput("D")}>
|
||||
気動車を選択
|
||||
</Text>
|
||||
<Text
|
||||
style={regexTextButtonStyle}
|
||||
onPress={() => setInput("3\\d\\d\\dM")}
|
||||
>
|
||||
マリンライナーを選択
|
||||
</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>
|
||||
<View
|
||||
style={{
|
||||
|
Loading…
Reference in New Issue
Block a user