@lodev09/react-native-true-sheet 3.0.0-beta.3 → 3.0.0-beta.5

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 (36) hide show
  1. package/RNTrueSheet.podspec +5 -1
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +50 -0
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +7 -0
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +0 -9
  5. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +8 -4
  6. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +11 -2
  7. package/android/src/main/jni/CMakeLists.txt +87 -0
  8. package/android/src/main/jni/TrueSheetSpec.h +17 -0
  9. package/ios/TrueSheetContainerView.mm +61 -5
  10. package/ios/TrueSheetContentView.mm +0 -11
  11. package/ios/TrueSheetView.h +0 -16
  12. package/ios/TrueSheetView.mm +13 -10
  13. package/ios/TrueSheetViewController.h +2 -1
  14. package/ios/TrueSheetViewController.mm +32 -41
  15. package/ios/utils/ConversionUtil.h +24 -0
  16. package/ios/utils/ConversionUtil.mm +50 -0
  17. package/lib/module/TrueSheet.js +3 -23
  18. package/lib/module/TrueSheet.js.map +1 -1
  19. package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +3 -1
  20. package/lib/module/fabric/TrueSheetViewNativeComponent.ts +1 -6
  21. package/lib/typescript/src/TrueSheet.d.ts +0 -3
  22. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  23. package/lib/typescript/src/TrueSheet.types.d.ts +10 -14
  24. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
  25. package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -1
  26. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +1 -5
  27. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/react-native.config.js +5 -2
  30. package/src/TrueSheet.tsx +3 -27
  31. package/src/TrueSheet.types.ts +26 -31
  32. package/src/fabric/TrueSheetContainerViewNativeComponent.ts +3 -1
  33. package/src/fabric/TrueSheetViewNativeComponent.ts +1 -6
  34. package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +0 -27
  35. package/ios/events/OnSizeChangeEvent.h +0 -28
  36. package/ios/events/OnSizeChangeEvent.mm +0 -30
@@ -13,8 +13,12 @@ Pod::Spec.new do |s|
13
13
  s.platforms = { :ios => min_ios_version_supported }
14
14
  s.source = { :git => "https://github.com/lodev09/react-native-true-sheet.git", :tag => "#{s.version}" }
15
15
 
16
- s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
16
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}", "common/cpp/**/*.{cpp,h}"
17
17
  s.private_header_files = "ios/**/*.h"
18
18
 
19
+ s.pod_target_xcconfig = {
20
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\""
21
+ }
22
+
19
23
  install_modules_dependencies(s)
20
24
  end
@@ -3,6 +3,9 @@ package com.lodev09.truesheet
3
3
  import android.annotation.SuppressLint
4
4
  import android.view.View
5
5
  import androidx.core.view.isNotEmpty
6
+ import com.facebook.react.bridge.WritableNativeMap
7
+ import com.facebook.react.uimanager.PixelUtil.pxToDp
8
+ import com.facebook.react.uimanager.StateWrapper
6
9
  import com.facebook.react.uimanager.ThemedReactContext
7
10
  import com.facebook.react.views.view.ReactViewGroup
8
11
 
@@ -26,6 +29,53 @@ class TrueSheetContainerView(private val reactContext: ThemedReactContext) :
26
29
 
27
30
  var delegate: TrueSheetContainerViewDelegate? = null
28
31
 
