import React, { useState } from "react"; import { View, Text, TouchableOpacity, ScrollView, Image, ToastAndroid, Platform, } from "react-native"; import { useNavigation } from "@react-navigation/native"; import * as Updates from "expo-updates"; import { AS } from "../../storageControl"; import icons from "../../assets/icons/icons"; import { setAlternateAppIcon, getAppIconName } from "expo-alternate-app-icons"; import { widthPercentageToDP } from "react-native-responsive-screen"; import { SheetHeaderItem } from "../atom/SheetHeaderItem"; export const LauncherIconSettings = ({ navigate }) => { const { goBack } = useNavigation(); const [iconList] = useState(icons()); const [currentIcon] = useState(getAppIconName()); return ( {currentIcon ? ( <> 現在のアイコン: {iconList.filter(({ id }) => id == currentIcon)[0].id} id == currentIcon)[0].icon} style={{ width: 50, height: 50, padding: 30, borderWidth: 1, borderRadius: 10, borderColor: "white", margin: 10, backgroundColor: "white", }} /> JR四国非公式アプリ ) : ( <> )} {iconList.map(({ name, icon, id }) => { return ( { setAlternateAppIcon(id) .then((res) => { AS.setItem("isSetIcon", "true"); if (Platform.OS === "android") { ToastAndroid.show( "アイコンを変更しました。アプリを再起動します。", ToastAndroid.SHORT ); } else if (Platform.OS === "ios") { Updates.reloadAsync(); } }) .catch((err) => { alert(err); }); }} > {id} ); })} ); };