@fto-consult/expo-ui 6.16.6 → 6.16.7

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": "6.16.6",
3
+ "version": "6.16.7",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -103,8 +103,19 @@ const DrawerComponent = React.forwardRef((props,ref)=>{
103
103
  callbackRef.current = callback;
104
104
  setState({minimized:false,permanent:true});
105
105
  }
106
+ const checkToggleBtn = (cb)=>{
107
+ if(!Dimensions.isDesktopMedia() && drawerRef?.current?.isPermanent()){
108
+ setState({permanent:false});
109
+ if(typeof cb ==='function'){
110
+ cb(getDrawerState());
111
+ }
112
+ return false;
113
+ }
114
+ return true;
115
+ }
106
116
 
107
117
  context.toggleMinimized = (minimized,s2)=>{
118
+ if(!checkToggleBtn()) return;
108
119
  if(!Dimensions.isDesktopMedia() || typeof minimized !== 'boolean' || !drawerRef.current || !drawerRef.current.isOpen()) return;
109
120
  if(!minimizable === false) return;
110
121
  let nS = {minimized};
@@ -119,6 +130,17 @@ const DrawerComponent = React.forwardRef((props,ref)=>{
119
130
  context.isLeftPosition = ()=> isLeftPosition;
120
131
  context.canToggle = x=> canHandleExtra() ? true : permanent? false : true;
121
132
  context.canMinimize = x => minimizable !== false && canBeMinimizedOrPermanent() ? true : false;
133
+ context.togglePermanent = (x,cb)=>{
134
+ if(typeof x !== "boolean") return;
135
+ if(!checkToggleBtn(cb)) return;
136
+ const isPerm = drawerRef?.current?.isPermanent();
137
+ if(x && ! isPerm || !x && isPerm){
138
+ setState({permanent:x});
139
+ }
140
+ if(typeof cb =="function"){
141
+ cb(getDrawerState());
142
+ }
143
+ }
122
144
 
123
145
  let {permanent:isPermanent,minimized:isMinimized} = session.get();
124
146
  if(_canBeMinimizedOrPermanent && isPermanent){
@@ -288,9 +310,10 @@ const DrawerComponent = React.forwardRef((props,ref)=>{
288
310
  drawerRef.current.isOpen = context.isOpen = typeof drawerRef.current.isOpen =='function'? drawerRef.current.isOpen.bind(drawerRef.current) : x=> drawerRef && drawerRef.current ? drawerRef.current.drawerShown : false;
289
311
  drawerRef.current.isClosed = context.isClosed = x => !drawerRef.current.isOpen();
290
312
  context.toggle = drawerRef.current.toggleDrawer = drawerRef.current.toggle = cb =>{
313
+ if(!checkToggleBtn(cb)) return;
291
314
  if(isPermanent || isMinimized) {
292
315
  if(typeof cb ==='function'){
293
- cb(getDrawerState(getDrawerState()));
316
+ cb(getDrawerState());
294
317
  }
295
318
  return;
296
319
  }