32
+ private var stateWrapper: StateWrapper? = null
33
+
34
+ // Pending dimensions to update when stateWrapper becomes available
35
+ private var pendingWidth: Int = 0
36
+ private var pendingHeight: Int = 0
37
+
38
+ fun setStateWrapper(wrapper: StateWrapper?) {
39
+ stateWrapper = wrapper
40
+
41
+ if (wrapper == null) return
42
+
43
+ // Get dimensions from parent controller and update state if we haven't yet
44
+ val controller = parent as? TrueSheetViewController
45
+ if (controller != null && pendingWidth == 0) {
46
+ val w = controller.width
47
+ val h = controller.height
48
+ if (w > 0 && h > 0) {
49
+ updateState(w, h)
50
+ }
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Update state with container dimensions.
56
+ * Called by the controller when the dialog size changes.
57
+ */
58
+ fun updateState(width: Int, height: Int) {
59
+ // Skip if dimensions haven't changed
60
+ if (width == pendingWidth && height == pendingHeight && stateWrapper != null) {
61
+ return
62
+ }
63
+
64
+ // Store dimensions
65
+ pendingWidth = width
66
+ pendingHeight = height
67
+
68
+ val sw = stateWrapper ?: return
69
+
70
+ val realWidth = width.toFloat().pxToDp()
71
+ val realHeight = height.toFloat().pxToDp()
72
+
73
+ val newStateData = WritableNativeMap()
74
+ newStateData.putDouble("containerWidth", realWidth.toDouble())
75
+ newStateData.putDouble("containerHeight", realHeight.toDouble())
76
+ sw.updateState(newStateData)
77
+ }
78
+
29
79
  /**
30
80
  * Reference to content view (first child)
31
81
  */
@@ -1,6 +1,8 @@
1
1
  package com.lodev09.truesheet
2
2
 
3
3
  import com.facebook.react.module.annotations.ReactModule
4
+ import com.facebook.react.uimanager.ReactStylesDiffMap
5
+ import com.facebook.react.uimanager.StateWrapper
4
6
  import com.facebook.react.uimanager.ThemedReactContext
5
7
  import com.facebook.react.uimanager.ViewGroupManager
6
8
 
@@ -15,6 +17,11 @@ class TrueSheetContainerViewManager : ViewGroupManager<TrueSheetContainerView>()
15
17
 
16
18
  override fun createViewInstance(reactContext: ThemedReactContext): TrueSheetContainerView = TrueSheetContainerView(reactContext)
17
19
 
20
+ override fun updateState(view: TrueSheetContainerView, props: ReactStylesDiffMap?, stateWrapper: StateWrapper?): Any? {
21
+ view.setStateWrapper(stateWrapper)
22
+ return null
23
+ }
24
+
18
25
  companion object {
19
26
  const val REACT_CLASS = "TrueSheetContainerView"
20
27
  }
@@ -18,7 +18,6 @@ import com.lodev09.truesheet.events.DragChangeEvent
18
18
  import com.lodev09.truesheet.events.DragEndEvent
19
19
  import com.lodev09.truesheet.events.MountEvent
20
20
  import com.lodev09.truesheet.events.PositionChangeEvent
21
- import com.lodev09.truesheet.events.SizeChangeEvent
22
21
  import com.lodev09.truesheet.events.WillDismissEvent
23
22
  import com.lodev09.truesheet.events.WillPresentEvent
24
23
 
@@ -350,14 +349,6 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
350
349
  viewController.dismiss()
351
350
  }
352
351
 
353
- override fun viewControllerDidChangeSize(width: Int, height: Int) {
354
- // Dispatch size change event to JS
355
- val surfaceId = UIManagerHelper.getSurfaceId(this)
356
- eventDispatcher?.dispatchEvent(
357
- SizeChangeEvent(surfaceId, id, width, height)
358
- )
359
- }
360
-
361
352
  // ==================== TrueSheetContainerViewDelegate Implementation ====================
362
353
 
363
354
  override fun containerViewContentDidChangeSize(width: Int, height: Int) {
@@ -40,7 +40,6 @@ interface TrueSheetViewControllerDelegate {
40
40
  fun viewControllerDidDragChange(index: Int, position: Float)
41
41
  fun viewControllerDidDragEnd(index: Int, position: Float)
42
42
  fun viewControllerDidChangePosition(index: Int, position: Float, transitioning: Boolean)
43
- fun viewControllerDidChangeSize(width: Int, height: Int)
44
43
  }
45
44
 
46
45
  /**
@@ -65,6 +64,9 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
65
64
  private val jSTouchDispatcher = JSTouchDispatcher(this)
66
65
  private var jSPointerDispatcher: JSPointerDispatcher? = null
67
66
 
67
+ private var viewWidth = 0
68
+ private var viewHeight = 0
69
+
68
70
  /**
69
71
  * Delegate for handling view controller events
70
72
  */
@@ -774,6 +776,11 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
774
776
 
775
777
  override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
776
778
  super.onSizeChanged(w, h, oldw, oldh)
779
+ viewWidth = w
780
+ viewHeight = h
781
+
782
+ // Update container state with new dimensions
783
+ containerView?.updateState(viewWidth, viewHeight)
777
784
 
778
785
  // Only proceed if size actually changed
779
786
  if (w == oldw && h == oldh) return
@@ -796,9 +803,6 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
796
803
  delegate?.viewControllerDidChangePosition(detentInfo.index, detentInfo.position, transitioning = true)
797
804
  }
798
805
  }
799
-
800
- // Notify delegate about size change
801
- delegate?.viewControllerDidChangeSize(w, h)
802
806
  }
