@fto-consult/expo-ui 2.6.0 → 2.7.0

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.
@@ -2,6 +2,5 @@
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
4
 
5
- export default function NetworkLoginScreen(){
6
- return null;
7
- }
5
+ 1.Installer le package rimraf: npm i -g rimraf
6
+ 2. Executer le script : npm run delete-node-modules
package/metro.config.js CHANGED
@@ -24,5 +24,7 @@ module.exports = (opts)=>{
24
24
  ...sourceExts,"txt",
25
25
  'jsx', 'js','tsx',
26
26
  ]
27
+ // Remove all console logs in production...
28
+ config.transformer.minifierConfig.compress.drop_console = true;
27
29
  return config;
28
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "resolutions": {
@@ -42,7 +42,8 @@
42
42
  "electron-p": "npm run compile-electron-p && npm run electron",
43
43
  "update-app-version": "node ./update-app-version.js",
44
44
  "find-licenses": "node ./find-licenses.js",
45
- "fix-dependencies": "expo doctor --fix-dependencies"
45
+ "fix-dependencies": "expo doctor --fix-dependencies",
46
+ "delete-node-modules": "rimraf ./**/node_modules"
46
47
  },
47
48
  "repository": {
48
49
  "type": "git",
@@ -64,8 +65,9 @@
64
65
  "@emotion/native": "^11.10.0",
65
66
  "@expo/html-elements": "^0.2.0",
66
67
  "@expo/metro-config": "^0.4.0",
68
+ "@expo/vector-icons": "^13.0.0",
67
69
  "@expo/webpack-config": "^0.17.2",
68
- "@fto-consult/common": "^1.12.3",
70
+ "@fto-consult/common": "^1.13.1",
69
71
  "@gorhom/portal": "^1.0.14",
70
72
  "@react-native-async-storage/async-storage": "~1.17.3",
71
73
  "@react-native-community/datetimepicker": "6.5.2",
@@ -106,6 +108,7 @@
106
108
  "react-native-web": "~0.18.7",
107
109
  "react-native-webview": "11.23.1",
108
110
  "sharp-cli": "^2.1.0",
109
- "tippy.js": "^6.3.7"
111
+ "tippy.js": "^6.3.7",
112
+ "expo-font": "~11.0.1"
110
113
  }
111
114
  }
package/src/App.js CHANGED
@@ -22,10 +22,12 @@ import StatusBar from "$ecomponents/StatusBar";
22
22
  import SimpleSelect from '$ecomponents/SimpleSelect';
23
23
  import {Provider as AlertProvider} from '$ecomponents/Dialog/confirm/Alert';
24
24
  import APP from "$app";
25
+ import FontIcon from "$ecomponents/Icon/Font"
25
26
  import {isMobileNative} from "$cplatform";
26
27
  import {setDeviceIdRef} from "$capp";
27
28
  import appConfig from "$capp/config";
28
29
  import {showPrompt} from "$components/Dialog/confirm";
30
+
29
31
  import * as Utils from "$utils";
