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,
actionColor,
iconName,
disabled,
}) {
const appContext = useContext(AppContext);
const color = actionColor
const color = disabled
? appContext.appTheme.textDisabled
: actionColor
? appContext.appTheme.colors.primary
: appContext.appTheme.textSecondary;
return (
<View style={styleContainer}>
<TouchableOpacity onPress={onPress}>
<TouchableOpacity onPress={onPress} disabled={disabled}>
<View
style={[
{

View File

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

View File

@ -189,7 +189,15 @@ export default function SceneView({ navigation }) {
}
ListFooterComponent={
<>
{lastSceneAction?.type !== Constants.actionType.stop ? (
{lastSceneAction?.type === Constants.actionType.stop && (
<ActionListItem
drag={false}
navigation={navigation}
device={device}
item={lastSceneAction}
/>
)}
<MyTextButton
title={t("screens.device.scenes.buttonAddAction")}
styleContainer={[
@ -210,15 +218,8 @@ export default function SceneView({ navigation }) {
})
}
iconName="plus-circle-outline"
disabled={lastSceneAction?.type === Constants.actionType.stop}
/>
) : (
<ActionListItem
drag={false}
navigation={navigation}
device={device}
item={lastSceneAction}
/>
)}
</>
}
renderItem={({ item, drag }) => {
@ -564,11 +565,7 @@ function ActionListItem({ drag, navigation, device, item }) {
}}
style={{ padding: 4 }}
>
<MyIcon
name="menu"
size={20}
disabled={drag === false}
/>
<MyIcon name="menu" size={20} disabled={drag === false} />
</TouchableOpacity>
</View>

View File

@ -1,13 +1,7 @@
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 {
Appearance,
Platform,
StyleSheet,
Vibration,
View,
} from "react-native";
import { Appearance, Platform, StyleSheet, View } from "react-native";
import uuid from "react-native-uuid";
import * as Haptics from "expo-haptics";
@ -85,6 +79,7 @@ const DarkAppTheme = {
},
text: "#fff",
textSecondary: "#ddd",
textDisabled: "#b2bec3",
backgroundColor: "#21252a",
card: {
backgroundColor: "#2b3139",
@ -137,6 +132,7 @@ const LightAppTheme = {
},
text: "#000",
textSecondary: "#555",
textDisabled: "#636e72",
backgroundColor: "#f7f7f7",
card: {
backgroundColor: "#fff",