803
807
 
804
808
  override fun handleException(t: Throwable) {
@@ -61,8 +61,7 @@ class TrueSheetViewManager :
61
61
  DragBeginEvent.EVENT_NAME to hashMapOf("registrationName" to DragBeginEvent.REGISTRATION_NAME),
62
62
  DragChangeEvent.EVENT_NAME to hashMapOf("registrationName" to DragChangeEvent.REGISTRATION_NAME),
63
63
  DragEndEvent.EVENT_NAME to hashMapOf("registrationName" to DragEndEvent.REGISTRATION_NAME),
64
- PositionChangeEvent.EVENT_NAME to hashMapOf("registrationName" to PositionChangeEvent.REGISTRATION_NAME),
65
- SizeChangeEvent.EVENT_NAME to hashMapOf("registrationName" to SizeChangeEvent.REGISTRATION_NAME)
64
+ PositionChangeEvent.EVENT_NAME to hashMapOf("registrationName" to PositionChangeEvent.REGISTRATION_NAME)
66
65
  )
67
66
 
68
67
  // ==================== Props ====================
@@ -154,6 +153,16 @@ class TrueSheetViewManager :
154
153
  view.setEdgeToEdgeFullScreen(edgeToEdgeFullScreen)
155
154
  }
156
155
 
