diff --git a/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewState.h b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewState.h index 9a12bdef2cd..2b713926dd5 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewState.h +++ b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewState.h @@ -14,6 +14,10 @@ #include #endif +#if defined(__APPLE__) && TARGET_OS_IOS +#include "ModalHostViewUtils.h" +#endif + namespace facebook::react { /* @@ -23,7 +27,12 @@ class ModalHostViewState final { public: using Shared = std::shared_ptr; - ModalHostViewState(){}; +#if defined(__APPLE__) && TARGET_OS_IOS + ModalHostViewState() : screenSize(RCTModalHostViewScreenSize()) { +#else + ModalHostViewState(){ +#endif + }; ModalHostViewState(Size screenSize_) : screenSize(screenSize_){}; #ifdef ANDROID diff --git a/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.h b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.h new file mode 100644 index 00000000000..fc038ad33de --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook::react { + +Size RCTModalHostViewScreenSize(void); + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.mm b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.mm new file mode 100644 index 00000000000..d2c3560dca8 --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.mm @@ -0,0 +1,20 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "ModalHostViewUtils.h" +#import +#import + +namespace facebook::react { + +Size RCTModalHostViewScreenSize(void) +{ + CGSize screenSize = RCTScreenSize(); + return {screenSize.width, screenSize.height}; +} + +} // namespace facebook::react