action over params
parent
f695054720
commit
69dad08c0a
|
@ -6,6 +6,7 @@ import {
|
|||
AppContext,
|
||||
AppSelectedUserDevice,
|
||||
Constants,
|
||||
GetDevice,
|
||||
ModalContainer,
|
||||
NewAction,
|
||||
} from "../../../../../utils";
|
||||
|
@ -84,12 +85,8 @@ export default function LayerSelectionModalContent({ navigation, route }) {
|
|||
style={{ marginTop: 20, width: 180 }}
|
||||
disabled={selectedLayer.length === 0}
|
||||
onPress={() => {
|
||||
const device = appContext.devices.find(
|
||||
(d) => d.id === AppSelectedUserDevice.current.id
|
||||
);
|
||||
|
||||
const newAction = NewAction(
|
||||
device.selectedScene,
|
||||
GetDevice(appContext.devices).selectedScene,
|
||||
Constants.actionType.layers
|
||||
);
|
||||
|
||||
|
|
|
@ -85,12 +85,12 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
|||
lightMode.supportedFirmwareVersions.includes(deviceFirmwareVersion)
|
||||
);
|
||||
|
||||
const selectedSceneActionModeId = appContext.deviceSceneActions.find(
|
||||
const selectedSceneAction = appContext.deviceSceneActions.find(
|
||||
(a) => a.actionId === actionId
|
||||
).modeId;
|
||||
);
|
||||
|
||||
const selectedLightMode = supportedDeviceLightModes.find(
|
||||
(s) => s.id === selectedSceneActionModeId
|
||||
(s) => s.id === selectedSceneAction.modeId
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -105,7 +105,7 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
|||
setLightModeDefaultColors(selectedLightMode.defaults);
|
||||
setSelectedDefaultLightModeColor(0);
|
||||
}
|
||||
}, [selectedSceneActionModeId]);
|
||||
}, [selectedSceneAction.modeId]);
|
||||
|
||||
return (
|
||||
<View
|
||||
|
@ -146,7 +146,7 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
|||
"screens.device.scenes.modalLayersEditAction.dropdownColorModeSelection.label"
|
||||
)}
|
||||
selectedItemLabel={
|
||||
selectedSceneActionModeId === ""
|
||||
selectedSceneAction.modeId === ""
|
||||
? t(
|
||||
"screens.device.scenes.modalLayersEditAction.dropdownColorModeSelection.noColorModeSelected"
|
||||
)
|
||||
|
@ -155,13 +155,12 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
|||
onPress={() =>
|
||||
navigation.navigate("modalLayersEditActionColorModeSelection", {
|
||||
supportedDeviceLightModes: supportedDeviceLightModes,
|
||||
selectedSceneActionModeId: selectedSceneActionModeId,
|
||||
actionId: route.params.actionId,
|
||||
action: selectedSceneAction,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
{selectedSceneActionModeId !== "" && (
|
||||
{selectedSceneAction.modeId !== "" && (
|
||||
<>
|
||||
{lightModeDefaultColors.length > 0 && (
|
||||
<>
|
||||
|
@ -270,10 +269,10 @@ export function LightsEditActionModalContent({ navigation, route }) {
|
|||
</Card>
|
||||
|
||||
<EditActionAnimationsCardContent
|
||||
disabled={selectedSceneActionModeId === ""}
|
||||
disabled={selectedSceneAction.modeId === ""}
|
||||
navigation={navigation}
|
||||
deviceFirmwareVersion={deviceFirmwareVersion}
|
||||
actionId={actionId}
|
||||
action={selectedSceneAction}
|
||||
/>
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
@ -286,6 +285,8 @@ export function LayersEditActionColorModeSelectionModalContent({
|
|||
}) {
|
||||
const appContext = useContext(AppContext);
|
||||
|
||||
const { action } = route.params;
|
||||
|
||||
return (
|
||||
<ModalContainer withoutPadding>
|
||||
<FlatList
|
||||
|
@ -294,13 +295,13 @@ export function LayersEditActionColorModeSelectionModalContent({
|
|||
renderItem={({ item }) => (
|
||||
<MyPickerModalListItem
|
||||
itemName={item.name[appContext.appLanguage]}
|
||||
itemSelected={route.params.selectedSceneActionModeId === item.id}
|
||||
itemSelected={action.modeId === item.id}
|
||||
onPress={() => {
|
||||
appContext.setDeviceSceneActions((arr) => {
|
||||
const newArr = [...arr];
|
||||
|
||||
const actionIndex = newArr.findIndex(
|
||||
(a) => a.actionId === route.params.actionId
|
||||
(a) => a.actionId === action.actionId
|
||||
);
|
||||
|
||||
if (actionIndex !== -1) {
|
||||
|
|
|
@ -18,23 +18,21 @@ export default function EditActionAnimationsCardContent({
|
|||
disabled,
|
||||
navigation,
|
||||
deviceFirmwareVersion,
|
||||
actionId,
|
||||
action,
|
||||
}) {
|
||||
const appContext = useContext(AppContext);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const deviceSceneAction = appContext.deviceSceneActions.find(
|
||||
(action) => action.actionId === actionId
|
||||
);
|
||||
console.log("act", action);
|
||||
|
||||
const selectedLightAnimationIn =
|
||||
appContext.deviceFirmwareModes.lightAnimationsIn.find(
|
||||
(animation) => animation.id === deviceSceneAction.animationInId
|
||||
(animation) => animation.id === action.animationInId
|
||||
);
|
||||
|
||||
const selectedLightAnimationOut =
|
||||
appContext.deviceFirmwareModes.lightAnimationsOut.find(
|
||||
(animation) => animation.id === deviceSceneAction.animationOutId
|
||||
(animation) => animation.id === action.animationOutId
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -64,7 +62,7 @@ export default function EditActionAnimationsCardContent({
|
|||
navigation.navigate("modalEditActionAnimationInSelection", {
|
||||
animationType: "animationIn",
|
||||
deviceFirmwareVersion: deviceFirmwareVersion,
|
||||
actionId: actionId,
|
||||
action: action,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
@ -107,7 +105,7 @@ export default function EditActionAnimationsCardContent({
|
|||
navigation.navigate("modalEditActionAnimationOutSelection", {
|
||||
animationType: "animationOut",
|
||||
deviceFirmwareVersion: deviceFirmwareVersion,
|
||||
actionId: actionId,
|
||||
action: action,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
@ -132,7 +130,7 @@ export function EditActionAnimationSelectionModalContent({
|
|||
}) {
|
||||
const appContext = useContext(AppContext);
|
||||
|
||||
let { animationType, deviceFirmwareVersion, actionId } = route.params;
|
||||
let { animationType, deviceFirmwareVersion, action } = route.params;
|
||||
|
||||
const supportedLightAnimations =
|
||||
animationType === "animationIn"
|
||||
|
@ -149,10 +147,6 @@ export function EditActionAnimationSelectionModalContent({
|
|||
) || animation.supportedFirmwareVersions.includes("*")
|
||||
);
|
||||
|
||||
const deviceSceneAction = appContext.deviceSceneActions.find(
|
||||
(action) => action.actionId === actionId
|
||||
);
|
||||
|
||||
animationType =
|
||||
animationType === "animationIn" ? "animationInId" : "animationOutId";
|
||||
|
||||
|
@ -178,7 +172,7 @@ export function EditActionAnimationSelectionModalContent({
|
|||
renderItem={({ item }) => (
|
||||
<MyPickerModalListItem
|
||||
itemName={item.name[appContext.appLanguage]}
|
||||
itemSelected={deviceSceneAction[animationType] === item.id}
|
||||
itemSelected={action[animationType] === item.id}
|
||||
onPress={() => {
|
||||
navigation.goBack();
|
||||
|
||||
|
@ -186,7 +180,7 @@ export function EditActionAnimationSelectionModalContent({
|
|||
const newArr = [...arr];
|
||||
|
||||
const foundActionIndex = newArr.findIndex(
|
||||
(action) => action.actionId === actionId
|
||||
(a) => a.actionId === action.actionId
|
||||
);
|
||||
|
||||
newArr[foundActionIndex][animationType] = item.id;
|
||||
|
|
|
@ -402,6 +402,7 @@ const devDeviceSceneActions = [
|
|||
modeId: "",
|
||||
animationInId: "",
|
||||
animationOutId: "",
|
||||
adjustments: [], // affected layers, animation speed...
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -411,8 +412,9 @@ export function NewAction(sceneId, actionType) {
|
|||
sceneId: sceneId,
|
||||
type: actionType, // layers, ambilight, motor
|
||||
modeId: "",
|
||||
animationInId: "00000000-0000-0000-0000-000000000000",
|
||||
animationOutId: "00000000-0000-0000-0000-000000000000",
|
||||
animationInId: "00000000-0000-0000-0000-000000000000", // default animation id for -> No animation selected
|
||||
animationOutId: "00000000-0000-0000-0000-000000000000", // default animation id for -> No animation selected
|
||||
adjustments: [],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue