changed add action button to disabled if last action is stop

main
alex 2023-08-10 13:56:51 +00:00
parent 8ce4a5582e
commit f2a1eeb971
4 changed files with 41 additions and 40 deletions

View File

@ -38,16 +38,19 @@ export function MyTextButton({
onPress, onPress,
actionColor, actionColor,
iconName, iconName,
disabled,
}) { }) {
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
const color = actionColor const color = disabled
? appContext.appTheme.textDisabled
: actionColor
? appContext.appTheme.colors.primary ? appContext.appTheme.colors.primary
: appContext.appTheme.textSecondary; : appContext.appTheme.textSecondary;
return ( return (
<View style={styleContainer}> <View style={styleContainer}>
<TouchableOpacity onPress={onPress}> <TouchableOpacity onPress={onPress} disabled={disabled}>
<View <View
style={[ style={[
{ {

View File

@ -27,8 +27,13 @@ export default function StopEditActionModalContent({ navigation, route }) {
); );
return ( return (
<View style={{ marginTop: 40 }}> <View style={{ margin: 40 }}>
<Text style={[{ textAlign: "center" }, AppStyles.typography16]}> <Text
style={[
{ textAlign: "center", color: appContext.appTheme.text },
AppStyles.typography16,
]}
>
{t("screens.device.scenes.editActions.modalStopEditAction.description")} {t("screens.device.scenes.editActions.modalStopEditAction.description")}
</Text> </Text>
</View> </View>

View File

@ -189,29 +189,7 @@ export default function SceneView({ navigation }) {
} }
ListFooterComponent={ ListFooterComponent={
<> <>
{lastSceneAction?.type !== Constants.actionType.stop ? ( {lastSceneAction?.type === Constants.actionType.stop && (
<MyTextButton
title={t("screens.device.scenes.buttonAddAction")}
styleContainer={[
{
alignItems: "center",
marginTop: 10,
},
AppStyles.appBottom,
]}
style={{ padding: 8 }}
actionColor={
deviceSceneActions === undefined ||
deviceSceneActions.length === 0
}
onPress={() =>
navigation.navigate("modalAddSceneAction", {
deviceFirmwareVersion: device.firmware.version,
})
}
iconName="plus-circle-outline"
/>
) : (
<ActionListItem <ActionListItem
drag={false} drag={false}
navigation={navigation} navigation={navigation}
@ -219,6 +197,29 @@ export default function SceneView({ navigation }) {
item={lastSceneAction} item={lastSceneAction}
/> />
)} )}
<MyTextButton
title={t("screens.device.scenes.buttonAddAction")}
styleContainer={[
{
alignItems: "center",
marginTop: 10,
},
AppStyles.appBottom,
]}
style={{ padding: 8 }}
actionColor={
deviceSceneActions === undefined ||
deviceSceneActions.length === 0
}
onPress={() =>
navigation.navigate("modalAddSceneAction", {
deviceFirmwareVersion: device.firmware.version,
})
}
iconName="plus-circle-outline"
disabled={lastSceneAction?.type === Constants.actionType.stop}
/>
</> </>
} }
renderItem={({ item, drag }) => { renderItem={({ item, drag }) => {
@ -564,11 +565,7 @@ function ActionListItem({ drag, navigation, device, item }) {
}} }}
style={{ padding: 4 }} style={{ padding: 4 }}
> >
<MyIcon <MyIcon name="menu" size={20} disabled={drag === false} />
name="menu"
size={20}
disabled={drag === false}
/>
</TouchableOpacity> </TouchableOpacity>
</View> </View>

View File

@ -1,13 +1,7 @@
import AsyncStorage from "@react-native-async-storage/async-storage"; import AsyncStorage from "@react-native-async-storage/async-storage";
import { createContext, createRef, useEffect, useState } from "react"; import { createContext, createRef, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { import { Appearance, Platform, StyleSheet, View } from "react-native";
Appearance,
Platform,
StyleSheet,
Vibration,
View,
} from "react-native";
import uuid from "react-native-uuid"; import uuid from "react-native-uuid";
import * as Haptics from "expo-haptics"; import * as Haptics from "expo-haptics";
@ -85,6 +79,7 @@ const DarkAppTheme = {
}, },
text: "#fff", text: "#fff",
textSecondary: "#ddd", textSecondary: "#ddd",
textDisabled: "#b2bec3",
backgroundColor: "#21252a", backgroundColor: "#21252a",
card: { card: {
backgroundColor: "#2b3139", backgroundColor: "#2b3139",
@ -137,6 +132,7 @@ const LightAppTheme = {
}, },
text: "#000", text: "#000",
textSecondary: "#555", textSecondary: "#555",
textDisabled: "#636e72",
backgroundColor: "#f7f7f7", backgroundColor: "#f7f7f7",
card: { card: {
backgroundColor: "#fff", backgroundColor: "#fff",