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