156
+ @ReactProp(name = "fitScrollView", defaultBoolean = false)
157
+ override fun setFitScrollView(view: TrueSheetView, value: Boolean) {
158
+ // iOS-specific prop - no-op on Android
159
+ }
160
+
161
+ @ReactProp(name = "pageSizing", defaultBoolean = true)
162
+ override fun setPageSizing(view: TrueSheetView, value: Boolean) {
163
+ // iOS-specific prop - no-op on Android
164
+ }
165
+
157
166
  companion object {
158
167
  const val REACT_CLASS = "TrueSheetView"
159
168
  const val TAG_NAME = "TrueSheet"
@@ -0,0 +1,87 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+ set(CMAKE_VERBOSE_MAKEFILE ON)
3
+
4
+ set(LIB_LITERAL TrueSheetSpec)
5
+ set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL})
6
+
7
+ set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
8
+ set(LIB_COMMON_DIR ${LIB_ANDROID_DIR}/../common/cpp)
9
+ set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/build/generated/source/codegen/jni)
10
+ set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL})
11
+
12
+ file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS *.cpp ${LIB_COMMON_DIR}/react/renderer/components/${LIB_LITERAL}/*.cpp)
13
+ file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_JNI_DIR}/*.cpp ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp)
14
+
15
+ add_library(
16
+ ${LIB_TARGET_NAME}
17
+ SHARED
18
+ ${LIB_CUSTOM_SRCS}
19
+ ${LIB_CODEGEN_SRCS}
20
+ )
21
+
22
+ target_include_directories(
23
+ ${LIB_TARGET_NAME}
24
+ PUBLIC
25
+ .
26
+ ${LIB_COMMON_DIR}
27
+ ${LIB_ANDROID_GENERATED_JNI_DIR}
28
+ ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}
29
+ )
30
+
31
+ if (REACTNATIVE_MERGED_SO)
32
+ target_link_libraries(
33
+ ${LIB_TARGET_NAME}
34
+ fbjni
35
+ jsi
36
+ reactnative
37
+ log
38
+ )
39
+ else()
40
+ target_link_libraries(
41
+ ${LIB_TARGET_NAME}
42
+ fbjni
43
+ folly_runtime
44
+ glog
45
+ jsi
46
+ react_codegen_rncore
47
+ react_debug
48
+ react_nativemodule_core
49
+ react_render_core
50
+ react_render_debug
51
+ react_render_graphics
52
+ react_render_mapbuffer
53
+ react_render_componentregistry
54
+ react_utils
55
+ rrc_view
56
+ turbomodulejsijni
57
+ yoga
58
+ log
59
+ )
60
+ endif()
61
+
62
+ target_include_directories(
63
+ ${CMAKE_PROJECT_NAME}
64
+ PUBLIC
65
+ ${CMAKE_CURRENT_SOURCE_DIR}
66
+ )
67
+
68
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
69
+ target_compile_reactnative_options(${LIB_TARGET_NAME} PUBLIC)
70
+ else()
71
+ target_compile_options(
72
+ ${LIB_TARGET_NAME}
73
+ PRIVATE
74
+ -fexceptions
75
+ -frtti
76
+ -std=c++20
77
+ -Wall
78
+ )
79
+ endif()
80
+
81
+ target_compile_options(
82
+ ${LIB_TARGET_NAME}
83
+ PRIVATE
84
+ -Wpedantic
85
+ -Wno-gnu-zero-variadic-macro-arguments
86
+ -Wno-dollar-in-identifier-extension
87
+ )
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+
3
+ #include <ReactCommon/JavaTurboModule.h>
4
+ #include <ReactCommon/TurboModule.h>
5
+ #include <jsi/jsi.h>
6
+ #include <react/renderer/components/TrueSheetSpec/TrueSheetContainerViewComponentDescriptor.h>
7
+
8
+ namespace facebook {
9
+ namespace react {
10
+
11
+ JSI_EXPORT
12
+ std::shared_ptr<TurboModule> TrueSheetSpec_ModuleProvider(
13
+ const std::string &moduleName,
14
+ const JavaTurboModule::InitParams &params);
15
+
16
+ } // namespace react
17
+ } // namespace facebook
@@ -9,14 +9,18 @@
9
9
  #ifdef RCT_NEW_ARCH_ENABLED
10
10
 
11
11
  #import "TrueSheetContainerView.h"
12
- #import <react/renderer/components/TrueSheetSpec/ComponentDescriptors.h>
13
12
  #import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
14
13
  #import <react/renderer/components/TrueSheetSpec/Props.h>
15
14
  #import <react/renderer/components/TrueSheetSpec/RCTComponentViewHelpers.h>
15
+ #import <react/renderer/components/TrueSheetSpec/TrueSheetContainerViewComponentDescriptor.h>
16
+ #import <react/renderer/components/TrueSheetSpec/TrueSheetContainerViewShadowNode.h>
17
+ #import <react/renderer/components/TrueSheetSpec/TrueSheetContainerViewState.h>
16
18
  #import "TrueSheetContentView.h"
17
19
  #import "TrueSheetFooterView.h"
18
20
 
19
21
  #import <React/RCTConversions.h>
22
+ #import <React/RCTLog.h>
23
+ #import <react/renderer/core/State.h>
20
24
 
21
25
  using namespace facebook::react;
22
26
 
@@ -26,6 +30,8 @@ using namespace facebook::react;
26
30
  @implementation TrueSheetContainerView {
27
31
  TrueSheetContentView *_contentView;
28
32
  TrueSheetFooterView *_footerView;
33
+ TrueSheetContainerViewShadowNode::ConcreteState::Shared _state;
34
+ CGFloat _lastContainerWidth;
29
35
  }
30
36
 
31
37
  + (ComponentDescriptorProvider)componentDescriptorProvider {
@@ -41,11 +47,49 @@ using namespace facebook::react;
41
47
 
42
48
  _contentView = nil;
43
49
  _footerView = nil;
50
+ _lastContainerWidth = 0;
44
51
  }
45
52
  return self;
46
53
  }
47
54
 
48
- - (void)dealloc {
55
+ - (void)layoutSubviews {
56
+ [super layoutSubviews];
57
+
58
+ // Override Yoga layout - fill the entire parent (controller's view)
59
+ if (self.superview) {
60
+ CGRect parentBounds = self.superview.bounds;
61
+ if (!CGRectEqualToRect(self.frame, parentBounds)) {
62
+ self.frame = parentBounds;
63
+ }
64
+
65
+ // Update state with container width so Yoga can use it for children layout
66
+ [self updateStateIfNeeded];
67
+ }
68
+ }
69
+
70
+ - (void)updateStateIfNeeded {
71
+ if (!self.superview) {
72
+ return;
73
+ }
74
+
75
+ CGFloat containerWidth = self.superview.bounds.size.width;
76
+ if (containerWidth > 0 && fabs(containerWidth - _lastContainerWidth) > 0.5) {
77
+ _lastContainerWidth = containerWidth;
78
+ [self updateState];
79
+ }
80
+ }
81
+
82
+ - (void)updateState {
83
+ if (!_state) {
84
+ return;
85
+ }
86
+
87
+ _state->updateState([=](TrueSheetContainerViewShadowNode::ConcreteState::Data const &oldData)
88
+ -> TrueSheetContainerViewShadowNode::ConcreteState::SharedData {
89
+ auto newData = oldData;
90
+ newData.containerWidth = static_cast<float>(_lastContainerWidth);
91
+ return std::make_shared<TrueSheetContainerViewShadowNode::ConcreteState::Data const>(newData);
92
+ });
49
93
  }
50
94
 
51
95
  - (CGFloat)contentHeight {
@@ -64,7 +108,6 @@ using namespace facebook::react;
64
108
 
65
109
  - (void)setupContentScrollViewPinning:(BOOL)pinned {
66
110
  if (_contentView) {
67
- NSLog(@"setting up scrollview pinning: %i", pinned);
68
111
  [_contentView setupScrollViewPinning:pinned];
69
112
  }
70
113
  }
@@ -75,7 +118,7 @@ using namespace facebook::react;
75
118
  // Handle content view mounting
76
119
  if ([childComponentView isKindOfClass:[TrueSheetContentView class]]) {
77
120
  if (_contentView != nil) {
78
- NSLog(@"TrueSheet: Container can only have one content component.");
121
+ RCTLogWarn(@"TrueSheet: Container can only have one content component.");
79
122
  return;
80
123
  }
81
124
 
@@ -86,7 +129,7 @@ using namespace facebook::react;
86
129
  // Handle footer view mounting
87
130
  if ([childComponentView isKindOfClass:[TrueSheetFooterView class]]) {
88
131
  if (_footerView != nil) {
89
- NSLog(@"TrueSheet: Container can only have one footer component.");
132
+ RCTLogWarn(@"TrueSheet: Container can only have one footer component.");
90
133
  return;
91
134
  }
92
135
 
@@ -110,6 +153,19 @@ using namespace facebook::react;
110
153
  [super updateProps:props oldProps:oldProps];
111
154
  }
112
155
 
156
+ - (void)updateState:(const State::Shared &)state oldState:(const State::Shared &)oldState {
157
+ _state = std::static_pointer_cast<TrueSheetContainerViewShadowNode::ConcreteState const>(state);
158
+
159
+ // Reset last width when state is updated to ensure we push the correct width
160
+ // This handles re-presentation of the sheet where state is recreated
161
+ _lastContainerWidth = 0;
162
+ }
163
+
164
+ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
165
+ [super finalizeUpdates:updateMask];
166
+ [self updateStateIfNeeded];
167
+ }
168
+
113
169
  #pragma mark - TrueSheetContentViewDelegate
114
170
 
115
171
  - (void)contentViewDidChangeSize:(CGSize)newSize {
@@ -53,17 +53,6 @@ using namespace facebook::react;
53
53
  }
54
54
  }
55
55
 
56
- //- (void)didMoveToSuperview {
57
- // [super didMoveToSuperview];
58
- //
59
- // // Setup scroll view pinning after Fabric mounts the view in container
60
- // // Ensures proper view hierarchy for scroll detection and pinning
61
- // if (self.superview) {
62
- // NSLog(@"content has attached");
63
- //// [self setupScrollViewPinning];
64
- // }
65
- //}
66
-
67
56
  - (void)unpinScrollView {
68
57
  // Unpin previous scroll view if exists
69
58
  if (_pinnedScrollView) {
@@ -23,22 +23,6 @@ typedef void (^TrueSheetCompletionBlock)(BOOL success, NSError *_Nullable error)
23
23
 
24
24
  @interface TrueSheetView : RCTViewComponentView
25
25
 
26
- ///**
27
- // * The view controller managing the sheet presentation
28
- // * Exposed so container can access it
29
- // */
30
- //@property (nonatomic, readonly, strong) TrueSheetViewController *controller;
31
- //
32
- ///**
33
- // * Whether the sheet is currently presented
34
- // */
35
- //@property (nonatomic, readonly) BOOL isPresented;
36
- //
37
- ///**
38
- // * The currently active detent index
39
- // */
40
- //@property (nonatomic, readonly, strong, nullable) NSNumber *activeIndex;
41
-
42
26
  // TurboModule methods
