notify card

main
alex 2023-08-13 17:20:39 +00:00
parent aa46586b98
commit f33b7f7c97
11 changed files with 197 additions and 52 deletions

19
package-lock.json generated
View File

@ -15,6 +15,7 @@
"@react-navigation/stack": "^6.3.17", "@react-navigation/stack": "^6.3.17",
"expo": "~48.0.18", "expo": "~48.0.18",
"expo-haptics": "~12.2.1", "expo-haptics": "~12.2.1",
"expo-linear-gradient": "~12.1.2",
"expo-status-bar": "~1.4.4", "expo-status-bar": "~1.4.4",
"i18next": "^23.2.11", "i18next": "^23.2.11",
"i18next-browser-languagedetector": "^7.1.0", "i18next-browser-languagedetector": "^7.1.0",
@ -23,7 +24,6 @@
"react-native": "0.71.8", "react-native": "0.71.8",
"react-native-draggable-flatlist": "^4.0.1", "react-native-draggable-flatlist": "^4.0.1",
"react-native-gesture-handler": "~2.9.0", "react-native-gesture-handler": "~2.9.0",
"react-native-linear-gradient": "^2.8.2",
"react-native-pager-view": "6.1.2", "react-native-pager-view": "6.1.2",
"react-native-reanimated": "~2.14.4", "react-native-reanimated": "~2.14.4",
"react-native-safe-area-context": "4.5.0", "react-native-safe-area-context": "4.5.0",
@ -7193,6 +7193,14 @@
"expo": "*" "expo": "*"
} }
}, },
"node_modules/expo-linear-gradient": {
"version": "12.1.2",
"resolved": "https://registry.npmjs.org/expo-linear-gradient/-/expo-linear-gradient-12.1.2.tgz",
"integrity": "sha512-e1d6Hq5qsRL8sWutrOuQhuir4vHiRJ1PmvDIL8P33mt51Y8VFTQjTG/mr5qJlT8lUD/ADJfaBLzV7SNqSuDTLQ==",
"peerDependencies": {
"expo": "*"
}
},
"node_modules/expo-modules-autolinking": { "node_modules/expo-modules-autolinking": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-1.2.0.tgz", "resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-1.2.0.tgz",
@ -11940,15 +11948,6 @@
"resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.19.tgz", "resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.19.tgz",
"integrity": "sha512-1dVk9NwhoyKHCSxcrM6vY6cxmojeATsBobDicX0ZKr7DgUF2cBQRTKsimQFvzH8XhOVXyH8p4HyDSZNIFI8OlQ==" "integrity": "sha512-1dVk9NwhoyKHCSxcrM6vY6cxmojeATsBobDicX0ZKr7DgUF2cBQRTKsimQFvzH8XhOVXyH8p4HyDSZNIFI8OlQ=="
}, },
"node_modules/react-native-linear-gradient": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/react-native-linear-gradient/-/react-native-linear-gradient-2.8.2.tgz",
"integrity": "sha512-hgmCsgzd58WNcDCyPtKrvxsaoETjb/jLGxis/dmU3Aqm2u4ICIduj4ECjbil7B7pm9OnuTkmpwXu08XV2mpg8g==",
"peerDependencies": {
"react": "*",
"react-native": "*"
}
},
"node_modules/react-native-pager-view": { "node_modules/react-native-pager-view": {
"version": "6.1.2", "version": "6.1.2",
"resolved": "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-6.1.2.tgz", "resolved": "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-6.1.2.tgz",

View File

@ -24,7 +24,6 @@
"react-native": "0.71.8", "react-native": "0.71.8",
"react-native-draggable-flatlist": "^4.0.1", "react-native-draggable-flatlist": "^4.0.1",
"react-native-gesture-handler": "~2.9.0", "react-native-gesture-handler": "~2.9.0",
"react-native-linear-gradient": "^2.8.2",
"react-native-pager-view": "6.1.2", "react-native-pager-view": "6.1.2",
"react-native-reanimated": "~2.14.4", "react-native-reanimated": "~2.14.4",
"react-native-safe-area-context": "4.5.0", "react-native-safe-area-context": "4.5.0",
@ -32,7 +31,8 @@
"react-native-tab-view": "^3.5.2", "react-native-tab-view": "^3.5.2",
"react-native-uuid": "^2.0.1", "react-native-uuid": "^2.0.1",
"react-native-zeroconf": "^0.13.8", "react-native-zeroconf": "^0.13.8",
"reanimated-color-picker": "^2.3.1" "reanimated-color-picker": "^2.3.1",
"expo-linear-gradient": "~12.1.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0" "@babel/core": "^7.20.0"

View File

@ -6,8 +6,9 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from "react-native"; } from "react-native";
import { AppContext, AppStyles } from "../../utils"; import { AppContext, AppStyles, Constants } from "../../utils";
import MyIcon from "../Icon"; import MyIcon from "../Icon";
import { LinearGradient } from "expo-linear-gradient";
export default function MyButton({ export default function MyButton({
title, title,
@ -15,14 +16,19 @@ export default function MyButton({
disabled, disabled,
onPress, onPress,
buttonLeftComponent, buttonLeftComponent,
buttonBackgroundColor, buttonGradientColor,
}) { }) {
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
const bBackgroundColor = /*const bBackgroundColor =
buttonBackgroundColor === undefined buttonBackgroundColor === undefined
? appContext.appTheme.colors.primary ? appContext.appTheme.colors.primary
: buttonBackgroundColor; : buttonBackgroundColor; */
const bGradientColor =
buttonGradientColor === undefined
? Constants.gradients.orange
: buttonGradientColor;
return ( return (
<TouchableHighlight <TouchableHighlight
@ -30,16 +36,22 @@ export default function MyButton({
onPress={onPress} onPress={onPress}
style={[{ borderRadius: 6 }, style]} style={[{ borderRadius: 6 }, style]}
> >
<View <LinearGradient
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
colors={bGradientColor}
style={[ style={[
{ {
backgroundColor: bBackgroundColor, //backgroundColor: bBackgroundColor,
borderRadius: 6, borderRadius: 6,
padding: 10, padding: 10,
}, },
AppStyles.Shadow, //AppStyles.Shadow,
disabled && { opacity: 0.6 }, disabled && { opacity: 0.6 },
buttonLeftComponent && { flexDirection: "row", alignItems: "center" }, buttonLeftComponent && {
flexDirection: "row",
alignItems: "center",
},
]} ]}
> >
{buttonLeftComponent} {buttonLeftComponent}
@ -51,7 +63,7 @@ export default function MyButton({
> >
{title} {title}
</Text> </Text>
</View> </LinearGradient>
</TouchableHighlight> </TouchableHighlight>
); );
} }

View File

@ -1,6 +1,9 @@
import { useContext } from "react"; import { useContext, useState } from "react";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { AppContext, AppStyles } from "../../utils"; import { AppContext, AppStyles, Constants } from "../../utils";
import { LinearGradient } from "expo-linear-gradient";
import { MyIconButton } from "../Button";
import MyIcon from "../Icon";
export default function Card({ export default function Card({
children, children,
@ -40,11 +43,11 @@ export default function Card({
<View <View
style={[ style={[
{ {
borderRadius: 20,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
padding: 20, padding: 20,
}, },
AppStyles.Shadow, AppStyles.Shadow,
AppStyles.card,
]} ]}
> >
{children} {children}
@ -52,3 +55,83 @@ export default function Card({
</View> </View>
); );
} }
export function MyNotifyCard({
iconName,
notifyTitle,
notifyDescription,
onClose,
}) {
const [notifyVisible, setNotifyVisible] = useState(true);
if (!notifyVisible) return null;
return (
<View
style={[
{
marginTop: 10,
marginLeft: 10,
marginRight: 10,
},
AppStyles.card,
]}
>
<LinearGradient
style={[
{
width: "100%",
paddingTop: 20,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 20,
},
AppStyles.card,
]}
colors={Constants.gradients.red}
start={{ x: 0, y: 0 }}
end={{ x: 1, y: 0 }}
>
<View
style={{
flexDirection: "row",
justifyContent: "space-evenly",
gap: 10,
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center",
}}
>
<MyIcon name={iconName} color={"yellow"} size={36} />
</View>
<View style={{ width: "70%" }}>
<Text
style={[
{ color: "#fff", fontWeight: "bold" },
AppStyles.typography16,
]}
>
{notifyTitle}
</Text>
<Text style={{ color: "#fff" }}>{notifyDescription}</Text>
</View>
<MyIconButton
iconName="close"
iconSize={24}
iconColor={"#ddd"}
onPress={() => {
onClose();
setNotifyVisible(false);
}}
/>
</View>
</LinearGradient>
</View>
);
}

View File

@ -364,7 +364,9 @@ export function MyBottomSheetModal({
duration: 100, duration: 100,
easing: Easing.ease, easing: Easing.ease,
}); });
opacity.value = withTiming(0, { duration: 100, easing: Easing.ease }); opacity.value = withTiming(0, { duration: 100, easing: Easing.ease });
setTimeout(() => closeModal(), 100); setTimeout(() => closeModal(), 100);
}; };
@ -398,7 +400,6 @@ export function MyBottomSheetModal({
borderTopLeftRadius: 20, borderTopLeftRadius: 20,
borderTopRightRadius: 20, borderTopRightRadius: 20,
height: modalHeight, height: modalHeight,
paddingTop: 12,
shadowRadius: 8, shadowRadius: 8,
shadowOffset: { shadowOffset: {
width: 0, width: 0,
@ -406,6 +407,7 @@ export function MyBottomSheetModal({
}, },
shadowColor: "#000000", shadowColor: "#000000",
elevation: 6, elevation: 6,
paddingTop: 20,
}, },
animatedStyle, animatedStyle,
]} ]}
@ -414,8 +416,9 @@ export function MyBottomSheetModal({
style={{ style={{
flexDirection: "row", flexDirection: "row",
justifyContent: "space-between", justifyContent: "space-between",
marginLeft: 10, paddingLeft: 20,
marginRight: 10, paddingRight: 18,
paddingBottom: 2,
}} }}
> >
<Text <Text

View File

@ -64,8 +64,6 @@ const windowHeight = Dimensions.get("window").height;
const modalHeight = windowHeight * 0.6; // 60 % of device screen const modalHeight = windowHeight * 0.6; // 60 % of device screen
console.log("modalHe", modalHeight);
export default function WaitEditActionModalContent({ navigation, route }) { export default function WaitEditActionModalContent({ navigation, route }) {
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -1,5 +1,5 @@
import { Text, TouchableOpacity, View } from "react-native"; import { Text, TouchableOpacity, View } from "react-native";
import Card from "../../Components/Card"; import Card, { MyNotifyCard } from "../../Components/Card";
import { import {
AppContext, AppContext,
AppSelectedUserDevice, AppSelectedUserDevice,
@ -13,7 +13,7 @@ import MyDropdown from "../../Components/Dropdown";
import MyIcon from "../../Components/Icon"; import MyIcon from "../../Components/Icon";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import MyResult from "../../Components/Result"; import MyResult from "../../Components/Result";
import { MyTextButton } from "../../Components/Button"; import { MyIconButton, MyTextButton } from "../../Components/Button";
import { useFocusEffect } from "@react-navigation/native"; import { useFocusEffect } from "@react-navigation/native";
import { Divider } from "../../Components/Divider"; import { Divider } from "../../Components/Divider";
import { MyColorSwatch } from "../../Components/ColorPicker"; import { MyColorSwatch } from "../../Components/ColorPicker";
@ -21,6 +21,7 @@ import { MyDotsModal } from "../../Components/Modal";
import DraggableFlatList, { import DraggableFlatList, {
ScaleDecorator, ScaleDecorator,
} from "react-native-draggable-flatlist"; } from "react-native-draggable-flatlist";
import { LinearGradient } from "expo-linear-gradient";
export default function SceneView({ navigation }) { export default function SceneView({ navigation }) {
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
@ -132,10 +133,25 @@ export default function SceneView({ navigation }) {
const lastSceneAction = deviceSceneActions[deviceSceneActions.length - 1]; const lastSceneAction = deviceSceneActions[deviceSceneActions.length - 1];
const NotifyCard = () => {
// TODO: API show notify card if there are some problems with the esp
return (
<MyNotifyCard
iconName="connection"
notifyTitle={"Netzteil überprüfen"}
notifyDescription={
"Bitte überprüfen Sie, ob das korrekte Netzteil verwendet wurde."
}
onClose={() => console.log("closed notify")}
/>
);
};
return ( return (
<> <>
{device.selectedScene === "" ? ( {device.selectedScene === "" ? (
<> <>
<NotifyCard />
<DropdownCard /> <DropdownCard />
<MyResult <MyResult
@ -163,6 +179,8 @@ export default function SceneView({ navigation }) {
keyExtractor={(item) => item.actionId} keyExtractor={(item) => item.actionId}
ListHeaderComponent={ ListHeaderComponent={
<View style={{ marginBottom: 10 }}> <View style={{ marginBottom: 10 }}>
<NotifyCard />
<DropdownCard /> <DropdownCard />
</View> </View>
} }
@ -538,7 +556,6 @@ function ActionListItem({ drag, navigation, device, item }) {
</View> </View>
</View> </View>
{console.log("drag", drag)}
<TouchableOpacity <TouchableOpacity
disabled={drag === false} disabled={drag === false}
onLongPress={() => { onLongPress={() => {

View File

@ -1,17 +1,12 @@
import { Button, ScrollView, Text, View } from "react-native"; import { ScrollView, Text, View } from "react-native";
import Card from "../../Components/Card"; import Card from "../../Components/Card";
import { useContext, useEffect, useState } from "react"; import { useContext, useEffect, useState } from "react";
import { import { AppContext, AppStyles, Constants, GetDevice } from "../../utils";
AppContext,
AppSelectedUserDevice,
AppStyles,
GetDevice,
} from "../../utils";
import { Divider } from "../../Components/Divider"; import { Divider } from "../../Components/Divider";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import MySwitch from "../../Components/Switch"; import MySwitch from "../../Components/Switch";
import MyButton, { MyIconButton, MyTextButton } from "../../Components/Button"; import MyButton, { MyIconButton } from "../../Components/Button";
import { MyBottomSheetModal, MyConfirmModal } from "../../Components/Modal"; import { MyBottomSheetModal } from "../../Components/Modal";
export default function SettingsView({ navigation }) { export default function SettingsView({ navigation }) {
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
@ -64,8 +59,6 @@ export default function SettingsView({ navigation }) {
}, []); }, []);
const deleteDeviceFromApp = () => { const deleteDeviceFromApp = () => {
console.log("dev", appContext.devices.length);
appContext.setDevices((devices) => appContext.setDevices((devices) =>
devices.filter((d) => d.id !== device.id) devices.filter((d) => d.id !== device.id)
); );
@ -78,8 +71,6 @@ export default function SettingsView({ navigation }) {
actions.filter((a) => a.deviceId !== device.id) actions.filter((a) => a.deviceId !== device.id)
); );
console.log("dev", appContext.devices.length);
// show no devices connected screen if there are no devices left // show no devices connected screen if there are no devices left
if (appContext.devices.length < 2) { if (appContext.devices.length < 2) {
navigation.navigate("_noDevicesConnected"); navigation.navigate("_noDevicesConnected");
@ -88,8 +79,6 @@ export default function SettingsView({ navigation }) {
// TODO: remove device from app async storage if it is not already handled by appContext // TODO: remove device from app async storage if it is not already handled by appContext
}; };
const bottomSheetModalHeight = appContext.appLanguage === "en" ? 150 : 170;
return ( return (
<ScrollView> <ScrollView>
<Card <Card
@ -237,9 +226,9 @@ export default function SettingsView({ navigation }) {
headerTitle={t( headerTitle={t(
"screens.device.settings.bottomSheetModalCloseConnection.headerTitle" "screens.device.settings.bottomSheetModalCloseConnection.headerTitle"
)} )}
modalHeight={bottomSheetModalHeight} modalHeight={172}
> >
<View style={{ margin: 10 }}> <View style={{ paddingLeft: 20, paddingRight: 20 }}>
<Text <Text
style={[ style={[
{ color: appContext.appTheme.text }, { color: appContext.appTheme.text },
@ -266,6 +255,7 @@ export default function SettingsView({ navigation }) {
style={{ width: 100 }} style={{ width: 100 }}
buttonBackgroundColor={appContext.appTheme.buttonSecondary} buttonBackgroundColor={appContext.appTheme.buttonSecondary}
onPress={() => setIsBottomSheetModalCloseConnectionOpen(false)} onPress={() => setIsBottomSheetModalCloseConnectionOpen(false)}
buttonGradientColor={Constants.gradients.gray}
/> />
<MyButton <MyButton
title={t( title={t(
@ -310,9 +300,9 @@ export default function SettingsView({ navigation }) {
headerTitle={t( headerTitle={t(
"screens.device.settings.bottomSheetModalResetToFactorySettings.headerTitle" "screens.device.settings.bottomSheetModalResetToFactorySettings.headerTitle"
)} )}
modalHeight={bottomSheetModalHeight} modalHeight={appContext.appLanguage === "en" ? 152 : 172}
> >
<View style={{ margin: 10 }}> <View style={{ paddingLeft: 20, paddingRight: 20 }}>
<Text <Text
style={[ style={[
{ color: appContext.appTheme.text }, { color: appContext.appTheme.text },
@ -341,6 +331,7 @@ export default function SettingsView({ navigation }) {
onPress={() => onPress={() =>
setIsBottomSheetModalResetToFactorySettingsOpen(false) setIsBottomSheetModalResetToFactorySettingsOpen(false)
} }
buttonGradientColor={Constants.gradients.gray}
/> />
<MyButton <MyButton
title={t( title={t(

View File

@ -1,6 +1,8 @@
import { useContext } from "react"; import { useContext } from "react";
import { AppContext } from "../../utils"; import { AppContext } from "../../utils";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { LinearGradient } from "expo-linear-gradient";
import MyButton from "../../Components/Button";
export default function HelpScreen() { export default function HelpScreen() {
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
@ -14,6 +16,31 @@ export default function HelpScreen() {
> >
<Text style={{ color: appContext.appTheme.text }}>FAQ</Text> <Text style={{ color: appContext.appTheme.text }}>FAQ</Text>
<Text style={{ color: appContext.appTheme.text }}>Give Feedback</Text> <Text style={{ color: appContext.appTheme.text }}>Give Feedback</Text>
<LinearGradient
colors={["#4c669f", "#3b5998", "#192f6a"]}
style={{
width: 150,
height: 150,
paddingLeft: 15,
paddingRight: 15,
borderRadius: 5,
}}
>
<Text
style={{
fontSize: 18,
textAlign: "center",
margin: 10,
color: "#ffffff",
backgroundColor: "transparent",
}}
>
Sign in with Facebook
</Text>
</LinearGradient>
<MyButton title={"test"} onPress={() => console.log("t")} />
</View> </View>
); );
} }

View File

@ -3,6 +3,7 @@ import {
AddNewDevice, AddNewDevice,
AppContext, AppContext,
AppStyles, AppStyles,
Constants,
ModalContainer, ModalContainer,
} from "../../utils"; } from "../../utils";
import { import {
@ -173,6 +174,7 @@ export default function SearchForNewDevicesModalContent({ navigation }) {
</View> </View>
<MyButton <MyButton
buttonGradientColor={Constants.gradients.gray}
style={{ width: 200 }} style={{ width: 200 }}
title={texts.searchButton} title={texts.searchButton}
onPress={() => { onPress={() => {
@ -321,7 +323,12 @@ function FoundDevice({ item, appContext, t }) {
style={{ marginRight: 6 }} style={{ marginRight: 6 }}
/> />
) : connectingState === FoundDeviceState.connected ? ( ) : connectingState === FoundDeviceState.connected ? (
<MyIcon name="check" size={12} style={{ marginRight: 6 }} /> <MyIcon
name="check"
size={12}
style={{ marginRight: 6 }}
color={"#fff"}
/>
) : null ) : null
} }
/> />

View File

@ -42,6 +42,11 @@ export const Constants = {
max_scene_name_length: 20, max_scene_name_length: 20,
}, },
defaultAnimationId: "00000000-0000-0000-0000-000000000000", // used id for -> No animation selected defaultAnimationId: "00000000-0000-0000-0000-000000000000", // used id for -> No animation selected
gradients: {
orange: ["#fd4f2b", "#f9994d"],
gray: ["#60696b", "#A9A9A9"],
red: ["#f71e06", "#fd4b2f"],
},
}; };
export const AppStyles = StyleSheet.create({ export const AppStyles = StyleSheet.create({
@ -77,6 +82,9 @@ export const AppStyles = StyleSheet.create({
appBottom: { appBottom: {
marginBottom: 40, marginBottom: 40,
}, },
card: {
borderRadius: 20,
},
}); });
const DarkAppTheme = { const DarkAppTheme = {