react-native-screens 4.0.0-beta.11 → 4.0.0-beta.13

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 (118) hide show
  1. package/android/CMakeLists.txt +28 -19
  2. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +53 -71
  3. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/BottomSheetBehaviorExt.kt +42 -0
  4. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetUtils.kt +8 -0
  5. package/android/src/main/jni/CMakeLists.txt +28 -19
  6. package/ios/RNSConvert.h +13 -4
  7. package/ios/RNSConvert.mm +50 -28
  8. package/ios/RNSEnums.h +47 -0
  9. package/ios/RNSScreen.mm +1 -0
  10. package/ios/RNSScreenStackHeaderConfig.h +1 -1
  11. package/ios/RNSScreenStackHeaderConfig.mm +30 -25
  12. package/lib/commonjs/components/ScreenStack.js +2 -2
  13. package/lib/commonjs/components/ScreenStack.js.map +1 -1
  14. package/lib/commonjs/components/SearchBar.js +2 -2
  15. package/lib/commonjs/components/SearchBar.js.map +1 -1
  16. package/lib/commonjs/core.js +0 -3
  17. package/lib/commonjs/core.js.map +1 -1
  18. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  19. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js +2 -2
  20. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js.map +1 -1
  21. package/lib/commonjs/index.js +7 -14
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/native-stack/views/FooterComponent.js +2 -2
  24. package/lib/commonjs/native-stack/views/FooterComponent.js.map +1 -1
  25. package/lib/commonjs/native-stack/views/HeaderConfig.js +10 -8
  26. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  27. package/lib/commonjs/native-stack/views/NativeStackView.js +12 -9
  28. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  29. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +2 -2
  30. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  31. package/lib/commonjs/reanimated/ReanimatedScreen.js +2 -2
  32. package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
  33. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +2 -2
  34. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  35. package/lib/commonjs/utils.js +28 -6
  36. package/lib/commonjs/utils.js.map +1 -1
  37. package/lib/module/components/ScreenStack.js +1 -1
  38. package/lib/module/components/ScreenStack.js.map +1 -1
  39. package/lib/module/components/SearchBar.js +1 -1
  40. package/lib/module/components/SearchBar.js.map +1 -1
  41. package/lib/module/core.js +0 -3
  42. package/lib/module/core.js.map +1 -1
  43. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  44. package/lib/module/gesture-handler/GestureDetectorProvider.js +1 -1
  45. package/lib/module/gesture-handler/GestureDetectorProvider.js.map +1 -1
  46. package/lib/module/index.js +2 -2
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/native-stack/views/FooterComponent.js +1 -1
  49. package/lib/module/native-stack/views/FooterComponent.js.map +1 -1
  50. package/lib/module/native-stack/views/HeaderConfig.js +3 -1
  51. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  52. package/lib/module/native-stack/views/NativeStackView.js +4 -1
  53. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  54. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +1 -2
  55. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  56. package/lib/module/reanimated/ReanimatedScreen.js +1 -2
  57. package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
  58. package/lib/module/reanimated/ReanimatedScreenProvider.js +1 -1
  59. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  60. package/lib/module/utils.js +26 -5
  61. package/lib/module/utils.js.map +1 -1
  62. package/lib/typescript/components/Screen.d.ts +1 -1
  63. package/lib/typescript/components/Screen.d.ts.map +1 -1
  64. package/lib/typescript/components/Screen.web.d.ts +1 -1
  65. package/lib/typescript/components/Screen.web.d.ts.map +1 -1
  66. package/lib/typescript/components/ScreenContainer.d.ts +1 -1
  67. package/lib/typescript/components/ScreenContainer.d.ts.map +1 -1
  68. package/lib/typescript/components/ScreenStack.d.ts +1 -1
  69. package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
  70. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +1 -1
  71. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -1
  72. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts +1 -1
  73. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts.map +1 -1
  74. package/lib/typescript/components/SearchBar.d.ts +1 -1
  75. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  76. package/lib/typescript/core.d.ts +0 -1
  77. package/lib/typescript/core.d.ts.map +1 -1
  78. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +2 -2
  79. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
  80. package/lib/typescript/index.d.ts +2 -2
  81. package/lib/typescript/index.d.ts.map +1 -1
  82. package/lib/typescript/native-stack/types.d.ts +1 -1
  83. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  84. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
  85. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -1
  86. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
  87. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  88. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  89. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts.map +1 -1
  90. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  91. package/lib/typescript/reanimated/ReanimatedScreen.d.ts.map +1 -1
  92. package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts.map +1 -1
  93. package/lib/typescript/types.d.ts +1 -1
  94. package/lib/typescript/types.d.ts.map +1 -1
  95. package/lib/typescript/utils.d.ts +26 -1
  96. package/lib/typescript/utils.d.ts.map +1 -1
  97. package/package.json +1 -1
  98. package/src/components/Screen.tsx +1 -1
  99. package/src/components/Screen.web.tsx +1 -1
  100. package/src/components/ScreenContainer.tsx +1 -1
  101. package/src/components/ScreenStack.tsx +2 -1
  102. package/src/components/ScreenStackHeaderConfig.tsx +1 -1
  103. package/src/components/ScreenStackHeaderConfig.web.tsx +1 -1
  104. package/src/components/SearchBar.tsx +2 -5
  105. package/src/core.ts +0 -3
  106. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +2 -1
  107. package/src/gesture-handler/GestureDetectorProvider.tsx +1 -1
  108. package/src/index.tsx +1 -2
  109. package/src/native-stack/types.tsx +1 -1
  110. package/src/native-stack/utils/getDefaultHeaderHeight.tsx +1 -1
  111. package/src/native-stack/views/FooterComponent.tsx +1 -1
  112. package/src/native-stack/views/HeaderConfig.tsx +7 -5
  113. package/src/native-stack/views/NativeStackView.tsx +5 -8
  114. package/src/reanimated/ReanimatedNativeStackScreen.tsx +2 -2
  115. package/src/reanimated/ReanimatedScreen.tsx +2 -1
  116. package/src/reanimated/ReanimatedScreenProvider.tsx +2 -1
  117. package/src/types.tsx +1 -0
  118. package/src/utils.ts +27 -5
