You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gesture Handler on Android is implemented in Kotlin. If you need to set a specific Kotlin version to be used by the library, set the `kotlinVersion` ext property in `android/build.gradle` file and RNGH will use that version:
@@ -125,10 +122,9 @@ There is no additional configuration required for the web.
125
122
126
123
#### With [wix/react-native-navigation](https://github.com/wix/react-native-navigation)
127
124
128
-
If you are using a native navigation library like [wix/react-native-navigation](https://github.com/wix/react-native-navigation) you need to make sure that every screen is wrapped with `GestureHandlerRootView` (you can do this using `gestureHandlerRootHOC` function). This can be done for example at the stage when you register your screens. Here's an example:
125
+
If you are using a native navigation library like [wix/react-native-navigation](https://github.com/wix/react-native-navigation) you need to make sure that every screen is wrapped with `GestureHandlerRootView`. This can be done for example at the stage when you register your screens. Here's an example:
@@ -137,22 +133,40 @@ import PushedScreen from './PushedScreen';
137
133
exportfunctionregisterScreens() {
138
134
Navigation.registerComponent(
139
135
'example.FirstTabScreen',
140
-
() =>gestureHandlerRootHOC(FirstTabScreen),
136
+
() => {
137
+
return (
138
+
<GestureHandlerRootView>
139
+
<FirstTabScreen />
140
+
</GestureHandlerRootView>
141
+
);
142
+
},
141
143
() => FirstTabScreen
142
144
);
143
145
Navigation.registerComponent(
144
146
'example.SecondTabScreen',
145
-
() =>gestureHandlerRootHOC(SecondTabScreen),
147
+
() => {
148
+
return (
149
+
<GestureHandlerRootView>
150
+
<SecondTabScreen />
151
+
</GestureHandlerRootView>
152
+
);
153
+
},
146
154
() => SecondTabScreen
147
155
);
148
156
Navigation.registerComponent(
149
157
'example.PushedScreen',
150
-
() =>gestureHandlerRootHOC(PushedScreen),
158
+
() => {
159
+
return (
160
+
<GestureHandlerRootView>
161
+
<PushedScreen />
162
+
</GestureHandlerRootView>
163
+
);
164
+
},
151
165
() => PushedScreen
152
166
);
153
167
}
154
168
```
155
169
156
170
You can check out [this example project](https://github.com/henrikra/nativeNavigationGestureHandler) to see this kind of set up in action.
157
171
158
-
Remember that you need to wrap each screen that you use in your app with `GestureHandlerRootView`(you can do this using `gestureHandlerRootHOC` function) as with native navigation libraries each screen maps to a separate root view. It will not be enough to wrap the main screen only.
172
+
Remember that you need to wrap each screen that you use in your app with `GestureHandlerRootView` as with native navigation libraries each screen maps to a separate root view. It will not be enough to wrap the main screen only.
Note that `GestureHandlerRootView` acts like a normal `View`. So if you want it to fill the screen, you will need to pass `{ flex: 1 }` like you'll need to do with a normal View. By default, it'll take the size of the content nested inside.
If you are using a native navigation library like [wix/react-native-navigation](https://github.com/wix/react-native-navigation) you need to follow a different setup for your Android app to work properly. The reason is that both native navigation libraries and Gesture Handler library need to use their own special subclasses of `ReactRootView`.
175
169
176
-
Instead of changing Java code you will need to wrap every screen component using `gestureHandlerRootHOC` on the JS side. This can be done for example at the stage when you register your screens. Here's an example:
170
+
Instead of changing Java code you will need to wrap every screen component using `GestureHandlerRootView` on the JS side. This can be done for example at the stage when you register your screens. Here's an example:
@@ -187,25 +180,43 @@ import PushedScreen from './PushedScreen';
187
180
exportfunctionregisterScreens() {
188
181
Navigation.registerComponent(
189
182
'example.FirstTabScreen',
190
-
() =>gestureHandlerRootHOC(FirstTabScreen),
183
+
() => {
184
+
return (
185
+
<GestureHandlerRootView>
186
+
<FirstTabScreen />
187
+
</GestureHandlerRootView>
188
+
);
189
+
},
191
190
() => FirstTabScreen
192
191
);
193
192
Navigation.registerComponent(
194
193
'example.SecondTabScreen',
195
-
() =>gestureHandlerRootHOC(SecondTabScreen),
194
+
() => {
195
+
return (
196
+
<GestureHandlerRootView>
197
+
<SecondTabScreen />
198
+
</GestureHandlerRootView>
199
+
);
200
+
},
196
201
() => SecondTabScreen
197
202
);
198
203
Navigation.registerComponent(
199
204
'example.PushedScreen',
200
-
() =>gestureHandlerRootHOC(PushedScreen),
205
+
() => {
206
+
return (
207
+
<GestureHandlerRootView>
208
+
<PushedScreen />
209
+
</GestureHandlerRootView>
210
+
);
211
+
},
201
212
() => PushedScreen
202
213
);
203
214
}
204
215
```
205
216
206
217
You can check out [this example project](https://github.com/henrikra/nativeNavigationGestureHandler) to see this kind of set up in action.
207
218
208
-
Remember that you need to wrap each screen that you use in your app with `gestureHandlerRootHOC` as with native navigation libraries each screen maps to a separate root view. It will not be enough to wrap the main screen only.
219
+
Remember that you need to wrap each screen that you use in your app with `GestureHandlerRootView` as with native navigation libraries each screen maps to a separate root view. It will not be enough to wrap the main screen only.
0 commit comments