UNPKG

11.6 kBTypeScriptView Raw
1// Project: https://github.com/kmagiera/react-native-screens
2// TypeScript Version: 2.8
3
4declare module 'react-native-screens' {
5 import { ComponentClass } from 'react';
6 import {
7 Animated,
8 ImageProps,
9 NativeSyntheticEvent,
10 NativeTouchEvent,
11 ViewProps,
12 } from 'react-native';
13
14 export function enableScreens(shouldEnableScreens?: boolean): void;
15 export function screensEnabled(): boolean;
16
17 export type StackPresentationTypes =
18 | 'push'
19 | 'modal'
20 | 'transparentModal'
21 | 'containedModal'
22 | 'containedTransparentModal'
23 | 'fullScreenModal'
24 | 'formSheet';
25 export type StackAnimationTypes = 'default' | 'fade' | 'flip' | 'none';
26 export type BlurEffectTypes =
27 | 'extraLight'
28 | 'light'
29 | 'dark'
30 | 'regular'
31 | 'prominent'
32 | 'systemUltraThinMaterial'
33 | 'systemThinMaterial'
34 | 'systemMaterial'
35 | 'systemThickMaterial'
36 | 'systemChromeMaterial'
37 | 'systemUltraThinMaterialLight'
38 | 'systemThinMaterialLight'
39 | 'systemMaterialLight'
40 | 'systemThickMaterialLight'
41 | 'systemChromeMaterialLight'
42 | 'systemUltraThinMaterialDark'
43 | 'systemThinMaterialDark'
44 | 'systemMaterialDark'
45 | 'systemThickMaterialDark'
46 | 'systemChromeMaterialDark';
47 export type ScreenReplaceTypes = 'push' | 'pop';
48
49 export interface ScreenProps extends ViewProps {
50 active?: 0 | 1 | Animated.AnimatedInterpolation;
51 activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation;
52 children?: React.ReactNode;
53 /**
54 * @description All children screens should have the same value of their "enabled" prop as their container.
55 */
56 enabled?: boolean;
57 /**
58 * @description When set to false the back swipe gesture will be disabled when the parent Screen is on top of the stack. The default value is true.
59 */
60 gestureEnabled?: boolean;
61 /**
62 * @description A callback that gets called when the current screen appears.
63 */
64 onAppear?: (e: NativeSyntheticEvent<NativeTouchEvent>) => void;
65 onComponentRef?: (view: unknown) => void;
66 /**
67 * @description A callback that gets called when the current screen disappears.
68 */
69 onDisappear?: (e: NativeSyntheticEvent<NativeTouchEvent>) => void;
70 /**
71 * @description A callback that gets called when the current screen is dismissed by hardware back (on Android) or dismiss gesture (swipe back or down). The callback takes no arguments.
72 */
73 onDismissed?: (e: NativeSyntheticEvent<NativeTouchEvent>) => void;
74 /**
75 * @description A callback that gets called when the current screen will appear. This is called as soon as the transition begins.
76 */
77 onWillAppear?: (e: NativeSyntheticEvent<NativeTouchEvent>) => void;
78 /**
79 * @description A callback that gets called when the current screen will disappear. This is called as soon as the transition begins.
80 */
81 onWillDisappear?: (e: NativeSyntheticEvent<NativeTouchEvent>) => void;
82 /**
83 * @description Allows for the customization of the type of animation to use when this screen replaces another screen at the top of the stack. The following values are currently supported:
84 * @type "push" – performs push animation
85 * @type "pop" – performs pop animation (default)
86 */
87 replaceAnimation?: ScreenReplaceTypes;
88 /**
89 * @description Allows for the customization of how the given screen should appear/dissapear when pushed or popped at the top of the stack. The following values are currently supported:
90 * @type "default" – uses a platform default animation
91 * @type "fade" – fades screen in or out
92 * @type "flip" – flips the screen, requires stackPresentation: "modal" (iOS only)
93 * @type "none" – the screen appears/dissapears without an animation
94 */
95 stackAnimation?: StackAnimationTypes;
96 /**
97 * @type "push" – the new screen will be pushed onto a stack which on iOS means that the default animation will be slide from the side, the animation on Android may vary depending on the OS version and theme.
98 * @type "modal" – the new screen will be presented modally. In addition this allow for a nested stack to be rendered inside such screens.
99 * @type "transparentModal" – the new screen will be presented modally but in addition the second to last screen will remain attached to the stack container such that if the top screen is non opaque the content below can still be seen. If "modal" is used instead the below screen will get unmounted as soon as the transition ends.
100 * @type "containedModal" – will use "UIModalPresentationCurrentContext" modal style on iOS and will fallback to "modal" on Android.
101 * @type "containedTransparentModal" – will use "UIModalPresentationOverCurrentContext" modal style on iOS and will fallback to "transparentModal" on Android.
102 * @type "fullScreenModal" – will use "UIModalPresentationFullScreen" modal style on iOS and will fallback to "modal" on Android.
103 * @type "formSheet" – will use "UIModalPresentationFormSheet" modal style on iOS and will fallback to "modal" on Android.
104 */
105 stackPresentation?: StackPresentationTypes;
106 }
107
108 export interface ScreenContainerProps extends ViewProps {
109 /**
110 * @description A prop that gives users an option to switch between using Screens for the navigator (container). All children screens should have the same value of their "enabled" prop as their container.
111 */
112 enabled?: boolean;
113 }
114
115 export interface ScreenStackProps extends ViewProps {
116 /**
117 * @description A callback that gets called when the current screen finishes its transition.
118 */
119 onFinishTransitioning?: (e: NativeSyntheticEvent<NativeTouchEvent>) => void;
120 }
121
122 export interface ScreenStackHeaderConfigProps extends ViewProps {
123 /**
124 * @description Whether to show the back button with a custom left side of the header.
125 */
126 backButtonInCustomView?: boolean;
127 /**
128 * @description Controls the color of the navigation header.
129 */
130 backgroundColor?: string;
131 /**
132 * @host (iOS only)
133 * @description Allows for controlling the string to be rendered next to back button. By default iOS uses the title of the previous screen.
134 */
135 backTitle?: string;
136 /**
137 * @host (iOS only)
138 * @description Allows for customizing font family to be used for back button title on iOS.
139 */
140 backTitleFontFamily?: string;
141 /**
142 * @host (iOS only)
143 * @description Allows for customizing font size to be used for back button title on iOS.
144 */
145 backTitleFontSize?: number;
146 /**
147 * @host (iOS only)
148 * @description Blur effect to be applied to the header. Works with backgroundColor's alpha < 1.
149 */
150 blurEffect?: BlurEffectTypes;
151 /**
152 * Pass HeaderLeft, HeaderRight and HeaderTitle
153 */
154 children?: React.ReactNode;
155 /**
156 *@description Controls whether the stack should be in rtl or ltr form.
157 */
158 direction?: 'rtl' | 'ltr';
159 /**
160 * @description When set to true the header will be hidden while the parent Screen is on the top of the stack. The default value is false.
161 */
162 hidden?: boolean;
163 /**
164 * @description Controls the color of items rendered on the header. This includes back icon, back text (iOS only) and title text. If you want the title to have different color use titleColor property.
165 */
166 color?: string;
167 /**
168 * @description If set to true the back button will not be rendered as a part of navigation header.
169 */
170 hideBackButton?: boolean;
171 /**
172 * @description Boolean that allows for disabling drop shadow under navigation header. The default value is true.
173 */
174 hideShadow?: boolean;
175 /**
176 * @host (iOS only)
177 * @description When set to true it makes the title display using the large title effect.
178 */
179 largeTitle?: boolean;
180 /**
181 *@description Controls the color of the navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.
182 */
183 largeTitleBackgroundColor?: string;
184 /**
185 * @host (iOS only)
186 * @description Customize the color to be used for the large title. By default uses the titleColor property.
187 */
188 largeTitleColor?: string;
189 /**
190 * @host (iOS only)
191 * @description Customize font family to be used for the large title.
192 */
193 largeTitleFontFamily?: string;
194 /**
195 * @host (iOS only)
196 * @description Customize the size of the font to be used for the large title.
197 */
198 largeTitleFontSize?: number;
199 /**
200 * @description Boolean that allows for disabling drop shadow under navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.
201 */
202 largeTitleHideShadow?: boolean;
203 /**
204 * @host (iOS only)
205 * @description Sets the status bar animation (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file. Defaults to `fade`.
206 */
207 statusBarAnimation?: 'none' | 'fade' | 'slide';
208 /**
209 * @host (iOS only)
210 * @description When set to true, the status bar for this screen is hidden. Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file. Defaults to `false`.
211 */
212 statusBarHidden?: boolean;
213 /**
214 * @host (iOS only)
215 * @description Sets the status bar color (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file. Defaults to `auto`.
216 */
217 statusBarStyle?: 'inverted' | 'auto' | 'light' | 'dark';
218 /**
219 * @description String that representing screen title that will get rendered in the middle section of the header. On iOS the title is centered on the header while on Android it is aligned to the left and placed next to back button (if one is present).
220 */
221 title?: string;
222 /**
223 * @description Allows for setting text color of the title.
224 */
225 titleColor?: string;
226 /**
227 * @description Customize font family to be used for the title.
228 */
229 titleFontFamily?: string;
230 /**
231 * @description Customize the size of the font to be used for the title.
232 */
233 titleFontSize?: number;
234 /**
235 * @host (Android only)
236 * @description A flag to that lets you opt out of insetting the header. You may want to set this to `false` if you use an opaque status bar. Defaults to `true`.
237 */
238 topInsetEnabled?: boolean;
239 /**
240 * @description When set to true, it makes native navigation bar on iOS semi transparent with blur effect. It is a common way of presenting navigation bar introduced in iOS 11. The default value is false
241 */
242 translucent?: boolean;
243 }
244
245 export const Screen: ComponentClass<ScreenProps>;
246 export const ScreenContainer: ComponentClass<ScreenContainerProps>;
247 export const NativeScreen: ComponentClass<ScreenProps>;
248 export const NativeScreenContainer: ComponentClass<ScreenContainerProps>;
249 export const ScreenStack: ComponentClass<ScreenStackProps>;
250 export const ScreenStackHeaderBackButtonImage: ComponentClass<ImageProps>;
251 export const ScreenStackHeaderLeftView: ComponentClass<ViewProps>;
252 export const ScreenStackHeaderRightView: ComponentClass<ViewProps>;
253 export const ScreenStackHeaderCenterView: ComponentClass<ViewProps>;
254 export const ScreenStackHeaderConfig: ComponentClass<ScreenStackHeaderConfigProps>;
255 export const shouldUseActivityState: boolean;
256}