react-native-screens 3.24.0 → 3.26.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.
Files changed (140) hide show
  1. package/README.md +1 -1
  2. package/RNScreens.podspec +53 -32
  3. package/android/build.gradle +13 -11
  4. package/android/src/main/java/com/swmansion/rnscreens/FragmentHolder.kt +7 -0
  5. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +41 -10
  6. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +35 -36
  7. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainerViewManager.kt +7 -7
  8. package/android/src/main/java/com/swmansion/rnscreens/ScreenEventDispatcher.kt +21 -0
  9. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +46 -38
  10. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +22 -0
  11. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +40 -39
  12. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +35 -10
  13. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragmentWrapper.kt +15 -0
  14. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +6 -4
  15. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +11 -18
  16. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +27 -7
  17. package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +1 -1
  18. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +23 -7
  19. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +3 -5
  20. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +3 -5
  21. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +3 -5
  22. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +26 -0
  23. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAppearEvent.kt +3 -5
  24. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDisappearEvent.kt +3 -5
  25. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDismissedEvent.kt +4 -7
  26. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +7 -8
  27. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillAppearEvent.kt +3 -5
  28. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillDisappearEvent.kt +3 -5
  29. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +3 -5
  30. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +5 -6
  31. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +3 -5
  32. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +3 -5
  33. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +3 -5
  34. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +4 -6
  35. package/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt +3 -5
  36. package/android/src/main/java/com/swmansion/rnscreens/utils/DeviceUtils.kt +12 -0
  37. package/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml +1 -1
  38. package/ios/RNSFullWindowOverlay.mm +2 -2
  39. package/ios/RNSScreen.h +5 -0
  40. package/ios/RNSScreen.mm +164 -7
  41. package/ios/RNSScreenStack.mm +18 -0
  42. package/ios/RNSScreenStackHeaderConfig.mm +18 -0
  43. package/ios/events/RNSHeaderHeightChangeEvent.h +8 -0
  44. package/ios/events/RNSHeaderHeightChangeEvent.mm +44 -0
  45. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  46. package/lib/commonjs/index.native.js +11 -11
  47. package/lib/commonjs/index.native.js.map +1 -1
  48. package/lib/commonjs/native-stack/index.js +14 -0
  49. package/lib/commonjs/native-stack/index.js.map +1 -1
  50. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +1 -1
  51. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  52. package/lib/commonjs/native-stack/types.js.map +1 -1
  53. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js +13 -0
  54. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -0
  55. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  56. package/lib/commonjs/native-stack/utils/getStatusBarHeight.js +22 -0
  57. package/lib/commonjs/native-stack/utils/getStatusBarHeight.js.map +1 -0
  58. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js +19 -0
  59. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
  60. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +2 -2
  61. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
  62. package/lib/commonjs/native-stack/views/HeaderConfig.js +2 -2
  63. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  64. package/lib/commonjs/native-stack/views/NativeStackView.js +39 -21
  65. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  66. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js +13 -0
  67. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js.map +1 -0
  68. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +37 -6
  69. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  70. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +2 -2
  71. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  72. package/lib/commonjs/reanimated/index.js +7 -0
  73. package/lib/commonjs/reanimated/index.js.map +1 -1
  74. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js +19 -0
  75. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js.map +1 -0
  76. package/lib/commonjs/types.js.map +1 -1
  77. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  78. package/lib/module/index.native.js +12 -12
  79. package/lib/module/index.native.js.map +1 -1
  80. package/lib/module/native-stack/index.js +2 -0
  81. package/lib/module/native-stack/index.js.map +1 -1
  82. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +1 -1
  83. package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  84. package/lib/module/native-stack/types.js.map +1 -1
  85. package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js +4 -0
  86. package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -0
  87. package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  88. package/lib/module/native-stack/utils/getStatusBarHeight.js +16 -0
  89. package/lib/module/native-stack/utils/getStatusBarHeight.js.map +1 -0
  90. package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js +10 -0
  91. package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
  92. package/lib/module/native-stack/utils/useBackPressSubscription.js +2 -2
  93. package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
  94. package/lib/module/native-stack/views/HeaderConfig.js +2 -2
  95. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  96. package/lib/module/native-stack/views/NativeStackView.js +40 -22
  97. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  98. package/lib/module/reanimated/ReanimatedHeaderHeightContext.js +5 -0
  99. package/lib/module/reanimated/ReanimatedHeaderHeightContext.js.map +1 -0
  100. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +37 -6
  101. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  102. package/lib/module/reanimated/ReanimatedScreenProvider.js +2 -2
  103. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  104. package/lib/module/reanimated/index.js +1 -0
  105. package/lib/module/reanimated/index.js.map +1 -1
  106. package/lib/module/reanimated/useReanimatedHeaderHeight.js +10 -0
  107. package/lib/module/reanimated/useReanimatedHeaderHeight.js.map +1 -0
  108. package/lib/module/types.js.map +1 -1
  109. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +4 -0
  110. package/lib/typescript/native-stack/index.d.ts +2 -0
  111. package/lib/typescript/native-stack/types.d.ts +20 -12
  112. package/lib/typescript/native-stack/utils/AnimatedHeaderHeightContext.d.ts +4 -0
  113. package/lib/typescript/native-stack/utils/getStatusBarHeight.d.ts +2 -0
  114. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -0
  115. package/lib/typescript/reanimated/ReanimatedHeaderHeightContext.d.ts +4 -0
  116. package/lib/typescript/reanimated/index.d.ts +1 -0
  117. package/lib/typescript/reanimated/useReanimatedHeaderHeight.d.ts +3 -0
  118. package/lib/typescript/types.d.ts +26 -15
  119. package/native-stack/README.md +16 -1
  120. package/package.json +36 -38
  121. package/src/fabric/ScreenNativeComponent.ts +5 -0
  122. package/src/index.native.tsx +17 -19
  123. package/src/native-stack/index.tsx +3 -0
  124. package/src/native-stack/types.tsx +21 -12
  125. package/src/native-stack/utils/AnimatedHeaderHeightContext.tsx +8 -0
  126. package/src/native-stack/utils/SafeAreaProviderCompat.tsx +1 -1
  127. package/src/native-stack/utils/getStatusBarHeight.tsx +22 -0
  128. package/src/native-stack/utils/useAnimatedHeaderHeight.tsx +15 -0
  129. package/src/native-stack/views/HeaderConfig.tsx +1 -2
  130. package/src/native-stack/views/NativeStackView.tsx +78 -44
  131. package/src/reanimated/ReanimatedHeaderHeightContext.tsx +7 -0
  132. package/src/reanimated/ReanimatedNativeStackScreen.tsx +58 -11
  133. package/src/reanimated/index.tsx +1 -0
  134. package/src/reanimated/useReanimatedHeaderHeight.tsx +14 -0
  135. package/src/types.tsx +29 -14
  136. package/windows/RNScreens/RNScreens.vcxproj +6 -3
  137. package/windows/RNScreens/ScreenStack.cpp +16 -0
  138. package/windows/RNScreens/ScreenStack.h +1 -0
  139. /package/ios/{RNSScreenViewEvent.h → events/RNSScreenViewEvent.h} +0 -0
  140. /package/ios/{RNSScreenViewEvent.mm → events/RNSScreenViewEvent.mm} +0 -0
