From 3dd7afec418b95bcd2ff8d5724b2b07a5086ba50 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 31 Jul 2023 19:31:42 +0000 Subject: [PATCH] auto select first color --- App.js | 7 ++--- src/Screens/Device/index.js | 6 +++- .../Device/modals/EditActions/Lights/index.js | 29 +++++++++++++++---- .../Device/modals/EditActions/index.js | 4 +-- src/Screens/Device/scene.js | 9 +----- src/utils.js | 2 +- start.sh | 0 7 files changed, 34 insertions(+), 23 deletions(-) mode change 100644 => 100755 start.sh diff --git a/App.js b/App.js index 921000a..26341bf 100644 --- a/App.js +++ b/App.js @@ -33,10 +33,7 @@ import { SettingsAppLanguageModalContent, } from "./src/Screens/Settings"; import { SettingsChangeDeviceDisplayName } from "./src/Screens/Device/settings"; -import { - EditActionAnimationSelectionModalContent, - EditActionAnimationsSelectionModalContent, -} from "./src/Screens/Device/modals/EditActions"; +import { EditActionAnimationSelectionModalContent } from "./src/Screens/Device/modals/EditActions"; const Drawer = createDrawerNavigator(); const Stack = createStackNavigator(); @@ -256,7 +253,7 @@ export function MyApp() { options({ navigation: navigation, pageTitle: t( - "screens.device.modalSettingsChangeDeviceDisplayName.pageTitle" + "screens.device.settings.modalSettingsChangeDeviceDisplayName.pageTitle" ), }) } diff --git a/src/Screens/Device/index.js b/src/Screens/Device/index.js index 4dacec1..6a20d68 100644 --- a/src/Screens/Device/index.js +++ b/src/Screens/Device/index.js @@ -6,6 +6,7 @@ import { View, Text, KeyboardAvoidingView, + Alert, } from "react-native"; import { AppContext } from "../../utils"; import SettingsView from "./settings"; @@ -71,7 +72,10 @@ export default function DeviceScreen({ navigation }) { selectedViewNumber={1} top={topSecond} iconColor={getIconColor(1)} - onPress={() => setSelectedView(1)} + onPress={() => { + console.log("rotate"); + Alert.alert("Rotate device", "Soon the device will turn 180 degrees"); + }} /> s.id === selectedSceneActionModeId ); + useEffect(() => { + if (colorPickerRef.current && selectedLightMode.defaults.length > 0) { + colorPickerRef.current.setColor(selectedLightMode.defaults[0]); + } + }, [lightModeDefaultColors]); + useEffect(() => { if (selectedLightMode !== undefined) { sharedLightModeDefaultColors.value = selectedLightMode.defaults; setLightModeDefaultColors(selectedLightMode.defaults); - setSelectedDefaultLightModeColor(); + setSelectedDefaultLightModeColor(0); } }, [selectedSceneActionModeId]); @@ -169,7 +176,11 @@ export function LightsEditActionModalContent({ navigation, route }) { {t( @@ -192,7 +203,7 @@ export function LightsEditActionModalContent({ navigation, route }) { { - const newSelection = + /*const newSelection = selectedDefaultLightModeColor !== index ? index : undefined; @@ -203,7 +214,13 @@ export function LightsEditActionModalContent({ navigation, route }) { colorPickerRef.current.setColor( sharedLightModeDefaultColors.value[index] ); - } + }*/ + + setSelectedDefaultLightModeColor(index); + + colorPickerRef.current.setColor( + sharedLightModeDefaultColors.value[index] + ); }} > - + {t( "screens.device.scenes.editActionAnimationsCardContent.animationsIn" )} @@ -75,7 +75,7 @@ export default function EditActionAnimationsCardContent({ ))} {t( "screens.device.scenes.editActionAnimationsCardContent.animationsOut" diff --git a/src/Screens/Device/scene.js b/src/Screens/Device/scene.js index 20dce8f..0a88367 100644 --- a/src/Screens/Device/scene.js +++ b/src/Screens/Device/scene.js @@ -1,13 +1,6 @@ import { FlatList, Text, TouchableOpacity, View } from "react-native"; import Card from "../../Components/Card"; -import { - AppContext, - AppSelectedUserDevice, - Constants, - GetDevice, - GetDeviceScene, - GetDeviceScenes, -} from "../../utils"; +import { AppContext, Constants, GetDevice } from "../../utils"; import { useCallback, useContext, useState } from "react"; import MyDropdown from "../../Components/Dropdown"; import MyIcon from "../../Components/Icon"; diff --git a/src/utils.js b/src/utils.js index b586223..b81da2f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -208,7 +208,7 @@ const devDevicesFirmwareModes = { de: "Zufällig", en: "Random", }, - defaults: ["red", "orange", "blue"], + defaults: ["pink", "orange", "blue"], adjustments: [ { type: "slider", diff --git a/start.sh b/start.sh old mode 100644 new mode 100755