react-native-screens 4.12.0 → 4.13.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 (235) hide show
  1. package/RNScreens.podspec +29 -2
  2. package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +4 -0
  3. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +9 -1
  4. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +0 -1
  5. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +4 -4
  6. package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +1 -1
  7. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/DimmingView.kt +4 -4
  8. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/DimmingViewManager.kt +8 -2
  9. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAnimationDelegate.kt +1 -2
  10. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenEventEmitter.kt +16 -13
  11. package/android/src/main/java/com/swmansion/rnscreens/gamma/common/BaseEventEmitter.kt +22 -0
  12. package/android/src/main/java/com/swmansion/rnscreens/gamma/common/FragmentProviding.kt +11 -0
  13. package/android/src/main/java/com/swmansion/rnscreens/gamma/common/NamingAwareEventType.kt +13 -0
  14. package/android/src/main/java/com/swmansion/rnscreens/gamma/helpers/EventHelpers.kt +6 -0
  15. package/android/src/main/java/com/swmansion/rnscreens/gamma/helpers/FragmentManagerHelper.kt +76 -0
  16. package/android/src/main/java/com/swmansion/rnscreens/gamma/helpers/SystemDrawable.kt +33 -0
  17. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreen.kt +101 -0
  18. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenDelegate.kt +17 -0
  19. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenEventEmitter.kt +46 -0
  20. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenFragment.kt +37 -0
  21. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabScreenViewManager.kt +178 -0
  22. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHost.kt +433 -0
  23. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHostEventEmitter.kt +14 -0
  24. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHostViewManager.kt +177 -0
  25. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenDidAppearEvent.kt +30 -0
  26. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenDidDisappearEvent.kt +30 -0
  27. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenWillAppearEvent.kt +30 -0
  28. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabScreenWillDisappearEvent.kt +30 -0
  29. package/android/src/main/java/com/swmansion/rnscreens/gamma/tabs/event/TabsHostNativeFocusChangeEvent.kt +36 -0
  30. package/android/src/main/java/com/swmansion/rnscreens/stack/views/ChildDrawingOrderStrategyImpl.kt +0 -1
  31. package/android/src/main/java/com/swmansion/rnscreens/transition/ExternalBoundaryValuesEvaluator.kt +9 -2
  32. package/android/src/main/java/com/swmansion/rnscreens/utils/FragmentTransactionKt.kt +4 -1
  33. package/android/src/main/jni/rnscreens.h +1 -0
  34. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsManagerDelegate.java +76 -0
  35. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsManagerInterface.java +33 -0
  36. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsScreenManagerDelegate.java +97 -0
  37. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSBottomTabsScreenManagerInterface.java +40 -0
  38. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +2 -2
  39. package/android/src/versioned/backgroundcolor/76/ViewBackgroundUtils.kt +0 -1
  40. package/android/src/versioned/backgroundcolor/latest/ViewBackgroundUtils.kt +0 -3
  41. package/android/src/versioned/pointerevents/77/com/swmansion/rnscreens/PointerEventsBoxNoneImpl.kt +1 -1
  42. package/android/src/versioned/pointerevents/latest/com/swmansion/rnscreens/PointerEventsBoxNoneImpl.kt +1 -1
  43. package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsComponentDescriptor.h +31 -0
  44. package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsShadowNode.cpp +20 -0
  45. package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsShadowNode.h +32 -0
  46. package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsState.cpp +22 -0
  47. package/common/cpp/react/renderer/components/rnscreens/RNSBottomTabsState.h +44 -0
  48. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +8 -0
  49. package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenComponentDescriptor.h +40 -0
  50. package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenShadowNode.cpp +13 -0
  51. package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenShadowNode.h +36 -0
  52. package/common/cpp/react/renderer/components/rnscreens/RNSSplitViewScreenState.h +32 -0
  53. package/cpp/RNScreensTurboModule.h +5 -0
  54. package/ios/RNSEnums.h +6 -0
  55. package/ios/RNSScreen.h +2 -1
  56. package/ios/RNSScreen.mm +48 -1
  57. package/ios/RNSScreenContainer.mm +6 -0
  58. package/ios/RNSScreenStack.h +3 -1
  59. package/ios/RNSScreenStack.mm +39 -2
  60. package/ios/RNSScreenStackHeaderConfig.mm +1 -1
  61. package/ios/RNSScrollViewBehaviorOverriding.h +24 -0
  62. package/ios/RNSScrollViewFinder.h +13 -0
  63. package/ios/RNSScrollViewFinder.mm +22 -0
  64. package/ios/RNSScrollViewHelper.h +10 -0
  65. package/ios/RNSScrollViewHelper.mm +15 -0
  66. package/ios/RNScreens-Bridging-Header.h +4 -0
  67. package/ios/UIScrollView+RNScreens.h +14 -0
  68. package/ios/UIScrollView+RNScreens.mm +15 -0
  69. package/ios/bottom-tabs/RCTConvert+RNSBottomTabs.h +18 -0
  70. package/ios/bottom-tabs/RCTConvert+RNSBottomTabs.mm +25 -0
  71. package/ios/bottom-tabs/RNSBottomTabsHostComponentView.h +80 -0
  72. package/ios/bottom-tabs/RNSBottomTabsHostComponentView.mm +486 -0
  73. package/ios/bottom-tabs/RNSBottomTabsHostComponentViewManager.h +11 -0
  74. package/ios/bottom-tabs/RNSBottomTabsHostComponentViewManager.mm +48 -0
  75. package/ios/bottom-tabs/RNSBottomTabsHostEventEmitter.h +53 -0
  76. package/ios/bottom-tabs/RNSBottomTabsHostEventEmitter.mm +57 -0
  77. package/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h +95 -0
  78. package/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm +492 -0
  79. package/ios/bottom-tabs/RNSBottomTabsScreenComponentViewManager.h +9 -0
  80. package/ios/bottom-tabs/RNSBottomTabsScreenComponentViewManager.mm +55 -0
  81. package/ios/bottom-tabs/RNSBottomTabsScreenEventEmitter.h +53 -0
  82. package/ios/bottom-tabs/RNSBottomTabsScreenEventEmitter.mm +106 -0
  83. package/ios/bottom-tabs/RNSBottomTabsSpecialEffectsSupporting.h +17 -0
  84. package/ios/bottom-tabs/RNSTabBarAppearanceCoordinator.h +34 -0
  85. package/ios/bottom-tabs/RNSTabBarAppearanceCoordinator.mm +243 -0
  86. package/ios/bottom-tabs/RNSTabBarAppearanceProvider.h +23 -0
  87. package/ios/bottom-tabs/RNSTabBarController.h +132 -0
  88. package/ios/bottom-tabs/RNSTabBarController.mm +206 -0
  89. package/ios/bottom-tabs/RNSTabBarControllerDelegate.h +9 -0
  90. package/ios/bottom-tabs/RNSTabBarControllerDelegate.mm +63 -0
  91. package/ios/bottom-tabs/RNSTabsScreenViewController.h +42 -0
  92. package/ios/bottom-tabs/RNSTabsScreenViewController.mm +105 -0
  93. package/ios/bottom-tabs/extensions/RNSBottomTabsHostComponentView+RNSImageLoader.h +21 -0
  94. package/ios/bottom-tabs/extensions/RNSBottomTabsHostComponentView+RNSImageLoader.mm +22 -0
  95. package/ios/bridging/RNSReactBaseView.h +31 -0
  96. package/ios/bridging/RNSReactBaseView.mm +5 -0
  97. package/ios/bridging/Swift-Bridging.h +7 -0
  98. package/ios/conversion/RNSConversions-BottomTabs.mm +216 -0
  99. package/ios/conversion/RNSConversions-SplitView.mm +63 -0
  100. package/ios/conversion/RNSConversions.h +53 -0
  101. package/ios/gamma/ReactMountingTransactionObserving.swift +7 -0
  102. package/ios/gamma/split-view/RNSSplitViewHostComponentView.h +29 -0
  103. package/ios/gamma/split-view/RNSSplitViewHostComponentView.mm +209 -0
  104. package/ios/gamma/split-view/RNSSplitViewHostComponentViewManager.h +11 -0
  105. package/ios/gamma/split-view/RNSSplitViewHostComponentViewManager.mm +7 -0
  106. package/ios/gamma/split-view/RNSSplitViewHostController.swift +98 -0
  107. package/ios/gamma/split-view/RNSSplitViewNavigationController.swift +31 -0
  108. package/ios/gamma/split-view/RNSSplitViewScreenComponentView.h +24 -0
  109. package/ios/gamma/split-view/RNSSplitViewScreenComponentView.mm +106 -0
  110. package/ios/gamma/split-view/RNSSplitViewScreenComponentViewManager.h +11 -0
  111. package/ios/gamma/split-view/RNSSplitViewScreenComponentViewManager.mm +7 -0
  112. package/ios/gamma/split-view/RNSSplitViewScreenController.swift +86 -0
  113. package/ios/gamma/split-view/RNSSplitViewScreenShadowStateProxy.h +35 -0
  114. package/ios/gamma/split-view/RNSSplitViewScreenShadowStateProxy.mm +56 -0
  115. package/ios/gamma/stack/RNSScreenStackHostComponentView.h +16 -0
  116. package/ios/gamma/stack/RNSScreenStackHostComponentView.mm +143 -0
  117. package/ios/gamma/stack/RNSScreenStackHostComponentViewManager.h +11 -0
  118. package/ios/gamma/stack/RNSScreenStackHostComponentViewManager.mm +7 -0
  119. package/ios/gamma/stack/RNSStackController.swift +65 -0
  120. package/ios/gamma/stack/RNSStackScreenComponentEventEmitter.h +37 -0
  121. package/ios/gamma/stack/RNSStackScreenComponentEventEmitter.mm +60 -0
  122. package/ios/gamma/stack/RNSStackScreenComponentView.h +36 -0
  123. package/ios/gamma/stack/RNSStackScreenComponentView.mm +124 -0
  124. package/ios/gamma/stack/RNSStackScreenComponentViewManager.h +11 -0
  125. package/ios/gamma/stack/RNSStackScreenComponentViewManager.mm +7 -0
  126. package/ios/gamma/stack/RNSStackScreenController.swift +56 -0
  127. package/ios/utils/NSString+RNSUtility.h +17 -0
  128. package/ios/utils/NSString+RNSUtility.mm +37 -0
  129. package/lib/commonjs/components/BottomTabs.js +54 -0
  130. package/lib/commonjs/components/BottomTabs.js.map +1 -0
  131. package/lib/commonjs/components/BottomTabsScreen.js +149 -0
  132. package/lib/commonjs/components/BottomTabsScreen.js.map +1 -0
  133. package/lib/commonjs/components/gamma/ScreenStackHost.js +27 -0
  134. package/lib/commonjs/components/gamma/ScreenStackHost.js.map +1 -0
  135. package/lib/commonjs/components/gamma/SplitViewHost.js +57 -0
  136. package/lib/commonjs/components/gamma/SplitViewHost.js.map +1 -0
  137. package/lib/commonjs/components/gamma/SplitViewScreen.js +22 -0
  138. package/lib/commonjs/components/gamma/SplitViewScreen.js.map +1 -0
  139. package/lib/commonjs/components/gamma/StackScreen.js +51 -0
  140. package/lib/commonjs/components/gamma/StackScreen.js.map +1 -0
  141. package/lib/commonjs/fabric/BottomTabsNativeComponent.js +19 -0
  142. package/lib/commonjs/fabric/BottomTabsNativeComponent.js.map +1 -0
  143. package/lib/commonjs/fabric/BottomTabsScreenNativeComponent.js +14 -0
  144. package/lib/commonjs/fabric/BottomTabsScreenNativeComponent.js.map +1 -0
  145. package/lib/commonjs/fabric/gamma/ScreenStackHostNativeComponent.js +11 -0
  146. package/lib/commonjs/fabric/gamma/ScreenStackHostNativeComponent.js.map +1 -0
  147. package/lib/commonjs/fabric/gamma/SplitViewHostNativeComponent.js +11 -0
  148. package/lib/commonjs/fabric/gamma/SplitViewHostNativeComponent.js.map +1 -0
  149. package/lib/commonjs/fabric/gamma/SplitViewScreenNativeComponent.js +13 -0
  150. package/lib/commonjs/fabric/gamma/SplitViewScreenNativeComponent.js.map +1 -0
  151. package/lib/commonjs/fabric/gamma/StackScreenNativeComponent.js +12 -0
  152. package/lib/commonjs/fabric/gamma/StackScreenNativeComponent.js.map +1 -0
  153. package/lib/commonjs/flags.js +70 -0
  154. package/lib/commonjs/flags.js.map +1 -0
  155. package/lib/commonjs/index.js +66 -3
  156. package/lib/commonjs/index.js.map +1 -1
  157. package/lib/commonjs/utils.js +0 -28
  158. package/lib/commonjs/utils.js.map +1 -1
  159. package/lib/module/components/BottomTabs.js +48 -0
  160. package/lib/module/components/BottomTabs.js.map +1 -0
  161. package/lib/module/components/BottomTabsScreen.js +144 -0
  162. package/lib/module/components/BottomTabsScreen.js.map +1 -0
  163. package/lib/module/components/gamma/ScreenStackHost.js +20 -0
  164. package/lib/module/components/gamma/ScreenStackHost.js.map +1 -0
  165. package/lib/module/components/gamma/SplitViewHost.js +50 -0
  166. package/lib/module/components/gamma/SplitViewHost.js.map +1 -0
  167. package/lib/module/components/gamma/SplitViewScreen.js +15 -0
  168. package/lib/module/components/gamma/SplitViewScreen.js.map +1 -0
  169. package/lib/module/components/gamma/StackScreen.js +44 -0
  170. package/lib/module/components/gamma/StackScreen.js.map +1 -0
  171. package/lib/module/fabric/BottomTabsNativeComponent.js +15 -0
  172. package/lib/module/fabric/BottomTabsNativeComponent.js.map +1 -0
  173. package/lib/module/fabric/BottomTabsScreenNativeComponent.js +12 -0
  174. package/lib/module/fabric/BottomTabsScreenNativeComponent.js.map +1 -0
  175. package/lib/module/fabric/gamma/ScreenStackHostNativeComponent.js +5 -0
  176. package/lib/module/fabric/gamma/ScreenStackHostNativeComponent.js.map +1 -0
  177. package/lib/module/fabric/gamma/SplitViewHostNativeComponent.js +5 -0
  178. package/lib/module/fabric/gamma/SplitViewHostNativeComponent.js.map +1 -0
  179. package/lib/module/fabric/gamma/SplitViewScreenNativeComponent.js +7 -0
  180. package/lib/module/fabric/gamma/SplitViewScreenNativeComponent.js.map +1 -0
  181. package/lib/module/fabric/gamma/StackScreenNativeComponent.js +8 -0
  182. package/lib/module/fabric/gamma/StackScreenNativeComponent.js.map +1 -0
  183. package/lib/module/flags.js +64 -0
  184. package/lib/module/flags.js.map +1 -0
  185. package/lib/module/index.js +16 -1
  186. package/lib/module/index.js.map +1 -1
  187. package/lib/module/utils.js +0 -27
  188. package/lib/module/utils.js.map +1 -1
  189. package/lib/typescript/components/BottomTabs.d.ts +30 -0
  190. package/lib/typescript/components/BottomTabs.d.ts.map +1 -0
  191. package/lib/typescript/components/BottomTabsScreen.d.ts +56 -0
  192. package/lib/typescript/components/BottomTabsScreen.d.ts.map +1 -0
  193. package/lib/typescript/components/gamma/ScreenStackHost.d.ts +13 -0
  194. package/lib/typescript/components/gamma/ScreenStackHost.d.ts.map +1 -0
  195. package/lib/typescript/components/gamma/SplitViewHost.d.ts +13 -0
  196. package/lib/typescript/components/gamma/SplitViewHost.d.ts.map +1 -0
  197. package/lib/typescript/components/gamma/SplitViewScreen.d.ts +13 -0
  198. package/lib/typescript/components/gamma/SplitViewScreen.d.ts.map +1 -0
  199. package/lib/typescript/components/gamma/StackScreen.d.ts +21 -0
  200. package/lib/typescript/components/gamma/StackScreen.d.ts.map +1 -0
  201. package/lib/typescript/fabric/BottomTabsNativeComponent.d.ts +31 -0
  202. package/lib/typescript/fabric/BottomTabsNativeComponent.d.ts.map +1 -0
  203. package/lib/typescript/fabric/BottomTabsScreenNativeComponent.d.ts +51 -0
  204. package/lib/typescript/fabric/BottomTabsScreenNativeComponent.d.ts.map +1 -0
  205. package/lib/typescript/fabric/gamma/ScreenStackHostNativeComponent.d.ts +7 -0
  206. package/lib/typescript/fabric/gamma/ScreenStackHostNativeComponent.d.ts.map +1 -0
  207. package/lib/typescript/fabric/gamma/SplitViewHostNativeComponent.d.ts +16 -0
  208. package/lib/typescript/fabric/gamma/SplitViewHostNativeComponent.d.ts.map +1 -0
  209. package/lib/typescript/fabric/gamma/SplitViewScreenNativeComponent.d.ts +7 -0
  210. package/lib/typescript/fabric/gamma/SplitViewScreenNativeComponent.d.ts.map +1 -0
  211. package/lib/typescript/fabric/gamma/StackScreenNativeComponent.d.ts +15 -0
  212. package/lib/typescript/fabric/gamma/StackScreenNativeComponent.d.ts.map +1 -0
  213. package/lib/typescript/flags.d.ts +45 -0
  214. package/lib/typescript/flags.d.ts.map +1 -0
  215. package/lib/typescript/index.d.ts +14 -1
  216. package/lib/typescript/index.d.ts.map +1 -1
  217. package/lib/typescript/utils.d.ts +0 -26
  218. package/lib/typescript/utils.d.ts.map +1 -1
  219. package/package.json +34 -6
  220. package/react-native.config.js +2 -1
  221. package/src/components/BottomTabs.tsx +115 -0
  222. package/src/components/BottomTabsScreen.tsx +291 -0
  223. package/src/components/gamma/ScreenStackHost.tsx +32 -0
  224. package/src/components/gamma/SplitViewHost.tsx +84 -0
  225. package/src/components/gamma/SplitViewScreen.tsx +26 -0
  226. package/src/components/gamma/StackScreen.tsx +64 -0
  227. package/src/fabric/BottomTabsNativeComponent.ts +82 -0
  228. package/src/fabric/BottomTabsScreenNativeComponent.ts +107 -0
  229. package/src/fabric/gamma/ScreenStackHostNativeComponent.ts +8 -0
  230. package/src/fabric/gamma/SplitViewHostNativeComponent.ts +39 -0
  231. package/src/fabric/gamma/SplitViewScreenNativeComponent.ts +10 -0
  232. package/src/fabric/gamma/StackScreenNativeComponent.ts +25 -0
  233. package/src/flags.ts +72 -0
  234. package/src/index.tsx +18 -1
  235. package/src/utils.ts +0 -28
package/RNScreens.podspec CHANGED
@@ -2,11 +2,19 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
+ gamma_project_enabled = ENV['RNS_GAMMA_ENABLED'] == '1'
5
6
  new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
7
+
8
+ source_files_exts = new_arch_enabled ? '{h,m,mm,cpp,swift}' : '{h,m,mm,swift}'
9
+ source_files = ["ios/**/*.#{source_files_exts}"]
10
+
11
+ if !new_arch_enabled
12
+ source_files.push("cpp/RNScreensTurboModule.cpp", "cpp/RNScreensTurboModule.h")
13
+ end
14
+
6
15
  min_supported_ios_version = new_arch_enabled ? "15.1" : "15.1"
7
16
  min_supported_tvos_version = "15.1"
8
17
  min_supported_visionos_version = "1.0"
9
- source_files = new_arch_enabled ? 'ios/**/*.{h,m,mm,cpp}' : ["ios/**/*.{h,m,mm}", "cpp/RNScreensTurboModule.cpp", "cpp/RNScreensTurboModule.h"]
10
18
 
11
19
  Pod::Spec.new do |s|
12
20
  s.name = "RNScreens"
@@ -21,13 +29,32 @@ Pod::Spec.new do |s|
21
29
  s.platforms = { :ios => min_supported_ios_version, :tvos => min_supported_tvos_version, :visionos => min_supported_visionos_version }
22
30
  s.source = { :git => "https://github.com/software-mansion/react-native-screens.git", :tag => "#{s.version}" }
23
31
  s.source_files = source_files
24
- s.project_header_files = "cpp/**/*.h" # Don't expose C++ headers publicly to allow importing framework into Swift files
32
+ s.project_header_files = "ios/bridging/Swift-Bridging.h"
25
33
  s.requires_arc = true
26
34
 
35
+ if !gamma_project_enabled
36
+ s.exclude_files = "ios/gamma/**/*.#{source_files_exts}"
37
+ else
38
+ Pod::UI.puts "[RNScreens] Gamma project enabled. Including source files."
39
+ end
40
+
41
+ if gamma_project_enabled
42
+ # This setting is required to make Swift code build. However we have
43
+ # dependency on `React-RCTImage` pod, which does not set `DEFINES_MODULE`
44
+ # and therefore it fails to build. Currently we do patch react-native source
45
+ # code to make it work & the fix is already merged, however it'll be most likely released
46
+ # with 0.81. We can not expect users to patch the react-native sources, thus
47
+ # we can not have Swift code in stable package.
48
+ s.pod_target_xcconfig = {
49
+ 'DEFINES_MODULE' => 'YES'
50
+ }
51
+ end
52
+
27
53
  install_modules_dependencies(s)
28
54
  if new_arch_enabled
29
55
  s.subspec "common" do |ss|
30
56
  ss.source_files = ["common/cpp/**/*.{cpp,h}", "cpp/**/*.{cpp,h}"]
57
+ ss.project_header_files = "common/cpp/**/*.h", "cpp/**/*.h" # Don't expose C++ headers publicly to allow importing framework into Swift files
31
58
  ss.header_dir = "rnscreens"
32
59
  ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
33
60
  end
@@ -7,6 +7,8 @@ import com.facebook.react.module.annotations.ReactModuleList
7
7
  import com.facebook.react.module.model.ReactModuleInfo
8
8
  import com.facebook.react.module.model.ReactModuleInfoProvider
9
9
  import com.facebook.react.uimanager.ViewManager
10
+ import com.swmansion.rnscreens.gamma.tabs.TabScreenViewManager
11
+ import com.swmansion.rnscreens.gamma.tabs.TabsHostViewManager
10
12
  import com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper
11
13
 
12
14
  // Fool autolinking for older versions that do not support BaseReactPackage.
@@ -45,6 +47,8 @@ class RNScreensPackage : BaseReactPackage() {
45
47
  SearchBarManager(),
46
48
  ScreenFooterManager(),
47
49
  ScreenContentWrapperManager(),
50
+ TabsHostViewManager(),
51
+ TabScreenViewManager(),
48
52
  )
49
53
  }
50
54
 
@@ -18,6 +18,7 @@ import com.facebook.react.uimanager.ThemedReactContext
18
18
  import com.facebook.react.uimanager.UIManagerHelper
19
19
  import com.swmansion.rnscreens.Screen.ActivityState
20
20
  import com.swmansion.rnscreens.events.ScreenDismissedEvent
21
+ import com.swmansion.rnscreens.gamma.common.FragmentProviding
21
22
 