package/src/types.tsx CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  View,
6
6
  TargetedEvent,
7
7
  TextInputFocusEventData,
8
+ ColorValue,
8
9
  } from 'react-native';
9
10
 
10
11
  export type SearchBarCommands = {
@@ -72,6 +73,10 @@ export type HeaderSubviewTypes =
72
73
  | 'center'
73
74
  | 'searchBar';
74
75
 
76
+ export type HeaderHeightChangeEventType = {
77
+ headerHeight: number;
78
+ };
79
+
75
80
  export type TransitionProgressEventType = {
76
81
  progress: number;
77
82
  closing: number;
@@ -106,6 +111,10 @@ export interface ScreenProps extends ViewProps {
106
111
  * Internal boolean used to not attach events used only by native-stack. It prevents non native-stack navigators from sending transition progress from their Screen components.
107
112
  */
108
113
  isNativeStack?: boolean;
114
+ /**
115
+ * Internal boolean used to detect if current header has large title on iOS.
116
+ */
117
+ hasLargeHeader?: boolean;
109
118
  /**
110
119
  * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
111
120
  * When `enableFreeze()` is run at the top of the application defaults to `true`.
@@ -156,7 +165,7 @@ export interface ScreenProps extends ViewProps {
156
165
  *
157
166
  * @platform android
158
167
  */
159
- navigationBarColor?: string;
168
+ navigationBarColor?: ColorValue;
160
169
  /**
161
170
  * Sets the visibility of the navigation bar. Defaults to `false`.
162
171
  *
@@ -177,6 +186,12 @@ export interface ScreenProps extends ViewProps {
177
186
  * The callback takes the number of dismissed screens as an argument since iOS 14 native header back button can pop more than 1 screen at a time.
178
187
  */
179
188
  onDismissed?: (e: NativeSyntheticEvent<{ dismissCount: number }>) => void;
189
+ /**
190
+ * A callback that gets called when the header height has changed.
191
+ */
192
+ onHeaderHeightChange?: (
193
+ e: NativeSyntheticEvent<HeaderHeightChangeEventType>
194
+ ) => void;
180
195
  /**
181
196
  * A callback that gets called after swipe back is canceled.
182
197
  */
@@ -263,7 +278,7 @@ export interface ScreenProps extends ViewProps {
263
278
  * The corner radius that the sheet will try to render with.
264
279
  * Works only when `stackPresentation` is set to `formSheet`.
265
280
  *
266
- * If set to non-negative value it will try to render sheet with provided radius, else ti will apply system default.
281
+ * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default.
267
282
  *
268
283
  * If left unset system default is used.
269
284
  *
@@ -328,7 +343,7 @@ export interface ScreenProps extends ViewProps {
328
343
  *
329
344
  * @platform android
330
345
  */
331
- statusBarColor?: string;
346
+ statusBarColor?: ColorValue;
332
347
  /**
333
348
  * Whether the status bar should be hidden on this screen. Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `false`.
334
349
  */
@@ -390,7 +405,7 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
390
405
  /**
391
406
  * Controls the color of the navigation header.
392
407
  */
393
- backgroundColor?: string;
408
+ backgroundColor?: ColorValue;
394
409
  /**
395
410
  * Title to display in the back button.
396
411
  * @platform ios.
@@ -423,7 +438,7 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
423
438
  /**
424
439
  * 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.
425
440
  */
426
- color?: string;
441
+ color?: ColorValue;
427
442
  /**
428
443
  * Whether the stack should be in rtl or ltr form.
429
444
  */
@@ -457,12 +472,12 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
457
472
  /**
458
473
  * Controls the color of the navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.
459
474
  */
460
- largeTitleBackgroundColor?: string;
475
+ largeTitleBackgroundColor?: ColorValue;
461
476
  /**
462
477
  * Customize the color to be used for the large title. By default uses the titleColor property.
463
478
  * @platform ios
464
479
  */
465
- largeTitleColor?: string;
480
+ largeTitleColor?: ColorValue;
466
481
  /**
467
482
  * Customize font family to be used for the large title.
468
483
  * @platform ios
@@ -497,7 +512,7 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
497
512
  /**
498
513
  * Allows for setting text color of the title.
499
514
  */
500
- titleColor?: string;
515
+ titleColor?: ColorValue;
501
516
  /**
502
517
  * Customize font family to be used for the title.
503
518
  */
@@ -552,13 +567,13 @@ export interface SearchBarProps {
552
567
  /**
553
568
  * The search field background color
554
569
  */
555
- barTintColor?: string;
570
+ barTintColor?: ColorValue;
556
571
  /**
557
572
  * The color for the cursor caret and cancel button text.
558
573
  *
559
574
  * @platform ios
560
575
  */
561
- tintColor?: string;
576
+ tintColor?: ColorValue;
562
577
  /**
563
578
  * The text to be used instead of default `Cancel` button text
564
579
  *
@@ -591,7 +606,7 @@ export interface SearchBarProps {
591
606
  */
592
607
  inputType?: 'text' | 'phone' | 'number' | 'email';
593
608
  /**
594
- * Indicates whether to to obscure the underlying content
609
+ * Indicates whether to obscure the underlying content
595
610
  */
596
611
  obscureBackground?: boolean;
597
612
  /**
@@ -653,19 +668,19 @@ export interface SearchBarProps {
653
668
  /**
654
669
  * The search field text color
655
670
  */
656
- textColor?: string;
671
+ textColor?: ColorValue;
657
672
  /**
658
673
  * The search hint text color
659
674
  *
660
675
  * @plaform android
661
676
  */
662
- hintTextColor?: string;
677
+ hintTextColor?: ColorValue;
663
678
  /**
664
679
  * The search and close icon color shown in the header
665
680
  *
666
681
  * @plaform android
667
682
  */
668
- headerIconColor?: string;
683
+ headerIconColor?: ColorValue;
669
684
  /**
670
685
  * Show the search hint icon when search bar is focused
671
686
  *
@@ -13,13 +13,16 @@
13
13
  <AppContainerApplication>true</AppContainerApplication>
14
14
  <ApplicationType>Windows Store</ApplicationType>
15
15
  <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
16
- <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.18362.0</WindowsTargetPlatformVersion>
17
- <WindowsTargetPlatformMinVersion>10.0.16299.0</WindowsTargetPlatformMinVersion>
18
16
  </PropertyGroup>
19
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
20
17
  <PropertyGroup Label="ReactNativeWindowsProps">
21
18
  <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
22
19
  </PropertyGroup>
20
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Default.props')" />
21
+ <PropertyGroup Label="Fallback Windows SDK Versions">
22
+ <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.18362.0</WindowsTargetPlatformVersion>
23
+ <WindowsTargetPlatformMinVersion Condition=" '$(WindowsTargetPlatformMinVersion)' == '' ">10.0.16299.0</WindowsTargetPlatformMinVersion>
24
+ </PropertyGroup>
25
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
23
26
  <ItemGroup Label="ProjectConfigurations">
24
27
  <ProjectConfiguration Include="Debug|ARM">
25
28
  <Configuration>Debug</Configuration>
@@ -35,6 +35,7 @@ void ScreenStack::removeAllChildren() {
35
35
 
36
36
  void ScreenStack::removeChildAt(int64_t index) {
37
37
  m_children.RemoveAt(static_cast<uint32_t>(index));
38
+ onChildModified(index);
38
39
  }
39
40
 
40
41
  void ScreenStack::replaceChild(
@@ -45,5 +46,20 @@ void ScreenStack::replaceChild(
45
46
  return;
46
47
 
47
48
  m_children.SetAt(index, newChild);
49
+ onChildModified(index);
50
+ }
51
+
52
+ void ScreenStack::onChildModified(int64_t index) {
53
+ // Was it the topmost item in the stack?
54
+ if (index >= m_children.Size() - 1) {
55
+ if (m_children.Size() == 0) {
56
+ // Nobody left
57
+ Content(nullptr);
58
+ } else {
59
+ // Focus on the top item
60
+ auto uiElement = m_children.GetAt(m_children.Size() - 1);
61
+ Content(uiElement);
62
+ }
63
+ }
48
64
  }
49
65
  } // namespace winrt::RNScreens::implementation
@@ -17,6 +17,7 @@ class ScreenStack
17
17
  m_children;
18
18
 
19
19
  private:
20
+ void onChildModified(int64_t index);
20
21
  winrt::Microsoft::ReactNative::IReactContext m_reactContext{nullptr};
21
22
  };
22
23
  } // namespace winrt::RNScreens::implementation