@@ -41,28 +41,37 @@ find_package(ReactAndroid REQUIRED CONFIG)
41
41
  if(${RNS_NEW_ARCH_ENABLED})
42
42
  find_package(fbjni REQUIRED CONFIG)
43
43
 
44
- target_link_libraries(
45
- rnscreens
44
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
45
+ target_link_libraries(rnscreens
46
+ ReactAndroid::reactnative
46
47
  ReactAndroid::jsi
47
- ReactAndroid::react_nativemodule_core
48
- ReactAndroid::react_utils
49
- ReactAndroid::reactnativejni
50
- ReactAndroid::fabricjni
51
- ReactAndroid::react_debug
52
- ReactAndroid::react_render_core
53
- ReactAndroid::runtimeexecutor
54
- ReactAndroid::react_render_graphics
55
- ReactAndroid::rrc_view
56
- ReactAndroid::yoga
57
- ReactAndroid::rrc_text
58
- ReactAndroid::glog
59
- ReactAndroid::react_render_componentregistry
60
- ReactAndroid::react_render_consistency
61
- ReactAndroid::react_performance_timeline
62
- ReactAndroid::react_render_observers_events
63
48
  fbjni::fbjni
64
49
  android
65
- )
50
+ )
51
+ else()
52
+ target_link_libraries(
53
+ rnscreens
54
+ ReactAndroid::jsi
55
+ ReactAndroid::react_nativemodule_core
56
+ ReactAndroid::react_utils
57
+ ReactAndroid::reactnativejni
58
+ ReactAndroid::fabricjni
59
+ ReactAndroid::react_debug
60
+ ReactAndroid::react_render_core
61
+ ReactAndroid::runtimeexecutor
62
+ ReactAndroid::react_render_graphics
63
+ ReactAndroid::rrc_view
64
+ ReactAndroid::yoga
65
+ ReactAndroid::rrc_text
66
+ ReactAndroid::glog
67
+ ReactAndroid::react_render_componentregistry
68
+ ReactAndroid::react_render_consistency
69
+ ReactAndroid::react_performance_timeline
70
+ ReactAndroid::react_render_observers_events
71
+ fbjni::fbjni
72
+ android
73
+ )
74
+ endif()
66
75
  else()
67
76
  target_link_libraries(rnscreens
68
77
  ReactAndroid::jsi
@@ -37,6 +37,11 @@ import com.google.android.material.shape.MaterialShapeDrawable
37
37
  import com.google.android.material.shape.ShapeAppearanceModel
38
38
  import com.swmansion.rnscreens.bottomsheet.DimmingFragment
39
39
  import com.swmansion.rnscreens.bottomsheet.SheetUtils
40
+ import com.swmansion.rnscreens.bottomsheet.isSheetFitToContents
41
+ import com.swmansion.rnscreens.bottomsheet.useSingleDetent
42
+ import com.swmansion.rnscreens.bottomsheet.useThreeDetents
43
+ import com.swmansion.rnscreens.bottomsheet.useTwoDetents
44
+ import com.swmansion.rnscreens.bottomsheet.usesFormSheetPresentation
40
45
  import com.swmansion.rnscreens.ext.recycle
41
46
  import com.swmansion.rnscreens.utils.DeviceUtils
42
47
 
@@ -157,14 +162,15 @@ class ScreenStackFragment :
157
162
  screen.notifySheetDetentChange(
158
163
  SheetUtils.detentIndexFromSheetState(
159
164
  lastStableState,
160
- screen.sheetDetents.count()
161
- ), true
165
+ screen.sheetDetents.count(),
166
+ ),
167
+ true,
162
168
  )