43
27
  - (void)presentAtIndex:(NSInteger)index
44
28
  animated:(BOOL)animated
@@ -22,7 +22,6 @@
22
22
  #import "events/OnDragEndEvent.h"
23
23
  #import "events/OnMountEvent.h"
24
24
  #import "events/OnPositionChangeEvent.h"
25
- #import "events/OnSizeChangeEvent.h"
26
25
  #import "events/OnWillDismissEvent.h"
27
26
  #import "events/OnWillPresentEvent.h"
28
27
  #import "utils/LayoutUtil.h"
@@ -35,6 +34,7 @@
35
34
 
36
35
  #import <React/RCTConversions.h>
37
36
  #import <React/RCTFabricComponentsPlugins.h>
37
+ #import <React/RCTLog.h>
38
38
  #import <React/RCTSurfaceTouchHandler.h>
39
39
  #import <React/RCTUtils.h>
40
40
 
@@ -216,6 +216,9 @@ using namespace facebook::react;
216
216
  // Update grabber
217
217
  _controller.grabber = newProps.grabber;
218
218
 
219
+ // Update page sizing
220
+ _controller.pageSizing = newProps.pageSizing;
221
+
219
222
  // Update dismissible
220
223
  _controller.modalInPresentation = !newProps.dismissible;
