delete action
parent
d8b3f14658
commit
7ffb26c9a5
|
@ -86,6 +86,10 @@
|
||||||
},
|
},
|
||||||
"modeSpecificColors": "Modus spezifische Farben"
|
"modeSpecificColors": "Modus spezifische Farben"
|
||||||
},
|
},
|
||||||
|
"modalDotsEditAction": {
|
||||||
|
"duplicateAction": "Aktion duplizieren",
|
||||||
|
"deleteAction": "Aktion löschen"
|
||||||
|
},
|
||||||
"editActionAnimationsCardContent": {
|
"editActionAnimationsCardContent": {
|
||||||
"animationsIn": "Animations in",
|
"animationsIn": "Animations in",
|
||||||
"animationsOut": "Animations out",
|
"animationsOut": "Animations out",
|
||||||
|
|
|
@ -86,6 +86,10 @@
|
||||||
},
|
},
|
||||||
"modeSpecificColors": "Mode specific colors"
|
"modeSpecificColors": "Mode specific colors"
|
||||||
},
|
},
|
||||||
|
"modalDotsEditAction": {
|
||||||
|
"duplicateAction": "Duplicate action",
|
||||||
|
"deleteAction": "Delete action"
|
||||||
|
},
|
||||||
"editActionAnimationsCardContent": {
|
"editActionAnimationsCardContent": {
|
||||||
"animationsIn": "Animations in",
|
"animationsIn": "Animations in",
|
||||||
"animationsOut": "Animations out",
|
"animationsOut": "Animations out",
|
||||||
|
|
|
@ -112,7 +112,28 @@ export function MyDefaultModalHeader({ title, closeModal }) {
|
||||||
);
|
);
|
||||||
} */
|
} */
|
||||||
|
|
||||||
export function MyDotsModal({ isOpen, closeModal, data }) {
|
export function MyDotsModal({ modalData }) {
|
||||||
|
const [isDotsModalOpen, setIsDotsModalOpen] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MyIconButton
|
||||||
|
iconName="dots-vertical"
|
||||||
|
iconSize={24}
|
||||||
|
style={AppStyles.headerNavigationIcons}
|
||||||
|
onPress={() => setIsDotsModalOpen(true)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DotsModal
|
||||||
|
isOpen={isDotsModalOpen}
|
||||||
|
closeModal={() => setIsDotsModalOpen(false)}
|
||||||
|
data={modalData}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DotsModal({ isOpen, closeModal, data }) {
|
||||||
const appContext = useContext(AppContext);
|
const appContext = useContext(AppContext);
|
||||||
|
|
||||||
const listItemStyle = (isFirst, isLast) => {
|
const listItemStyle = (isFirst, isLast) => {
|
||||||
|
|
|
@ -13,9 +13,12 @@ import {
|
||||||
} from "../../../deviceTabButton";
|
} from "../../../deviceTabButton";
|
||||||
import Card from "../../../../../Components/Card";
|
import Card from "../../../../../Components/Card";
|
||||||
import MyDropdown from "../../../../../Components/Dropdown";
|
import MyDropdown from "../../../../../Components/Dropdown";
|
||||||
import { useContext, useEffect, useRef, useState } from "react";
|
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { AppContext, AppStyles, ModalContainer } from "../../../../../utils";
|
import { AppContext, AppStyles, ModalContainer } from "../../../../../utils";
|
||||||
import { MyPickerModalListItem } from "../../../../../Components/Modal";
|
import {
|
||||||
|
MyDotsModal,
|
||||||
|
MyPickerModalListItem,
|
||||||
|
} from "../../../../../Components/Modal";
|
||||||
import { MyColorPickerV2 } from "../../../../../Components/ColorPicker";
|
import { MyColorPickerV2 } from "../../../../../Components/ColorPicker";
|
||||||
import Animated, {
|
import Animated, {
|
||||||
useAnimatedStyle,
|
useAnimatedStyle,
|
||||||
|
@ -27,6 +30,7 @@ import EditActionAnimationsCardContent, {
|
||||||
EditActionAdjustmentsContent,
|
EditActionAdjustmentsContent,
|
||||||
} from "..";
|
} from "..";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useFocusEffect } from "@react-navigation/native";
|
||||||
|
|
||||||
function LightModeDefaultColor({
|
function LightModeDefaultColor({
|
||||||
sharedColor,
|
sharedColor,
|
||||||
|
@ -79,6 +83,39 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
||||||
|
|
||||||
const { actionId, deviceFirmwareVersion } = route.params;
|
const { actionId, deviceFirmwareVersion } = route.params;
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
navigation.setOptions({
|
||||||
|
headerRight: () => (
|
||||||
|
<MyDotsModal
|
||||||
|
modalData={[
|
||||||
|
{
|
||||||
|
icon: "content-duplicate",
|
||||||
|
label: t(
|
||||||
|
"screens.device.scenes.modalDotsEditAction.duplicateAction"
|
||||||
|
),
|
||||||
|
onPress: () => {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "trash-can",
|
||||||
|
label: t(
|
||||||
|
"screens.device.scenes.modalDotsEditAction.deleteAction"
|
||||||
|
),
|
||||||
|
onPress: () => {
|
||||||
|
appContext.setDeviceSceneActions((actions) =>
|
||||||
|
actions.filter((a) => a.actionId !== actionId)
|
||||||
|
);
|
||||||
|
|
||||||
|
navigation.goBack();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
const supportedDeviceLightModes =
|
const supportedDeviceLightModes =
|
||||||
appContext.deviceFirmwareModes.lightModes.filter((lightMode) =>
|
appContext.deviceFirmwareModes.lightModes.filter((lightMode) =>
|
||||||
lightMode.supportedFirmwareVersions.includes(deviceFirmwareVersion)
|
lightMode.supportedFirmwareVersions.includes(deviceFirmwareVersion)
|
||||||
|
@ -90,8 +127,9 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
||||||
|
|
||||||
const [lightModeDefaultColors, setLightModeDefaultColors] = useState([]);
|
const [lightModeDefaultColors, setLightModeDefaultColors] = useState([]);
|
||||||
|
|
||||||
|
// check if selectedSceneAction exists before accessing modeId as the action could be deleted by the user
|
||||||
const selectedLightMode = supportedDeviceLightModes.find(
|
const selectedLightMode = supportedDeviceLightModes.find(
|
||||||
(s) => s.id === selectedSceneAction.modeId
|
(s) => s.id === (selectedSceneAction && selectedSceneAction.modeId)
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -109,7 +147,7 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
||||||
setLightModeDefaultColors(selectedSceneAction.modeAdjustments.colors);
|
setLightModeDefaultColors(selectedSceneAction.modeAdjustments.colors);
|
||||||
setSelectedDefaultLightModeColor(0);
|
setSelectedDefaultLightModeColor(0);
|
||||||
}
|
}
|
||||||
}, [selectedSceneAction.modeId]);
|
}, [selectedSceneAction?.modeId]);
|
||||||
|
|
||||||
const saveColorsToModeAdjustments = () => {
|
const saveColorsToModeAdjustments = () => {
|
||||||
appContext.setDeviceSceneActions((arr) => {
|
appContext.setDeviceSceneActions((arr) => {
|
||||||
|
@ -128,6 +166,8 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!selectedSceneAction) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -3,7 +3,6 @@ import Card from "../../../../Components/Card";
|
||||||
import {
|
import {
|
||||||
AppContext,
|
AppContext,
|
||||||
AppStyles,
|
AppStyles,
|
||||||
Constants,
|
|
||||||
IsPlatformIos,
|
IsPlatformIos,
|
||||||
ModalContainer,
|
ModalContainer,
|
||||||
} from "../../../../utils";
|
} from "../../../../utils";
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { FlatList, Text, TouchableOpacity, View } from "react-native";
|
import { Text, TouchableOpacity, View } from "react-native";
|
||||||
import Card from "../../Components/Card";
|
import Card from "../../Components/Card";
|
||||||
import {
|
import {
|
||||||
AppContext,
|
AppContext,
|
||||||
AppSelectedUserDevice,
|
AppSelectedUserDevice,
|
||||||
AppStyles,
|
|
||||||
Constants,
|
Constants,
|
||||||
GetDevice,
|
GetDevice,
|
||||||
VibrateShort,
|
VibrateShort,
|
||||||
|
@ -13,14 +12,12 @@ import MyDropdown from "../../Components/Dropdown";
|
||||||
import MyIcon from "../../Components/Icon";
|
import MyIcon from "../../Components/Icon";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import MyResult from "../../Components/Result";
|
import MyResult from "../../Components/Result";
|
||||||
import { MyIconButton, MyTextButton } from "../../Components/Button";
|
import { MyTextButton } from "../../Components/Button";
|
||||||
import { useFocusEffect } from "@react-navigation/native";
|
import { useFocusEffect } from "@react-navigation/native";
|
||||||
import { Divider } from "../../Components/Divider";
|
import { Divider } from "../../Components/Divider";
|
||||||
import { MyColorSwatch } from "../../Components/ColorPicker";
|
import { MyColorSwatch } from "../../Components/ColorPicker";
|
||||||
import { MyDotsModal } from "../../Components/Modal";
|
import { MyDotsModal } from "../../Components/Modal";
|
||||||
import DraggableFlatList, {
|
import DraggableFlatList, {
|
||||||
NestableDraggableFlatList,
|
|
||||||
NestableScrollContainer,
|
|
||||||
ScaleDecorator,
|
ScaleDecorator,
|
||||||
} from "react-native-draggable-flatlist";
|
} from "react-native-draggable-flatlist";
|
||||||
|
|
||||||
|
@ -29,7 +26,6 @@ export default function SceneView({ navigation }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [device, setDevice] = useState();
|
const [device, setDevice] = useState();
|
||||||
const [isDotsModalOpen, setIsDotsModalOpen] = useState(false);
|
|
||||||
|
|
||||||
const getSelectedDeviceSceneName = () => {
|
const getSelectedDeviceSceneName = () => {
|
||||||
let scene;
|
let scene;
|
||||||
|
@ -53,11 +49,57 @@ export default function SceneView({ navigation }) {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
headerRight: () =>
|
headerRight: () =>
|
||||||
device.selectedScene !== "" ? (
|
device.selectedScene !== "" ? (
|
||||||
<MyIconButton
|
<MyDotsModal
|
||||||
iconName="dots-vertical"
|
modalData={[
|
||||||
iconSize={24}
|
{
|
||||||
style={AppStyles.headerNavigationIcons}
|
icon: "pencil",
|
||||||
onPress={() => setIsDotsModalOpen(true)}
|
label: t(
|
||||||
|
"screens.device.scenes.modalDotsScene.changeSceneName"
|
||||||
|
),
|
||||||
|
onPress: () =>
|
||||||
|
navigation.navigate("modalUpdateSceneName", {
|
||||||
|
deviceSelectedScene: device.selectedScene,
|
||||||
|
sceneName: getSelectedDeviceSceneName(),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "trash-can",
|
||||||
|
label: t(
|
||||||
|
"screens.device.scenes.modalDotsScene.deleteScene"
|
||||||
|
),
|
||||||
|
onPress: () => {
|
||||||
|
appContext.setDeviceScenes((scenes) =>
|
||||||
|
scenes.filter(
|
||||||
|
(scene) =>
|
||||||
|
scene.sceneId !==
|
||||||
|
GetDevice(appContext.devices).selectedScene
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
appContext.setDevices((arr) => {
|
||||||
|
const newArr = [...arr];
|
||||||
|
|
||||||
|
const foundDeviceIndex = arr.findIndex(
|
||||||
|
(d) => d.id === AppSelectedUserDevice.current.id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (foundDeviceIndex !== -1) {
|
||||||
|
newArr[foundDeviceIndex].selectedScene = "";
|
||||||
|
|
||||||
|
appContext.setDeviceSceneActions((actions) =>
|
||||||
|
actions.filter(
|
||||||
|
(action) =>
|
||||||
|
action.sceneId !==
|
||||||
|
newArr[foundDeviceIndex].selectedScene
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
) : null,
|
) : null,
|
||||||
});
|
});
|
||||||
|
@ -158,57 +200,6 @@ export default function SceneView({ navigation }) {
|
||||||
onRelease={VibrateShort}
|
onRelease={VibrateShort}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<MyDotsModal
|
|
||||||
isOpen={isDotsModalOpen}
|
|
||||||
closeModal={() => setIsDotsModalOpen(false)}
|
|
||||||
data={[
|
|
||||||
{
|
|
||||||
icon: "pencil",
|
|
||||||
label: t("screens.device.scenes.modalDotsScene.changeSceneName"),
|
|
||||||
onPress: () =>
|
|
||||||
navigation.navigate("modalUpdateSceneName", {
|
|
||||||
deviceSelectedScene: device.selectedScene,
|
|
||||||
sceneName: getSelectedDeviceSceneName(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "trash-can",
|
|
||||||
label: t("screens.device.scenes.modalDotsScene.deleteScene"),
|
|
||||||
onPress: () => {
|
|
||||||
appContext.setDeviceScenes((scenes) =>
|
|
||||||
scenes.filter(
|
|
||||||
(scene) =>
|
|
||||||
scene.sceneId !==
|
|
||||||
GetDevice(appContext.devices).selectedScene
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
appContext.setDevices((arr) => {
|
|
||||||
const newArr = [...arr];
|
|
||||||
|
|
||||||
const foundDeviceIndex = arr.findIndex(
|
|
||||||
(d) => d.id === AppSelectedUserDevice.current.id
|
|
||||||
);
|
|
||||||
|
|
||||||
if (foundDeviceIndex !== -1) {
|
|
||||||
newArr[foundDeviceIndex].selectedScene = "";
|
|
||||||
|
|
||||||
appContext.setDeviceSceneActions((actions) =>
|
|
||||||
actions.filter(
|
|
||||||
(action) =>
|
|
||||||
action.sceneId !==
|
|
||||||
newArr[foundDeviceIndex].selectedScene
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newArr;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue