From 067f5e711da6a01cd26f80d397759bd3704b8bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Mon, 10 Apr 2023 00:16:23 +0200 Subject: [PATCH] helperText is working great --- front/components/GtkUI/ElementList.tsx | 95 ++++++++++++++++---- front/views/settings/SettingsProfileView.tsx | 17 +++- 2 files changed, 92 insertions(+), 20 deletions(-) diff --git a/front/components/GtkUI/ElementList.tsx b/front/components/GtkUI/ElementList.tsx index d451634..cb0cd91 100644 --- a/front/components/GtkUI/ElementList.tsx +++ b/front/components/GtkUI/ElementList.tsx @@ -1,7 +1,22 @@ import React from "react"; import { StyleProp, ViewStyle } from "react-native"; +import IconButton from "../IconButton"; +import { Ionicons } from "@expo/vector-icons"; -import { Box, Center, Column, Row, Text, Divider, Switch } from "native-base"; +import { + Box, + Center, + Button, + Column, + Row, + Icon, + Text, + Divider, + Switch, + Popover, + useBreakpointValue, + Select, +} from "native-base"; type ElementType = "custom" | "default" | "text" | "toggle" | "dropdown"; @@ -27,7 +42,7 @@ type ElementDropdownProps = { defaultValue?: string; }; -const getElementTextNode = ({ text, type }: ElementTextProps) => { +const getElementTextNode = ({ text }: ElementTextProps) => { return ( { - return Dropdown; + return ( + + ); }; type ElementProps = { @@ -67,6 +93,7 @@ type ElementProps = { icon?: React.ReactNode; type?: ElementType | "custom"; helperText?: string; + description?: string; disabled?: boolean; onPress?: () => void; // node is only used if type is "custom" @@ -79,11 +106,14 @@ const Element = ({ icon, type, helperText, + description, disabled, onPress, node, data, }: ElementProps) => { + const screenSize = useBreakpointValue({ base: "small", md: "big" }); + const isSmallScreen = screenSize === "small"; return ( {title} - {(() => { - switch (type) { - case "text": - return getElementTextNode(data as ElementTextProps); - case "toggle": - return getElementToggleNode(data as ElementToggleProps); - case "dropdown": - return getElementDropdownNode(data as ElementDropdownProps); - case "custom": - return node; - default: - return Unknown type; - } - })()} + + {helperText && ( + ( +