|
@@ -1,13 +1,13 @@
|
1
|
1
|
# Android Specific Use Cases
|
2
|
2
|
|
3
|
|
-TOC
|
4
|
|
-* [Activity Lifecycle and onActivityResult](https://github.com/wix/react-native-navigation/wiki/Android#activity-lifecycle-and-onactivityresult)
|
5
|
|
-* [Adjusting soft input mode](https://github.com/wix/react-native-navigation/wiki/Android/#adjusting-soft-input-mode)
|
6
|
|
-* [Splash screen](https://github.com/wix/react-native-navigation/wiki/Android/#splash-screen)
|
7
|
|
-* [Collapsing React header](https://github.com/wix/react-native-navigation/wiki/Android/#collapsing-react-header---android-only)
|
8
|
|
- * [Collapsing react view](https://github.com/wix/react-native-navigation/wiki/Android/#collapsing-react-view)
|
9
|
|
- * [Collapsing react view with top tabs](https://github.com/wix/react-native-navigation/wiki/Android/_edit#collapsing-react-view-with-top-tabs)
|
10
|
|
-* [Reloading from terminal](https://github.com/wix/react-native-navigation/wiki/Android/#reloading-from-terminal)
|
|
3
|
+* [Activity Lifecycle and onActivityResult](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=activity-lifecycle-and-onactivityresult)
|
|
4
|
+* [Adjusting soft input mode](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=adjusting-soft-input-mode)
|
|
5
|
+* [Splash screen](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=splash-screen)
|
|
6
|
+* [Collapsing React header](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=collapsing-react-header)
|
|
7
|
+ * [Collapsing react view](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=collapsing-react-view)
|
|
8
|
+ * [Collapsing react view with top tabs](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=collapsing-react-view-with-top-tabs)
|
|
9
|
+* [Shared Element Transition](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=shared-element-transition)
|
|
10
|
+* [Reloading from terminal](https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=reloading-from-terminal)
|
11
|
11
|
|
12
|
12
|
# Activity Lifecycle and onActivityResult
|
13
|
13
|
In order to listen to activity lifecycle callbacks, set `ActivityCallback` in `MainApplication.onCreate` as follows:
|
|
@@ -79,7 +79,7 @@ public class MyApplication extends NavigationApplication {
|
79
|
79
|
# Splash screen
|
80
|
80
|
Override `getSplashLayout` or `createSplashLayout` in `MainActivity` to provide a splash layout which will be displayed while Js context initialises.
|
81
|
81
|
|
82
|
|
-# Collapsing React header - Android only
|
|
82
|
+# Collapsing React header
|
83
|
83
|
A screen can have a header, either an image or a react component, that collapses as the screen is scrolled.
|
84
|
84
|
|
85
|
85
|
## Collapsing react view
|
|
@@ -138,6 +138,63 @@ Navigation.startSingleScreenApp({
|
138
|
138
|
]
|
139
|
139
|
});
|
140
|
140
|
```
|
|
141
|
+# Shared Element Transition
|
|
142
|
+Screen transitions provide visual connections between different states through motion and transformations between common elements. You can specify custom animations for transitions of shared elements between screens.
|
|
143
|
+
|
|
144
|
+The `<SharedElementTransition>` component determines how views that are shared between two screens transition between these screens. For example, if two screens have the same image in different positions and sizes, the `<SharedElementTransition>` will translate and scale the image smoothly between these screens.
|
|
145
|
+
|
|
146
|
+>When you Shared Element Transition is used, the default cross-fading transition is activated between the entering and exiting screens. To disable the corss-fade animation set `animated: false` when pushing the second screen.
|
|
147
|
+
|
|
148
|
+## Supported transitions
|
|
149
|
+* Scale
|
|
150
|
+* Text color
|
|
151
|
+* Linear translation
|
|
152
|
+* Curved motion translation
|
|
153
|
+* Image bounds and scale transformation - Unlike the basic scale transformation, this transformation will change the actual image scale and bounds, instead of simply scaling it up or down.
|
|
154
|
+
|
|
155
|
+## Specifying shared elements
|
|
156
|
+First, wrap the view you would like to transition in a `<SharedElementTransition/>` and give it a unique id. This is how our `<Text/>` element is defined in the first screen:
|
|
157
|
+
|
|
158
|
+```js
|
|
159
|
+<SharedElementTransition sharedElementId={'SharedTextId'}>
|
|
160
|
+ <Text style={{color: 'blue'}}>React Native Navigation</Text>
|
|
161
|
+</SharedElementTransition>
|
|
162
|
+```
|
|
163
|
+<br>In the second screen, we also wrap the corresponding `<Text/>` element but this time, we also specify the transition props:
|
|
164
|
+
|
|
165
|
+```js
|
|
166
|
+<SharedElementTransition
|
|
167
|
+ sharedElementId={'SharedTextId'}
|
|
168
|
+ showDuration={600}
|
|
169
|
+ hideDuration={400}
|
|
170
|
+ showInterpolation={
|
|
171
|
+ {
|
|
172
|
+ type: 'linear',
|
|
173
|
+ easing: 'FastOutSlowIn'
|
|
174
|
+ }
|
|
175
|
+ }
|
|
176
|
+ hideInterpolation={
|
|
177
|
+ {
|
|
178
|
+ type: 'linear',
|
|
179
|
+ easing:'FastOutSlowIn'
|
|
180
|
+ }
|
|
181
|
+ }
|
|
182
|
+ >
|
|
183
|
+ <Text style={{color: 'green'}}>React Native Navigation</Text>
|
|
184
|
+ </SharedElementTransition>
|
|
185
|
+</View>
|
|
186
|
+```
|
|
187
|
+<br>Finally, specify the elements you'd like to transition when pushing the second screen:
|
|
188
|
+
|
|
189
|
+```js
|
|
190
|
+this.props.navigator.push({
|
|
191
|
+ screen: 'SharedElementScreen',
|
|
192
|
+ sharedElements: ['SharedTextId']
|
|
193
|
+ }
|
|
194
|
+});
|
|
195
|
+```
|
|
196
|
+## Animating image bounds and scale
|
|
197
|
+By default, when animating images, a basic scale transition is used. This is good enough for basic use cases where both images have the same aspect ratio. If the images have different size and scale, you can animate their bounds and scale by setting `animateClipBounds={true}` on the final `<SharedElementTransition/> element.
|
141
|
198
|
|
142
|
199
|
# Reloading from terminal
|
143
|
|
-You can easily reload your app from terminal using `adb shell am broadcast -a react.native.RELOAD`. This is particularly useful when debugging on device.
|
|
200
|
+You can easily reload your app from terminal using `adb shell am broadcast -a react.native.RELOAD`. This is particularly useful when debugging on device.
|