react-native-windows 0.77.0 → 0.78.0-preview.1
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.
- package/.flowconfig +1 -1
- package/Chakra/ChakraTracing.cpp +1 -1
- package/Libraries/Animated/animations/Animation.js +22 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -0
- package/Libraries/Animated/animations/SpringAnimation.js +1 -0
- package/Libraries/Animated/animations/TimingAnimation.js +1 -0
- package/Libraries/Animated/nodes/AnimatedAddition.js +9 -2
- package/Libraries/Animated/nodes/AnimatedColor.js +4 -1
- package/Libraries/Animated/nodes/AnimatedDiffClamp.js +10 -2
- package/Libraries/Animated/nodes/AnimatedDivision.js +9 -2
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +5 -1
- package/Libraries/Animated/nodes/AnimatedModulo.js +5 -2
- package/Libraries/Animated/nodes/AnimatedMultiplication.js +9 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +25 -46
- package/Libraries/Animated/nodes/AnimatedObject.js +9 -2
- package/Libraries/Animated/nodes/AnimatedProps.js +5 -1
- package/Libraries/Animated/nodes/AnimatedStyle.js +5 -1
- package/Libraries/Animated/nodes/AnimatedSubtraction.js +9 -2
- package/Libraries/Animated/nodes/AnimatedTracking.js +5 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +5 -1
- package/Libraries/Animated/nodes/AnimatedValue.js +49 -4
- package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -1
- package/Libraries/Animated/useAnimatedProps.js +0 -43
- package/Libraries/Components/Button.windows.js +3 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +3 -1
- package/Libraries/Components/LayoutConformance/LayoutConformance.d.ts +21 -0
- package/Libraries/Components/LayoutConformance/LayoutConformance.js +59 -0
- package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +29 -0
- package/Libraries/Components/Pressable/Pressable.windows.js +3 -0
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +5 -0
- package/Libraries/Components/TextInput/TextInput.flow.js +6 -0
- package/Libraries/Components/TextInput/TextInput.js +6 -0
- package/Libraries/Components/TextInput/TextInput.windows.js +9 -0
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +2 -0
- package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +2 -0
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +2 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +2 -0
- package/Libraries/Components/View/View.windows.js +3 -0
- package/Libraries/Components/View/ViewAccessibility.d.ts +7 -2
- package/Libraries/Components/View/ViewAccessibility.windows.js +1 -0
- package/Libraries/Components/View/ViewPropTypes.d.ts +0 -7
- package/Libraries/Components/View/ViewPropTypes.js +0 -9
- package/Libraries/Components/View/ViewPropTypes.windows.js +1 -9
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/setUpBatchedBridge.js +1 -16
- package/Libraries/EventEmitter/RCTEventEmitter.js +2 -6
- package/Libraries/Image/AssetSourceResolver.js +11 -0
- package/Libraries/Image/AssetSourceResolver.windows.js +11 -0
- package/Libraries/Image/Image.windows.js +2 -0
- package/Libraries/Inspector/BorderBox.js +26 -14
- package/Libraries/Inspector/BoxInspector.js +60 -42
- package/Libraries/Inspector/ElementBox.js +55 -48
- package/Libraries/Inspector/StyleInspector.js +36 -30
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Lists/FlatList.d.ts +1 -1
- package/Libraries/Modal/Modal.js +2 -0
- package/Libraries/Modal/Modal.windows.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.android.js +0 -2
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +0 -2
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +0 -2
- package/Libraries/Network/RCTNetworking.android.js +24 -16
- package/Libraries/Network/RCTNetworking.ios.js +1 -46
- package/Libraries/Network/RCTNetworking.windows.js +1 -46
- package/Libraries/Network/RCTNetworkingEventDefinitions.flow.js +57 -0
- package/Libraries/ReactNative/UIManagerProperties.js +3 -1
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +15828 -26461
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3907 -2560
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4399 -2878
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +16102 -26908
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +4034 -2695
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4535 -3045
- package/Libraries/Renderer/shims/ReactNativeTypes.js +5 -6
- package/Libraries/StyleSheet/processTransform.js +6 -0
- package/Libraries/Text/Text.d.ts +6 -1
- package/Libraries/Text/Text.windows.js +4 -0
- package/Libraries/Text/TextProps.js +2 -2
- package/Libraries/Text/TextProps.windows.js +3 -2
- package/Libraries/Utilities/BackHandler.android.js +5 -4
- package/Libraries/Utilities/BackHandler.ios.js +4 -5
- package/Libraries/Utilities/BackHandler.windows.js +5 -4
- package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +0 -1
- package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +92 -17
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +9 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +13 -33
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -3
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +43 -5
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +12 -10
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +11 -9
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +191 -329
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
- package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +66 -0
- package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +21 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -4
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +79 -19
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +71 -17
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +16 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +5 -10
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +4 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +138 -110
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +27 -27
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +38 -33
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +0 -2
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +5 -16
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
- package/Microsoft.ReactNative/Fabric/ImageManager.cpp +9 -0
- package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +1 -1
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +5 -0
- package/Microsoft.ReactNative/IReactContext.cpp +2 -2
- package/Microsoft.ReactNative/IReactContext.h +1 -1
- package/Microsoft.ReactNative/IReactContext.idl +2 -2
- package/Microsoft.ReactNative/IReactPackageBuilder.idl +3 -3
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +97 -87
- package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +4 -0
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +9 -4
- package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +1 -1
- package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +32 -35
- package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h +7 -4
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +2 -2
- package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +3 -3
- package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +7 -5
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -1
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +10 -10
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +24 -24
- package/Microsoft.ReactNative/Modules/Timing.cpp +2 -2
- package/Microsoft.ReactNative/ReactHost/IReactInstance.h +5 -0
- package/Microsoft.ReactNative/ReactHost/React.h +0 -3
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +39 -16
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +4 -2
- package/Microsoft.ReactNative/ReactNativeHost.cpp +9 -4
- package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
- package/Microsoft.ReactNative/ReactPackageBuilder.cpp +3 -3
- package/Microsoft.ReactNative/ReactPackageBuilder.h +4 -4
- package/Microsoft.ReactNative/Utils/Helpers.cpp +0 -2
- package/Microsoft.ReactNative/Views/DevMenu.cpp +6 -6
- package/Microsoft.ReactNative/Views/DevMenu.h +1 -1
- package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +2 -2
- package/Microsoft.ReactNative/Views/ViewPanel.cpp +1 -1
- package/Microsoft.ReactNative/Views/ViewViewManager.cpp +2 -2
- package/Microsoft.ReactNative/XamlUIService.cpp +13 -7
- package/Microsoft.ReactNative/XamlUIService.h +4 -1
- package/Microsoft.ReactNative/XamlUIService.idl +2 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +6 -2
- package/Microsoft.ReactNative.Cxx/ReactContext.h +1 -1
- package/Microsoft.ReactNative.Cxx/XamlUtils.h +12 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/React.Cpp.props +3 -0
- package/PropertySheets/WebView2.props +1 -1
- package/PropertySheets/WinUI.props +5 -4
- package/ReactCommon/ReactCommon.vcxproj +5 -1
- package/ReactCommon/ReactCommon.vcxproj.filters +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +3 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +3 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +91 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +1 -12
- package/{Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h → ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/textinput/TextInputState.h} +37 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +1 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +4 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/ImageRequestParams.h +30 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h +4 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/primitives.h +179 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +43 -57
- package/Shared/HermesRuntimeHolder.cpp +2 -2
- package/Shared/Shared.vcxitems +8 -14
- package/Shared/Shared.vcxitems.filters +4 -16
- package/Shared/Threading/BatchingQueueThread.cpp +3 -3
- package/codegen/NativeCPUTimeSpec.g.h +41 -0
- package/codegen/NativeFantomSpec.g.h +78 -0
- package/codegen/NativePerformanceSpec.g.h +31 -43
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +84 -84
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +212 -0
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +295 -0
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +200 -0
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +224 -0
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +250 -0
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +267 -0
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +234 -0
- package/codegen/react/components/rnwcore/InputAccessory.g.h +200 -0
- package/codegen/react/components/rnwcore/ModalHostView.g.h +283 -0
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +246 -0
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +197 -0
- package/codegen/react/components/rnwcore/Switch.g.h +263 -0
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +200 -0
- package/codegen/rnwcoreJSI-generated.cpp +90 -57
- package/codegen/rnwcoreJSI.h +241 -104
- package/index.js +5 -0
- package/index.windows.js +5 -0
- package/just-task.js +1 -1
- package/package.json +25 -26
- package/src/private/animated/NativeAnimatedValidation.js +1 -1
- package/src/private/featureflags/ReactNativeFeatureFlags.js +33 -27
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +5 -5
- package/src/private/renderer/errorhandling/ErrorHandlers.js +12 -55
- package/src/private/specs/modules/{NativeJSCSamplingProfiler.js → NativeCPUTime.js} +7 -2
- package/src/private/specs/modules/NativeFantom.js +37 -0
- package/src/private/utilities/ensureInstance.js +21 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +49 -6
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +17 -9
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +11 -11
- package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +1 -1
- package/src/private/webapis/intersectionobserver/IntersectionObserverManager.js +1 -1
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
- package/src/private/webapis/performance/Performance.js +0 -12
- package/src/private/webapis/performance/specs/NativePerformance.js +0 -11
- package/types/index.d.ts +1 -0
- package/Libraries/HeapCapture/HeapCapture.js +0 -29
- package/Libraries/HeapCapture/NativeJSCHeapCapture.js +0 -13
- package/Libraries/Performance/NativeJSCSamplingProfiler.js +0 -13
- package/Libraries/Performance/SamplingProfiler.js +0 -39
- package/Libraries/ReactNative/__mocks__/FabricUIManager.js +0 -334
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -34
- package/Microsoft.ReactNative/Fabric/ReactNativeConfigProperties.cpp +0 -53
- package/Microsoft.ReactNative/Fabric/ReactNativeConfigProperties.h +0 -26
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/LayoutableShadowNode.cpp +0 -363
- package/codegen/NativeJSCSamplingProfilerSpec.g.h +0 -35
- package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +0 -413
- package/src/private/webapis/intersectionobserver/specs/__mocks__/NativeIntersectionObserver.js +0 -181
- package/src/private/webapis/mutationobserver/specs/__mocks__/NativeMutationObserver.js +0 -327
package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp
CHANGED
|
@@ -5,379 +5,241 @@
|
|
|
5
5
|
|
|
6
6
|
#include "WindowsModalHostViewComponentView.h"
|
|
7
7
|
|
|
8
|
-
#include
|
|
9
|
-
#include <
|
|
10
|
-
#include "../CompositionDynamicAutomationProvider.h"
|
|
11
|
-
#include "Unicode.h"
|
|
12
|
-
|
|
13
|
-
#include <DispatcherQueue.h>
|
|
14
|
-
#include <Fabric/ComponentView.h>
|
|
15
|
-
#include <Fabric/Composition/CompositionContextHelper.h>
|
|
16
|
-
#include <Fabric/Composition/CompositionUIService.h>
|
|
17
|
-
#include <Fabric/Composition/ReactNativeIsland.h>
|
|
18
|
-
#include <windows.ui.composition.interop.h>
|
|
19
|
-
#include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
|
|
8
|
+
#include "../../../codegen/react/components/rnwcore/ModalHostView.g.h"
|
|
9
|
+
#include <ComponentView.Experimental.interop.h>
|
|
20
10
|
#include <winrt/Microsoft.UI.Content.h>
|
|
11
|
+
#include <winrt/Microsoft.UI.Input.h>
|
|
12
|
+
#include <winrt/Microsoft.UI.Windowing.h>
|
|
21
13
|
#include <winrt/Microsoft.UI.interop.h>
|
|
22
|
-
#include <winrt/Windows.UI.Composition.Desktop.h>
|
|
23
|
-
#include <winrt/Windows.UI.Composition.h>
|
|
24
|
-
#include "IReactContext.h"
|
|
25
|
-
#include "ReactHost/ReactInstanceWin.h"
|
|
26
|
-
#include "ReactNativeHost.h"
|
|
27
|
-
#include "WindowsModalHostViewShadowNode.h"
|
|
28
14
|
|
|
29
15
|
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
30
|
-
WindowsModalHostComponentView::WindowsModalHostComponentView(
|
|
31
|
-
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
32
|
-
facebook::react::Tag tag,
|
|
33
|
-
winrt::Microsoft::ReactNative::ReactContext const &reactContext)
|
|
34
|
-
: Super(compContext, tag, reactContext) {}
|
|
35
|
-
|
|
36
|
-
WindowsModalHostComponentView::~WindowsModalHostComponentView() {
|
|
37
|
-
// dispatch onDismiss event
|
|
38
|
-
auto emitter = std::static_pointer_cast<const facebook::react::ModalHostViewEventEmitter>(m_eventEmitter);
|
|
39
|
-
facebook::react::ModalHostViewEventEmitter::OnDismiss onDismissArgs;
|
|
40
|
-
emitter->onDismiss(onDismissArgs);
|
|
41
|
-
|
|
42
|
-
// reset the topWindowID
|
|
43
|
-
if (m_prevWindowID) {
|
|
44
|
-
auto host =
|
|
45
|
-
winrt::Microsoft::ReactNative::implementation::ReactNativeHost::GetReactNativeHost(m_reactContext.Properties());
|
|
46
|
-
winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
|
|
47
|
-
host.InstanceSettings().Properties(), m_prevWindowID);
|
|
48
|
-
m_prevWindowID = 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// enable input to parent
|
|
52
|
-
EnableWindow(m_parentHwnd, true);
|
|
53
|
-
|
|
54
|
-
// Check if the window handle (m_hwnd) exists and destroy it if necessary
|
|
55
|
-
if (m_hwnd) {
|
|
56
|
-
// Close/Destroy the modal window
|
|
57
|
-
SendMessage(m_hwnd, WM_DESTROY, 0, 0);
|
|
58
|
-
m_hwnd = nullptr;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
winrt::Microsoft::ReactNative::ComponentView WindowsModalHostComponentView::Create(
|
|
63
|
-
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
64
|
-
facebook::react::Tag tag,
|
|
65
|
-
winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept {
|
|
66
|
-
return winrt::make<WindowsModalHostComponentView>(compContext, tag, reactContext);
|
|
67
|
-
}
|
|
68
16
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
17
|
+
struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::Foundation::IInspectable>,
|
|
18
|
+
::Microsoft::ReactNativeSpecs::BaseModalHostView<ModalHostView> {
|
|
19
|
+
~ModalHostView() {
|
|
20
|
+
if (m_window && m_window.IsVisible()) {
|
|
21
|
+
CloseWindow();
|
|
22
|
+
}
|
|
74
23
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
24
|
+
if (m_reactNativeIsland) {
|
|
25
|
+
m_reactNativeIsland.Island().Close();
|
|
26
|
+
}
|
|
78
27
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
28
|
+
if (m_bridge) {
|
|
29
|
+
if (m_departFocusToken && !m_bridge.IsClosed()) {
|
|
30
|
+
auto navHost = winrt::Microsoft::UI::Input::InputFocusNavigationHost::GetForSiteBridge(m_bridge);
|
|
31
|
+
navHost.DepartFocusRequested(m_departFocusToken);
|
|
32
|
+
}
|
|
33
|
+
m_bridge.Close();
|
|
34
|
+
}
|
|
83
35
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
36
|
+
if (m_window) {
|
|
37
|
+
m_window.Destroy();
|
|
38
|
+
m_window = nullptr;
|
|
39
|
+
}
|
|
87
40
|
}
|
|
88
41
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
winrt::com_ptr<::IUnknown> spunk;
|
|
93
|
-
|
|
94
|
-
// get the root hwnd
|
|
95
|
-
m_prevWindowID =
|
|
96
|
-
winrt::Microsoft::ReactNative::ReactCoreInjection::GetTopLevelWindowId(m_reactContext.Properties().Handle());
|
|
42
|
+
void InitializePortalViewComponent(
|
|
43
|
+
const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portalComponentView) noexcept {
|
|
44
|
+
m_reactContext = portalComponentView.ReactContext();
|
|
97
45
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
m_hwnd = CreateWindow(
|
|
103
|
-
c_modalWindowClassName,
|
|
104
|
-
L"React-Native Modal",
|
|
105
|
-
windowsStyle,
|
|
106
|
-
CW_USEDEFAULT,
|
|
107
|
-
CW_USEDEFAULT,
|
|
108
|
-
MODAL_MIN_WIDTH,
|
|
109
|
-
MODAL_MIN_HEIGHT,
|
|
110
|
-
m_parentHwnd, // parent
|
|
111
|
-
nullptr,
|
|
112
|
-
hInstance,
|
|
113
|
-
spunk.get());
|
|
114
|
-
|
|
115
|
-
// Check if window creation succeeded
|
|
116
|
-
if (!m_hwnd) {
|
|
117
|
-
throw std::exception("Failed to create new hwnd for Modal: " + GetLastError());
|
|
46
|
+
portalComponentView.Mounted(
|
|
47
|
+
[](const auto & /*sender*/, const auto &view) { view.UserData().as<ModalHostView>()->OnMounted(view); });
|
|
48
|
+
portalComponentView.Unmounted(
|
|
49
|
+
[](const auto & /*sender*/, const auto &view) { view.UserData().as<ModalHostView>()->OnUnmounted(view); });
|
|
118
50
|
}
|
|
119
51
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
auto bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(
|
|
135
|
-
compositor, winrt::Microsoft::UI::GetWindowIdFromWindow(m_hwnd));
|
|
136
|
-
m_reactNativeIsland = winrt::Microsoft::ReactNative::ReactNativeIsland(compositor, m_reactContext.Handle(), *this);
|
|
137
|
-
auto contentIsland = m_reactNativeIsland.Island();
|
|
138
|
-
bridge.Connect(contentIsland);
|
|
139
|
-
bridge.Show();
|
|
140
|
-
|
|
141
|
-
// set ScaleFactor
|
|
142
|
-
ScaleFactor(m_hwnd);
|
|
143
|
-
|
|
144
|
-
// set layout contraints
|
|
145
|
-
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
|
|
146
|
-
constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
|
|
147
|
-
|
|
148
|
-
RECT rc;
|
|
149
|
-
GetClientRect(m_parentHwnd, &rc);
|
|
150
|
-
// Maximum size is set to size of parent hwnd
|
|
151
|
-
constraints.MaximumSize = {(rc.right - rc.left) * ScaleFactor(m_hwnd), (rc.bottom - rc.top) / ScaleFactor(m_hwnd)};
|
|
152
|
-
constraints.MinimumSize = {MODAL_MIN_WIDTH * ScaleFactor(m_hwnd), MODAL_MIN_HEIGHT * ScaleFactor(m_hwnd)};
|
|
153
|
-
m_reactNativeIsland.Arrange(constraints, {0, 0});
|
|
154
|
-
bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
|
|
155
|
-
|
|
156
|
-
spunk.detach();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
void WindowsModalHostComponentView::ShowOnUIThread() {
|
|
160
|
-
if (m_hwnd && !IsWindowVisible(m_hwnd)) {
|
|
161
|
-
ShowWindow(m_hwnd, SW_NORMAL);
|
|
162
|
-
BringWindowToTop(m_hwnd);
|
|
163
|
-
SetFocus(m_hwnd);
|
|
164
|
-
|
|
165
|
-
// disable input to parent
|
|
166
|
-
EnableWindow(m_parentHwnd, false);
|
|
167
|
-
|
|
168
|
-
// dispatch onShow event
|
|
169
|
-
auto emitter = std::static_pointer_cast<const facebook::react::ModalHostViewEventEmitter>(m_eventEmitter);
|
|
170
|
-
facebook::react::ModalHostViewEventEmitter::OnShow onShowArgs;
|
|
171
|
-
emitter->onShow(onShowArgs);
|
|
52
|
+
void UpdateProps(
|
|
53
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
54
|
+
const winrt::com_ptr<::Microsoft::ReactNativeSpecs::ModalHostViewProps> &newProps,
|
|
55
|
+
const winrt::com_ptr<::Microsoft::ReactNativeSpecs::ModalHostViewProps> &oldProps) noexcept override {
|
|
56
|
+
if (!oldProps || newProps->visible != oldProps->visible) {
|
|
57
|
+
if (newProps->visible.value_or(true)) {
|
|
58
|
+
// We do not immediately show the window, since we want to resize/position
|
|
59
|
+
// the window based on the layout metrics before we show it
|
|
60
|
+
m_showQueued = true;
|
|
61
|
+
} else {
|
|
62
|
+
CloseWindow();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
::Microsoft::ReactNativeSpecs::BaseModalHostView<ModalHostView>::UpdateProps(view, newProps, oldProps);
|
|
172
66
|
}
|
|
173
|
-
}
|
|
174
67
|
|
|
175
|
-
void
|
|
176
|
-
|
|
177
|
-
|
|
68
|
+
void UpdateLayoutMetrics(
|
|
69
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
70
|
+
const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
|
|
71
|
+
const winrt::Microsoft::ReactNative::LayoutMetrics & /*oldLayoutMetrics*/) noexcept override {
|
|
72
|
+
if (m_window) {
|
|
73
|
+
AdjustWindowSize(newLayoutMetrics);
|
|
74
|
+
}
|
|
178
75
|
}
|
|
179
76
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
77
|
+
void FinalizeUpdate(
|
|
78
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
79
|
+
winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept override {
|
|
80
|
+
if (m_showQueued) {
|
|
81
|
+
ShowOnUIThread(view);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
184
84
|
|
|
185
|
-
|
|
186
|
-
|
|
85
|
+
private:
|
|
86
|
+
void OnMounted(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
|
|
87
|
+
m_mounted = true;
|
|
187
88
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
winrt::Microsoft::ReactNative::implementation::ReactNativeHost::GetReactNativeHost(m_reactContext.Properties());
|
|
192
|
-
winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
|
|
193
|
-
host.InstanceSettings().Properties(), m_prevWindowID);
|
|
194
|
-
m_prevWindowID = 0;
|
|
89
|
+
if (m_showQueued) {
|
|
90
|
+
ShowOnUIThread(view);
|
|
91
|
+
}
|
|
195
92
|
}
|
|
196
|
-
}
|
|
197
93
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
LRESULT CALLBACK ModalBoxWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) noexcept {
|
|
201
|
-
auto data = reinterpret_cast<::IUnknown *>(GetProp(
|
|
202
|
-
hwnd,
|
|
203
|
-
CompHostProperty)); // gets data handle from the property list of specified window (ie the window we want to make)
|
|
204
|
-
winrt::Microsoft::ReactNative::CompositionHwndHost host{nullptr};
|
|
205
|
-
|
|
206
|
-
if (data) {
|
|
207
|
-
winrt::check_hresult(data->QueryInterface(
|
|
208
|
-
winrt::guid_of<winrt::Microsoft::ReactNative::CompositionHwndHost>(),
|
|
209
|
-
winrt::put_abi(host))); // look into the data for a CompositionHwndHost and store it in host
|
|
210
|
-
auto result = static_cast<LRESULT>(host.TranslateMessage(message, wparam, lparam));
|
|
211
|
-
if (result) {
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
94
|
+
void OnUnmounted(const winrt::Microsoft::ReactNative::ComponentView & /*view*/) noexcept {
|
|
95
|
+
m_mounted = false;
|
|
214
96
|
}
|
|
215
97
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
data = static_cast<::IUnknown *>(createStruct->lpCreateParams);
|
|
220
|
-
SetProp(hwnd, CompHostProperty, data); // adds new properties to window
|
|
221
|
-
break;
|
|
98
|
+
void AdjustWindowSize(const winrt::Microsoft::ReactNative::LayoutMetrics &layoutMetrics) noexcept {
|
|
99
|
+
if (layoutMetrics.Frame.Width == 0 && layoutMetrics.Frame.Height == 0) {
|
|
100
|
+
return;
|
|
222
101
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
102
|
+
|
|
103
|
+
// get Modal's position based on parent
|
|
104
|
+
RECT parentRC;
|
|
105
|
+
GetWindowRect(m_parentHwnd, &parentRC);
|
|
106
|
+
int32_t xCor = static_cast<int32_t>(
|
|
107
|
+
(parentRC.left + parentRC.right - layoutMetrics.Frame.Width * layoutMetrics.PointScaleFactor) / 2);
|
|
108
|
+
int32_t yCor = static_cast<int32_t>(
|
|
109
|
+
(parentRC.top + parentRC.bottom - layoutMetrics.Frame.Height * layoutMetrics.PointScaleFactor) / 2);
|
|
110
|
+
|
|
111
|
+
// Adjust window position and size
|
|
112
|
+
m_window.ResizeClient(
|
|
113
|
+
{static_cast<int32_t>(layoutMetrics.Frame.Width * (layoutMetrics.PointScaleFactor)),
|
|
114
|
+
static_cast<int32_t>(layoutMetrics.Frame.Height * (layoutMetrics.PointScaleFactor))});
|
|
115
|
+
m_window.Move({xCor, yCor});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
void ShowOnUIThread(const winrt::Microsoft::ReactNative::ComponentView &view) {
|
|
119
|
+
if (!m_mounted)
|
|
120
|
+
return;
|
|
121
|
+
|
|
122
|
+
m_showQueued = false;
|
|
123
|
+
EnsureModalCreated(view);
|
|
124
|
+
|
|
125
|
+
if (m_window && !m_window.IsVisible()) {
|
|
126
|
+
m_bridge.Enable();
|
|
127
|
+
m_window.Show(true);
|
|
128
|
+
|
|
129
|
+
auto navHost = winrt::Microsoft::UI::Input::InputFocusNavigationHost::GetForSiteBridge(m_bridge);
|
|
130
|
+
auto result = navHost.NavigateFocus(winrt::Microsoft::UI::Input::FocusNavigationRequest::Create(
|
|
131
|
+
winrt::Microsoft::UI::Input::FocusNavigationReason::First));
|
|
132
|
+
|
|
133
|
+
// dispatch onShow event
|
|
134
|
+
if (auto eventEmitter = EventEmitter()) {
|
|
135
|
+
::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnShow eventArgs;
|
|
136
|
+
eventEmitter->onShow(eventArgs);
|
|
232
137
|
}
|
|
233
|
-
SetProp(hwnd, CompHostProperty, nullptr);
|
|
234
|
-
break;
|
|
235
138
|
}
|
|
236
139
|
}
|
|
237
140
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
// Creates and Register a new window class
|
|
242
|
-
void WindowsModalHostComponentView::RegisterWndClass() noexcept {
|
|
243
|
-
static bool registered = false;
|
|
244
|
-
if (registered) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
HINSTANCE hInstance =
|
|
249
|
-
GetModuleHandle(NULL); // returns a handle to the file used to create the calling process (.exe file)
|
|
250
|
-
|
|
251
|
-
WNDCLASSEX wcex = {}; // contains window class information
|
|
252
|
-
wcex.cbSize = sizeof(wcex); // size of windows class (bytes)
|
|
253
|
-
wcex.style = CS_HREDRAW | CS_VREDRAW; // class style (redraw window on size adjustment)
|
|
254
|
-
wcex.lpfnWndProc = &ModalBoxWndProc; // pointer to windows procedure
|
|
255
|
-
wcex.cbClsExtra = DLGWINDOWEXTRA; // extra bytes to allocate
|
|
256
|
-
wcex.cbWndExtra =
|
|
257
|
-
sizeof(winrt::impl::abi<winrt::Microsoft::ReactNative::ICompositionHwndHost>::type *); // extra bytes to allocate
|
|
258
|
-
wcex.hInstance = hInstance;
|
|
259
|
-
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); // handle to class cursor
|
|
260
|
-
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // background color
|
|
261
|
-
wcex.lpszClassName = c_modalWindowClassName; // specify resource name
|
|
262
|
-
ATOM classId = RegisterClassEx(&wcex); // register new windows class
|
|
263
|
-
WINRT_VERIFY(classId); // 0 = fail
|
|
264
|
-
winrt::check_win32(!classId);
|
|
265
|
-
|
|
266
|
-
registered = true;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual
|
|
270
|
-
WindowsModalHostComponentView::VisualToMountChildrenInto() noexcept {
|
|
271
|
-
return m_reactNativeIsland
|
|
272
|
-
.as<winrt::Microsoft::ReactNative::Composition::Experimental::IInternalCompositionRootView>()
|
|
273
|
-
.InternalRootVisual();
|
|
274
|
-
}
|
|
141
|
+
void CloseWindow() noexcept {
|
|
142
|
+
// enable input to parent before closing the modal window, so focus can return back to the parent window
|
|
143
|
+
EnableWindow(m_parentHwnd, true);
|
|
275
144
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
|
|
280
|
-
uint32_t index) noexcept {
|
|
281
|
-
EnsureModalCreated();
|
|
282
|
-
base_type::MountChildComponentView(childComponentView, index);
|
|
283
|
-
}
|
|
145
|
+
if (m_window) {
|
|
146
|
+
m_window.Hide();
|
|
147
|
+
}
|
|
284
148
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
149
|
+
// dispatch onDismiss event
|
|
150
|
+
if (auto eventEmitter = EventEmitter()) {
|
|
151
|
+
::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnDismiss eventArgs;
|
|
152
|
+
eventEmitter->onDismiss(eventArgs);
|
|
153
|
+
}
|
|
290
154
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
AdjustWindowSize();
|
|
298
|
-
ShowOnUIThread();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
155
|
+
// reset the topWindowID
|
|
156
|
+
if (m_prevWindowID) {
|
|
157
|
+
winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
|
|
158
|
+
m_reactContext.Properties().Handle(), m_prevWindowID);
|
|
159
|
+
m_prevWindowID = 0;
|
|
160
|
+
}
|
|
301
161
|
|
|
302
|
-
|
|
303
|
-
if (m_layoutMetrics.overflowInset.right == 0 && m_layoutMetrics.overflowInset.bottom == 0) {
|
|
304
|
-
return;
|
|
162
|
+
m_bridge.Disable();
|
|
305
163
|
}
|
|
306
164
|
|
|
307
|
-
//
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
RECT rect = {0, 0, (int)xPos, (int)yPos};
|
|
313
|
-
|
|
314
|
-
if (m_showTitleBar) {
|
|
315
|
-
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); // Adjust for title bar and borders
|
|
316
|
-
}
|
|
165
|
+
// creates a new modal window
|
|
166
|
+
void EnsureModalCreated(const winrt::Microsoft::ReactNative::ComponentView &view) {
|
|
167
|
+
if (m_window) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
317
170
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
m_layoutMetrics.overflowInset.bottom = 0;
|
|
171
|
+
// get the root hwnd
|
|
172
|
+
m_prevWindowID =
|
|
173
|
+
winrt::Microsoft::ReactNative::ReactCoreInjection::GetTopLevelWindowId(view.ReactContext().Properties());
|
|
322
174
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
GetWindowRect(m_parentHwnd, &parentRC);
|
|
326
|
-
float xCor = (parentRC.left + parentRC.right - m_layoutMetrics.frame.size.width) / 2; // midpointx - width / 2
|
|
327
|
-
float yCor = (parentRC.top + parentRC.bottom - m_layoutMetrics.frame.size.height) / 2; // midpointy - height / 2
|
|
175
|
+
m_parentHwnd =
|
|
176
|
+
view.as<::Microsoft::ReactNative::Composition::Experimental::IComponentViewInterop>()->GetHwndForParenting();
|
|
328
177
|
|
|
329
|
-
|
|
330
|
-
|
|
178
|
+
auto presenter = winrt::Microsoft::UI::Windowing::OverlappedPresenter::CreateForDialog();
|
|
179
|
+
presenter.SetBorderAndTitleBar(true, false);
|
|
180
|
+
presenter.IsModal(true);
|
|
331
181
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
->NotifySizeChanged();
|
|
335
|
-
};
|
|
182
|
+
m_window = winrt::Microsoft::UI::Windowing::AppWindow::Create(
|
|
183
|
+
presenter, winrt::Microsoft::UI::GetWindowIdFromWindow(m_parentHwnd));
|
|
336
184
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
185
|
+
// set the top-level windows as the new hwnd
|
|
186
|
+
winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
|
|
187
|
+
view.ReactContext().Properties(),
|
|
188
|
+
reinterpret_cast<uint64_t>(winrt::Microsoft::UI::GetWindowFromWindowId(m_window.Id())));
|
|
189
|
+
|
|
190
|
+
// create a react native island - code taken from CompositionHwndHost
|
|
191
|
+
m_bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(
|
|
192
|
+
view.Parent().as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor(), m_window.Id());
|
|
193
|
+
m_reactNativeIsland = winrt::Microsoft::ReactNative::ReactNativeIsland::CreatePortal(
|
|
194
|
+
view.as<winrt::Microsoft::ReactNative::Composition::PortalComponentView>());
|
|
195
|
+
auto contentIsland = m_reactNativeIsland.Island();
|
|
196
|
+
|
|
197
|
+
auto navHost = winrt::Microsoft::UI::Input::InputFocusNavigationHost::GetForSiteBridge(m_bridge);
|
|
198
|
+
m_departFocusToken = navHost.DepartFocusRequested(
|
|
199
|
+
[wkView = winrt::make_weak(view)](
|
|
200
|
+
const auto &sender, const winrt::Microsoft::UI::Input::FocusNavigationRequestEventArgs &args) {
|
|
201
|
+
if (auto strongView = wkView.get()) {
|
|
202
|
+
TrySetFocus(strongView.Parent());
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
m_bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
|
|
207
|
+
m_bridge.Connect(contentIsland);
|
|
208
|
+
AdjustWindowSize(view.LayoutMetrics());
|
|
209
|
+
m_bridge.Show();
|
|
346
210
|
}
|
|
347
|
-
base_type::updateProps(props, oldProps);
|
|
348
|
-
}
|
|
349
211
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const facebook::react::ModalHostViewProps &WindowsModalHostComponentView::modalHostViewProps() const noexcept {
|
|
355
|
-
return *std::static_pointer_cast<const facebook::react::ModalHostViewProps>(viewProps());
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
facebook::react::Tag WindowsModalHostComponentView::hitTest(
|
|
359
|
-
facebook::react::Point pt,
|
|
360
|
-
facebook::react::Point &localPt,
|
|
361
|
-
bool ignorePointerEvents) const noexcept {
|
|
362
|
-
facebook::react::Point ptLocal{pt.x - m_layoutMetrics.frame.origin.x, pt.y - m_layoutMetrics.frame.origin.y};
|
|
363
|
-
|
|
364
|
-
if ((ignorePointerEvents || viewProps()->pointerEvents == facebook::react::PointerEventsMode::Auto ||
|
|
365
|
-
viewProps()->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
|
|
366
|
-
ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 &&
|
|
367
|
-
ptLocal.y <= m_layoutMetrics.frame.size.height) {
|
|
368
|
-
localPt = ptLocal;
|
|
369
|
-
return Tag();
|
|
212
|
+
static void TrySetFocus(const winrt::Microsoft::ReactNative::ComponentView &view) {
|
|
213
|
+
auto focusController = winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(
|
|
214
|
+
view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Root().ReactNativeIsland().Island());
|
|
215
|
+
focusController.TrySetFocus();
|
|
370
216
|
}
|
|
371
217
|
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
218
|
+
ReactContext m_reactContext{nullptr};
|
|
219
|
+
HWND m_parentHwnd{nullptr};
|
|
220
|
+
winrt::Microsoft::UI::Windowing::AppWindow m_window{nullptr};
|
|
221
|
+
uint64_t m_prevWindowID;
|
|
222
|
+
bool m_showTitleBar{false};
|
|
223
|
+
bool m_showQueued{false};
|
|
224
|
+
bool m_mounted{false};
|
|
225
|
+
winrt::Microsoft::UI::Input::InputFocusNavigationHost::DepartFocusRequested_revoker m_departFocusRevoker;
|
|
226
|
+
winrt::event_token m_departFocusToken;
|
|
227
|
+
winrt::Microsoft::UI::Content::DesktopChildSiteBridge m_bridge{nullptr};
|
|
228
|
+
winrt::Microsoft::ReactNative::ReactNativeIsland m_reactNativeIsland{nullptr};
|
|
229
|
+
};
|
|
378
230
|
|
|
379
|
-
|
|
380
|
-
|
|
231
|
+
void RegisterWindowsModalHostNativeComponent(
|
|
232
|
+
winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept {
|
|
233
|
+
::Microsoft::ReactNativeSpecs::RegisterModalHostViewNativeComponent<ModalHostView>(
|
|
234
|
+
packageBuilder,
|
|
235
|
+
[](const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder &builder) {
|
|
236
|
+
builder.SetPortalComponentViewInitializer(
|
|
237
|
+
[](const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portalComponentView) noexcept {
|
|
238
|
+
auto userData = winrt::make_self<ModalHostView>();
|
|
239
|
+
userData->InitializePortalViewComponent(portalComponentView);
|
|
240
|
+
portalComponentView.UserData(*userData);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
381
243
|
}
|
|
382
244
|
|
|
383
245
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -3,69 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
-
#include <
|
|
7
|
-
#include <Microsoft.ReactNative.Cxx/ReactContext.h>
|
|
8
|
-
|
|
9
|
-
#include "Composition.WindowsModalHostComponentView.g.h"
|
|
10
|
-
#include "../CompositionViewComponentView.h"
|
|
11
|
-
|
|
12
|
-
#include <Fabric/Composition/RootComponentView.h>
|
|
13
|
-
#include <react/components/rnwcore/ShadowNodes.h>
|
|
6
|
+
#include <winrt/Microsoft.ReactNative.h>
|
|
14
7
|
|
|
15
8
|
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
using Super = WindowsModalHostComponentViewT<WindowsModalHostComponentView, RootComponentView>;
|
|
20
|
-
|
|
21
|
-
~WindowsModalHostComponentView();
|
|
22
|
-
|
|
23
|
-
[[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
|
|
24
|
-
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
25
|
-
facebook::react::Tag tag,
|
|
26
|
-
winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept;
|
|
27
|
-
|
|
28
|
-
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual VisualToMountChildrenInto() noexcept override;
|
|
29
|
-
void MountChildComponentView(
|
|
30
|
-
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
|
|
31
|
-
uint32_t index) noexcept override;
|
|
32
|
-
void UnmountChildComponentView(
|
|
33
|
-
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
|
|
34
|
-
uint32_t index) noexcept override;
|
|
35
|
-
|
|
36
|
-
void AdjustWindowSize() noexcept;
|
|
37
|
-
|
|
38
|
-
void updateLayoutMetrics(
|
|
39
|
-
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
40
|
-
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
41
|
-
|
|
42
|
-
void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
|
|
43
|
-
override;
|
|
44
|
-
static facebook::react::SharedViewProps defaultProps() noexcept;
|
|
45
|
-
const facebook::react::ModalHostViewProps &modalHostViewProps() const noexcept;
|
|
46
|
-
bool focusable() const noexcept override;
|
|
47
|
-
facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
|
|
48
|
-
const noexcept override;
|
|
49
|
-
virtual std::string DefaultControlType() const noexcept;
|
|
50
|
-
|
|
51
|
-
WindowsModalHostComponentView(
|
|
52
|
-
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
53
|
-
facebook::react::Tag tag,
|
|
54
|
-
winrt::Microsoft::ReactNative::ReactContext const &reactContext);
|
|
55
|
-
|
|
56
|
-
// Used for creating new window
|
|
57
|
-
void ShowOnUIThread();
|
|
58
|
-
void HideOnUIThread() noexcept;
|
|
59
|
-
void EnsureModalCreated();
|
|
60
|
-
static void RegisterWndClass() noexcept;
|
|
61
|
-
|
|
62
|
-
private:
|
|
63
|
-
HWND m_parentHwnd{nullptr};
|
|
64
|
-
HWND m_hwnd{nullptr};
|
|
65
|
-
uint64_t m_prevWindowID;
|
|
66
|
-
bool m_isVisible{false};
|
|
67
|
-
bool m_showTitleBar{false};
|
|
68
|
-
winrt::Microsoft::ReactNative::ReactNativeIsland m_reactNativeIsland;
|
|
69
|
-
};
|
|
10
|
+
void RegisterWindowsModalHostNativeComponent(
|
|
11
|
+
winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept;
|
|
70
12
|
|
|
71
13
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|