react-native-sheet2 1.1.19 → 1.1.20
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 +1 -1
- package/src/index.tsx +0 -1
- package/src/TransparentActivity.tsx +0 -98
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
findNodeHandle,
|
|
3
|
-
NativeModules,
|
|
4
|
-
Platform,
|
|
5
|
-
requireNativeComponent,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
View,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
|
|
11
|
-
const TransparentActivity = requireNativeComponent<any>('TransparentActivity');
|
|
12
|
-
const TopModalView = requireNativeComponent<any>('TopModalView');
|
|
13
|
-
|
|
14
|
-
interface Props {
|
|
15
|
-
onActivityDismiss?: () => void;
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
animated?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface State {
|
|
21
|
-
show: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class TransparentActivityView extends React.PureComponent<Props, State> {
|
|
25
|
-
private sheetRef = React.createRef<any>();
|
|
26
|
-
|
|
27
|
-
constructor(props: Props) {
|
|
28
|
-
super(props);
|
|
29
|
-
this.state = { show: false };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
show = () => {
|
|
33
|
-
if (this.state.show) return;
|
|
34
|
-
this.setState({ show: true });
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
hide = () => {
|
|
38
|
-
if (!this.state.show) return;
|
|
39
|
-
const tag = findNodeHandle(this.sheetRef.current);
|
|
40
|
-
if (!tag) return;
|
|
41
|
-
console.log('[TopModal.hide]', tag);
|
|
42
|
-
if (Platform.OS === 'android')
|
|
43
|
-
NativeModules.TransparentActivity.dismiss(tag);
|
|
44
|
-
else NativeModules.TopModalView.dismiss(tag);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
private onDismiss = () => {
|
|
48
|
-
console.log('[FittedSheet.onDismiss]');
|
|
49
|
-
this.setState({ show: false });
|
|
50
|
-
this.props.onActivityDismiss?.();
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
componentWillUnmount() {
|
|
54
|
-
this.hide();
|
|
55
|
-
console.log('[TopModal.componentWillUnmount]');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render() {
|
|
59
|
-
if (!this.state.show) {
|
|
60
|
-
this.hide();
|
|
61
|
-
console.log('[TopModal.render.remove]');
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (Platform.OS === 'android') {
|
|
66
|
-
return (
|
|
67
|
-
<TransparentActivity
|
|
68
|
-
onActivityDismiss={this.onDismiss}
|
|
69
|
-
ref={this.sheetRef}
|
|
70
|
-
animated={this.props.animated ?? true}
|
|
71
|
-
>
|
|
72
|
-
<View
|
|
73
|
-
accessibilityLabel={'transparent-activity-root-view'}
|
|
74
|
-
nativeID={'transparent-activity-root-view'}
|
|
75
|
-
style={StyleSheet.absoluteFill}
|
|
76
|
-
children={this.props.children}
|
|
77
|
-
/>
|
|
78
|
-
</TransparentActivity>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<TopModalView
|
|
84
|
-
animationType={'none'}
|
|
85
|
-
animated={false}
|
|
86
|
-
onModalDismiss={this.onDismiss}
|
|
87
|
-
ref={this.sheetRef}
|
|
88
|
-
>
|
|
89
|
-
<View
|
|
90
|
-
accessibilityLabel={'transparent-activity-root-view'}
|
|
91
|
-
nativeID={'transparent-activity-root-view'}
|
|
92
|
-
style={StyleSheet.absoluteFill}
|
|
93
|
-
children={this.props.children}
|
|
94
|
-
/>
|
|
95
|
-
</TopModalView>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|