diff --git a/front/components/GtkUI/Element.tsx b/front/components/GtkUI/Element.tsx index d3dd14f..2eb3c9e 100644 --- a/front/components/GtkUI/Element.tsx +++ b/front/components/GtkUI/Element.tsx @@ -70,7 +70,7 @@ export const Element = (props: T) => { { props.type === 'sectionDropdown' && dropdownValue && - + { props.data.section.map((value, index) => ( { {elements.map((element, index) => ( - {index < elements.length - 1 && } + {index < elements.length - 1 && } ))} diff --git a/front/components/UI/InteractiveBase.tsx b/front/components/UI/InteractiveBase.tsx index 93f00e0..f1b3c71 100644 --- a/front/components/UI/InteractiveBase.tsx +++ b/front/components/UI/InteractiveBase.tsx @@ -1,8 +1,6 @@ -import React, { useRef, useState } from 'react'; -import { Animated, StyleSheet, TouchableOpacity, ActivityIndicator, View, Image, StyleProp, ViewStyle } from 'react-native'; -// import Ionicons from '@expo/vector-icons/Ionicons'; -// import { Text, useTheme } from 'native-base' -// import { BlurView } from '@react-native-community/blur'; +import { Pressable } from 'native-base'; +import React, { useRef } from 'react'; +import { Animated, StyleSheet, StyleProp, ViewStyle } from 'react-native'; interface InteractiveBaseProps { children?: React.ReactNode; @@ -128,7 +126,7 @@ const InteractiveBase: React.FC = ({ children, onPress, st ]).start(); }; // Mouse Up - const handlePressOut = async () => { + const handlePressOut = () => { Animated.parallel([ Animated.spring(scaleAnimator, { toValue: 1, @@ -157,7 +155,7 @@ const InteractiveBase: React.FC = ({ children, onPress, st ]).start(); if (onPress && !isDisabled) { - await onPress(); + onPress(); } } // Mouse Leave @@ -205,29 +203,16 @@ const InteractiveBase: React.FC = ({ children, onPress, st }, ]} > - {children} - {/* */} - + ); }; diff --git a/front/components/UI/TextFormField copy.tsx b/front/components/UI/TextFormField copy.tsx deleted file mode 100644 index 1204f18..0000000 --- a/front/components/UI/TextFormField copy.tsx +++ /dev/null @@ -1,183 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { View, TextInput, TouchableOpacity, StyleSheet, Text, Animated } from 'react-native'; -import Icon from 'react-native-vector-icons/Ionicons'; // Supposons que nous utilisons la bibliothèque Ionicons pour les icônes - -interface TextFormFieldProps { - value?: string; - icon?: string; - placeholder?: string; - autoComplete?: - | 'birthdate-day' - | 'birthdate-full' - | 'birthdate-month' - | 'birthdate-year' - | 'cc-csc' - | 'cc-exp' - | 'cc-exp-day' - | 'cc-exp-month' - | 'cc-exp-year' - | 'cc-number' - | 'email' - | 'gender' - | 'name' - | 'name-family' - | 'name-given' - | 'name-middle' - | 'name-middle-initial' - | 'name-prefix' - | 'name-suffix' - | 'password' - | 'password-new' - | 'postal-address' - | 'postal-address-country' - | 'postal-address-extended' - | 'postal-address-extended-postal-code' - | 'postal-address-locality' - | 'postal-address-region' - | 'postal-code' - | 'street-address' - | 'sms-otp' - | 'tel' - | 'tel-country-code' - | 'tel-national' - | 'tel-device' - | 'username' - | 'username-new' - | 'off' - | undefined; - isSecret?: boolean; - isRequired?: boolean; - error?: string; - onChangeText?: ((text: string) => void) | undefined; -} - -const ERROR_HEIGHT = 20; -const ERROR_PADDING_TOP = 8; - -const TextFormField: React.FC = ({ value = '', placeholder = '', icon, autoComplete = 'off', isSecret = false, isRequired = false, error, ...props }) => { - const [isPasswordVisible, setPasswordVisible] = useState(!isSecret); - const [isFocused, setFocused] = useState(false); - const [fieldValue, setFieldValue] = useState(value); - const fadeAnim = React.useRef(new Animated.Value(0)).current; // Initial value for opacity: 0 - const heightAnim = React.useRef(new Animated.Value(0)).current; // Initial value for height: 0 - const paddingTopAnim = React.useRef(new Animated.Value(0)).current; // Initial value for paddingTop: 0 - - // Update fieldValue whenever value changes - useEffect(() => { - setFieldValue(value); - }, [value]); - - // Animate the error message - useEffect(() => { - Animated.parallel([ - Animated.timing( - fadeAnim, - { - toValue: error ? 1 : 0, - duration: 500, - useNativeDriver: true - } - ), - Animated.timing( - heightAnim, - { - toValue: error ? ERROR_HEIGHT : 0, - duration: 250, - useNativeDriver: false // height cannot be animated using native driver - } - ), - Animated.timing( - paddingTopAnim, - { - toValue: error ? ERROR_PADDING_TOP : 0, - duration: 150, - useNativeDriver: false // paddingTop cannot be animated using native driver - } - ), - ]).start(); - }, [error]); - - const handleTextChange = (text: string) => { - setFieldValue(text); - if (props.onChangeText) { - props.onChangeText(text); - } - }; - - return ( - - - - {icon && } - - setFocused(true)} - onBlur={() => setFocused(false)} - onChangeText={handleTextChange} - {...props} - /> - {isSecret && ( - setPasswordVisible(prevState => !prevState)}> - - - )} - - - - {error} - - - ); -}; - -const styles = StyleSheet.create({ - wrapper: { - width: '100%', - }, - container: { - flexDirection: 'row', - alignItems: 'center', - backgroundColor: '#22222D', - borderRadius: 16, - }, - error: { - }, - containerFocused: { - }, - input: { - flex: 1, - color: '#ffffff', - paddingHorizontal: 16 + 24 + 16, - paddingVertical: 16, - outlineStyle: 'none', - }, - iconContainerLeft: { - position: 'absolute', - left: 16, - zIndex: 1, - }, - iconContainerRight: { - position: 'absolute', - outlineStyle: 'none', - right: 16, - zIndex: 1, - }, - errorContainer: { - flexDirection: 'row', - alignItems: 'center', - paddingLeft: 40, - }, - errorText: { - color: 'red', - fontSize: 12, - marginLeft: 8, - }, -}); - -export default TextFormField; diff --git a/front/components/UI/TextFormField.tsx b/front/components/UI/TextFormField.tsx index 1abcfba..310396e 100644 --- a/front/components/UI/TextFormField.tsx +++ b/front/components/UI/TextFormField.tsx @@ -24,7 +24,7 @@ const TextFormField: React.FC = ({ error, style, ...textFiel { toValue: error ? 1 : 0, duration: 150, - useNativeDriver: true + useNativeDriver: false } ), Animated.timing( diff --git a/front/views/ProfileView.tsx b/front/views/ProfileView.tsx index 0dd12ad..ec2a30a 100644 --- a/front/views/ProfileView.tsx +++ b/front/views/ProfileView.tsx @@ -42,7 +42,7 @@ const ProfileView = () => { navigation.navigate('Settings', { screen: 'profile' })} + onPress={() => navigation.navigate('Settings')} translate={{ translationKey: 'settingsBtn' }} /> diff --git a/front/views/settings/SettingsView.tsx b/front/views/settings/SettingsView.tsx index b8a4d27..30c718d 100644 --- a/front/views/settings/SettingsView.tsx +++ b/front/views/settings/SettingsView.tsx @@ -15,7 +15,7 @@ import API from '../../API'; import { RouteProps } from '../../Navigation'; import { PressableAndroidRippleConfig, StyleProp, TextStyle, View, ViewStyle, useWindowDimensions } from 'react-native'; import { TabView, SceneMap, TabBar, NavigationState, Route, SceneRendererProps, TabBarIndicatorProps, TabBarItemProps } from 'react-native-tab-view'; -import { HeartEdit, Star1, UserEdit, Notification, SecurityUser, Music, Icon } from 'iconsax-react-native'; +import { HeartEdit, Star1, UserEdit, Notification, SecurityUser, Music, FolderCross } from 'iconsax-react-native'; import { Scene, Event } from 'react-native-tab-view/lib/typescript/src/types'; import { LinearGradient } from 'expo-linear-gradient'; import PremiumSettings from './SettingsPremiumView'; @@ -37,17 +37,36 @@ const renderScene = SceneMap({ piano: PianoSettingsView, }); +const getTabData = (key: string) => { + switch (key){ + case 'profile': + return { index: 0, icon: UserEdit }; + case 'premium': + return { index: 1, icon: Star1 }; + case 'preferences': + return { index: 2, icon: HeartEdit }; + case 'notifications': + return { index: 3, icon: Notification }; + case 'privacy': + return { index: 4, icon: SecurityUser }; + case 'piano': + return { index: 5, icon: Music }; + default: + return { index: 6, icon: FolderCross }; + } +} + const SetttingsNavigator = () => { const layout = useWindowDimensions(); const [index, setIndex] = React.useState(0); - const [routes] = React.useState([ - {index: 0, key: 'profile', title: 'Profile', icon: UserEdit}, - {index: 1, key: 'premium', title: 'Premium', icon: Star1}, - {index: 2, key: 'preferences', title: 'Preferences', icon: HeartEdit}, - {index: 3, key: 'notifications', title: 'Notifications', icon: Notification}, - {index: 4, key: 'privacy', title: 'Privacy', icon: SecurityUser}, - {index: 5, key: 'piano', title: 'Piano', icon: Music}, + const [routes] = React.useState([ + {key: 'profile', title: 'Profile'}, + {key: 'premium', title: 'Premium'}, + {key: 'preferences', title: 'Preferences'}, + {key: 'notifications', title: 'Notifications'}, + {key: 'privacy', title: 'Privacy'}, + {key: 'piano', title: 'Piano'}, ]); const renderTabBar = (props: JSX.IntrinsicAttributes & SceneRendererProps & { navigationState: NavigationState; scrollEnabled?: boolean | undefined; bounces?: boolean | undefined; activeColor?: string | undefined; inactiveColor?: string | undefined; pressColor?: string | undefined; pressOpacity?: number | undefined; getLabelText?: ((scene: Scene) => string | undefined) | undefined; getAccessible?: ((scene: Scene) => boolean | undefined) | undefined; getAccessibilityLabel?: ((scene: Scene) => string | undefined) | undefined; getTestID?: ((scene: Scene) => string | undefined) | undefined; renderLabel?: ((scene: Scene & { focused: boolean; color: string; }) => React.ReactNode) | undefined; renderIcon?: ((scene: Scene & { focused: boolean; color: string; }) => React.ReactNode) | undefined; renderBadge?: ((scene: Scene) => React.ReactNode) | undefined; renderIndicator?: ((props: TabBarIndicatorProps) => React.ReactNode) | undefined; renderTabBarItem?: ((props: TabBarItemProps & { key: string; }) => React.ReactElement>) | undefined; onTabPress?: ((scene: Scene & Event) => void) | undefined; onTabLongPress?: ((scene: Scene) => void) | undefined; tabStyle?: StyleProp; indicatorStyle?: StyleProp; indicatorContainerStyle?: StyleProp; labelStyle?: StyleProp; contentContainerStyle?: StyleProp; style?: StyleProp; gap?: number | undefined; testID?: string | undefined; android_ripple?: PressableAndroidRippleConfig | undefined; }) => ( @@ -59,10 +78,10 @@ const SetttingsNavigator = () => { focused: boolean; color: string; }) => { - const MyIcon: Icon = scene.route?.icon as unknown as Icon; - return scene.route?.index == index ? - - : + const tabHeader = getTabData(scene.route!.key); + return tabHeader.index == index ? + + : }} renderLabel={({ route, focused, color }) => ( layout.width > 750 ?