30
32
  Object.map(Utils,(v,i)=>{
31
33
  if(typeof v =='function' && typeof window !='undefined' && window && !window[i]){
@@ -63,7 +65,14 @@ export default function getIndex(options){
63
65
  const children = typeof App =='function'? App({children:child,APP}) : child;
64
66
  return (
65
67
  <GestureHandlerRootView style={{ flex: 1 }}>
66
- <PaperProvider theme={theme}>
68
+ <PaperProvider
69
+ theme={theme}
70
+ settings={{
71
+ icon: (props) => {
72
+ return <FontIcon {...props}/>
73
+ },
74
+ }}
75
+ >
67
76
  <SafeAreaProvider>
68
77
  <AuthProvider>
69
78
  <PortalProvider>
@@ -0,0 +1,77 @@
1
+ // Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+ import theme from "$theme";
5
+ import React from "react";
6
+ import {defaultStr,isNonNullString} from "$utils";
7
+ import PropTypes from "prop-types";
8
+ import { StyleSheet } from "react-native";
9
+ import * as FontAsset from 'expo-font';
10
+
11
+ /*** @see : https://materialdesignicons.com/ pour les icon MaterialComunityIcons*/
12
+ import MaterialCommunityIcons from "@expo/vector-icons/MaterialCommunityIcons";
13
+ /*** @see : https://icons.expo.fyi/ popur tous les icons supportés*/
14
+ const FontIcon = React.forwardRef(({icon,name,testID,color,iconStyle,backgroundColor,style,...props},ref)=>{
15
+ icon = defaultStr(icon,name).trim();
16
+ testID = defaultStr(testID,"RN_FontIconComponent");
17
+ const fStyle = StyleSheet.flatten(style) || {};
18
+ color = theme.Colors.isValid(color)? color : fStyle.color || theme.colors.text;
19
+ 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;
23
+ if(!icon || !Icon){
24
+ 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
+ return null;
26
+ }
27
+ return <Icon {...props}
28
+ ref = {ref}
29
+ testID = {testID}
30
+ color={color}
31
+ name = {icon}
32
+ backgroundColor = {backgroundColor}
33
+ />
34
+ });
35
+
36
+ FontIcon.propTypes = {
37
+ name : PropTypes.string,
38
+ icon : PropTypes.string,
39
+ color : PropTypes.string,
40
+ size : PropTypes.number,
41
+ borderRadius : PropTypes.oneOfType([
42
+ PropTypes.number,
43
+ ]),
44
+ onPress : PropTypes.func,
45
+ direction: PropTypes.oneOf(['rtl','ltr','auto']),
46
+ iconStyle : theme.StyleProps,
47
+
48
+ }
49
+ FontIcon.displayName = "FontIconComponent";
50
+
51
+ /*** vérfie si l'icon passé en paramètre est un icon pour l'icon set
52
+ * @param {string} name le nom de l'icone à vérifier
53
+ * @param {string} iconSet, le set d'icon dans lequel vérifier
54
+ */
55
+ export const isIcon = (name,iconSet)=>{
56
+ if(!isNonNullString(name) || !isNonNullString(iconSet)) return false;
57
+ name = name.toLowerCase();
58
+ iconSet = iconSet.toLowerCase().rtrim().rtrim("-");
59
+ return name.contains(iconSet+"-") || name.contains(iconSet+"s"+"-") ? true : false;
60
+ }
61
+
62
+ export default theme.withStyles(FontIcon,{displayName:FontIcon.displayName,mode:'normal'});
63
+ export const fonts = [
64
+ MaterialCommunityIcons.font,
65
+ ];
66
+
67
+ export const fontsNames = {
68
+ MaterialCommunityIcons:true,
69
+ }
70
+
71
+ export function loadFonts() {
72
+ return Promise.all(fonts.map(font => {
73
+ if(!isObj(font)) return Promise.reject({message:'Invalid font'});
74
+ return FontAsset.loadAsync(font);
75
+ }))
76
+ };
77
+
@@ -1,10 +1,12 @@
1
1
  import Checkbox from "./Checkbox";
2
2
  import Icon from "./Icon";
3
-
3
+ import Font from "./Font";
4
4
  export * from "./utils";
5
+ export * from "./Font";
5
6
 
6
7
  Icon.Checkbox = Checkbox;
8
+ Icon.Font = Font;
7
9
 
8
- export {Checkbox};
10
+ export {Checkbox,Font};
9
11
 
10
- export default Icon;
12
+ export default Icon;
@@ -160,11 +160,12 @@ const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelect
160
160
  const scrollContentContainerStyle = {flex:1,width:listWidth,minWidth:totalWidths,height:'100%'};
161
161
  const scrollEventThrottle = isMobileNative()?200:50;
162
162
  const scrollViewFlexGrow = {flexGrow:0};
163
+ const maxScrollheight = f.length && fFilters.length ? 170 : f.length || fFilters.length ? 120 : 80;
163
164
  const allScrollViewProps = {
164
165
  scrollEventThrottle,
165
166
  horizontal : true,
166
167
  ...scrollViewProps,
167
- style : [{maxHeight:130},scrollViewProps.style],
168
+ style : [{maxHeight:maxScrollheight},scrollViewProps.style],
168
169
  contentContainerStyle : [styles.scrollView,scrollViewProps.contentContainerStyle,scrollViewFlexGrow,scrollContentContainerStyle]
169
170
  }
170
171
  const listWidth = '100%';
@@ -377,7 +378,7 @@ const styles = StyleSheet.create({
377
378
  flexWrap : 'wrap',
378
379
  },
379
380
  footers : {
380
- minHeight : 50,
381
+ minHeight : 40,
381
382
  },
382
383
  headerItemOrCell : {
383
384
  alignItems: 'flex-start',
package/src/index.js CHANGED
@@ -17,13 +17,15 @@ import {notify} from "$ecomponents/Dialog";
17
17
  import {decycle} from "$utils/json";
18
18
  import init from "$capp/init";
19
19
  import { setIsInitialized} from "$capp/utils";
20
+ import {isObj,isNonNullString} from "$cutils";
21
+ import {loadFonts} from "$ecomponents/Icon/Font";
20
22
 
21
23
  let MAX_BACK_COUNT = 1;
22
24
  let countBack = 0;
23
25
  let isBackConfirmShowing = false;
24
26
 
25
27
  const resetExitCounter = ()=>{
26
- countBack = 0;
28
+ countBack = 0
27
29
  isBackConfirmShowing = false;
28
30
  };
29
31
 
@@ -38,6 +40,15 @@ function App(props) {
38
40
  isInitialized:true,
39
41
  });
40
42
  React.useEffect(() => {
43
+ const loadResources = ()=>{
44
+ return new Promise((resolve)=>{
45
+ loadFonts().catch((e)=>{
46
+ console.warn(e," ierror loading app resources fonts");
47
+ }).finally(()=>{
48
+ resolve(true);
49
+ });
50
+ })
51
+ }
41
52
  const restoreState = () => {
42
53
  return new Promise((resolve,reject)=>{
43
54
  (async ()=>{
@@ -102,16 +113,18 @@ function App(props) {
102
113
  NetInfo.fetch().catch((e)=>{
103
114
  console.log(e," is net info heinn")
104
115
  });
105
- init().then(()=>{
106
- if(Auth.isLoggedIn()){
107
- Auth.loginUser(false);
108
- }
109
- setState({
110
- ...state,isInitialized:true,isLoading : false,
111
- });
112
- }).catch((e)=>{
113
- console.error(e," initializing app")
114
- setState({...state,isInitialized:true,isLoading : false});
116
+ loadResources().finally(()=>{
117
+ init().then(()=>{
118
+ if(Auth.isLoggedIn()){
119
+ Auth.loginUser(false);
120
+ }
121
+ setState({
122
+ ...state,isInitialized:true,isLoading : false,
123
+ });
124
+ }).catch((e)=>{
125
+ console.error(e," initializing app")
126
+ setState({...state,isInitialized:true,isLoading : false});
127
+ })
115
128
  });
116
129
 
117
130
  const Events = {}
@@ -139,7 +152,7 @@ function App(props) {
139
152
  }, []);
140
153
  const {isInitialized} = state;
141
154
  const hasGetStarted = true;
142
- const isLoading = state.isLoading || !isInitialized || !appReadyRef.current ? true : false;
155
+ const isLoading = state.isLoading || !isInitialized || !appReadyRef.current? true : false;
143
156
  React.useEffect(()=>{
144
157
  if(isInitialized){
145
158
  setIsInitialized(true);
@@ -5,9 +5,6 @@
5
5
  import { isRouteActive} from "$cnavigation";
6
6
  import "$cutils";
7
7
  import appConfig from "$capp/config";
8
- import {isMobileNative} from "$platform";
9
- import NetworkLoginScreen from "$escreens/NetworkLogin";
10
- import {defaultVal} from "$utils";
11
8
  import APP from "$capp";
12
9
  ///les items du drawer
13
10
  import items from "$drawerItems";
@@ -46,13 +43,6 @@ export const getItems = (force)=>{
46
43
  }
47
44
  ]
48
45
  };
49
- /*if(false && __DEV__ && isMobileNative()){
50
- dataHelp.items.unshift({
51
- icon : 'math-log',
52
- label : 'Inpecter les requêtes réseau',
53
- routeName : NetworkLoginScreen.screenName,
54
- });
55
- }*/
56
46
  r.push(dataHelp);
57
47
  }
58
48
  return r;
@@ -1,8 +1,6 @@
1
1
  import Auth from "./Auth";
2
2
  import Help from "./Help";
3
- //import NetworkLoginScreen from "./NetworkLogin";
4
3
  export default [
5
4
  ...Auth,
6
5
  ...Help,
7
- //NetworkLoginScreen,
8
6
  ]
@@ -1,22 +0,0 @@
1
- // Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- //import NetworkLogger from 'react-native-network-logger';
6
- import theme from "$theme";
7
- import Screen from "$elayouts/Screen/ScreenWithOrWithoutAuthContainer";
8
-
9
- const NetworkLoginScreen = () => {
10
- return null;
11
- <Screen withScrollView title="Débuggin du réseau" subtitle = {false}>
12
- <NetworkLogger
13
- theme={theme.isDark()?"dark":undefined}
14
- />
15
- </Screen>
16
- };
17
-
18
- NetworkLoginScreen.displayName = "NetworkLogin";
19
- NetworkLoginScreen.authRequired = false;
20
- NetworkLoginScreen.Modal = true;
21
-
22
- export default NetworkLoginScreen;