@fto-consult/expo-ui 2.7.0 → 2.7.3
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/expo-ui-path.js +2 -0
- package/package.json +4 -3
- package/src/components/Icon/Font.js +71 -10
- package/src/index.js +3 -1
package/expo-ui-path.js
CHANGED
|
@@ -6,6 +6,8 @@ const fs = require("fs");
|
|
|
6
6
|
const path = require("path");
|
|
7
7
|
///retourne le chemin vers le package @expo-ui
|
|
8
8
|
module.exports = function (...args){
|
|
9
|
+
const argv = require('args-parser')(process.argv);
|
|
10
|
+
console.log(argv," is argvvvvvvvv");
|
|
9
11
|
const suffix = path.join(...args);
|
|
10
12
|
const p = require("./lookup-expo-ui-path")();
|
|
11
13
|
const sep = path.sep;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"resolutions": {
|
|
@@ -75,12 +75,14 @@
|
|
|
75
75
|
"@react-navigation/native": "^6.0.13",
|
|
76
76
|
"@react-navigation/native-stack": "^6.9.1",
|
|
77
77
|
"@shopify/flash-list": "1.3.1",
|
|
78
|
+
"args-parser": "^1.3.0",
|
|
78
79
|
"babel-plugin-inline-dotenv": "^1.7.0",
|
|
79
80
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
80
81
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
81
82
|
"expo": "^47.0.8",
|
|
82
83
|
"expo-camera": "~13.1.0",
|
|
83
84
|
"expo-clipboard": "~4.0.1",
|
|
85
|
+
"expo-font": "~11.0.1",
|
|
84
86
|
"expo-image-picker": "~14.0.2",
|
|
85
87
|
"expo-linking": "~3.2.3",
|
|
86
88
|
"expo-sqlite": "~11.0.0",
|
|
@@ -108,7 +110,6 @@
|
|
|
108
110
|
"react-native-web": "~0.18.7",
|
|
109
111
|
"react-native-webview": "11.23.1",
|
|
110
112
|
"sharp-cli": "^2.1.0",
|
|
111
|
-
"tippy.js": "^6.3.7"
|
|
112
|
-
"expo-font": "~11.0.1"
|
|
113
|
+
"tippy.js": "^6.3.7"
|
|
113
114
|
}
|
|
114
115
|
}
|
|
@@ -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")
|
|
21
|
-
const
|
|
22
|
-
|
|
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().
|
|
59
|
-
return name.
|
|
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
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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);
|