react-native-screens 3.7.1 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -3
- package/android/build.gradle +8 -7
- package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +71 -0
- package/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +7 -0
- package/android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt +29 -0
- package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +2 -1
- package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +7 -41
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +55 -40
- package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +19 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +30 -101
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +75 -14
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +13 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +8 -0
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +7 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +1 -0
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +90 -0
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +150 -0
- package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +40 -0
- package/createNativeStackNavigator/README.md +33 -9
- package/ios/RNSScreen.h +1 -0
- package/ios/RNSScreen.m +35 -0
- package/ios/RNSScreenContainer.h +2 -0
- package/ios/RNSScreenStack.m +24 -6
- package/ios/RNSScreenStackHeaderConfig.m +45 -2
- package/ios/RNSScreenWindowTraits.h +5 -0
- package/ios/RNSScreenWindowTraits.m +29 -0
- package/lib/commonjs/index.js +24 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +103 -17
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +67 -0
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -0
- package/lib/commonjs/native-stack/views/HeaderConfig.js +46 -4
- package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +60 -0
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -0
- package/lib/commonjs/reanimated/ReanimatedScreen.js +7 -79
- package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +61 -0
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -0
- package/lib/commonjs/reanimated/index.js +2 -2
- package/lib/commonjs/reanimated/index.js.map +1 -1
- package/lib/commonjs/utils.js +20 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +99 -19
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-stack/utils/useBackPressSubscription.js +50 -0
- package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -0
- package/lib/module/native-stack/views/HeaderConfig.js +46 -5
- package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js +40 -0
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -0
- package/lib/module/reanimated/ReanimatedScreen.js +6 -73
- package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreenProvider.js +49 -0
- package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -0
- package/lib/module/reanimated/index.js +1 -1
- package/lib/module/reanimated/index.js.map +1 -1
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/native-stack/types.d.ts +0 -2
- package/lib/typescript/native-stack/utils/useBackPressSubscription.d.ts +16 -0
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +5 -0
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts +5 -2
- package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts +2 -0
- package/lib/typescript/reanimated/index.d.ts +1 -1
- package/lib/typescript/types.d.ts +46 -1
- package/lib/typescript/utils.d.ts +2 -0
- package/native-stack/README.md +35 -7
- package/package.json +5 -2
- package/src/index.native.tsx +138 -43
- package/src/index.tsx +10 -0
- package/src/native-stack/types.tsx +0 -2
- package/src/native-stack/utils/useBackPressSubscription.tsx +66 -0
- package/src/native-stack/views/HeaderConfig.tsx +46 -3
- package/src/reanimated/ReanimatedNativeStackScreen.tsx +61 -0
- package/src/reanimated/ReanimatedScreen.tsx +6 -84
- package/src/reanimated/ReanimatedScreenProvider.tsx +42 -0
- package/src/reanimated/index.tsx +1 -1
- package/src/types.tsx +46 -1
- package/src/utils.ts +12 -0
- package/windows/.gitignore +0 -92
|
@@ -1,103 +1,25 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
Screen,
|
|
5
|
-
ScreenProps,
|
|
6
|
-
ScreenContext,
|
|
7
|
-
TransitionProgressEventType,
|
|
8
|
-
} from 'react-native-screens';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Screen, ScreenProps } from 'react-native-screens';
|
|
9
3
|
|
|
10
4
|
// @ts-ignore file to be used only if `react-native-reanimated` available in the project
|
|
11
|
-
import Animated
|
|
12
|
-
import ReanimatedTransitionProgressContext from './ReanimatedTransitionProgressContext';
|
|
5
|
+
import Animated from 'react-native-reanimated';
|
|
13
6
|
|
|
14
7
|
const AnimatedScreen = Animated.createAnimatedComponent(
|
|
15
8
|
(Screen as unknown) as React.ComponentClass
|
|
16
9
|
);
|
|
17
10
|
|
|
18
|
-
class ReanimatedScreenWrapper extends React.Component<ScreenProps> {
|
|
19
|
-
private ref: React.ElementRef<typeof View> | null = null;
|
|
20
|
-
|
|
21
|
-
setNativeProps(props: ScreenProps): void {
|
|
22
|
-
this.ref?.setNativeProps(props);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
setRef = (ref: React.ElementRef<typeof View> | null): void => {
|
|
26
|
-
this.ref = ref;
|
|
27
|
-
this.props.onComponentRef?.(ref);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
render() {
|
|
31
|
-
return (
|
|
32
|
-
<ReanimatedScreen
|
|
33
|
-
{...this.props}
|
|
34
|
-
// @ts-ignore some problems with ref
|
|
35
|
-
ref={this.setRef}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
11
|
const ReanimatedScreen = React.forwardRef<typeof AnimatedScreen, ScreenProps>(
|
|
42
12
|
(props, ref) => {
|
|
43
|
-
const { children, ...rest } = props;
|
|
44
|
-
|
|
45
|
-
const progress = useSharedValue(0);
|
|
46
|
-
const closing = useSharedValue(0);
|
|
47
|
-
const goingForward = useSharedValue(0);
|
|
48
|
-
|
|
49
13
|
return (
|
|
50
14
|
<AnimatedScreen
|
|
51
15
|
// @ts-ignore some problems with ref and onTransitionProgressReanimated being "fake" prop for parsing of `useEvent` return value
|
|
52
16
|
ref={ref}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
!props.isNativeStack
|
|
56
|
-
? undefined
|
|
57
|
-
: useEvent(
|
|
58
|
-
(event: TransitionProgressEventType) => {
|
|
59
|
-
'worklet';
|
|
60
|
-
progress.value = event.progress;
|
|
61
|
-
closing.value = event.closing;
|
|
62
|
-
goingForward.value = event.goingForward;
|
|
63
|
-
},
|
|
64
|
-
[
|
|
65
|
-
// This should not be necessary, but is not properly managed by `react-native-reanimated`
|
|
66
|
-
// @ts-ignore wrong type
|
|
67
|
-
Platform.OS === 'android'
|
|
68
|
-
? 'onTransitionProgress'
|
|
69
|
-
: 'topTransitionProgress',
|
|
70
|
-
]
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
{...rest}>
|
|
74
|
-
{!props.isNativeStack ? ( // see comment of this prop in types.tsx for information why it is needed
|
|
75
|
-
children
|
|
76
|
-
) : (
|
|
77
|
-
<ReanimatedTransitionProgressContext.Provider
|
|
78
|
-
value={{
|
|
79
|
-
progress: progress,
|
|
80
|
-
closing: closing,
|
|
81
|
-
goingForward: goingForward,
|
|
82
|
-
}}>
|
|
83
|
-
{children}
|
|
84
|
-
</ReanimatedTransitionProgressContext.Provider>
|
|
85
|
-
)}
|
|
86
|
-
</AnimatedScreen>
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
87
19
|
);
|
|
88
20
|
}
|
|
89
21
|
);
|
|
90
22
|
|
|
91
|
-
// used to silence error "Component definition is missing display name"
|
|
92
23
|
ReanimatedScreen.displayName = 'ReanimatedScreen';
|
|
93
24
|
|
|
94
|
-
export default
|
|
95
|
-
props: PropsWithChildren<unknown>
|
|
96
|
-
) {
|
|
97
|
-
return (
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
<ScreenContext.Provider value={ReanimatedScreenWrapper as any}>
|
|
100
|
-
{props.children}
|
|
101
|
-
</ScreenContext.Provider>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
25
|
+
export default ReanimatedScreen;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { ScreenProps, ScreenContext } from 'react-native-screens';
|
|
4
|
+
import ReanimatedNativeStackScreen from './ReanimatedNativeStackScreen';
|
|
5
|
+
import AnimatedScreen from './ReanimatedScreen';
|
|
6
|
+
|
|
7
|
+
class ReanimatedScreenWrapper extends React.Component<ScreenProps> {
|
|
8
|
+
private ref: React.ElementRef<typeof View> | null = null;
|
|
9
|
+
|
|
10
|
+
setNativeProps(props: ScreenProps): void {
|
|
11
|
+
this.ref?.setNativeProps(props);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setRef = (ref: React.ElementRef<typeof View> | null): void => {
|
|
15
|
+
this.ref = ref;
|
|
16
|
+
this.props.onComponentRef?.(ref);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
const ReanimatedScreen = this.props.isNativeStack
|
|
21
|
+
? ReanimatedNativeStackScreen
|
|
22
|
+
: AnimatedScreen;
|
|
23
|
+
return (
|
|
24
|
+
<ReanimatedScreen
|
|
25
|
+
{...this.props}
|
|
26
|
+
// @ts-ignore some problems with ref
|
|
27
|
+
ref={this.setRef}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default function ReanimatedScreenProvider(
|
|
34
|
+
props: PropsWithChildren<unknown>
|
|
35
|
+
) {
|
|
36
|
+
return (
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
<ScreenContext.Provider value={ReanimatedScreenWrapper as any}>
|
|
39
|
+
{props.children}
|
|
40
|
+
</ScreenContext.Provider>
|
|
41
|
+
);
|
|
42
|
+
}
|
package/src/reanimated/index.tsx
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as ReanimatedScreenProvider } from './
|
|
1
|
+
export { default as ReanimatedScreenProvider } from './ReanimatedScreenProvider';
|
|
2
2
|
export { default as useReanimatedTransitionProgress } from './useReanimatedTransitionProgress';
|
package/src/types.tsx
CHANGED
|
@@ -331,6 +331,14 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
|
|
|
331
331
|
* 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.
|
|
332
332
|
*/
|
|
333
333
|
largeTitleHideShadow?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Callback which is executed when screen header is attached
|
|
336
|
+
*/
|
|
337
|
+
onAttached?: () => void;
|
|
338
|
+
/**
|
|
339
|
+
* Callback which is executed when screen header is detached
|
|
340
|
+
*/
|
|
341
|
+
onDetached?: () => void;
|
|
334
342
|
/**
|
|
335
343
|
* String that can be displayed in the header as a fallback for `headerTitle`.
|
|
336
344
|
*/
|
|
@@ -371,24 +379,47 @@ export interface SearchBarProps {
|
|
|
371
379
|
* The auto-capitalization behavior
|
|
372
380
|
*/
|
|
373
381
|
autoCapitalize?: 'none' | 'words' | 'sentences' | 'characters';
|
|
382
|
+
/**
|
|
383
|
+
* Automatically focuses search bar on mount
|
|
384
|
+
*
|
|
385
|
+
* @platform android
|
|
386
|
+
*/
|
|
387
|
+
autoFocus?: boolean;
|
|
374
388
|
/**
|
|
375
389
|
* The search field background color
|
|
376
390
|
*/
|
|
377
391
|
barTintColor?: string;
|
|
378
392
|
/**
|
|
379
393
|
* The text to be used instead of default `Cancel` button text
|
|
394
|
+
*
|
|
395
|
+
* @platform ios
|
|
380
396
|
*/
|
|
381
397
|
cancelButtonText?: string;
|
|
382
|
-
|
|
398
|
+
/**
|
|
399
|
+
* Specifies whether the back button should close search bar's text input or not.
|
|
400
|
+
*
|
|
401
|
+
* @platform android
|
|
402
|
+
*/
|
|
403
|
+
disableBackButtonOverride?: boolean;
|
|
383
404
|
/**
|
|
384
405
|
* Indicates whether to hide the navigation bar
|
|
406
|
+
*
|
|
407
|
+
* @platform ios
|
|
385
408
|
*/
|
|
386
409
|
hideNavigationBar?: boolean;
|
|
387
410
|
/**
|
|
388
411
|
* Indicates whether to hide the search bar when scrolling
|
|
412
|
+
*
|
|
413
|
+
* @platform ios
|
|
389
414
|
*/
|
|
390
415
|
hideWhenScrolling?: boolean;
|
|
391
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Sets type of the input. Defaults to `text`.
|
|
419
|
+
*
|
|
420
|
+
* @platform android
|
|
421
|
+
*/
|
|
422
|
+
inputType?: 'text' | 'phone' | 'number' | 'email';
|
|
392
423
|
/**
|
|
393
424
|
* Indicates whether to to obscure the underlying content
|
|
394
425
|
*/
|
|
@@ -399,6 +430,8 @@ export interface SearchBarProps {
|
|
|
399
430
|
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
400
431
|
/**
|
|
401
432
|
* A callback that gets called when the cancel button is pressed
|
|
433
|
+
*
|
|
434
|
+
* @platform ios
|
|
402
435
|
*/
|
|
403
436
|
onCancelButtonPress?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
404
437
|
|
|
@@ -410,7 +443,19 @@ export interface SearchBarProps {
|
|
|
410
443
|
/**
|
|
411
444
|
* A callback that gets called when search bar has received focus
|
|
412
445
|
*/
|
|
446
|
+
onClose?: () => void;
|
|
447
|
+
/**
|
|
448
|
+
* A callback that gets called when search bar is opened
|
|
449
|
+
*
|
|
450
|
+
* @platform android
|
|
451
|
+
*/
|
|
413
452
|
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
453
|
+
/**
|
|
454
|
+
* A callback that gets called when search bar is closed
|
|
455
|
+
*
|
|
456
|
+
* @platform android
|
|
457
|
+
*/
|
|
458
|
+
onOpen?: () => void;
|
|
414
459
|
/**
|
|
415
460
|
* A callback that gets called when the search button is pressed. It receives the current text value of the search bar.
|
|
416
461
|
*/
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BackHandler, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const isSearchBarAvailableForCurrentPlatform = [
|
|
4
|
+
'ios',
|
|
5
|
+
'android',
|
|
6
|
+
].includes(Platform.OS);
|
|
7
|
+
|
|
8
|
+
export function executeNativeBackPress() {
|
|
9
|
+
// This function invokes the native back press event
|
|
10
|
+
BackHandler.exitApp();
|
|
11
|
+
return true;
|
|
12
|
+
}
|
package/windows/.gitignore
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
*AppPackages*
|
|
2
|
-
*BundleArtifacts*
|
|
3
|
-
|
|
4
|
-
#OS junk files
|
|
5
|
-
[Tt]humbs.db
|
|
6
|
-
*.DS_Store
|
|
7
|
-
|
|
8
|
-
#Visual Studio files
|
|
9
|
-
*.[Oo]bj
|
|
10
|
-
*.user
|
|
11
|
-
*.aps
|
|
12
|
-
*.pch
|
|
13
|
-
*.vspscc
|
|
14
|
-
*.vssscc
|
|
15
|
-
*_i.c
|
|
16
|
-
*_p.c
|
|
17
|
-
*.ncb
|
|
18
|
-
*.suo
|
|
19
|
-
*.tlb
|
|
20
|
-
*.tlh
|
|
21
|
-
*.bak
|
|
22
|
-
*.[Cc]ache
|
|
23
|
-
*.ilk
|
|
24
|
-
*.log
|
|
25
|
-
*.lib
|
|
26
|
-
*.sbr
|
|
27
|
-
*.sdf
|
|
28
|
-
*.opensdf
|
|
29
|
-
*.opendb
|
|
30
|
-
*.unsuccessfulbuild
|
|
31
|
-
ipch/
|
|
32
|
-
[Oo]bj/
|
|
33
|
-
[Bb]in
|
|
34
|
-
[Dd]ebug*/
|
|
35
|
-
[Rr]elease*/
|
|
36
|
-
Ankh.NoLoad
|
|
37
|
-
|
|
38
|
-
# Visual C++ cache files
|
|
39
|
-
ipch/
|
|
40
|
-
*.aps
|
|
41
|
-
*.ncb
|
|
42
|
-
*.opendb
|
|
43
|
-
*.opensdf
|
|
44
|
-
*.sdf
|
|
45
|
-
*.cachefile
|
|
46
|
-
*.VC.db
|
|
47
|
-
*.VC.VC.opendb
|
|
48
|
-
|
|
49
|
-
#MonoDevelop
|
|
50
|
-
*.pidb
|
|
51
|
-
*.userprefs
|
|
52
|
-
|
|
53
|
-
#Tooling
|
|
54
|
-
_ReSharper*/
|
|
55
|
-
*.resharper
|
|
56
|
-
[Tt]est[Rr]esult*
|
|
57
|
-
*.sass-cache
|
|
58
|
-
|
|
59
|
-
#Project files
|
|
60
|
-
[Bb]uild/
|
|
61
|
-
|
|
62
|
-
#Subversion files
|
|
63
|
-
.svn
|
|
64
|
-
|
|
65
|
-
# Office Temp Files
|
|
66
|
-
~$*
|
|
67
|
-
|
|
68
|
-
# vim Temp Files
|
|
69
|
-
*~
|
|
70
|
-
|
|
71
|
-
#NuGet
|
|
72
|
-
packages/
|
|
73
|
-
*.nupkg
|
|
74
|
-
|
|
75
|
-
#ncrunch
|
|
76
|
-
*ncrunch*
|
|
77
|
-
*crunch*.local.xml
|
|
78
|
-
|
|
79
|
-
# visual studio database projects
|
|
80
|
-
*.dbmdl
|
|
81
|
-
|
|
82
|
-
#Test files
|
|
83
|
-
*.testsettings
|
|
84
|
-
|
|
85
|
-
#Other files
|
|
86
|
-
*.DotSettings
|
|
87
|
-
.vs/
|
|
88
|
-
*project.lock.json
|
|
89
|
-
|
|
90
|
-
#Files generated by the VS build
|
|
91
|
-
**/Generated Files/**
|
|
92
|
-
|