22
23
  open class ScreenContainer(
23
24
  context: Context?,
@@ -175,7 +176,7 @@ open class ScreenContainer(
175
176
  private fun setupFragmentManager() {
176
177
  var parent: ViewParent = this
177
178
  // We traverse view hierarchy up until we find screen parent or a root view
178
- while (!(parent is ReactRootView || parent is Screen) &&
179
+ while (!(parent is ReactRootView || parent is Screen || parent is FragmentProviding) &&
179
180
  parent.parent != null
180
181
  ) {
181
182
  parent = parent.parent
@@ -190,6 +191,13 @@ open class ScreenContainer(
190
191
  setFragmentManager(fragmentWrapper.fragment.childFragmentManager)
191
192
  },
192
193
  ) { "Parent Screen does not have its Fragment attached" }
194
+ } else if (parent is FragmentProviding) {
195
+ // TODO: We're missing parent-child relationship here between old container & new one
196
+ val fragmentManager =
197
+ checkNotNull(
198
+ parent.getFragment(),
199
+ ) { "[RNScreens] Parent $parent returned nullish fragment" }.childFragmentManager
200
+ setFragmentManager(fragmentManager)
193
201
  } else {
194
202
  // we expect top level view to be of type ReactRootView, this isn't really necessary but in
195
203
  // order to find root view we test if parent is null. This could potentially happen also when
@@ -34,7 +34,6 @@ interface ScreenFragmentWrapper :
34
34
  */
35
35
  fun isTranslucent(): Boolean
36
36
 
37
-
38
37
  // Helpers
39
38
  fun tryGetActivity(): Activity?
40
39
 
@@ -24,10 +24,10 @@ import kotlin.math.max
24
24
 
25
25
  class ScreenStackHeaderConfig(
26
26
  context: Context,
27
- private val pointerEventsImpl: ReactPointerEventsView
28
- ) : FabricEnabledHeaderConfigViewGroup(context), ReactPointerEventsView by pointerEventsImpl {
29
-
30
- constructor(context: Context): this(context, pointerEventsImpl = PointerEventsBoxNoneImpl())
27
+ private val pointerEventsImpl: ReactPointerEventsView,
28
+ ) : FabricEnabledHeaderConfigViewGroup(context),
29
+ ReactPointerEventsView by pointerEventsImpl {
30
+ constructor(context: Context) : this(context, pointerEventsImpl = PointerEventsBoxNoneImpl())
31
31
 
32
32
  private val configSubviews = ArrayList<ScreenStackHeaderSubview>(3)
33
33
  val toolbar: CustomToolbar
@@ -39,7 +39,7 @@ class ScreensModule(
39
39
 
40
40
  override fun invalidate() {
41
41
  super.invalidate()
42
- proxy?.invalidateNative();
42
+ proxy?.invalidateNative()
43
43
  nativeUninstall()
44
44
  }
45
45
 
@@ -19,14 +19,14 @@ import com.swmansion.rnscreens.ext.equalWithRespectToEps
19
19
  internal class DimmingView(
20
20
  context: Context,
21
21
  initialAlpha: Float = 0.6F,
22
- private val pointerEventsProxy: DimmingViewPointerEventsProxy
22
+ private val pointerEventsProxy: DimmingViewPointerEventsProxy,
23
23
  ) : ViewGroup(context),
24
24
  ReactCompoundViewGroup,
25
25
  ReactPointerEventsView by pointerEventsProxy {
26
-
27
26
  constructor(context: Context, initialAlpha: Float = 0.6F) : this(
28
- context, initialAlpha,
29
- DimmingViewPointerEventsProxy(null)
27
+ context,
28
+ initialAlpha,
29
+ DimmingViewPointerEventsProxy(null),
30
30
  )
31
31
 
32
32
  init {
@@ -48,7 +48,10 @@ class DimmingViewManager(
48
48
  /**
49
49
  * Ask the manager whether it will apply non-zero alpha for sheet at given detent index.
50
50
  */
51
- fun willDimForDetentIndex(screen: Screen, index: Int) = index > screen.sheetLargestUndimmedDetentIndex
51
+ fun willDimForDetentIndex(
52
+ screen: Screen,
53
+ index: Int,
54
+ ) = index > screen.sheetLargestUndimmedDetentIndex
52
55
 
53
56
  fun invalidate(behavior: BottomSheetBehavior<Screen>?) {
54
57
  dimmingViewCallback?.let { callback -> behavior?.removeBottomSheetCallback(callback) }
@@ -165,7 +168,10 @@ class DimmingViewManager(
165
168
  }
166
169
  }
167
170
 
168
- private fun requireBottomSheetCallback(screen: Screen, forceCreation: Boolean = false): BottomSheetCallback {
171
+ private fun requireBottomSheetCallback(
172
+ screen: Screen,
173
+ forceCreation: Boolean = false,
174
+ ): BottomSheetCallback {
169
175
  if (dimmingViewCallback == null || forceCreation) {
170
176
  dimmingViewCallback = AnimateDimmingViewCallback(screen, dimmingView, maxAlpha)
171
177
  }
@@ -1,7 +1,6 @@
1
1
  package com.swmansion.rnscreens.events
2
2
 
3
3
  import android.animation.Animator
4
- import android.util.Log
5
4
  import com.swmansion.rnscreens.ScreenStackFragmentWrapper
6
5
 
7
6
  // The goal is to make this universal delegate for handling animation progress related logic.
@@ -13,7 +12,7 @@ class ScreenAnimationDelegate(
13
12
  ) : Animator.AnimatorListener {
14
13
  enum class AnimationType {
15
14
  ENTER,
16
- EXIT
15
+ EXIT,
17
16
  }
18
17
 
19
18
  private var currentState: LifecycleState = LifecycleState.INITIALIZED
@@ -6,31 +6,34 @@ import com.swmansion.rnscreens.ScreenFragment
6
6
 
7
7
  // TODO: Consider taking weak ref here or accepting screen as argument in every method
8
8
  // to avoid reference cycle.
9
- class ScreenEventEmitter(val screen: Screen) {
9
+ class ScreenEventEmitter(
10
+ val screen: Screen,
11
+ ) {
10
12
  val reactEventDispatcher
11
13
  get() = screen.reactEventDispatcher
12
14
 
13
15
  val reactSurfaceId
14
16
  get() = UIManagerHelper.getSurfaceId(screen)
15
17
 
16
- fun dispatchOnWillAppear() =
17
- reactEventDispatcher?.dispatchEvent(ScreenWillAppearEvent(reactSurfaceId, screen.id))
18
+ fun dispatchOnWillAppear() = reactEventDispatcher?.dispatchEvent(ScreenWillAppearEvent(reactSurfaceId, screen.id))
18
19
 
19
- fun dispatchOnAppear() =
20
- reactEventDispatcher?.dispatchEvent(ScreenAppearEvent(reactSurfaceId, screen.id))
20
+ fun dispatchOnAppear() = reactEventDispatcher?.dispatchEvent(ScreenAppearEvent(reactSurfaceId, screen.id))
21
21
 
22
- fun dispatchOnWillDisappear() =
23
- reactEventDispatcher?.dispatchEvent(ScreenWillDisappearEvent(reactSurfaceId, screen.id))
22
+ fun dispatchOnWillDisappear() = reactEventDispatcher?.dispatchEvent(ScreenWillDisappearEvent(reactSurfaceId, screen.id))
24
23
 
25
- fun dispatchOnDisappear() =
26
- reactEventDispatcher?.dispatchEvent(ScreenDisappearEvent(reactSurfaceId, screen.id))
24
+ fun dispatchOnDisappear() = reactEventDispatcher?.dispatchEvent(ScreenDisappearEvent(reactSurfaceId, screen.id))
27
25
 
28
- fun dispatchOnDismissed() =
29
- reactEventDispatcher?.dispatchEvent(ScreenDismissedEvent(reactSurfaceId, screen.id))
26
+ fun dispatchOnDismissed() = reactEventDispatcher?.dispatchEvent(ScreenDismissedEvent(reactSurfaceId, screen.id))
30
27
 
31
- fun dispatchTransitionProgress(progress: Float, isExitAnimation: Boolean, isGoingForward: Boolean) {
28
+ fun dispatchTransitionProgress(
29
+ progress: Float,
30
+ isExitAnimation: Boolean,
31
+ isGoingForward: Boolean,
32
+ ) {
32
33
  val sanitizedProgress = progress.coerceIn(0.0f, 1.0f)
33
34
  val coalescingKey = ScreenFragment.getCoalescingKey(sanitizedProgress)
34
- reactEventDispatcher?.dispatchEvent(ScreenTransitionProgressEvent(reactSurfaceId, screen.id, sanitizedProgress, isExitAnimation, isGoingForward, coalescingKey))
35
+ reactEventDispatcher?.dispatchEvent(
36
+ ScreenTransitionProgressEvent(reactSurfaceId, screen.id, sanitizedProgress, isExitAnimation, isGoingForward, coalescingKey),
37
+ )
35
38
  }
36
39
  }
@@ -0,0 +1,22 @@
1
+ package com.swmansion.rnscreens.gamma.common
2
+
3
+ import com.facebook.react.bridge.ReactContext
4
+ import com.facebook.react.uimanager.UIManagerHelper
5
+ import com.facebook.react.uimanager.events.EventDispatcher
6
+
7
+ internal abstract class BaseEventEmitter(
8
+ val reactContext: ReactContext,
9
+ val viewTag: Int,
10
+ ) {
11
+ protected val reactEventDispatcher: EventDispatcher =
12
+ checkNotNull(UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewTag)) {
13
+ "[RNScreens] Nullish event dispatcher for view with tag: $viewTag"
14
+ }
15
+
16
+ protected val surfaceId: Int
17
+ get() = UIManagerHelper.getSurfaceId(reactContext)
18
+
19
+ companion object {
20
+ const val TAG = "BaseEventEmitter"
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ package com.swmansion.rnscreens.gamma.common
2
+
3
+ import androidx.fragment.app.Fragment
4
+
5
+ /**
6
+ * Implementors of this interface indicate that they do have a fragment associated with them, that
7
+ * can be used to retrieve child fragment manager for nesting operations.
8
+ */
9
+ interface FragmentProviding {
10
+ fun getFragment(): Fragment?
11
+ }
@@ -0,0 +1,13 @@
1
+ package com.swmansion.rnscreens.gamma.common
2
+
3
+ internal interface NamingAwareEventType {
4
+ /**
5
+ * React event name with `top` prefix
6
+ */
7
+ fun getEventName(): String
8
+
9
+ /**
10
+ * Name of the event as expected in Element Tree.
11
+ */
12
+ fun getEventRegistrationName(): String
13
+ }
@@ -0,0 +1,6 @@
1
+ package com.swmansion.rnscreens.gamma.helpers
2
+
3
+ import com.swmansion.rnscreens.gamma.common.NamingAwareEventType
4
+
5
+ internal fun makeEventRegistrationInfo(event: NamingAwareEventType): Pair<String, HashMap<String, String>> =
6
+ event.getEventName() to hashMapOf("registrationName" to event.getEventRegistrationName())
@@ -0,0 +1,76 @@
1
+ package com.swmansion.rnscreens.gamma.helpers
2
+
3
+ import android.content.ContextWrapper
4
+ import android.view.ViewGroup
5
+ import android.view.ViewParent
6
+ import androidx.fragment.app.Fragment
7
+ import androidx.fragment.app.FragmentActivity
8
+ import androidx.fragment.app.FragmentManager
9
+ import com.facebook.react.ReactRootView
10
+ import com.swmansion.rnscreens.gamma.common.FragmentProviding
11
+
12
+ object FragmentManagerHelper {
13
+ fun findFragmentManagerForView(view: ViewGroup): FragmentManager? {
14
+ var parent: ViewParent = view
15
+
16
+ // We traverse view hierarchy up until we find fragment providing parent or a root view
17
+ while (!(parent is ReactRootView || parent is FragmentProviding) &&
18
+ parent.parent != null
19
+ ) {
20
+ parent = parent.parent
21
+ }
22
+
23
+ // If parent adheres to FragmentProviding interface it means we are inside a nested fragment structure.
24
+ // Otherwise we expect to connect directly with root view and get root fragment manager
25
+ if (parent is FragmentProviding) {
26
+ return checkNotNull(parent.getFragment()) {
27
+ "[RNScreens] Parent fragment providing view $parent returned nullish fragment"
28
+ }.childFragmentManager
29
+ } else {
30
+ // we expect top level view to be of type ReactRootView, this isn't really necessary but in
31
+ // order to find root view we test if parent is null. This could potentially happen also when
32
+ // the view is detached from the hierarchy and that test would not correctly indicate the root
33
+ // view. So in order to make sure we indeed reached the root we test if it is of a correct type.
34
+ // This allows us to provide a more descriptive error message for the aforementioned case.
35
+ check(
36
+ parent is ReactRootView,
37
+ ) { "[RNScreens] Expected parent to be a ReactRootView, instead found: ${parent::class.java.name}" }
38
+ return resolveFragmentManagerForReactRootView(parent)
39
+ }
40
+ }
41
+
42
+ private fun resolveFragmentManagerForReactRootView(rootView: ReactRootView): FragmentManager? {
43
+ var context = rootView.context
44
+
45
+ // ReactRootView is expected to be initialized with the main React Activity as a context but
46
+ // in case of Expo the activity is wrapped in ContextWrapper and we need to unwrap it
47
+ while (context !is FragmentActivity && context is ContextWrapper) {
48
+ context = context.baseContext
49
+ }
50
+
51
+ check(context is FragmentActivity) {
52
+ "[RNScreens] In order to use react-native-screens components your app's activity need to extend ReactActivity"
53
+ }
54
+
55
+ // In case React Native is loaded on a Fragment (not directly in activity) we need to find
56
+ // fragment manager whose fragment's view is ReactRootView. As of now, we detect such case by
57
+ // checking whether any fragments are attached to activity which hosts ReactRootView.
58
+ // See: https://github.com/software-mansion/react-native-screens/issues/1506 on why the cases
59
+ // must be treated separately.
60
+ return if (context.supportFragmentManager.fragments.isEmpty()) {
61
+ // We are in standard React Native application w/o custom native navigation based on fragments.
62
+ context.supportFragmentManager
63
+ } else {
64
+ // We are in some custom setup & we want to use the closest fragment manager in hierarchy.
65
+ // `findFragment` method throws IllegalStateException when it fails to resolve appropriate
66
+ // fragment. It might happen when e.g. React Native is loaded directly in Activity
67
+ // but some custom fragments are still used. Such use case seems highly unlikely
68
+ // so, as for now we fallback to activity's FragmentManager in hope for the best.
69
+ try {
70
+ FragmentManager.findFragment<Fragment>(rootView).childFragmentManager
71
+ } catch (ex: IllegalStateException) {
72
+ context.supportFragmentManager
73
+ }
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,33 @@
1
+ package com.swmansion.rnscreens.gamma.helpers
2
+
3
+ import android.content.Context
4
+ import android.graphics.drawable.Drawable
5
+ import android.util.Log
6
+ import androidx.appcompat.content.res.AppCompatResources
7
+ import com.swmansion.rnscreens.gamma.tabs.TabScreen.Companion.TAG
8
+
9
+ internal fun getSystemDrawableResource(
10
+ context: Context,
11
+ iconName: String?,
12
+ ): Drawable? {
13
+ if (iconName == null) {
14
+ return null
15
+ }
16
+
17
+ // Try to get resource app scope
18
+ val appDrawableId = context.resources.getIdentifier(iconName, "drawable", context.packageName)
19
+
20
+ if (appDrawableId > 0) {
21
+ return AppCompatResources.getDrawable(context, appDrawableId)
22
+ }
23
+
24
+ // Try to get resource from system scope
25
+ val systemDrawableId = context.resources.getIdentifier(iconName, "drawable", "android")
26
+
27
+ if (systemDrawableId > 0) {
28
+ return AppCompatResources.getDrawable(context, systemDrawableId)
29
+ }
30
+
31
+ Log.w(TAG, "TabScreen could not resolve drawable resource with the name $iconName")
32
+ return null
33
+ }
@@ -0,0 +1,101 @@
1
+ package com.swmansion.rnscreens.gamma.tabs
2
+
3
+ import android.graphics.drawable.Drawable
4
+ import android.util.Log
5
+ import android.view.ViewGroup
6
+ import androidx.fragment.app.Fragment
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import com.swmansion.rnscreens.gamma.common.FragmentProviding
9
+ import com.swmansion.rnscreens.gamma.helpers.getSystemDrawableResource
10
+ import java.lang.ref.WeakReference
11
+ import kotlin.properties.Delegates
12
+
13
+ /**
14
+ * React Component view.
15
+ */
16
+ class TabScreen(
17
+ val reactContext: ThemedReactContext,
18
+ ) : ViewGroup(reactContext),
19
+ FragmentProviding {
20
+ override fun onLayout(
21
+ changed: Boolean,
22
+ l: Int,
23
+ t: Int,
24
+ r: Int,
25
+ b: Int,
26
+ ) = Unit
27
+
28
+ private var tabScreenDelegate: WeakReference<TabScreenDelegate> = WeakReference(null)
29
+
30
+ internal lateinit var eventEmitter: TabScreenEventEmitter
31
+
32
+ var tabKey: String? = null
33
+ set(value) {
34
+ field =
35
+ if (value?.isBlank() == true) {
36
+ null
37
+ } else {
38
+ value
39
+ }
40
+ }
41
+
42
+ var tabTitle: String? by Delegates.observable(null) { _, oldValue, newValue ->
43
+ updateMenuItemAttributesIfNeeded(oldValue, newValue)
44
+ }
45
+
46
+ var iconResourceName: String? by Delegates.observable(null) { _, oldValue, newValue ->
47
+ if (newValue != oldValue) {
48
+ icon = getSystemDrawableResource(reactContext, newValue)
49
+ }
50
+ }
51
+
52
+ var icon: Drawable? by Delegates.observable(null) { _, oldValue, newValue ->
53
+ updateMenuItemAttributesIfNeeded(oldValue, newValue)
54
+ }
55
+
56
+ private fun <T> updateMenuItemAttributesIfNeeded(
57
+ oldValue: T,
58
+ newValue: T,
59
+ ) {
60
+ if (newValue != oldValue) {
61
+ onMenuItemAttributesChange()
62
+ }
63
+ }
64
+
65
+ override fun onAttachedToWindow() {
66
+ Log.d(TAG, "TabScreen [$id] attached to window")
67
+ super.onAttachedToWindow()
68
+ }
69
+
70
+ var isFocusedTab: Boolean = false
71
+ set(value) {
72
+ if (field != value) {
73
+ field = value
74
+ onTabFocusChangedFromJS()
75
+ }
76
+ }
77
+
78
+ internal fun setTabScreenDelegate(delegate: TabScreenDelegate?) {
79
+ tabScreenDelegate = WeakReference(delegate)
80
+ }
81
+
82
+ override fun getFragment(): Fragment? = tabScreenDelegate.get()?.getFragmentForTabScreen(this)
83
+
84
+ private fun onTabFocusChangedFromJS() {
85
+ tabScreenDelegate.get()?.onTabFocusChangedFromJS(this, isFocusedTab)
86
+ }
87
+
88
+ private fun onMenuItemAttributesChange() {
89
+ tabScreenDelegate.get()?.onMenuItemAttributesChange(this)
90
+ }
91
+
92
+ internal fun onViewManagerAddEventEmitters() {
93
+ // When this is called from View Manager the view tag is already set
94
+ check(id != NO_ID) { "[RNScreens] TabScreen must have its tag set when registering event emitters" }
95
+ eventEmitter = TabScreenEventEmitter(reactContext, id)
96
+ }
97
+
98
+ companion object {
99
+ const val TAG = "TabScreen"
100
+ }
101
+ }
@@ -0,0 +1,17 @@
1
+ package com.swmansion.rnscreens.gamma.tabs
2
+
3
+ import androidx.fragment.app.Fragment
4
+
5
+ internal interface TabScreenDelegate {
6
+ fun onTabFocusChangedFromJS(
7
+ tabScreen: TabScreen,
8
+ isFocused: Boolean,
9
+ )
10
+
11
+ fun onMenuItemAttributesChange(tabScreen: TabScreen)
12
+
13
+ /**
14
+ * This returns fragment **if one is associated with given tab screen**.
15
+ */
16
+ fun getFragmentForTabScreen(tabScreen: TabScreen): Fragment?
17
+ }
@@ -0,0 +1,46 @@
1
+ package com.swmansion.rnscreens.gamma.tabs
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.ReactContext
5
+ import com.swmansion.rnscreens.gamma.common.BaseEventEmitter
6
+ import com.swmansion.rnscreens.gamma.tabs.TabScreenEventEmitter.Companion.TAG
7
+ import com.swmansion.rnscreens.gamma.tabs.event.TabScreenDidAppearEvent
8
+ import com.swmansion.rnscreens.gamma.tabs.event.TabScreenDidDisappearEvent
9
+ import com.swmansion.rnscreens.gamma.tabs.event.TabScreenWillAppearEvent
10
+ import com.swmansion.rnscreens.gamma.tabs.event.TabScreenWillDisappearEvent
11
+
12
+ internal class TabScreenEventEmitter(
13
+ reactContext: ReactContext,
14
+ viewTag: Int,
15
+ ) : BaseEventEmitter(reactContext, viewTag) {
16
+ fun emitOnWillAppear() {
17
+ logEventDispatch(viewTag, TabScreenWillAppearEvent.EVENT_REGISTRATION_NAME)
18
+ reactEventDispatcher.dispatchEvent(TabScreenWillAppearEvent(surfaceId, viewTag))
19
+ }
20
+
21
+ fun emitOnDidAppear() {
22
+ logEventDispatch(viewTag, TabScreenDidAppearEvent.EVENT_REGISTRATION_NAME)
23
+ reactEventDispatcher.dispatchEvent(TabScreenDidAppearEvent(surfaceId, viewTag))
24
+ }
25
+
26
+ fun emitOnWillDisappear() {
27
+ logEventDispatch(viewTag, TabScreenWillDisappearEvent.EVENT_REGISTRATION_NAME)
28
+ reactEventDispatcher.dispatchEvent(TabScreenWillDisappearEvent(surfaceId, viewTag))
29
+ }
30
+
31
+ fun emitOnDidDisappear() {
32
+ logEventDispatch(viewTag, TabScreenDidDisappearEvent.EVENT_REGISTRATION_NAME)
33
+ reactEventDispatcher.dispatchEvent(TabScreenDidDisappearEvent(surfaceId, viewTag))
34
+ }
35
+
36
+ companion object {
37
+ const val TAG = "TabScreenEventEmitter"
38
+ }
39
+ }
40
+
41
+ private fun logEventDispatch(
42
+ viewTag: Int,
43
+ eventName: String,
44
+ ) {
45
+ Log.d(TAG, "TabScreen [$viewTag] emits event: $eventName")
46
+ }
@@ -0,0 +1,37 @@
1
+ package com.swmansion.rnscreens.gamma.tabs
2
+
3
+ import android.os.Bundle
4
+ import android.view.LayoutInflater
5
+ import android.view.View
6
+ import android.view.ViewGroup
7
+ import androidx.fragment.app.Fragment
8
+
9
+ class TabScreenFragment(
10
+ internal val tabScreen: TabScreen,
11
+ ) : Fragment() {
12
+ override fun onCreateView(
13
+ inflater: LayoutInflater,
14
+ container: ViewGroup?,
15
+ savedInstanceState: Bundle?,
16
+ ): View = tabScreen
17
+
18
+ override fun onStart() {
19
+ tabScreen.eventEmitter.emitOnWillAppear()
20
+ super.onStart()
21
+ }
22
+
23
+ override fun onResume() {
24
+ tabScreen.eventEmitter.emitOnDidAppear()
25
+ super.onResume()
26
+ }
27
+
28
+ override fun onPause() {
29
+ tabScreen.eventEmitter.emitOnWillDisappear()
30
+ super.onPause()
31
+ }
32
+
33
+ override fun onStop() {
34
+ tabScreen.eventEmitter.emitOnDidDisappear()
35
+ super.onStop()
36
+ }
37
+ }