Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TabSideIcon.tsx 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import React from 'react';
  2. import { TouchableRipple, useTheme } from 'react-native-paper';
  3. import { StyleSheet, View } from 'react-native';
  4. import * as Animatable from 'react-native-animatable';
  5. import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
  6. import GENERAL_STYLES from '../../constants/Styles';
  7. interface Props {
  8. focused: boolean;
  9. label: string | undefined;
  10. icon: string;
  11. focusedIcon: string;
  12. onPress: () => void;
  13. }
  14. Animatable.initializeRegistryWithDefinitions({
  15. focusIn: {
  16. 0: {
  17. // @ts-ignore
  18. scale: 1,
  19. translateY: 0,
  20. },
  21. 0.4: {
  22. // @ts-ignore
  23. scale: 1.3,
  24. translateY: 6,
  25. },
  26. 0.6: {
  27. // @ts-ignore
  28. scale: 1.1,
  29. translateY: 6,
  30. },
  31. 0.8: {
  32. // @ts-ignore
  33. scale: 1.25,
  34. translateY: 6,
  35. },
  36. 1: {
  37. // @ts-ignore
  38. scale: 1.2,
  39. translateY: 6,
  40. },
  41. },
  42. focusOut: {
  43. 0: {
  44. // @ts-ignore
  45. scale: 1.2,
  46. translateY: 6,
  47. },
  48. 1: {
  49. // @ts-ignore
  50. scale: 1,
  51. translateY: 0,
  52. },
  53. },
  54. });
  55. function TabSideIcon(props: Props) {
  56. const theme = useTheme();
  57. const color = props.focused ? theme.colors.primary : theme.colors.disabled;
  58. let icon = props.focused ? props.focusedIcon : props.icon;
  59. return (
  60. <TouchableRipple
  61. onPress={props.onPress}
  62. borderless
  63. rippleColor={theme.colors.primary}
  64. style={{
  65. ...styles.ripple,
  66. borderTopEndRadius: theme.roundness,
  67. borderTopStartRadius: theme.roundness,
  68. }}
  69. >
  70. <View>
  71. <Animatable.View
  72. duration={props.focused ? 500 : 200}
  73. easing="ease-out"
  74. animation={props.focused ? 'focusIn' : 'focusOut'}
  75. useNativeDriver
  76. >
  77. <MaterialCommunityIcons
  78. name={icon}
  79. color={color}
  80. size={26}
  81. style={GENERAL_STYLES.centerHorizontal}
  82. />
  83. </Animatable.View>
  84. <Animatable.Text
  85. animation={props.focused ? 'fadeOutDown' : 'fadeIn'}
  86. useNativeDriver
  87. style={{
  88. color: color,
  89. ...styles.text,
  90. }}
  91. >
  92. {props.label}
  93. </Animatable.Text>
  94. </View>
  95. </TouchableRipple>
  96. );
  97. }
  98. const styles = StyleSheet.create({
  99. ripple: {
  100. flex: 1,
  101. justifyContent: 'center',
  102. },
  103. text: {
  104. ...GENERAL_STYLES.centerHorizontal,
  105. fontSize: 10,
  106. },
  107. });
  108. export default TabSideIcon;