diff --git a/App.js b/App.js index b300b58..4d918b4 100644 --- a/App.js +++ b/App.js @@ -15,7 +15,6 @@ import { Suspense, lazy, useContext, useEffect } from "react"; import { SafeAreaView } from "react-native-safe-area-context"; import "./i18n"; import DeviceScreen from "./src/Screens/Device"; -import DeviceOldScreen from "./src/Screens/DeviceOld"; import { createStackNavigator } from "@react-navigation/stack"; import { TouchableOpacity } from "react-native"; import MyIcon from "./src/Components/Icon"; @@ -310,8 +309,6 @@ function MyDrawer() { /> ))} - - diff --git a/src/Components/SideBar/index.js b/src/Components/SideBar/index.js index febe962..2fbd06a 100644 --- a/src/Components/SideBar/index.js +++ b/src/Components/SideBar/index.js @@ -144,11 +144,6 @@ export default function Sidebar(props) { routeName={device.displayName} /> ))} - - props.navigation.navigate("Old Turtle")} - /> diff --git a/src/Components/TextInput/index.js b/src/Components/TextInput/index.js index 6ee29bc..cc6df77 100644 --- a/src/Components/TextInput/index.js +++ b/src/Components/TextInput/index.js @@ -12,7 +12,7 @@ export default function MyTextInput({ const appContext = useContext(AppContext); return ( - + {textTitle} diff --git a/src/Screens/DeviceOld/colorScenes.js b/src/Screens/DeviceOld/colorScenes.js deleted file mode 100644 index 96000fd..0000000 --- a/src/Screens/DeviceOld/colorScenes.js +++ /dev/null @@ -1,78 +0,0 @@ -import { View } from "react-native"; -import Card from "../../Components/Card"; -import MyIcon from "../../Components/Icon"; -import { useContext } from "react"; -import { AppContext } from "../../utils"; -import { TouchableOpacity } from "react-native-gesture-handler"; -import MyColorPicker from "../../Components/ColorPicker"; - -export default function ColorScenesView({ - deviceLedsColors, - setDeviceLedsColor, - selectedDeviceLed, - setSelectedDeviceLed, -}) { - const appContext = useContext(AppContext); - - return ( - - - { - console.log("up"); - - setDeviceLedsColor((arr) => { - const newArr = [...arr]; - - newArr[16] = "red"; - - return newArr; - }); - }} - > - - - console.log("down")}> - - - { - console.log("left", selectedDeviceLed); - - if (selectedDeviceLed > 0) { - setSelectedDeviceLed((prev) => (prev = prev - 1)); - } - }} - > - - - { - console.log("right"); - setSelectedDeviceLed((prev) => (prev = prev + 1)); - - console.log("sel", selectedDeviceLed); - }} - > - - - - - ); -} diff --git a/src/Screens/DeviceOld/index.js b/src/Screens/DeviceOld/index.js deleted file mode 100644 index 39c3f76..0000000 --- a/src/Screens/DeviceOld/index.js +++ /dev/null @@ -1,260 +0,0 @@ -import { lazy, useContext, useState } from "react"; -import { - Image, - ScrollView, - StyleSheet, - View, - Text, - TouchableHighlight, - TouchableOpacity, - Dimensions, - ImageBackground, -} from "react-native"; -import LightView from "./light"; -import { AppContext } from "../../utils"; -import MyIcon from "../../Components/Icon"; - -const MotorView = lazy(() => import("./motor")); -const SettingsView = lazy(() => import("./settings")); -const ColorScenesView = lazy(() => import("./colorScenes")); - -const spaceToSide = 10; // left and right -const top = 35; -const spaceBetweenButtons = 60; - -const topFirst = top; -const topSecond = top + spaceBetweenButtons; -const topThird = top + 2 * spaceBetweenButtons; - -const windowDimensions = Dimensions.get("window"); - -let data = []; - -const ledLines = 4; -const ledsPerLine = 16; - -const deviceLeds = ledLines * ledsPerLine; - -// setting default color for testing -for (let i = 0; i < deviceLeds; i++) { - data.push("lime"); -} - -export default function DeviceOldScreen() { - const appContext = useContext(AppContext); - const [selectedView, setSelectedView] = useState(0); - const [deviceLedsColors, setDeviceLedsColor] = useState(data); - const [selectedDeviceLed, setSelectedDeviceLed] = useState(2); - - const SelectedView = () => { - switch (selectedView) { - case 0: - return ; - case 2: - return ; - case 3: - return ; - case 4: - return ( - - ); - default: - Not found; - } - }; - - const MyButton = ({ selectedViewNumber, top, left, space, iconName }) => { - const TouchComponent = - appContext.appColorScheme === "dark" - ? TouchableHighlight - : TouchableOpacity; - - return ( - setSelectedView(selectedViewNumber)} - style={[ - { - position: "absolute", - backgroundColor: appContext.appTheme.card.backgroundColor, - borderRadius: 10, - padding: 8, - }, - { top: top }, - left === true ? { left: space } : { right: space }, - ]} - > - - - ); - }; - - const DeviceLedsColor = () => { - let elements = []; - let test = 400; - - for (let l = 0; l < ledLines; l++) { - let left = 0; - let ledsElements = []; - - for (let p = 0; p < ledsPerLine; p++) { - left = left + 1.5; - - const ledId = l > 0 ? l * 16 + p : p; - - const deviceLedColor = - l > 0 ? deviceLedsColors[l * 16 + p] : deviceLedsColors[p]; - - ledsElements.push( - 360 - ? 0.27 * (test / 16) - : 0.26 * (test / 16), - }} - /> - ); - } - - elements.push( - - {ledsElements} - - ); - } - - return <>{elements}; - }; - - return ( - - {selectedView === 4 && ( - - - - - - )} - - {appContext.isUserDeveloperModeEnabled ? ( - <> - {selectedView !== 4 && ( - - )} - - ) : ( - <> - {selectedView !== 4 && ( - - )} - - )} - - - - - - - - - - - - - - ); -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: "center", - justifyContent: "center", - backgroundColor: "#2e2e30", - }, - scrollView: { - width: "100%", - padding: 20, - }, - image: { - width: "100%", - height: 250, - }, -}); diff --git a/src/Screens/DeviceOld/light.js b/src/Screens/DeviceOld/light.js deleted file mode 100644 index 2297353..0000000 --- a/src/Screens/DeviceOld/light.js +++ /dev/null @@ -1,416 +0,0 @@ -import { useContext, useState } from "react"; -import { - StyleSheet, - Text, - TouchableOpacity, - View, - TouchableHighlight, -} from "react-native"; -import Animated, { - useAnimatedStyle, - useSharedValue, -} from "react-native-reanimated"; -import ColorPicker, { - Swatches, - InputWidget, - HueCircular, - Panel1, - Panel3, - BrightnessSlider, - OpacitySlider, - HueSlider, - SaturationSlider, -} from "reanimated-color-picker"; -import { AppContext, AppStyles, IsPlatformIos } from "../../utils"; -import Card from "../../Components/Card"; -import MySwitch from "../../Components/Switch"; -import MyIcon from "../../Components/Icon"; -import { useTranslation } from "react-i18next"; -import MySlider from "../../Components/Slider"; -import MyPickerModal from "../../Components/Modal"; - -const colorModePickerOptions = [ - { label: "Pulse", value: "pulse" }, - { label: "Random", value: "random" }, - { label: "Rainbow", value: "rainbow" }, -]; - -function ColorLayer({ layerNumber, sharedColor, selected, onPress }) { - const backgroundColorStyle = useAnimatedStyle(() => { - return { - backgroundColor: sharedColor.value, - }; - }); - - const contrastColorText = useAnimatedStyle(() => { - const getContrastRatio = (hexColor) => { - const hex = hexColor.replace("#", ""); - const r = parseInt(hex.substr(0, 2), 16); - const g = parseInt(hex.substr(2, 2), 16); - const b = parseInt(hex.substr(4, 2), 16); - const luminance = (r * 0.299 + g * 0.587 + b * 0.114) / 255; - return luminance > 0.5 ? "#000000" : "#ffffff"; - }; - - let obj = {}; - - obj.color = getContrastRatio(sharedColor.value); - - return obj; - }); - - const contrastColorBorder = useAnimatedStyle(() => { - const getContrastRatio = (hexColor) => { - const hex = hexColor.replace("#", ""); - const r = parseInt(hex.substr(0, 2), 16); - const g = parseInt(hex.substr(2, 2), 16); - const b = parseInt(hex.substr(4, 2), 16); - const luminance = (r * 0.299 + g * 0.587 + b * 0.114) / 255; - return luminance > 0.5 ? "#000000" : "#ffffff"; - }; - - let obj = {}; - - //obj.color = getContrastRatio(sharedColor.value); - - if (selected === true) { - obj.borderColor = getContrastRatio(sharedColor.value); - obj.borderBottomWidth = 2; - } else { - obj.borderBottomWidth = 0; - } - - return obj; - }); - - return ( - - - - - {layerNumber} - - - - - ); -} - -export default function LightView() { - const appContext = useContext(AppContext); - const { t } = useTranslation(); - const [switchState, setSwitchState] = useState(false); - const [selectedGlasLayer, setSelectedGlasLayer] = useState(1); - const [colorSwatchesFavorites, setColorSwatchesFavorites] = useState([]); - const [modalDeviceColorModeVisible, setModalDeviceColorModeVisible] = - useState(false); - const [selectedDeviceColorMode, setSelectedDeviceColorMode] = useState(""); - - const selectedColorPickerColor = useSharedValue("#ddd"); - const selectedColorLayer1 = useSharedValue(selectedColorPickerColor.value); - const selectedColorLayer2 = useSharedValue(selectedColorPickerColor.value); - const selectedColorLayer3 = useSharedValue(selectedColorPickerColor.value); - const selectedColorLayer4 = useSharedValue(selectedColorPickerColor.value); - - const [sliderBrightness, setSliderBrightness] = useState(10); - - const onColorSelect = (color) => { - selectedColorPickerColor.value = color.hex; - - switch (selectedGlasLayer) { - case 1: - selectedColorLayer1.value = color.hex; - break; - case 2: - selectedColorLayer2.value = color.hex; - break; - case 3: - selectedColorLayer3.value = color.hex; - break; - case 4: - selectedColorLayer4.value = color.hex; - break; - } - }; - - return ( - <> - - setModalDeviceColorModeVisible(true)}> - - - - {t("screens.device.light.pickerColorModeText")} - - - {selectedDeviceColorMode === "" - ? t("screens.device.light.pickerColorModePlaceholder") - : colorModePickerOptions.find( - (item) => item.value === selectedDeviceColorMode - ).label} - - - - - - - { - return { - label: item.label, - onPress: () => setSelectedDeviceColorMode(item.value), - selected: selectedDeviceColorMode === item.value, - }; - })} - /> - - - setSwitchState(e)} - /> - - setSliderBrightness(v)} - /> - - - - - - { - setSelectedGlasLayer(1); - selectedColorPickerColor.value = selectedColorLayer1.value; - }} - /> - { - setSelectedGlasLayer(2); - selectedColorPickerColor.value = selectedColorLayer2.value; - }} - /> - { - setSelectedGlasLayer(3); - selectedColorPickerColor.value = selectedColorLayer3.value; - }} - /> - { - setSelectedGlasLayer(4); - selectedColorPickerColor.value = selectedColorLayer4.value; - }} - /> - - - - setColorSwatchesFavorites([ - ...colorSwatchesFavorites, - selectedColorPickerColor.value, - ]) - } - style={{ - position: "absolute", - top: 20, - right: 0, - }} - > - - - - - - - - - - - - - - {appContext.isUserExpertModeEnabled && ( - - - - )} - - - - - - - - - - Auto brightness - - - - setSwitchState(e)} - /> - - - - ); -} - -const styles = StyleSheet.create({ - previewTxtContainer: { - paddingTop: 20, - marginTop: 20, - borderTopWidth: 1, - borderColor: "#bebdbe", - }, - panelStyle: { - width: "60%", - height: "60%", - alignSelf: "center", - borderRadius: 16, - }, - sliderStyle: { - borderRadius: 20, - marginTop: 20, - width: 10, - }, - swatchesContainer: { - borderTopWidth: 1, - borderColor: "#bebdbe", - marginTop: 20, - paddingTop: 20, - justifyContent: "center", - gap: 10, - }, - swatchStyle: { - borderRadius: 20, - height: 25, - width: 25, - margin: 0, - marginBottom: 0, - marginHorizontal: 0, - marginVertical: 0, - }, -}); diff --git a/src/Screens/DeviceOld/motor.js b/src/Screens/DeviceOld/motor.js deleted file mode 100644 index f077ea4..0000000 --- a/src/Screens/DeviceOld/motor.js +++ /dev/null @@ -1,33 +0,0 @@ -import { View } from "react-native"; -import Card from "../../Components/Card"; -import { useContext, useState } from "react"; -import MySwitch from "../../Components/Switch"; -import MySlider from "../../Components/Slider"; -import { AppContext, IsPlatformIos } from "../../utils"; -import MyIcon from "../../Components/Icon"; - -export default function MotorView() { - const appContext = useContext(AppContext); - const [switchState, setSwitchState] = useState(false); - - return ( - - - setSwitchState(e)} - /> - - - - - - - - ); -} diff --git a/src/Screens/DeviceOld/settings.js b/src/Screens/DeviceOld/settings.js deleted file mode 100644 index 6dc1a6c..0000000 --- a/src/Screens/DeviceOld/settings.js +++ /dev/null @@ -1,174 +0,0 @@ -import { Text, TouchableOpacity, View } from "react-native"; -import Card from "../../Components/Card"; -import { useContext, useState } from "react"; -import { AppContext, AppStyles } from "../../utils"; -import { Divider } from "../../Components/Divider"; -import { useTranslation } from "react-i18next"; -import MySwitch from "../../Components/Switch"; -import MyIcon from "../../Components/Icon"; -import { MyTextInputModal } from "../../Components/Modal"; - -export default function SettingsView() { - const appContext = useContext(AppContext); - const { t } = useTranslation(); - const [modalTextInputVisible, setModalTextInputVisible] = useState(false); - const [switchState, setSwitchState] = useState(false); - - return ( - <> - - - {t("screens.device.settings.settingsTitle")} - - - - - - {t("screens.device.settings.wifiStandByTitle")} - - - {t("screens.device.settings.wifiStandByDescription")} - - - setSwitchState(e)} - /> - - - - - - {t("screens.device.settings.deviceInformationText")} - - - - - - {t("screens.device.settings.deviceNameText")} - - - Turtle - - - - setModalTextInputVisible(true)}> - - - - - console.log("save")} - modalTitle={t("screens.device.settings.deviceNameText")} - inputTitle={t("screens.device.settings.deviceNameText")} - inputDescription={t( - "screens.device.settings.modalTextInputDeviceNameDescription" - )} - /> - - - - - {t("screens.device.settings.deviceModelText")} - - - Shimmex Aurora - - - - - - {t("screens.device.settings.deviceFirmwareVersionText")} - - - 1.0.1 - - - - - - {t("screens.device.settings.deviceLastUpdatedText")} - - - 11.07.2023 um 20:33 Uhr - - - - ); -}