@fto-consult/expo-ui 6.42.0 → 6.42.1
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
@@ -6,7 +6,7 @@ import Label from "$ecomponents/Label";
|
|
6
6
|
import { renderActions } from "$ecomponents/Dialog";
|
7
7
|
import {isObjOrArray,defaultVal,defaultObj} from "$cutils";
|
8
8
|
import {renderSplitedActions} from "$ecomponents/AppBar/utils";
|
9
|
-
import {isWeb,isNativeMobile} from "$cplatform";
|
9
|
+
import {isWeb,isNativeMobile,isTouchDevice} from "$cplatform";
|
10
10
|
import Divider from "$ecomponents/Divider";
|
11
11
|
import {isMobileOrTabletMedia} from "$cplatform/dimensions";
|
12
12
|
import APP from "$capp/instance";
|
@@ -17,7 +17,7 @@ import View from "$ecomponents/View";
|
|
17
17
|
import Portal from "$ecomponents/Portal";
|
18
18
|
import { ScrollView } from "react-native";
|
19
19
|
import BackHandler from "$ecomponents/BackHandler";
|
20
|
-
import Reanimated, { useSharedValue,
|
20
|
+
import Reanimated, { useSharedValue,withTiming,useAnimatedStyle, } from 'react-native-reanimated';
|
21
21
|
import {
|
22
22
|
Pressable,
|
23
23
|
Animated,
|
@@ -75,13 +75,16 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
75
75
|
} else {
|
76
76
|
height = Math.max(winHeight/3,defaultHeight);
|
77
77
|
}
|
78
|
-
const [pan
|
78
|
+
const [pan] = React.useState(new Animated.ValueXY());
|
79
79
|
const [visible,setVisible] = React.useState(typeof customVisible === 'boolean'?customVisible : false);
|
80
|
+
const heightRef = React.useRef(height);
|
81
|
+
heightRef.current = height;
|
80
82
|
const isMounted = React.useIsMounted();
|
81
83
|
const prevVisible = React.usePrevious(visible);
|
82
84
|
const animatedHeight = useSharedValue(0);
|
83
85
|
const hasCallCallbackRef = React.useState(false);
|
84
|
-
|
86
|
+
const visibleRef = React.useRef(visible);
|
87
|
+
visibleRef.current = visible;
|
85
88
|
const open = ()=>{
|
86
89
|
if(!isMounted() || visible)return;
|
87
90
|
setVisible(true);
|
@@ -111,10 +114,11 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
111
114
|
|
112
115
|
const closeModal = (cb)=>{
|
113
116
|
removeListeners();
|
114
|
-
|
117
|
+
if(!isMounted()) return;
|
118
|
+
pan.setValue({ x: 0, y: 0 });
|
115
119
|
const callback = ()=>{
|
116
120
|
if(hasCallCallbackRef.current) return;
|
117
|
-
if(
|
121
|
+
if(visibleRef.current){
|
118
122
|
setVisible(false);
|
119
123
|
}
|
120
124
|
if(typeof cb =='function'){
|
@@ -136,20 +140,21 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
136
140
|
const [panResponder] = React.useState(PanResponder.create({
|
137
141
|
onStartShouldSetPanResponder: () => closeOnDragDown,
|
138
142
|
onPanResponderMove: (e, gestureState) => {
|
139
|
-
|
140
|
-
|
143
|
+
const diff = gestureState.dy > 0 ? animatedHeight.value - gestureState.dy : Math.min(heightRef.current,animatedHeight.value-gestureState.dy);
|
144
|
+
if(diff >0 && diff !== animatedHeight.value){
|
145
|
+
animatedHeight.value = withTiming(diff,{duration:100});
|
141
146
|
}
|
142
147
|
},
|
143
|
-
onPanResponderRelease: (e, gestureState) => {
|
148
|
+
onPanResponderRelease: (e, gestureState) => {
|
149
|
+
const height = animatedHeight.value;
|
144
150
|
if (height/3 - gestureState.dy < 0) {
|
145
151
|
closeModal();
|
146
|
-
} else {
|
147
|
-
Animated.spring(pan, { toValue: { x: 0, y: 0 }, useNativeDriver}).start();
|
148
152
|
}
|
149
153
|
}
|
150
154
|
}))
|
151
155
|
const animatedStyles = useAnimatedStyle(() => ({
|
152
156
|
height : animatedHeight.value,
|
157
|
+
transform :[{ translateX: 0 }],
|
153
158
|
}));
|
154
159
|
React.useEffect(()=>{
|
155
160
|
if(typeof customVisible !=='boolean' || customVisible === visible) return;
|
@@ -233,7 +238,7 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
233
238
|
React.setRef(ref,null);
|
234
239
|
}
|
235
240
|
},[]);
|
236
|
-
const dragFromTopOnly = typeof dragFromTopOnly ==='boolean' ? dragFromTopOnly : withScrollView !== false ? true :
|
241
|
+
const dragFromTopOnly = typeof dragFromTopOnly ==='boolean' ? dragFromTopOnly : withScrollView !== false ? true : isTouchDevice();
|
237
242
|
const testID = defaultStr(customTestID,"RN_BottomSheetComponent");
|
238
243
|
const containerProps = defaultObj(customContainerProps);
|
239
244
|
const elevation = typeof customElevation =='number'? Math.ceil(customElevation) : 10;
|
@@ -257,7 +262,7 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
257
262
|
<Reanimated.View
|
258
263
|
{...(!dragFromTopOnly && panResponder.panHandlers)}
|
259
264
|
testID = {testID+"_Container"} {...containerProps}
|
260
|
-
style={[styles.container,containerProps.style,{borderTopWidth:borderWidth,borderTopColor:borderColor,backgroundColor:theme.colors.surface},Elevations[elevation],panStyle,animatedStyles]}
|
265
|
+
style={[styles.container,containerProps.style,{borderTopWidth:borderWidth,borderTopColor:borderColor,backgroundColor:theme.colors.surface},Elevations[elevation],panStyle,styles.animated,animatedStyles]}
|
261
266
|
>
|
262
267
|
{closeOnDragDown && (
|
263
268
|
<View
|
@@ -326,8 +331,8 @@ BottomSheetComponent.defaultProps = {
|
|
326
331
|
animationType: isNativeMobile ? "slide" : "fade",//Background animation ("none", "fade", "slide")
|
327
332
|
height:undefined,//Height of Bottom Sheet
|
328
333
|
minClosingHeight: 0,//Minimum height of Bottom Sheet before close
|
329
|
-
openDuration:
|
330
|
-
closeDuration:
|
334
|
+
openDuration: 300,//Open Bottom Sheet animation duration
|
335
|
+
closeDuration: 300,
|
331
336
|
closeOnDragDown: true,//Use gesture drag down to close Bottom Sheet
|
332
337
|
dragFromTopOnly: false, //Drag only the top area of the draggableIcon to close Bottom Sheet instead of the whole content
|
333
338
|
closeOnPressMask: true, //Press the area outside to close Bottom Sheet
|
@@ -520,7 +520,7 @@ export default class FormListComponent extends AppComponent {
|
|
520
520
|
this.restDatagridProps = dgProps;
|
521
521
|
this._onRowsClick = dgProps.onRowPress;
|
522
522
|
listContent = <Datagrid
|
523
|
-
testID = {testID+"
|
523
|
+
testID = {testID+"_FormListDatagrid"}
|
524
524
|
{...dgProps}
|
525
525
|
onRowPress = {this.onRowPress.bind(this)}
|
526
526
|
rowKey = {dgProps.rowKey === false || this.props.rowKey === false ? undefined : defaultStr(dgProps.rowKey,this.props.rowKey,dgProps.indexField,this.props.indexField,'_id')}
|
@@ -547,8 +547,8 @@ export default class FormListComponent extends AppComponent {
|
|
547
547
|
if(!React.isValidElement(addIcon,true)){
|
548
548
|
addIcon = isObj(addIcon) ? <Button {...addIconObj} {...addIcon}/> : null;
|
549
549
|
}
|
550
|
-
listContent = <View testID={testID+"
|
551
|
-
<View testID={testID+"
|
550
|
+
listContent = <View testID={testID+"_FormList"} {...ListProps} style={[styles.listContainer,ListProps.styles]}>
|
551
|
+
<View testID={testID+"_FormListHeaderContainer"} style={[styles.row]}>
|
552
552
|
{!isCurrentDisplayTable && addIcon ? <List.Subheader>{addIcon}</List.Subheader> : null}
|
553
553
|
{canRenderTable && this.canChangeDisplayType && <List.Subheader >
|
554
554
|
<Button
|
@@ -561,7 +561,7 @@ export default class FormListComponent extends AppComponent {
|
|
561
561
|
</Button>
|
562
562
|
</List.Subheader>}
|
563
563
|
</View>
|
564
|
-
<View testID={testID+"
|
564
|
+
<View testID={testID+"_FormListWrapper"} style={[theme.styles.ph1]}>
|
565
565
|
<FlashList
|
566
566
|
items = {allData}
|
567
567
|
responsive
|
@@ -647,7 +647,7 @@ export default class FormListComponent extends AppComponent {
|
|
647
647
|
</View>
|
648
648
|
</View>
|
649
649
|
}
|
650
|
-
return <View testID={testID+"
|
650
|
+
return <View testID={testID+"_FormListContainer"} style={[styles.container]}>
|
651
651
|
{listContent}
|
652
652
|
</View>
|
653
653
|
}
|
@@ -792,5 +792,11 @@ const styles = StyleSheet.create({
|
|
792
792
|
},
|
793
793
|
item : {
|
794
794
|
paddingRight : 0,
|
795
|
-
}
|
795
|
+
},
|
796
|
+
listContainer : {
|
797
|
+
width : "100%"
|
798
|
+
},
|
799
|
+
container : {
|
800
|
+
width : "100%"
|
801
|
+
},
|
796
802
|
})
|