@fto-consult/expo-ui 2.7.0 → 2.7.2

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": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "resolutions": {
@@ -10,20 +10,58 @@ import * as FontAsset from 'expo-font';
10
10
 
11
11
  /*** @see : https://materialdesignicons.com/ pour les icon MaterialComunityIcons*/
12
12
  import MaterialCommunityIcons from "@expo/vector-icons/MaterialCommunityIcons";
13
+ import FontAwesome5 from "@expo/vector-icons/FontAwesome5";
14
+ import AntDesign from "@expo/vector-icons/AntDesign";
15
+ import Fontisto from "@expo/vector-icons/Fontisto";
16
+ import Foundation from "@expo/vector-icons/Foundation";
17
+ import Ionicons from "@expo/vector-icons/Ionicons";
18
+ import MaterialIcons from "@expo/vector-icons/MaterialIcons";
19
+ import Octicons from "@expo/vector-icons/Octicons";
20
+ import SimpleLineIcons from "@expo/vector-icons/SimpleLineIcons";
21
+ import Zocial from "@expo/vector-icons/Zocial";
22
+
13
23
  /*** @see : https://icons.expo.fyi/ popur tous les icons supportés*/
24
+ /*** L'iconSet par défaut est le MaterialCommunityIcon qui ne nécessite pas de préfixer les noms des icones
25
+ * Les prefix suivant doivent être utilisés :
26
+ * fa - pour l'iconSet FontAweSome5
27
+ * ant - pour l'iconSet AntDesign
28
+ * fontisto - pour l'iconSet Fontisto
29
+ * foundation - pour l'iconSet Foundation
30
+ * ionic - pour l'iconSet IonicIcons
31
+ * octicons - pour l'iconSet Octicons
32
+ * simple-line - pour l'iconSet SimpleLinesIcons
33
+ * zocial - pour l'iconSet Zocial
34
+ */
14
35
  const FontIcon = React.forwardRef(({icon,name,testID,color,iconStyle,backgroundColor,style,...props},ref)=>{
15
36
  icon = defaultStr(icon,name).trim();
16
37
  testID = defaultStr(testID,"RN_FontIconComponent");
17
38
  const fStyle = StyleSheet.flatten(style) || {};
18
39
  color = theme.Colors.isValid(color)? color : fStyle.color || theme.colors.text;
19
40
  backgroundColor = theme.Colors.isValid(backgroundColor)? backgroundColor : fStyle.backgroundColor || 'transparent';
20
- const isMaterial = isIcon(name,"material") || true;
21
- const isExpo = isIcon(name,"expo");
22
- let Icon = isExpo ? null : MaterialCommunityIcons;
41
+ const isMaterial = isIcon(name,"material");
42
+ const isFa = isIcon(name,"fa");
43
+ const isAnt = isIcon(name,"ant");
44
+ const isFontisto = isIcon(name,"fontisto");
45
+ const isFoundation = isIcon(name,"foundation");
46
+ const isIonicons = isIcon(name,"ionic");
47
+ const isOcticons = isIcon(name,"octicons");
48
+ const isSimpleLineIcons = isIcon(name,"simple-line");
49
+ const isZocial = isIcon(name,"zocial");
50
+ let Icon = isMaterial ? MaterialIcons :
51
+ isFa ? FontAwesome5 :
52
+ isFontisto ? Fontisto :
53
+ isAnt ? AntDesign :
54
+ isFoundation ? Foundation :
55
+ isIonicons ? Ionicons :
56
+ isOcticons ? Octicons:
57
+ isSimpleLineIcons ? SimpleLineIcons :
58
+ isZocial ? Zocial :
59
+ MaterialCommunityIcons;
23
60
  if(!icon || !Icon){
24
61
  console.warn("Icone non définie pour le composant FontIcon, icon [{0}], merci de spécifier une icone supportée par la liste du module https://github.com/expo/vector-icons/MaterialCommunityIcons".sprintf(icon),props);
25
62
  return null;
26
63
  }
64
+ const iconName = icon.ltrim("")
27
65
  return <Icon {...props}
28
66
  ref = {ref}
29
67
  testID = {testID}
@@ -55,22 +93,45 @@ FontIcon.displayName = "FontIconComponent";
55
93
  export const isIcon = (name,iconSet)=>{
56
94
  if(!isNonNullString(name) || !isNonNullString(iconSet)) return false;
57
95
  name = name.toLowerCase();
58
- iconSet = iconSet.toLowerCase().rtrim().rtrim("-");
59
- return name.contains(iconSet+"-") || name.contains(iconSet+"s"+"-") ? true : false;
96
+ iconSet = iconSet.toLowerCase().trim();
97
+ return name.startsWith(iconSet+"-") || name.startsWith(iconSet+"s"+"-") ? true : false;
60
98
  }
61
99
 
62
100
  export default theme.withStyles(FontIcon,{displayName:FontIcon.displayName,mode:'normal'});
63
101
  export const fonts = [
64
102
  MaterialCommunityIcons.font,
103
+ FontAwesome5.font,
104
+ AntDesign.font,
105
+ Fontisto.font,
106
+ Foundation.font,
107
+ Ionicons.font,
108
+ MaterialIcons.font,
109
+ Octicons.font,
110
+ SimpleLineIcons.font,
111
+ Zocial.font,
65
112
  ];
113
+ export const fontsNames = {};
114
+ Object.map(fonts,(f,k)=>{
115
+ if(isObj(f)){
116
+ for(let i in f){
117
+ fontsNames[i] = true;
118
+ }
119
+ }
120
+ });
66
121
 
67
- export const fontsNames = {
68
- MaterialCommunityIcons:true,
69
- }
70
-
71
- export function loadFonts() {
122
+ /*** chage les fonts liés à l'application
123
+ * @param {function} filter, le filtre prenant en paramètr ele fontAsset en suite et le nom de la font en question
124
+ * @return {Promise}
125
+ */
126
+ export function loadFonts(filter) {
127
+ filter = typeof filter =='function'? filter : (f,name,nameLower)=> name.toLowerCase().contains("material") ? true : false;
72
128
  return Promise.all(fonts.map(font => {
73
129
  if(!isObj(font)) return Promise.reject({message:'Invalid font'});
130
+ const fontName = Object.keys(font)[0]?.toLowerCase();
131
+ if(!isNonNullString(fontName) || !fontsNames[fontName] || !filter(font,fontName,fontName.toLowerCase)) return Promise.resolve({
132
+ status : false,
133
+ message : 'Font {0} introuvable'.sprintf(fontName)
134
+ });
74
135
  return FontAsset.loadAsync(font);
75
136
  }))
76
137
  };
package/src/index.js CHANGED
@@ -19,6 +19,7 @@ import init from "$capp/init";
19
19
  import { setIsInitialized} from "$capp/utils";
20
20
  import {isObj,isNonNullString} from "$cutils";
21
21
  import {loadFonts} from "$ecomponents/Icon/Font";
22
+ import appConfig from "$capp/config";
22
23
 
23
24
  let MAX_BACK_COUNT = 1;
24
25
  let countBack = 0;
@@ -42,7 +43,8 @@ function App(props) {
42
43
  React.useEffect(() => {
43
44
  const loadResources = ()=>{
44
45
  return new Promise((resolve)=>{
45
- loadFonts().catch((e)=>{
46
+ //FontsIconsFilter porte le nom de la props de appConfig dans lequel définir les filtres à utiliser pour charger l'iconSet désirée pour l'appication
47
+ loadFonts(appConfig.get("FontsIconsFilter")).catch((e)=>{
46
48
  console.warn(e," ierror loading app resources fonts");
47
49
  }).finally(()=>{
48
50
  resolve(true);