|
|
@@ -1,10 +1,10 @@
|
|
1
|
1
|
// @flow
|
|
2
|
2
|
|
|
3
|
|
-import React, { Component, type Node } from 'react';
|
|
4
|
|
-import { TouchableWithoutFeedback, View } from 'react-native';
|
|
|
3
|
+import React, { PureComponent, type Node } from 'react';
|
|
|
4
|
+import { SafeAreaView, View } from 'react-native';
|
|
5
|
5
|
|
|
6
|
6
|
import { ColorSchemeRegistry } from '../../../color-scheme';
|
|
7
|
|
-import { Modal } from '../../../react';
|
|
|
7
|
+import { SlidingView } from '../../../react';
|
|
8
|
8
|
import { connect } from '../../../redux';
|
|
9
|
9
|
import { StyleType } from '../../../styles';
|
|
10
|
10
|
|
|
|
@@ -33,19 +33,22 @@ type Props = {
|
|
33
|
33
|
};
|
|
34
|
34
|
|
|
35
|
35
|
/**
|
|
36
|
|
- * A component emulating Android's BottomSheet. For all intents and purposes,
|
|
37
|
|
- * this component has been designed to work and behave as a {@code Dialog}.
|
|
|
36
|
+ * A component emulating Android's BottomSheet.
|
|
38
|
37
|
*/
|
|
39
|
|
-class BottomSheet extends Component<Props> {
|
|
|
38
|
+class BottomSheet extends PureComponent<Props> {
|
|
40
|
39
|
/**
|
|
41
|
|
- * Initializes a new {@code BottomSheet} instance.
|
|
|
40
|
+ * Assembles a style for the BottomSheet container.
|
|
42
|
41
|
*
|
|
43
|
|
- * @inheritdoc
|
|
|
42
|
+ * @private
|
|
|
43
|
+ * @returns {StyleType}
|
|
44
|
44
|
*/
|
|
45
|
|
- constructor(props: Props) {
|
|
46
|
|
- super(props);
|
|
|
45
|
+ _getContainerStyle() {
|
|
|
46
|
+ const { _styles } = this.props;
|
|
47
|
47
|
|
|
48
|
|
- this._onCancel = this._onCancel.bind(this);
|
|
|
48
|
+ return {
|
|
|
49
|
+ ...styles.container,
|
|
|
50
|
+ backgroundColor: _styles.sheet.backgroundColor
|
|
|
51
|
+ };
|
|
49
|
52
|
}
|
|
50
|
53
|
|
|
51
|
54
|
/**
|
|
|
@@ -57,39 +60,19 @@ class BottomSheet extends Component<Props> {
|
|
57
|
60
|
render() {
|
|
58
|
61
|
const { _styles } = this.props;
|
|
59
|
62
|
|
|
60
|
|
- return [
|
|
61
|
|
- <View
|
|
62
|
|
- key = 'overlay'
|
|
63
|
|
- style = { styles.overlay } />,
|
|
64
|
|
- <Modal
|
|
65
|
|
- key = 'modal'
|
|
66
|
|
- onRequestClose = { this._onCancel }
|
|
67
|
|
- visible = { true }>
|
|
68
|
|
- <View style = { styles.container }>
|
|
69
|
|
- <TouchableWithoutFeedback
|
|
70
|
|
- onPress = { this._onCancel } >
|
|
71
|
|
- <View style = { styles.backdrop } />
|
|
72
|
|
- </TouchableWithoutFeedback>
|
|
|
63
|
+ return (
|
|
|
64
|
+ <SlidingView
|
|
|
65
|
+ onHide = { this.props.onCancel }
|
|
|
66
|
+ position = 'bottom'
|
|
|
67
|
+ show = { true }>
|
|
|
68
|
+ <SafeAreaView
|
|
|
69
|
+ style = { this._getContainerStyle() }>
|
|
73
|
70
|
<View style = { _styles.sheet }>
|
|
74
|
71
|
{ this.props.children }
|
|
75
|
72
|
</View>
|
|
76
|
|
- </View>
|
|
77
|
|
- </Modal>
|
|
78
|
|
- ];
|
|
79
|
|
- }
|
|
80
|
|
-
|
|
81
|
|
- _onCancel: () => void;
|
|
82
|
|
-
|
|
83
|
|
- /**
|
|
84
|
|
- * Cancels the dialog by calling the onCancel prop callback.
|
|
85
|
|
- *
|
|
86
|
|
- * @private
|
|
87
|
|
- * @returns {void}
|
|
88
|
|
- */
|
|
89
|
|
- _onCancel() {
|
|
90
|
|
- const { onCancel } = this.props;
|
|
91
|
|
-
|
|
92
|
|
- onCancel && onCancel();
|
|
|
73
|
+ </SafeAreaView>
|
|
|
74
|
+ </SlidingView>
|
|
|
75
|
+ );
|
|
93
|
76
|
}
|
|
94
|
77
|
}
|
|
95
|
78
|
|