アイコン更新画面を作成

This commit is contained in:
harukin-expo-dev-env
2025-03-10 15:24:11 +00:00
parent a9488b98bc
commit 0838414540
5 changed files with 210 additions and 19 deletions

View File

@@ -1,23 +1,23 @@
import React, { useEffect, useState } from "react";
import { View, Text, TouchableOpacity, ScrollView, Image } from "react-native";
import React, { useState } from "react";
import {
View,
Text,
TouchableOpacity,
ScrollView,
Image,
ToastAndroid,
Platform,
} 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 { setAlternateAppIcon, getAppIconName } 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());
const [iconList] = useState(icons());
const [currentIcon] = useState(getAppIconName());
return (
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
<View style={{ backgroundColor: "#0099CC", flexDirection: "row" }}>
@@ -81,9 +81,7 @@ export const LauncherIconSettings = ({ navigate }) => {
}}
>
<Image
source={
iconList.filter(({ id }) => id == currentIcon)[0].icon
}
source={iconList.filter(({ id }) => id == currentIcon)[0].icon}
style={{
width: 50,
height: 50,
@@ -128,7 +126,13 @@ export const LauncherIconSettings = ({ navigate }) => {
onPress={() => {
setAlternateAppIcon(id)
.then((res) => {
alert(res);
AS.setItem("isSetIcon", "true");
if (Platform.OS === "android") {
ToastAndroid.show(
"アイコンを変更しました。アプリを再起動します。",
ToastAndroid.SHORT
);
}
})
.catch((err) => {
alert(err);