@fto-consult/expo-ui 1.1.41 → 1.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "1.1.41",
3
+ "version": "1.1.42",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,14 +3,14 @@ import {
3
3
  StyleSheet,
4
4
  } from 'react-native';
5
5
  import {TouchableRipple} from "react-native-paper";
6
- import Icon from './Icon';
7
- import CrossFadeIcon from './CrossFadeIcon';
6
+ import CrossFadeIcon from 'react-native-paper/lib/commonjs/components/CrossFadeIcon';
8
7
  import Surface from '$ecomponents/Surface';
8
+ import { IconButton } from 'react-native-paper';
9
9
  import PropTypes from "prop-types";
10
10
  import theme,{StyleProp,Colors} from "$theme";
11
- import {defaultStr,isNonNullString} from "$utils";
11
+ import {defaultStr} from "$utils";
12
12
 
13
- const IconButton = ({
13
+ const IconButtonComponent = ({
14
14
  icon,
15
15
  iconColor: customIconColor,
16
16
  containerColor,
@@ -26,7 +26,7 @@ const IconButton = ({
26
26
  testID,
27
27
  ...rest
28
28
  }) => {
29
- const IconComponent = animated ? CrossFadeIcon : Icon;
29
+ const IconComponent = animated ? CrossFadeIcon : IconButton;
30
30
  testID = defaultStr(testID,"RN_IconButtonComponent");
31
31
  containerProps = defaultObj(containerProps);
32
32
  const containerStyle = StyleSheet.flatten(containerProps.style) || {};
@@ -102,7 +102,7 @@ const styles = StyleSheet.create({
102
102
  },
103
103
  });
104
104
 
105
- IconButton.propTypes = {
105
+ IconButtonComponent.propTypes = {
106
106
  /**
107
107
  * Icon to display.
108
108
  */
@@ -152,4 +152,4 @@ IconButton.propTypes = {
152
152
  style : StyleProp,
153
153
  ref : PropTypes.object,
154
154
  }
155
- export default theme.withStyles(IconButton,{displayName:"IconButtonComponent"});
155
+ export default theme.withStyles(IconButtonComponent,{displayName:"IconButtonComponent"});
@@ -1,5 +1,4 @@
1
1
  import {isIos} from "$cplatform";
2
- import theme,{Colors} from "$theme";
3
2
 
4
3
  export const BACK_ICON = isIos() ? "chevron-left" : "arrow-left";
5
4
 
@@ -1,12 +1,9 @@
1
- import {IconButton } from "react-native-paper";
2
1
  import { Component } from "react";
3
2
  import {isNativeMobile} from "$cplatform";
4
- import {Image} from "react-native";
5
3
  import View from "$ecomponents/View";
6
4
  import React from "$react";
7
5
  import theme,{remToPixel,Colors,flattenStyle} from '$theme';
8
6
  import {StyleSheet} from "react-native";
9
- import source from "$assets/logo.png";
10
7
  import {defaultStr} from "$utils";
11
8
  import LogoComponent from "$logoComponent";
12
9
 
@@ -17,19 +14,22 @@ export default class Logo extends Component {
17
14
  let {icon,color,style,testID,logo,text} = this.props;
18
15
  testID = defaultStr(testID,"RN_LogoComponent");
19
16
  const styles = getStyle(style,color);
17
+ let logoImage = null,img,txt=null,hasTwice = false;
18
+ if(LogoComponent){
19
+ hasTwice = React.isComponent(LogoComponent.Image) && React.isComponent(LogoComponent.Text);
20
+ if(!hasTwice){
21
+ logoImage = React.isValidElement(LogoComponent)? LogoComponent : React.isComponent(LogoComponent)? <LogoComponent {...props} style={styles.logoContent} testID={testID+"_Content"} styles={styles}/> : null;
22
+ } else {
23
+ img = icon !== false ? <View testID={testID+"_ContentContainer"} style={styles.logoImage}>
24
+ <LogoComponent.Image styles={styles}/>
25
+ </View> : null;
26
+ txt = text !== false ? <LogoComponent.Text style={styles.logoContent} styles={styles}/> : null;
27
+ }
28
+ }
20
29
  return <View testID={testID} style={styles.container}>
21
- {icon !== false ? <View testID={testID+"_ContentContainer"} style={styles.logoImage}>
22
- {<IconButton testID={testID+"_IconButton"} style={styles.logoImageContent}
23
- size={50}
24
- icon={() => (
25
- <Image
26
- source={source}
27
- style={{ width: 50, height: 50}}
28
- />
29
- )}
30
- />}
31
- </View> : null}
32
- {text !== false && logo !== false ? (React.isValidElement(LogoComponent)? LogoComponent : React.isComponent(LogoComponent)? <LogoComponent {...props} style={styles.logoContent} testID={testID+"_Content"} styles={styles}/> : null) : null}
30
+ {hasTwice ? img : null}
31
+ {hasTwice? txt : null}
32
+ {!hasTwice ? logoImage : null}
33
33
  </View>
34
34
  }
35
35
 
@@ -1,133 +0,0 @@
1
- import * as React from 'react';
2
- import { Animated, StyleSheet, View } from 'react-native';
3
- import Icon, { isValidIcon, isEqualIcon } from './Icon';
4
- import PropTypes from 'prop-types';
5
- import theme from "$theme";
6
- import {defaultStr,defaultObj} from "$utils";
7
-
8
- const CrossFadeIcon = ({ color,testID,containerProps,style, size, source}) => {
9
- const [currentIcon, setCurrentIcon] = React.useState(
10
- () => source
11
- );
12
- testID = defaultStr(testID,"RN_CrossFadeIconComponent");
13
- const [previousIcon, setPreviousIcon] = React.useState(
14
- null
15
- );
16
-
17
- const { current: fade } = React.useRef(new Animated.Value(1));
18
-
19
- const { scale } = theme.animation;
20
-
21
- if (currentIcon !== source) {
22
- setPreviousIcon(() => currentIcon);
23
- setCurrentIcon(() => source);
24
- }
25
-
26
- React.useEffect(() => {
27
- if (isValidIcon(previousIcon) && !isEqualIcon(previousIcon, currentIcon)) {
28
- fade.setValue(1);
29
-
30
- Animated.timing(fade, {
31
- duration: scale * 200,
32
- toValue: 0,
33
- useNativeDriver: true,
34
- }).start();
35
- }
36
- }, [currentIcon, previousIcon, fade, scale]);
37
-
38
- const opacityPrev = fade;
39
- const opacityNext = previousIcon
40
- ? fade.interpolate({
41
- inputRange: [0, 1],
42
- outputRange: [1, 0],
43
- })
44
- : 1;
45
-
46
- const rotatePrev = fade.interpolate({
47
- inputRange: [0, 1],
48
- outputRange: ['-90deg', '0deg'],
49
- });
50
- containerProps = defaultObj(containerProps);
51
- const rotateNext = previousIcon
52
- ? fade.interpolate({
53
- inputRange: [0, 1],
54
- outputRange: ['0deg', '-180deg'],
55
- })
56
- : '0deg';
57
-
58
- return (
59
- <View
60
- testID={testID+"_Container"}
61
- {...containerProps}
62
- style={[
63
- styles.content,
64
- {
65
- height: size,
66
- width: size,
67
- },
68
- containerProps.style
69
- ]}
70
- >
71
- {previousIcon ? (
72
- <Animated.View
73
- testID={testID+"_PrevIcon"}
74
- style={[
75
- styles.icon,
76
- {
77
- opacity: opacityPrev,
78
- transform: [{ rotate: rotatePrev }],
79
- },
80
- ]}
81
- >
82
- <Icon testID={testID+"_Left"} source={previousIcon} size={size} color={color} />
83
- </Animated.View>
84
- ) : null}
85
- <Animated.View
86
- testID={testID+"_RightIcon"}
87
- style={[
88
- styles.icon,
89
- {
90
- opacity: opacityNext,
91
- transform: [{ rotate: rotateNext }],
92
- },
93
- ]}
94
- >
95
- <Icon testID={testID+"_Right"} source={currentIcon} size={size} color={color} />
96
- </Animated.View>
97
- </View>
98
- );
99
- };
100
-
101
- export default theme.withStyles(CrossFadeIcon,{displayName:"CrossFadeIconComponent",mode:'normal'});
102
-
103
- const styles = StyleSheet.create({
104
- content: {
105
- alignItems: 'center',
106
- justifyContent: 'center',
107
- },
108
- icon: {
109
- position: 'absolute',
110
- top: 0,
111
- left: 0,
112
- right: 0,
113
- bottom: 0,
114
- },
115
- });
116
-
117
- CrossFadeIcon.propTypes = {
118
- /**
119
- * Icon to display for the `CrossFadeIcon`.
120
- */
121
- source: PropTypes.oneOfType([
122
- PropTypes.string,
123
- PropTypes.object,
124
- ]),
125
- /**
126
- * Color of the icon.
127
- */
128
- color: PropTypes.string,
129
- /**
130
- * Size of the icon.
131
- */
132
- size: PropTypes.number,
133
- }
@@ -1,93 +0,0 @@
1
- import * as React from 'react';
2
- import { StyleSheet, Text, Platform} from 'react-native';
3
- import { black } from "$theme/defaultTheme";
4
- import theme from "$theme";
5
- let MaterialCommunityIcons = undefined;
6
-
7
- try {
8
- // Optionally require vector-icons
9
- MaterialCommunityIcons = require('react-native-vector-icons/MaterialCommunityIcons').default;
10
- } catch (e) {
11
- let isErrorLogged = false;
12
-
13
- // Fallback component for icons
14
- MaterialCommunityIcons = ({ name, color, size, ...rest }) => {
15
- /* eslint-disable no-console */
16
- if (!isErrorLogged) {
17
- if (
18
- !/(Cannot find module|Module not found|Cannot resolve module)/.test(
19
- (e).message
20
- )
21
- ) {
22
- console.error(e);
23
- }
24
-
25
- console.warn(
26
- `Tried to use the icon '${name}' in a component from 'react-native-paper', but 'react-native-vector-icons/MaterialCommunityIcons' could not be loaded.`,
27
- `To remove this warning, try installing 'react-native-vector-icons' or use another method to specify icon: https://callstack.github.io/react-native-paper/icons.html.`
28
- );
29
-
30
- isErrorLogged = true;
31
- }
32
-
33
- return (
34
- <Text
35
- {...rest}
36
- style={[styles.icon, { color, fontSize: size }]}
37
- // @ts-expect-error: Text doesn't support this, but it seems to affect TouchableNativeFeedback
38
- pointerEvents="none"
39
- selectable={false}
40
- >
41
-
42
- </Text>
43
- );
44
- };
45
- }
46
-
47
- export const accessibilityProps =
48
- Platform.OS === 'web'
49
- ? {
50
- role: 'img',
51
- focusable: false,
52
- }
53
- : {
54
- accessibilityElementsHidden: true,
55
- importantForAccessibility:
56
- 'no-hide-descendants',
57
- };
58
-
59
- const defaultIcon = ({
60
- name,
61
- color = theme.colors.text,
62
- size,
63
- direction,
64
- allowFontScaling,
65
- ...rest
66
- }) => (
67
- <MaterialCommunityIcons
68
- pointerEvents="none"
69
- {...rest}
70
- allowFontScaling={allowFontScaling}
71
- name={name}
72
- color={color}
73
- size={size}
74
- style={[
75
- {
76
- transform: [{ scaleX: direction === 'rtl' ? -1 : 1 }],
77
- lineHeight: size,
78
- },
79
- styles.icon,
80
- rest.style,
81
- ]}
82
- selectable={false}
83
- {...accessibilityProps}
84
- />
85
- );
86
-
87
- const styles = StyleSheet.create({
88
- icon: {
89
- backgroundColor: 'transparent',
90
- },
91
- });
92
-
93
- export default theme.withStyles(defaultIcon,"MaterialIconComponent");