221
224
 
@@ -268,7 +271,7 @@ using namespace facebook::react;
268
271
  // Check if it's a container view
269
272
  if ([childComponentView isKindOfClass:[TrueSheetContainerView class]]) {
270
273
  if (_containerView != nil) {
271
- NSLog(@"TrueSheet: Sheet can only have one container component.");
274
+ RCTLogWarn(@"TrueSheet: Sheet can only have one container component.");
272
275
  return;
273
276
  }
274
277
 
@@ -289,6 +292,10 @@ using namespace facebook::react;
289
292
  // Ensure container is above background view
290
293
  [_controller.view bringSubviewToFront:_containerView];
291
294
 
295
+ // Force layout pass immediately so container gets correct width on mount
296
+ // This pushes the width to Yoga before the sheet is presented
297
+ [_controller.view layoutIfNeeded];
298
+
292
299
  // Get initial content height from container
293
300
  CGFloat contentHeight = [_containerView contentHeight];
294
301
  if (contentHeight > 0) {
@@ -363,10 +370,6 @@ using namespace facebook::react;
363
370
  _controller.activeDetentIndex = index;
364
371
 
365
372
  [OnWillPresentEvent emit:_eventEmitter index:index position:position];
366
-
367
- // Emit onChangeSize event to layout our container on JS
368
- CGSize controllerSize = _controller.view.frame.size;
369
- [OnSizeChangeEvent emit:_eventEmitter width:controllerSize.width height:controllerSize.height];
370
373
  }
371
374
 
372
375
  - (void)viewControllerDidPresent {
@@ -418,10 +421,6 @@ using namespace facebook::react;
418
421
  [OnPositionChangeEvent emit:_eventEmitter index:index position:position transitioning:transitioning];
419
422
  }
420
423
 
421
- - (void)viewControllerDidChangeSize:(CGSize)size {
422
- [OnSizeChangeEvent emit:_eventEmitter width:size.width height:size.height];
423
- }
424
-
425
424
  #pragma mark - Private Helpers
426
425
 
427
426
  - (UIViewController *)findPresentingViewController {
@@ -433,6 +432,10 @@ using namespace facebook::react;
433
432
 
434
433
  UIViewController *rootViewController = keyWindow.rootViewController;
435
434
 
435
+ if (!rootViewController) {
436
+ return nil;
437
+ }
438
+
436
439
  // Find the top-most presented view controller
437
440
  while (rootViewController.presentedViewController) {
438
441
  UIViewController *presented = rootViewController.presentedViewController;
@@ -26,7 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
26
26
  - (void)viewControllerDidChangeDetent:(NSInteger)index position:(CGFloat)position;
27
27
  - (void)viewControllerDidDrag:(UIGestureRecognizerState)state index:(NSInteger)index position:(CGFloat)position;
28
28
  - (void)viewControllerDidChangePosition:(NSInteger)index position:(CGFloat)position transitioning:(BOOL)transitioning;
29
- - (void)viewControllerDidChangeSize:(CGSize)size;
30
29
 
31
30
  @end
32
31
 
@@ -47,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
47
46
  @property (nonatomic, assign) BOOL dimmed;
48
47
  @property (nonatomic, strong, nullable) NSNumber *dimmedDetentIndex;
49
48
  @property (nonatomic, copy, nullable) NSString *blurTint;
49
+ @property (nonatomic, assign) BOOL pageSizing;
50
50
  @property (nonatomic, assign) BOOL layoutTransitioning;
51
51
  @property (nonatomic, assign) BOOL isPresented;
52
52
  @property (nonatomic, assign) NSInteger activeDetentIndex;
@@ -57,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
57
57
  - (void)setupSheetProps;
58
58
  - (NSInteger)currentDetentIndex;
59
59
  - (CGFloat)currentPosition;
60
+ - (CGFloat)bottomInset;
60
61
  - (CGFloat)currentHeight;
61
62
  - (CGFloat)containerHeight;
62
63