save edit on text enter
parent
998f62b0f9
commit
da484d8b5f
14
App.js
14
App.js
|
@ -39,6 +39,7 @@ import MotorEditActionModalContent, {
|
|||
MotorEditActionMotorModeSelectionModalContent,
|
||||
} from "./src/Screens/Device/modals/EditActions/Motor";
|
||||
import WaitXSecondsEditActionModalContent from "./src/Screens/Device/modals/EditActions/Wait";
|
||||
import StopEditActionModalContent from "./src/Screens/Device/modals/EditActions/Stop";
|
||||
|
||||
const Drawer = createDrawerNavigator();
|
||||
const Stack = createStackNavigator();
|
||||
|
@ -248,6 +249,19 @@ export function MyApp() {
|
|||
}
|
||||
/>
|
||||
|
||||
<Stack.Screen
|
||||
name="modalStopEditAction"
|
||||
component={StopEditActionModalContent}
|
||||
options={({ navigation }) =>
|
||||
options({
|
||||
navigation: navigation,
|
||||
pageTitle: t(
|
||||
"screens.device.scenes.editActions.modalStopEditAction.pageTitle"
|
||||
),
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Stack.Screen
|
||||
name="modalUpdateSceneName"
|
||||
component={UpdateSceneNameModalContent}
|
||||
|
|
|
@ -145,6 +145,10 @@
|
|||
"singular": "Sekunde",
|
||||
"plural": "Sekunden"
|
||||
}
|
||||
},
|
||||
"modalStopEditAction": {
|
||||
"pageTitle": "Stop",
|
||||
"description": "Das Gerät stoppt hier und wird keine weiteren Aktionen ausführen."
|
||||
}
|
||||
},
|
||||
"modalUpdateSceneName": {
|
||||
|
|
|
@ -145,6 +145,10 @@
|
|||
"singular": "Second",
|
||||
"plural": "Seconds"
|
||||
}
|
||||
},
|
||||
"modalStopEditAction": {
|
||||
"pageTitle": "Stop",
|
||||
"description": "The device will stop here and will not execute further actions."
|
||||
}
|
||||
},
|
||||
"modalUpdateSceneName": {
|
||||
|
|
|
@ -279,6 +279,7 @@ export function MyTextInputModalContent({
|
|||
textInputTitle,
|
||||
textInputDescription,
|
||||
textMaxLength,
|
||||
textOnSubmitEditing,
|
||||
}) {
|
||||
const [newValue, setNewValue] = useState(defaultValue);
|
||||
|
||||
|
@ -308,6 +309,10 @@ export function MyTextInputModalContent({
|
|||
value={newValue}
|
||||
onChangeText={(v) => setNewValue(v)}
|
||||
textMaxLength={textMaxLength}
|
||||
onSubmitEditing={(e) => {
|
||||
navigation.goBack();
|
||||
textOnSubmitEditing(e);
|
||||
}}
|
||||
/>
|
||||
</ModalContainer>
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@ export default function MyTextInput({
|
|||
value,
|
||||
onChangeText,
|
||||
inputMode,
|
||||
onSubmitEditing,
|
||||
}) {
|
||||
const appContext = useContext(AppContext);
|
||||
|
||||
|
@ -28,6 +29,7 @@ export default function MyTextInput({
|
|||
maxLength={textMaxLength}
|
||||
value={value}
|
||||
onChangeText={onChangeText}
|
||||
onSubmitEditing={onSubmitEditing}
|
||||
/>
|
||||
<Text
|
||||
style={[
|
||||
|
|
|
@ -171,13 +171,19 @@ export default function AddSceneActionModalContent({ navigation, route }) {
|
|||
iconName={ActionTypeIconName(Constants.actionType.waitUntilTimeX)}
|
||||
onPress={() => console.log("pressed action")}
|
||||
deviceFirmwareVersion={deviceFirmwareVersion}
|
||||
supportedFirmwareVersions={["1.0.1"]}
|
||||
supportedFirmwareVersions={["1.0.0"]}
|
||||
/>
|
||||
|
||||
<Action
|
||||
text={t("screens.device.scenes.modalAddSceneAction.actions.stop")}
|
||||
iconName={ActionTypeIconName(Constants.actionType.stop)}
|
||||
onPress={() => console.log("pressed action")}
|
||||
onPress={() =>
|
||||
handleCreateAction(
|
||||
Constants.actionType.stop,
|
||||
{},
|
||||
"modalStopEditAction"
|
||||
)
|
||||
}
|
||||
deviceFirmwareVersion={deviceFirmwareVersion}
|
||||
supportedFirmwareVersions={["1.0.1"]}
|
||||
/>
|
||||
|
@ -189,7 +195,7 @@ export default function AddSceneActionModalContent({ navigation, route }) {
|
|||
iconName={ActionTypeIconName(Constants.actionType.timeControl)}
|
||||
onPress={() => console.log("pressed action")}
|
||||
deviceFirmwareVersion={deviceFirmwareVersion}
|
||||
supportedFirmwareVersions={["1.0.1"]}
|
||||
supportedFirmwareVersions={["1.0.0"]}
|
||||
/>
|
||||
|
||||
<Action
|
||||
|
|
|
@ -70,8 +70,6 @@ export default function WaitEditActionModalContent({ navigation, route }) {
|
|||
|
||||
const { action } = route.params;
|
||||
|
||||
console.log("params", route.params);
|
||||
|
||||
const [selectedHours, setSelectedHours] = useState(
|
||||
action.modeAdjustments.hours
|
||||
);
|
||||
|
|
|
@ -10,12 +10,7 @@ export default function SettingsChangeDeviceDisplayNameModalContent({
|
|||
const appContext = useContext(AppContext);
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<MyTextInputModalContent
|
||||
navigation={navigation}
|
||||
textMaxLength={Constants.globals.max_device_name_length}
|
||||
defaultValue={route.params.displayName}
|
||||
onCheckIconPress={(newDeviceDisplayName) => {
|
||||
const updateDeviceDisplayName = (newDeviceDisplayName) => {
|
||||
appContext.setDevices((arr) => {
|
||||
let newArr = [...arr];
|
||||
|
||||
|
@ -27,7 +22,17 @@ export default function SettingsChangeDeviceDisplayNameModalContent({
|
|||
|
||||
return newArr;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<MyTextInputModalContent
|
||||
navigation={navigation}
|
||||
textMaxLength={Constants.globals.max_device_name_length}
|
||||
defaultValue={route.params.displayName}
|
||||
onCheckIconPress={(newDeviceDisplayName) => {
|
||||
updateDeviceDisplayName(newDeviceDisplayName);
|
||||
}}
|
||||
textOnSubmitEditing={(e) => updateDeviceDisplayName(e.nativeEvent.text)}
|
||||
textInputTitle={t(
|
||||
"screens.device.settings.modalSettingsChangeDeviceDisplayName.textTitle"
|
||||
)}
|
||||
|
|
|
@ -9,6 +9,22 @@ export default function UpdateSceneNameModalContent({ navigation, route }) {
|
|||
|
||||
const { deviceSelectedScene, sceneName } = route.params;
|
||||
|
||||
const updateSceneName = (newName) => {
|
||||
appContext.setDeviceScenes((arr) => {
|
||||
let newArr = [...arr];
|
||||
|
||||
const foundSceneIndex = newArr.findIndex(
|
||||
(scene) => scene.sceneId === deviceSelectedScene
|
||||
);
|
||||
|
||||
if (foundSceneIndex !== -1) {
|
||||
newArr[foundSceneIndex].name = newName;
|
||||
}
|
||||
|
||||
return newArr;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<MyTextInputModalContent
|
||||
navigation={navigation}
|
||||
|
@ -19,20 +35,9 @@ export default function UpdateSceneNameModalContent({ navigation, route }) {
|
|||
"screens.device.scenes.modalUpdateSceneName.textDescription"
|
||||
)}
|
||||
onCheckIconPress={(newValue) => {
|
||||
appContext.setDeviceScenes((arr) => {
|
||||
let newArr = [...arr];
|
||||
|
||||
const foundSceneIndex = newArr.findIndex(
|
||||
(scene) => scene.sceneId === deviceSelectedScene
|
||||
);
|
||||
|
||||
if (foundSceneIndex !== -1) {
|
||||
newArr[foundSceneIndex].name = newValue;
|
||||
}
|
||||
|
||||
return newArr;
|
||||
});
|
||||
updateSceneName(newValue);
|
||||
}}
|
||||
textOnSubmitEditing={(e) => updateSceneName(e.nativeEvent.text)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -246,6 +246,8 @@ function ActionListItem({ drag, navigation, device, item }) {
|
|||
|
||||
if (item.type === Constants.actionType.wait) {
|
||||
title = t("screens.device.scenes.modalAddSceneAction.actions.wait");
|
||||
} else if (item.type === Constants.actionType.stop) {
|
||||
title = t("screens.device.scenes.modalAddSceneAction.actions.stop");
|
||||
} else if (item.modeId !== "") {
|
||||
title = itemModeList.find((m) => m.id === item.modeId).name[
|
||||
appContext.appLanguage
|
||||
|
@ -428,6 +430,9 @@ function ActionListItem({ drag, navigation, device, item }) {
|
|||
|
||||
adjustments.push(<ListItem text={<Text>{msg}</Text>} />);
|
||||
break;
|
||||
case Constants.actionType.stop:
|
||||
navigateTo = "modalStopEditAction";
|
||||
break;
|
||||
default:
|
||||
console.log("item type not defined" + item.type);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue