アイコンの設定更新
This commit is contained in:
147
components/Settings/LauncherIconSettings.js
Normal file
147
components/Settings/LauncherIconSettings.js
Normal file
@@ -0,0 +1,147 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { View, Text, TouchableOpacity, ScrollView, Image } from "react-native";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { CheckBox } from "react-native-elements";
|
||||
import { AS } from "../../storageControl";
|
||||
import icons from "../../assets/icons/icons";
|
||||
import app from "../../app.json";
|
||||
import { ListItem } from "native-base";
|
||||
import {
|
||||
setAlternateAppIcon,
|
||||
resetAppIcon,
|
||||
getAppIconName,
|
||||
supportsAlternateIcons,
|
||||
} from "expo-alternate-app-icons";
|
||||
import { widthPercentageToDP } from "react-native-responsive-screen";
|
||||
|
||||
export const LauncherIconSettings = ({ navigate }) => {
|
||||
const { goBack } = useNavigation();
|
||||
const [iconList, ] = useState(icons());
|
||||
const [currentIcon, ] = useState(getAppIconName());
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
<View style={{ backgroundColor: "#0099CC", flexDirection: "row" }}>
|
||||
<View style={{ flex: 1 }}>
|
||||
<TouchableOpacity
|
||||
onPress={goBack}
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
fontWeight: "bold",
|
||||
textAlign: "left",
|
||||
textAlignVertical: "center",
|
||||
color: "white",
|
||||
padding: 10,
|
||||
}}
|
||||
>
|
||||
< 設定
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
fontWeight: "bold",
|
||||
textAlign: "center",
|
||||
color: "white",
|
||||
padding: 10,
|
||||
}}
|
||||
>
|
||||
アイコン設定
|
||||
</Text>
|
||||
<View style={{ flex: 1 }}></View>
|
||||
</View>
|
||||
<ScrollView style={{ flex: 1, backgroundColor: "white" }}>
|
||||
{currentIcon ? (
|
||||
<>
|
||||
<Text
|
||||
style={{
|
||||
backgroundColor: "#DDDDDD",
|
||||
}}
|
||||
>
|
||||
現在のアイコン:
|
||||
{iconList.filter(({ id }) => id == currentIcon)[0].id}
|
||||
</Text>
|
||||
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "cokumn",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "#DDDDDD",
|
||||
padding: 10,
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
source={
|
||||
iconList.filter(({ id }) => id == currentIcon)[0].icon
|
||||
}
|
||||
style={{
|
||||
width: 50,
|
||||
height: 50,
|
||||
padding: 30,
|
||||
borderWidth: 1,
|
||||
borderRadius: 10,
|
||||
borderColor: "white",
|
||||
margin: 10,
|
||||
backgroundColor: "white",
|
||||
}}
|
||||
/>
|
||||
<Text>JR四国非公式アプリ</Text>
|
||||
</View>
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap",
|
||||
alignContent: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
{iconList.map(({ name, icon, id }) => {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={id}
|
||||
style={{
|
||||
margin: 10,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
width: widthPercentageToDP("30%"),
|
||||
maxWidth: 60,
|
||||
height: 100,
|
||||
|
||||
borderColor: "#999999",
|
||||
borderWidth: id == currentIcon ? 2 : 0,
|
||||
borderRadius: 10,
|
||||
}}
|
||||
onPress={() => {
|
||||
setAlternateAppIcon(id)
|
||||
.then((res) => {
|
||||
alert(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Image source={icon} style={{ width: 50, height: 50 }} />
|
||||
<Text>{id}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
};
|
@@ -120,106 +120,62 @@ export const SettingTopPage = ({
|
||||
falseText={"リンクメニュー"}
|
||||
trueText={"列車位置情報"}
|
||||
/>
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
<SettingList
|
||||
string="お気に入り登録の並び替え"
|
||||
onPress={() =>
|
||||
navigation.navigate("setting", { screen: "FavoriteSettings" })
|
||||
}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>お気に入り登録の並び替え</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
/>
|
||||
<SettingList
|
||||
string={`通知設定${
|
||||
expoPushToken == "" ? "(通知設定をオンにしてください)" : "(β)"
|
||||
}`}
|
||||
onPress={() =>
|
||||
navigation.navigate("setting", { screen: "NotificationSettings" })
|
||||
}
|
||||
disabled={expoPushToken == ""}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>
|
||||
通知設定
|
||||
{expoPushToken == "" ? "(通知設定をオンにしてください)" : "(β)"}
|
||||
</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
/>
|
||||
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
<SettingList
|
||||
string="レイアウト設定"
|
||||
onPress={() =>
|
||||
navigation.navigate("setting", { screen: "LayoutSettings" })
|
||||
}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>レイアウト設定</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
/>
|
||||
{Platform.OS === "android" ? (
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
<SettingList
|
||||
string="ウィジェット設定"
|
||||
onPress={() =>
|
||||
navigation.navigate("setting", { screen: "WidgetSettings" })
|
||||
}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>ウィジェット設定</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
/>
|
||||
) : null}
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
<SettingList
|
||||
string="アイコン設定"
|
||||
onPress={() =>
|
||||
navigation.navigate("setting", { screen: "LauncherIconSettings" })
|
||||
}
|
||||
/>
|
||||
<SettingList
|
||||
string="プライバシーポリシー"
|
||||
onPress={() =>
|
||||
Linking.openURL(
|
||||
"https://nexcloud.haruk.in/sites/press-harukin/JRShikokuApps/policy"
|
||||
)
|
||||
}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>プライバシーポリシー</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
/>
|
||||
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
<SettingList
|
||||
string="開発情報"
|
||||
onPress={() =>
|
||||
Linking.openURL("https://nexcloud.haruk.in/s/2WFEN5oLPGtrRqT")
|
||||
}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>開発情報</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
/>
|
||||
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
<SettingList
|
||||
string="運営Twitter"
|
||||
onPress={() => Linking.openURL("https://twitter.com/Xprocess_main")}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>運営Twitter</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
/>
|
||||
|
||||
{/* <ListItem style={{ flexDirection: "row" }} onPress={() => testNFC()}>
|
||||
<Text
|
||||
@@ -258,3 +214,20 @@ export const SettingTopPage = ({
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const SettingList = ({ string, onPress, disabled }) => {
|
||||
return (
|
||||
<ListItem
|
||||
activeScale={0.95}
|
||||
Component={TouchableScale}
|
||||
bottomDivider
|
||||
onPress={onPress}
|
||||
disabled={disabled}
|
||||
>
|
||||
<ListItem.Content>
|
||||
<ListItem.Title>{string}</ListItem.Title>
|
||||
</ListItem.Content>
|
||||
<ListItem.Chevron />
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
|
@@ -23,6 +23,7 @@ import { LayoutSettings } from "./LayoutSettings";
|
||||
import { FavoriteSettings } from "./FavoriteSettings";
|
||||
import { WidgetSettings } from "./WidgetSettings";
|
||||
import { NotificationSettings } from "./NotificationSettings";
|
||||
import { LauncherIconSettings } from "./LauncherIconSettings";
|
||||
|
||||
const Stack = createStackNavigator();
|
||||
export default function Setting(props) {
|
||||
@@ -148,6 +149,18 @@ export default function Setting(props) {
|
||||
>
|
||||
{(props) => <WidgetSettings {...props} navigate={navigate} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="LauncherIconSettings"
|
||||
options={{
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
}}
|
||||
>
|
||||
{(props) => <LauncherIconSettings {...props} navigate={navigate} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="FavoriteSettings"
|
||||
options={{
|
||||
|
Reference in New Issue
Block a user