163
169
  } else if (newState == BottomSheetBehavior.STATE_DRAGGING) {
164
170
  screen.notifySheetDetentChange(
165
171
  SheetUtils.detentIndexFromSheetState(
166
172
  lastStableState,
167
- screen.sheetDetents.count()
173
+ screen.sheetDetents.count(),
168
174
  ),
169
175
  false,
170
176
  )
@@ -223,7 +229,7 @@ class ScreenStackFragment :
223
229
  LinearLayout.LayoutParams.MATCH_PARENT,
224
230
  ).apply {
225
231
  behavior =
226
- if (screen.stackPresentation == Screen.StackPresentation.FORM_SHEET) {
232
+ if (screen.usesFormSheetPresentation()) {
227
233
  createAndConfigureBottomSheetBehaviour()
228
234
  } else if (isToolbarTranslucent) {
229
235
  null
@@ -232,7 +238,7 @@ class ScreenStackFragment :
232
238
  }
233
239
  }
234
240
 
235
- if (screen.stackPresentation == Screen.StackPresentation.FORM_SHEET) {
241
+ if (screen.usesFormSheetPresentation()) {
236
242
  screen.clipToOutline = true
237
243
  // TODO(@kkafar): without this line there is no drawable / outline & nothing shows...? Determine what's going on here
238
244
  attachShapeToScreen(screen)
@@ -241,7 +247,7 @@ class ScreenStackFragment :
241
247
 
242
248
  coordinatorLayout.addView(screen.recycle())
243
249
 
244
- if (screen.stackPresentation != Screen.StackPresentation.FORM_SHEET) {
250
+ if (!screen.usesFormSheetPresentation()) {
245
251
  appBarLayout =
246
252
  context?.let { AppBarLayout(it) }?.apply {
247
253
  // By default AppBarLayout will have a background color set but since we cover the whole layout
@@ -348,52 +354,39 @@ class ScreenStackFragment :
348
354
  return when (keyboardState) {
349
355
  is KeyboardNotVisible -> {
350
356
  when (screen.sheetDetents.count()) {
351
- 1 -> if (screen.sheetDetents.first() == Screen.SHEET_FIT_TO_CONTENTS) {
352
- behavior.apply {
353
- state = BottomSheetBehavior.STATE_EXPANDED
354
- screen.contentWrapper.get()?.let {
355
- maxHeight = it.height
356
- }
357
- skipCollapsed = true
358
- isFitToContents = true
359
- }
360
- } else {
357
+ 1 ->
361
358
  behavior.apply {
362
- state = BottomSheetBehavior.STATE_EXPANDED
363
- skipCollapsed = true
364
- isFitToContents = true
365
- maxHeight = (screen.sheetDetents.first() * containerHeight).toInt()
359
+ val height =
360
+ if (screen.isSheetFitToContents()) {
361
+ screen.contentWrapper.get()?.height
362
+ } else {
363
+ (screen.sheetDetents.first() * containerHeight).toInt()
364
+ }
365
+ useSingleDetent(height = height)
366
366
  }
367
- }
368
367
 
369
368
  2 ->
370
- behavior.apply {
369
+ behavior.useTwoDetents(
371
370
  state =
372
371
  SheetUtils.sheetStateFromDetentIndex(
373
372
  screen.sheetInitialDetentIndex,
374
373
  screen.sheetDetents.count(),
375
- )
376
- skipCollapsed = false
377
- isFitToContents = true
378
- peekHeight = (screen.sheetDetents[0] * containerHeight).toInt()
379
- maxHeight = (screen.sheetDetents[1] * containerHeight).toInt()
380
- }
374
+ ),
375
+ firstHeight = (screen.sheetDetents[0] * containerHeight).toInt(),
376
+ secondHeight = (screen.sheetDetents[1] * containerHeight).toInt(),
377
+ )
381
378
 
382
379
  3 ->
383
- behavior.apply {
380
+ behavior.useThreeDetents(
384
381
  state =
385
382
  SheetUtils.sheetStateFromDetentIndex(
386
383
  screen.sheetInitialDetentIndex,
387
384
  screen.sheetDetents.count(),
388
- )
389
- skipCollapsed = false
390
- isFitToContents = false
391
- peekHeight = (screen.sheetDetents[0] * containerHeight).toInt()
392
- expandedOffset =
393
- ((1 - screen.sheetDetents[2]) * containerHeight).toInt()
394
- halfExpandedRatio =
395
- (screen.sheetDetents[1] / screen.sheetDetents[2]).toFloat()
396
- }
385
+ ),
386
+ firstHeight = (screen.sheetDetents[0] * containerHeight).toInt(),
387
+ halfExpandedRatio = (screen.sheetDetents[1] / screen.sheetDetents[2]).toFloat(),
388
+ expandedOffsetFromTop = ((1 - screen.sheetDetents[2]) * containerHeight).toInt(),
389
+ )
397
390
 
398
391
  else -> throw IllegalStateException(
399
392
  "[RNScreens] Invalid detent count ${screen.sheetDetents.count()}. Expected at most 3.",
@@ -411,27 +404,24 @@ class ScreenStackFragment :
411
404
  when (screen.sheetDetents.count()) {
412
405
  1 ->
413
406
  behavior.apply {
414
- state = BottomSheetBehavior.STATE_EXPANDED
415
- skipCollapsed = true
416
- isFitToContents = true
417
- maxHeight = newMaxHeight
407
+ useSingleDetent(height = newMaxHeight)
418
408
  addBottomSheetCallback(keyboardSheetCallback)
419
409
  }
420
410
 
421
411
  2 ->
422
412
  behavior.apply {
423
- state = BottomSheetBehavior.STATE_EXPANDED
424
- skipCollapsed = false
425
- isFitToContents = true
426
- maxHeight = newMaxHeight
413
+ useTwoDetents(
414
+ state = BottomSheetBehavior.STATE_EXPANDED,
415
+ secondHeight = newMaxHeight,
416
+ )
427
417
  addBottomSheetCallback(keyboardSheetCallback)
428
418
  }
429
419
 
430
420
  3 ->
431
421
  behavior.apply {
432
- state = BottomSheetBehavior.STATE_EXPANDED
433
- skipCollapsed = false
434
- isFitToContents = false
422
+ useThreeDetents(
423
+ state = BottomSheetBehavior.STATE_EXPANDED,
424
+ )
435
425
  maxHeight = newMaxHeight
436
426
  addBottomSheetCallback(keyboardSheetCallback)
437
427
  }
@@ -450,30 +440,23 @@ class ScreenStackFragment :
450
440
  behavior.removeBottomSheetCallback(keyboardSheetCallback)
451
441
  when (screen.sheetDetents.count()) {
452
442
  1 ->
453
- behavior.apply {
454
- skipCollapsed = true
455
- isFitToContents = true
456
- maxHeight = (screen.sheetDetents.first() * containerHeight).toInt()
457
- }
443
+ behavior.useSingleDetent(
444
+ height = (screen.sheetDetents.first() * containerHeight).toInt(),
445
+ forceExpandedState = false,
446
+ )
458
447
 
459
448
  2 ->
460
- behavior.apply {
461
- skipCollapsed = false
462
- isFitToContents = true
463
- peekHeight = (screen.sheetDetents[0] * containerHeight).toInt()
464
- maxHeight = (screen.sheetDetents[1] * containerHeight).toInt()
465
- }
449
+ behavior.useTwoDetents(
450
+ firstHeight = (screen.sheetDetents[0] * containerHeight).toInt(),
451
+ secondHeight = (screen.sheetDetents[1] * containerHeight).toInt(),
452
+ )
466
453
 
467
454
  3 ->
468
- behavior.apply {
469
- skipCollapsed = false
470
- isFitToContents = false
471
- peekHeight = (screen.sheetDetents[0] * containerHeight).toInt()
472
- expandedOffset =
473
- ((1 - screen.sheetDetents[2]) * containerHeight).toInt()
474
- halfExpandedRatio =
475
- (screen.sheetDetents[1] / screen.sheetDetents[2]).toFloat()
476
- }
455
+ behavior.useThreeDetents(
456
+ firstHeight = (screen.sheetDetents[0] * containerHeight).toInt(),
457
+ halfExpandedRatio = (screen.sheetDetents[1] / screen.sheetDetents[2]).toFloat(),
458
+ expandedOffsetFromTop = ((1 - screen.sheetDetents[2]) * containerHeight).toInt(),
459
+ )
477
460
 
478
461
  else -> throw IllegalStateException(
479
462
  "[RNScreens] Invalid detent count ${screen.sheetDetents.count()}. Expected at most 3.",
@@ -595,8 +578,7 @@ class ScreenStackFragment :
595
578
  // ) : CoordinatorLayout(context), ReactCompoundViewGroup, ReactHitSlopView {
596
579
  ) : CoordinatorLayout(context),
597
580
  ReactPointerEventsView {
598
- override fun onApplyWindowInsets(insets: WindowInsets?): WindowInsets =
599
- super.onApplyWindowInsets(insets)
581
+ override fun onApplyWindowInsets(insets: WindowInsets?): WindowInsets = super.onApplyWindowInsets(insets)
600
582
 
601
583
  private val animationListener: Animation.AnimationListener =
602
584
  object : Animation.AnimationListener {
@@ -0,0 +1,42 @@
1
+ package com.swmansion.rnscreens.bottomsheet
2
+
3
+ import android.view.View
4
+ import com.google.android.material.bottomsheet.BottomSheetBehavior
5
+
6
+ internal fun <T : View> BottomSheetBehavior<T>.useSingleDetent(height: Int? = null, forceExpandedState: Boolean = true): BottomSheetBehavior<T> {
7
+ this.skipCollapsed = true
8
+ this.isFitToContents = true
9
+ if (forceExpandedState) {
10
+ this.state = BottomSheetBehavior.STATE_EXPANDED
11
+ }
12
+ height?.let { maxHeight = height }
13
+ return this
14
+ }
15
+
16
+ internal fun <T : View> BottomSheetBehavior<T>.useTwoDetents(
17
+ @BottomSheetBehavior.StableState state: Int? = null,
18
+ firstHeight: Int? = null,
19
+ secondHeight: Int? = null
20
+ ): BottomSheetBehavior<T> {
21
+ skipCollapsed = false
22
+ isFitToContents = true
23
+ state?.let { this.state = state }
24
+ firstHeight?.let { peekHeight = firstHeight }
25
+ secondHeight?.let { maxHeight = secondHeight }
26
+ return this
27
+ }
28
+
29
+ internal fun <T : View> BottomSheetBehavior<T>.useThreeDetents(
30
+ @BottomSheetBehavior.StableState state: Int? = null,
31
+ firstHeight: Int? = null,
32
+ halfExpandedRatio: Float? = null,
33
+ expandedOffsetFromTop: Int? = null
34
+ ): BottomSheetBehavior<T> {
35
+ skipCollapsed = false
36
+ isFitToContents = false
37
+ state?.let { this.state = state }
38
+ firstHeight?.let { this.peekHeight = firstHeight }
39
+ halfExpandedRatio?.let { this.halfExpandedRatio = halfExpandedRatio }
40
+ expandedOffsetFromTop?.let { this.expandedOffset = expandedOffsetFromTop }
41
+ return this
42
+ }
@@ -5,6 +5,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPS
5
5
  import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
6
6
  import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HALF_EXPANDED
7
7
  import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_HIDDEN
8
+ import com.swmansion.rnscreens.Screen
8
9
 
9
10
  object SheetUtils {
10
11
  /**
@@ -125,3 +126,10 @@ object SheetUtils {
125
126
  return false
126
127
  }
127
128
  }
129
+
130
+ fun Screen.isSheetFitToContents(): Boolean =
131
+ stackPresentation === Screen.StackPresentation.FORM_SHEET &&
132
+ sheetDetents.count() == 1 &&
133
+ sheetDetents.first() == Screen.SHEET_FIT_TO_CONTENTS
134
+
135
+ fun Screen.usesFormSheetPresentation(): Boolean = stackPresentation === Screen.StackPresentation.FORM_SHEET
@@ -38,25 +38,34 @@ target_include_directories(
38
38
  ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}
39
39
  )
40
40
 
41
- target_link_libraries(
42
- ${LIB_TARGET_NAME}
43
- fbjni
44
- folly_runtime
45
- glog
46
- jsi
47
- react_codegen_rncore
48
- react_debug
49
- react_nativemodule_core
50
- react_render_core
51
- react_render_debug
52
- react_render_graphics
53
- react_render_mapbuffer
54
- react_render_componentregistry
55
- react_utils
56
- rrc_view
57
- turbomodulejsijni
58
- yoga
59
- )
41
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
42
+ target_link_libraries(
43
+ ${LIB_TARGET_NAME}
44
+ ReactAndroid::reactnative
45
+ ReactAndroid::jsi
46
+ fbjni::fbjni
47
+ )
48
+ else()
49
+ target_link_libraries(
50
+ ${LIB_TARGET_NAME}
51
+ fbjni
52
+ folly_runtime
53
+ glog
54
+ jsi
55
+ react_codegen_rncore
56
+ react_debug
57
+ react_nativemodule_core
58
+ react_render_core
59
+ react_render_debug
60
+ react_render_graphics
61
+ react_render_mapbuffer
62
+ react_render_componentregistry
63
+ react_utils
64
+ rrc_view
65
+ turbomodulejsijni
66
+ yoga
67
+ )
68
+ endif()
60
69
 
61
70
  target_compile_options(
62
71
  ${LIB_TARGET_NAME}
package/ios/RNSConvert.h CHANGED
@@ -1,12 +1,17 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
1
  #import <UIKit/UIKit.h>
2
+ #ifdef RCT_NEW_ARCH_ENABLED
3
3
  #import <react/renderer/components/rnscreens/Props.h>
4
+ #endif // RCT_NEW_ARCH_ENABLED
4
5
  #import "RNSEnums.h"
5
6
 
7
+ #ifdef RCT_NEW_ARCH_ENABLED
6
8
  namespace react = facebook::react;
9
+ #endif // RCT_NEW_ARCH_ENABLED
7
10
 
8
11
  @interface RNSConvert : NSObject
9
12
 
13
+ #ifdef RCT_NEW_ARCH_ENABLED
14
+
10
15
  + (UISemanticContentAttribute)UISemanticContentAttributeFromCppEquivalent:
11
16
  (react::RNSScreenStackHeaderConfigDirection)direction;
12
17
 
@@ -42,8 +47,12 @@ namespace react = facebook::react;
42
47
 
43
48
  + (NSMutableArray<NSNumber *> *)arrayFromVector:(const std::vector<CGFloat> &)vector;
44
49
 
45
- + (UIBlurEffectStyle)UIBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect;
46
-
47
- @end
50
+ + (RNSBlurEffectStyle)RNSBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect;
48
51
 
49
52
  #endif // RCT_NEW_ARCH_ENABLED
53
+
54
+ /// This method fails (by assertion) when `blurEffect == RNSBlurEffectStyleNone` which has no counter part in the UIKit
55
+ /// type.
56
+ + (UIBlurEffectStyle)tryConvertRNSBlurEffectStyleToUIBlurEffectStyle:(RNSBlurEffectStyle)blurEffect;
57
+
58
+ @end
package/ios/RNSConvert.mm CHANGED
@@ -1,8 +1,12 @@
1
1
  #import "RNSConvert.h"
2
2
 
3
- #ifdef RCT_NEW_ARCH_ENABLED
3
+ #ifndef RCT_NEW_ARCH_ENABLED
4
+ #import <react/RCTAssert.h>
5
+ #endif // !RCT_NEW_ARCH_ENABLED
6
+
4
7
  @implementation RNSConvert
5
8
 
9
+ #ifdef RCT_NEW_ARCH_ENABLED
6
10
  + (UISemanticContentAttribute)UISemanticContentAttributeFromCppEquivalent:
7
11
  (react::RNSScreenStackHeaderConfigDirection)direction
8
12
  {
@@ -173,71 +177,89 @@
173
177
  return array;
174
178
  }
175
179
 
176
- + (UIBlurEffectStyle)UIBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect
180
+ + (RNSBlurEffectStyle)RNSBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect
177
181
  {
178
182
  #if !TARGET_OS_TV && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
179
183
  __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
180
184
  if (@available(iOS 13.0, *)) {
181
185
  switch (blurEffect) {
186
+ case react::RNSScreenStackHeaderConfigBlurEffect::None:
187
+ return RNSBlurEffectStyleNone;
182
188
  case react::RNSScreenStackHeaderConfigBlurEffect::ExtraLight:
183
- return UIBlurEffectStyleExtraLight;
189
+ return RNSBlurEffectStyleExtraLight;
184
190
  case react::RNSScreenStackHeaderConfigBlurEffect::Light:
185
- return UIBlurEffectStyleLight;
191
+ return RNSBlurEffectStyleLight;
186
192
  case react::RNSScreenStackHeaderConfigBlurEffect::Dark:
187
- return UIBlurEffectStyleDark;
193
+ return RNSBlurEffectStyleDark;
188
194
  case react::RNSScreenStackHeaderConfigBlurEffect::Regular:
189
- return UIBlurEffectStyleRegular;
195
+ return RNSBlurEffectStyleRegular;
190
196
  case react::RNSScreenStackHeaderConfigBlurEffect::Prominent:
191
- return UIBlurEffectStyleProminent;
197
+ return RNSBlurEffectStyleProminent;
192
198
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemUltraThinMaterial:
193
- return UIBlurEffectStyleSystemUltraThinMaterial;
199
+ return RNSBlurEffectStyleSystemUltraThinMaterial;
194
200
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemThinMaterial:
195
- return UIBlurEffectStyleSystemThinMaterial;
201
+ return RNSBlurEffectStyleSystemThinMaterial;
196
202
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemMaterial:
197
- return UIBlurEffectStyleSystemMaterial;
203
+ return RNSBlurEffectStyleSystemMaterial;
198
204
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemThickMaterial:
199
- return UIBlurEffectStyleSystemThickMaterial;
205
+ return RNSBlurEffectStyleSystemThickMaterial;
200
206
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemChromeMaterial:
201
- return UIBlurEffectStyleSystemChromeMaterial;
207
+ return RNSBlurEffectStyleSystemChromeMaterial;
202
208
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemUltraThinMaterialLight:
203
- return UIBlurEffectStyleSystemUltraThinMaterialLight;
209
+ return RNSBlurEffectStyleSystemUltraThinMaterialLight;
204
210
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemThinMaterialLight:
205
- return UIBlurEffectStyleSystemThinMaterialLight;
211
+ return RNSBlurEffectStyleSystemThinMaterialLight;
206
212
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemMaterialLight:
207
- return UIBlurEffectStyleSystemMaterialLight;
213
+ return RNSBlurEffectStyleSystemMaterialLight;
208
214
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemThickMaterialLight:
209
- return UIBlurEffectStyleSystemThickMaterialLight;
215
+ return RNSBlurEffectStyleSystemThickMaterialLight;
210
216
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemChromeMaterialLight:
211
- return UIBlurEffectStyleSystemChromeMaterialLight;
217
+ return RNSBlurEffectStyleSystemChromeMaterialLight;
212
218
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemUltraThinMaterialDark:
213
- return UIBlurEffectStyleSystemUltraThinMaterialDark;
219
+ return RNSBlurEffectStyleSystemUltraThinMaterialDark;
214
220
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemThinMaterialDark:
215
- return UIBlurEffectStyleSystemThinMaterialDark;
221
+ return RNSBlurEffectStyleSystemThinMaterialDark;
216
222
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemMaterialDark:
217
- return UIBlurEffectStyleSystemMaterialDark;
223
+ return RNSBlurEffectStyleSystemMaterialDark;
218
224
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemThickMaterialDark:
219
- return UIBlurEffectStyleSystemThickMaterialDark;
225
+ return RNSBlurEffectStyleSystemThickMaterialDark;
220
226
  case react::RNSScreenStackHeaderConfigBlurEffect::SystemChromeMaterialDark:
221
- return UIBlurEffectStyleSystemChromeMaterialDark;
227
+ return RNSBlurEffectStyleSystemChromeMaterialDark;
222
228
  }
223
229
  }
224
230
  #endif
225
231
 
226
232
  switch (blurEffect) {
233
+ case react::RNSScreenStackHeaderConfigBlurEffect::None:
234
+ return RNSBlurEffectStyleNone;
227
235
  case react::RNSScreenStackHeaderConfigBlurEffect::Light:
228
- return UIBlurEffectStyleLight;
236
+ return RNSBlurEffectStyleLight;
229
237
  case react::RNSScreenStackHeaderConfigBlurEffect::Dark:
230
- return UIBlurEffectStyleDark;
238
+ return RNSBlurEffectStyleDark;
231
239
  case react::RNSScreenStackHeaderConfigBlurEffect::Regular:
232
- return UIBlurEffectStyleRegular;
240
+ return RNSBlurEffectStyleRegular;
233
241
  case react::RNSScreenStackHeaderConfigBlurEffect::Prominent:
234
- return UIBlurEffectStyleProminent;
242
+ return RNSBlurEffectStyleProminent;
235
243
  case react::RNSScreenStackHeaderConfigBlurEffect::ExtraLight:
236
244
  default:
237
- return UIBlurEffectStyleExtraLight;
245
+ return RNSBlurEffectStyleNone;
238
246
  }
239
247
  }
240
248
 
241
- @end
249
+ #endif // RCT_NEW_ARCH_ENABLED
242
250
 
251
+ + (UIBlurEffectStyle)tryConvertRNSBlurEffectStyleToUIBlurEffectStyle:(RNSBlurEffectStyle)blurEffect
252
+ {
253
+ #ifdef RCT_NEW_ARCH_ENABLED
254
+ react_native_assert(blurEffect != RNSBlurEffectStyleNone);
255
+ #else
256
+ RCTAssert(
257
+ blurEffect != RNSBlurEffectStyleNone, @"RNSBlurEffectStyleNone variant is not convertible to UIBlurEffectStyle");
243
258
  #endif // RCT_NEW_ARCH_ENABLED
259
+
260
+ // Cast safety: RNSBlurEffectStyle is defined in such way that its values map 1:1 with
261
+ // UIBlurEffectStyle, except RNSBlurEffectStyleNone which is excluded above.
262
+ return (UIBlurEffectStyle)blurEffect;
263
+ }
264
+
265
+ @end
package/ios/RNSEnums.h CHANGED
@@ -30,6 +30,7 @@ typedef NS_ENUM(NSInteger, RNSScreenSwipeDirection) {
30
30
  };
31
31
 
32
32
  typedef NS_ENUM(NSInteger, RNSActivityState) {
33
+ RNSActivityStateUndefined = -1,
33
34
  RNSActivityStateInactive = 0,
34
35
  RNSActivityStateTransitioningOrBelowTop = 1,
35
36
  RNSActivityStateOnTop = 2
@@ -70,3 +71,49 @@ typedef NS_ENUM(NSInteger, RNSSearchBarPlacement) {
70
71
  RNSSearchBarPlacementInline,
71
72
  RNSSearchBarPlacementStacked,
72
73
  };
74
+
75
+ // Redefinition of UIBlurEffectStyle. We need to represent additional case of `None`.
76
+ typedef NS_ENUM(NSInteger, RNSBlurEffectStyle) {
77
+ /// No blur effect should be visible
78
+ RNSBlurEffectStyleNone = -1,
79
+ RNSBlurEffectStyleExtraLight = UIBlurEffectStyleExtraLight,
80
+ RNSBlurEffectStyleLight = UIBlurEffectStyleLight,
81
+ RNSBlurEffectStyleDark = UIBlurEffectStyleDark,
82
+ // TODO: Add support for this variant on tvOS
83
+ // RNSBlurEffectStyleExtraDark = UIBlurEffectStyleExtraDark API_AVAILABLE(tvos(10.0)) API_UNAVAILABLE(ios)
84
+ // API_UNAVAILABLE(watchos),
85
+ RNSBlurEffectStyleRegular API_AVAILABLE(ios(10.0)) API_UNAVAILABLE(watchos) = UIBlurEffectStyleRegular,
86
+ RNSBlurEffectStyleProminent API_AVAILABLE(ios(10.0)) API_UNAVAILABLE(watchos) = UIBlurEffectStyleProminent,
87
+ RNSBlurEffectStyleSystemUltraThinMaterial API_AVAILABLE(ios(13.0))
88
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemUltraThinMaterial,
89
+ RNSBlurEffectStyleSystemThinMaterial API_AVAILABLE(ios(13.0))
90
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemThinMaterial,
91
+ RNSBlurEffectStyleSystemMaterial API_AVAILABLE(ios(13.0))
92
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemMaterial,
93
+ RNSBlurEffectStyleSystemThickMaterial API_AVAILABLE(ios(13.0))
94
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemThickMaterial,
95
+ RNSBlurEffectStyleSystemChromeMaterial API_AVAILABLE(ios(13.0))
96
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemChromeMaterial,
97
+ RNSBlurEffectStyleSystemUltraThinMaterialLight API_AVAILABLE(ios(13.0))
98
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemUltraThinMaterialLight,
99
+ RNSBlurEffectStyleSystemThinMaterialLight API_AVAILABLE(ios(13.0))
100
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemThinMaterialLight,
101
+ RNSBlurEffectStyleSystemMaterialLight API_AVAILABLE(ios(13.0))
102
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemMaterialLight,
103
+ RNSBlurEffectStyleSystemThickMaterialLight API_AVAILABLE(ios(13.0))
104
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemThickMaterialLight,
105
+ RNSBlurEffectStyleSystemChromeMaterialLight API_AVAILABLE(ios(13.0))
106
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemChromeMaterialLight,
107
+
108
+ RNSBlurEffectStyleSystemUltraThinMaterialDark API_AVAILABLE(ios(13.0))
109
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemUltraThinMaterialDark,
110
+ RNSBlurEffectStyleSystemThinMaterialDark API_AVAILABLE(ios(13.0))
111
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemThinMaterialDark,
112
+ RNSBlurEffectStyleSystemMaterialDark API_AVAILABLE(ios(13.0))
113
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemMaterialDark,
114
+ RNSBlurEffectStyleSystemThickMaterialDark API_AVAILABLE(ios(13.0))
115
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemThickMaterialDark,
116
+ RNSBlurEffectStyleSystemChromeMaterialDark API_AVAILABLE(ios(13.0))
117
+ API_UNAVAILABLE(watchos, tvos) = UIBlurEffectStyleSystemChromeMaterialDark
118
+
119
+ } API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(watchos);
package/ios/RNSScreen.mm CHANGED
@@ -118,6 +118,7 @@ constexpr NSInteger SHEET_LARGEST_UNDIMMED_DETENT_NONE = -1;
118
118
  _hasStatusBarHiddenSet = NO;
119
119
  _hasOrientationSet = NO;
120
120
  _hasHomeIndicatorHiddenSet = NO;
121
+ _activityState = RNSActivityStateUndefined;
121
122
  #if !TARGET_OS_TV
122
123
  _sheetExpandsWhenScrolledToEdge = YES;
123
124
  #endif // !TARGET_OS_TV
@@ -56,7 +56,7 @@
56
56
  @property (nonatomic) BOOL backButtonInCustomView;
57
57
  @property (nonatomic) UISemanticContentAttribute direction;
58
58
  @property (nonatomic) UINavigationItemBackButtonDisplayMode backButtonDisplayMode;
59
- @property (nonatomic) UIBlurEffectStyle blurEffect;
59
+ @property (nonatomic) RNSBlurEffectStyle blurEffect;
60
60
 
61
61
  + (void)willShowViewController:(UIViewController *)vc
62
62
  animated:(BOOL)animated