Skip to content

Commit a77904a

Browse files
authored
fix: updated BottomSheetModal mock, add createBottomSheetScrollableComponent and enum mocks (#2265)(by @gabimoncha)
1 parent 8868e8a commit a77904a

File tree

1 file changed

+106
-5
lines changed

1 file changed

+106
-5
lines changed

mock.js

Lines changed: 106 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,36 @@ const BottomSheetComponent = props => {
2525
};
2626

2727
class BottomSheetModal extends React.Component {
28+
// Store mock data passed via present
29+
data = null;
30+
2831
snapToIndex() {}
2932
snapToPosition() {}
3033
expand() {}
3134
collapse() {}
32-
close() {}
33-
forceClose() {}
34-
present() {}
35-
dismiss() {}
35+
close() {
36+
this.data = null;
37+
}
38+
forceClose() {
39+
this.data = null;
40+
}
41+
present(data) {
42+
// Store data passed to present
43+
this.data = data;
44+
// Need to trigger a re-render somehow if component depends on this state,
45+
// but for basic mock, just storing is often enough.
46+
}
47+
dismiss() {
48+
this.data = null;
49+
}
3650

3751
render() {
38-
return this.props.children;
52+
const { children: Content } = this.props;
53+
return typeof Content === 'function' ? (
54+
<Content data={this.data} />
55+
) : (
56+
Content
57+
);
3958
}
4059
}
4160

@@ -103,6 +122,85 @@ const useBottomSheetDynamicSnapPoints = () => ({
103122
handleContentLayout: NOOP,
104123
});
105124

125+
const GESTURE_SOURCE = {
126+
UNDETERMINED: 0,
127+
SCROLLABLE: 1,
128+
HANDLE: 2,
129+
CONTENT: 3,
130+
};
131+
132+
const SHEET_STATE = {
133+
CLOSED: 0,
134+
OPENED: 1,
135+
EXTENDED: 2,
136+
OVER_EXTENDED: 3,
137+
FILL_PARENT: 4,
138+
};
139+
140+
const SCROLLABLE_STATE = {
141+
LOCKED: 0,
142+
UNLOCKED: 1,
143+
UNDETERMINED: 2,
144+
};
145+
146+
const SCROLLABLE_TYPE = {
147+
UNDETERMINED: 0,
148+
VIEW: 1,
149+
FLATLIST: 2,
150+
SCROLLVIEW: 3,
151+
SECTIONLIST: 4,
152+
VIRTUALIZEDLIST: 5,
153+
};
154+
155+
const ANIMATION_STATE = {
156+
UNDETERMINED: 0,
157+
RUNNING: 1,
158+
STOPPED: 2,
159+
INTERRUPTED: 3,
160+
};
161+
162+
const ANIMATION_SOURCE = {
163+
NONE: 0,
164+
MOUNT: 1,
165+
GESTURE: 2,
166+
USER: 3,
167+
CONTAINER_RESIZE: 4,
168+
SNAP_POINT_CHANGE: 5,
169+
KEYBOARD: 6,
170+
};
171+
172+
const ANIMATION_METHOD = {
173+
TIMING: 0,
174+
SPRING: 1,
175+
};
176+
177+
const KEYBOARD_STATE = {
178+
UNDETERMINED: 0,
179+
SHOWN: 1,
180+
HIDDEN: 2,
181+
};
182+
183+
const SNAP_POINT_TYPE = {
184+
PROVIDED: 0,
185+
DYNAMIC: 1,
186+
};
187+
188+
const ENUMS = {
189+
GESTURE_SOURCE,
190+
SHEET_STATE,
191+
SCROLLABLE_STATE,
192+
SCROLLABLE_TYPE,
193+
ANIMATION_STATE,
194+
ANIMATION_SOURCE,
195+
ANIMATION_METHOD,
196+
KEYBOARD_STATE,
197+
SNAP_POINT_TYPE,
198+
};
199+
200+
const createBottomSheetScrollableComponent = (_type, ScrollableComponent) => {
201+
return ScrollableComponent;
202+
};
203+
106204
module.exports = {
107205
BottomSheetView: BottomSheetComponent,
108206
BottomSheetTextInput: ReactNative.TextInput,
@@ -129,4 +227,7 @@ module.exports = {
129227
useBottomSheetInternal,
130228
useBottomSheetModalInternal,
131229
useBottomSheetDynamicSnapPoints,
230+
231+
...ENUMS,
232+
createBottomSheetScrollableComponent,
132233
};

0 commit comments

Comments
 (0)