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:
@@ -133,10 +130,9 @@ Nonetheless, it's recommended to adapt to the new implementation, as the legacy
133
130
134
131
#### With [wix/react-native-navigation](https://github.com/wix/react-native-navigation)
135
132
136
-
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:
133
+
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:
@@ -145,22 +141,40 @@ import PushedScreen from './PushedScreen';
145
141
exportfunctionregisterScreens() {
146
142
Navigation.registerComponent(
147
143
'example.FirstTabScreen',
148
-
() =>gestureHandlerRootHOC(FirstTabScreen),
144
+
() => {
145
+
return (
146
+
<GestureHandlerRootView>
147
+
<FirstTabScreen />
148
+
</GestureHandlerRootView>
149
+
);
150
+
},
149
151
() => FirstTabScreen
150
152
);
151
153
Navigation.registerComponent(
152
154
'example.SecondTabScreen',
153
-
() =>gestureHandlerRootHOC(SecondTabScreen),
155
+
() => {
156
+
return (
157
+
<GestureHandlerRootView>
158
+
<SecondTabScreen />
159
+
</GestureHandlerRootView>
160
+
);
161
+
},
154
162
() => SecondTabScreen
155
163
);
156
164
Navigation.registerComponent(
157
165
'example.PushedScreen',
158
-
() =>gestureHandlerRootHOC(PushedScreen),
166
+
() => {
167
+
return (
168
+
<GestureHandlerRootView>
169
+
<PushedScreen />
170
+
</GestureHandlerRootView>
171
+
);
172
+
},
159
173
() => PushedScreen
160
174
);
161
175
}
162
176
```
163
177
164
178
You can check out [this example project](https://github.com/henrikra/nativeNavigationGestureHandler) to see this kind of set up in action.
165
179
166
-
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.
180
+
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