added option to change layers after the action was created
parent
92d44ec406
commit
5c8a07ffcb
|
@ -58,6 +58,7 @@
|
||||||
"infoNoSceneSelected": "Keine Szene ausgewählt",
|
"infoNoSceneSelected": "Keine Szene ausgewählt",
|
||||||
"infoNoActionsAvailableInScene": "Keine Aktionen in der Szene vorhanden",
|
"infoNoActionsAvailableInScene": "Keine Aktionen in der Szene vorhanden",
|
||||||
"buttonAddAction": "Aktion hinzufügen",
|
"buttonAddAction": "Aktion hinzufügen",
|
||||||
|
"buttonChangeLayers": "Ebenen ändern",
|
||||||
"modalDotsScene": {
|
"modalDotsScene": {
|
||||||
"changeSceneName": "Szenennamen aktualisieren",
|
"changeSceneName": "Szenennamen aktualisieren",
|
||||||
"deleteScene": "Szene löschen"
|
"deleteScene": "Szene löschen"
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
"modeSpecificColors": "Modus spezifische Farben"
|
"modeSpecificColors": "Modus spezifische Farben"
|
||||||
},
|
},
|
||||||
"modalDotsEditAction": {
|
"modalDotsEditAction": {
|
||||||
"duplicateAction": "Aktion duplizieren",
|
"changeLayers": "Ebenen ändern",
|
||||||
"deleteAction": "Aktion löschen"
|
"deleteAction": "Aktion löschen"
|
||||||
},
|
},
|
||||||
"editActionAnimationsCardContent": {
|
"editActionAnimationsCardContent": {
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
"infoNoSceneSelected": "No scene selected",
|
"infoNoSceneSelected": "No scene selected",
|
||||||
"infoNoActionsAvailableInScene": "No actions available in the scene",
|
"infoNoActionsAvailableInScene": "No actions available in the scene",
|
||||||
"buttonAddAction": "Add action",
|
"buttonAddAction": "Add action",
|
||||||
|
"buttonChangeLayers": "Change layers",
|
||||||
"modalDotsScene": {
|
"modalDotsScene": {
|
||||||
"changeSceneName": "Change scene name",
|
"changeSceneName": "Change scene name",
|
||||||
"deleteScene": "Delete scene"
|
"deleteScene": "Delete scene"
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
"modeSpecificColors": "Mode specific colors"
|
"modeSpecificColors": "Mode specific colors"
|
||||||
},
|
},
|
||||||
"modalDotsEditAction": {
|
"modalDotsEditAction": {
|
||||||
"duplicateAction": "Duplicate action",
|
"changeLayers": "Change layers",
|
||||||
"deleteAction": "Delete action"
|
"deleteAction": "Delete action"
|
||||||
},
|
},
|
||||||
"editActionAnimationsCardContent": {
|
"editActionAnimationsCardContent": {
|
||||||
|
|
|
@ -47,7 +47,13 @@ function Layer({ number, selected, onPress }) {
|
||||||
export default function LayerSelectionModalContent({ navigation, route }) {
|
export default function LayerSelectionModalContent({ navigation, route }) {
|
||||||
const appContext = useContext(AppContext);
|
const appContext = useContext(AppContext);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [selectedLayer, setSelectedLayer] = useState([]);
|
|
||||||
|
const { actionId, selectedLayers } = route.params;
|
||||||
|
|
||||||
|
// The selected layers will be in the params if the user is changing the layers of an existing action
|
||||||
|
const [selectedLayer, setSelectedLayer] = useState(
|
||||||
|
selectedLayers === undefined ? [] : selectedLayers
|
||||||
|
);
|
||||||
|
|
||||||
const handleSelectLayerClick = (layerNumber) => {
|
const handleSelectLayerClick = (layerNumber) => {
|
||||||
if (selectedLayer.includes(layerNumber)) {
|
if (selectedLayer.includes(layerNumber)) {
|
||||||
|
@ -81,14 +87,23 @@ export default function LayerSelectionModalContent({ navigation, route }) {
|
||||||
|
|
||||||
<View style={{ alignItems: "center" }}>
|
<View style={{ alignItems: "center" }}>
|
||||||
<MyButton
|
<MyButton
|
||||||
title={t("screens.device.scenes.buttonAddAction")}
|
title={
|
||||||
|
actionId === undefined
|
||||||
|
? t("screens.device.scenes.buttonAddAction")
|
||||||
|
: t("screens.device.scenes.buttonChangeLayers")
|
||||||
|
}
|
||||||
style={{ marginTop: 20, width: 180 }}
|
style={{ marginTop: 20, width: 180 }}
|
||||||
disabled={selectedLayer.length === 0}
|
disabled={selectedLayer.length === 0}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
// The layers will be sorted in ascending order -> 1, 2, 3, 4
|
||||||
|
const sortedSelectedLayers = selectedLayer.sort((a, b) => a - b);
|
||||||
|
|
||||||
|
// New action will be created
|
||||||
|
if (actionId === undefined) {
|
||||||
const newAction = NewAction(
|
const newAction = NewAction(
|
||||||
GetDevice(appContext.devices).selectedScene,
|
GetDevice(appContext.devices).selectedScene,
|
||||||
Constants.actionType.layers,
|
Constants.actionType.layers,
|
||||||
{ layers: selectedLayer }
|
{ layers: sortedSelectedLayers }
|
||||||
);
|
);
|
||||||
|
|
||||||
appContext.setDeviceSceneActions((arr) => [...arr, newAction]);
|
appContext.setDeviceSceneActions((arr) => [...arr, newAction]);
|
||||||
|
@ -100,6 +115,26 @@ export default function LayerSelectionModalContent({ navigation, route }) {
|
||||||
...route.params,
|
...route.params,
|
||||||
actionType: Constants.actionType.layers,
|
actionType: Constants.actionType.layers,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// user is editing the layers of an existing action
|
||||||
|
|
||||||
|
appContext.setDeviceSceneActions((arr) => {
|
||||||
|
const newArr = [...arr];
|
||||||
|
|
||||||
|
const actionIndex = newArr.findIndex(
|
||||||
|
(item) => item.actionId === actionId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (actionIndex !== -1) {
|
||||||
|
newArr[actionIndex].modeAdjustments.layers =
|
||||||
|
sortedSelectedLayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
|
|
||||||
|
navigation.goBack();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -34,6 +34,7 @@ import {
|
||||||
RenderHeaderRight,
|
RenderHeaderRight,
|
||||||
} from "..";
|
} from "..";
|
||||||
import { MyPickerModalListItem } from "../../../../../Components/Modal";
|
import { MyPickerModalListItem } from "../../../../../Components/Modal";
|
||||||
|
import { ActionTypeIconName } from "../../../scene";
|
||||||
|
|
||||||
// This component is used by layers and ambilight
|
// This component is used by layers and ambilight
|
||||||
export default function LightsEditActionModalContent({ navigation, route }) {
|
export default function LightsEditActionModalContent({ navigation, route }) {
|
||||||
|
@ -64,6 +65,22 @@ export default function LightsEditActionModalContent({ navigation, route }) {
|
||||||
appContext={appContext}
|
appContext={appContext}
|
||||||
navigation={navigation}
|
navigation={navigation}
|
||||||
t={t}
|
t={t}
|
||||||
|
modalData={
|
||||||
|
actionType === Constants.actionType.layers && [
|
||||||
|
{
|
||||||
|
icon: ActionTypeIconName(Constants.actionType.layers),
|
||||||
|
label: t(
|
||||||
|
"screens.device.scenes.editActions.modalDotsEditAction.changeLayers"
|
||||||
|
),
|
||||||
|
onPress: () =>
|
||||||
|
navigation.navigate("modalLayerSelection", {
|
||||||
|
deviceFirmwareVersion: deviceFirmwareVersion,
|
||||||
|
actionId: action.actionId,
|
||||||
|
selectedLayers: action.modeAdjustments.layers,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
|
@ -325,37 +325,22 @@ function EditActionSliderAdjustment({ action, adjustmentType, adjustment }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RenderHeaderRight({ navigation, appContext, t, action }) {
|
export function RenderHeaderRight({
|
||||||
return (
|
navigation,
|
||||||
<MyDotsModal
|
appContext,
|
||||||
modalData={[
|
t,
|
||||||
/*{
|
action,
|
||||||
TODO: Fix it
|
modalData,
|
||||||
bug: Duplicated item as references to the old action -> if the color is changed it will apply on both actions
|
}) {
|
||||||
|
const data = [];
|
||||||
|
|
||||||
icon: "content-duplicate",
|
if (modalData) {
|
||||||
label: t(
|
for (let i = 0; i < modalData.length; i++) {
|
||||||
"screens.device.scenes.modalDotsEditAction.duplicateAction"
|
data.push(modalData[i]);
|
||||||
),
|
}
|
||||||
onPress: () => {
|
}
|
||||||
const currentSelectedAction =
|
|
||||||
appContext.deviceSceneActions.find(
|
|
||||||
(a) => a.actionId === actionId
|
|
||||||
);
|
|
||||||
|
|
||||||
appContext.setDeviceSceneActions((arr) => {
|
data.push({
|
||||||
const duplicatedAction = {
|
|
||||||
...currentSelectedAction,
|
|
||||||
actionId: GetUuid(),
|
|
||||||
};
|
|
||||||
|
|
||||||
return [...arr, duplicatedAction];
|
|
||||||
});
|
|
||||||
|
|
||||||
navigation.goBack();
|
|
||||||
},
|
|
||||||
},*/
|
|
||||||
{
|
|
||||||
icon: "trash-can",
|
icon: "trash-can",
|
||||||
label: t(
|
label: t(
|
||||||
"screens.device.scenes.editActions.modalDotsEditAction.deleteAction"
|
"screens.device.scenes.editActions.modalDotsEditAction.deleteAction"
|
||||||
|
@ -367,8 +352,7 @@ export function RenderHeaderRight({ navigation, appContext, t, action }) {
|
||||||
|
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
]}
|
|
||||||
/>
|
return <MyDotsModal modalData={data} />;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue