react-native-windows 0.76.7 → 0.76.9

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 (136) hide show
  1. package/Libraries/Components/Button.windows.js +9 -0
  2. package/Libraries/Components/Pressable/Pressable.windows.js +9 -0
  3. package/Libraries/Components/TextInput/TextInput.windows.js +11 -1
  4. package/Libraries/Components/Touchable/TouchableBounce.windows.js +229 -0
  5. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +373 -0
  6. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +7 -0
  7. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +8 -0
  8. package/Libraries/Components/View/View.windows.js +11 -1
  9. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  10. package/Libraries/Components/View/ViewAccessibility.windows.js +3 -0
  11. package/Libraries/Components/View/ViewPropTypes.windows.js +3 -0
  12. package/Libraries/Core/ReactNativeVersion.js +1 -1
  13. package/Libraries/Image/Image.windows.js +7 -0
  14. package/Libraries/Modal/Modal.windows.js +4 -1
  15. package/Libraries/Text/Text.windows.js +14 -1
  16. package/Libraries/Text/TextProps.windows.js +3 -0
  17. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  18. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +97 -0
  19. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.h +53 -0
  20. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +160 -17
  21. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
  22. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -2
  23. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +428 -39
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +39 -1
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +55 -33
  27. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +5 -3
  28. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +43 -5
  29. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  30. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.cpp +115 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.h +41 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +298 -0
  33. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.h +59 -0
  34. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +106 -56
  35. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
  36. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +163 -10
  37. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +17 -1
  38. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +4 -2
  39. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +9 -1
  40. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +348 -316
  41. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  42. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +78 -0
  43. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  44. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +22 -0
  45. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -5
  46. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +99 -37
  47. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  48. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +81 -22
  49. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +21 -2
  50. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +6 -1
  51. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +41 -37
  52. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +76 -33
  53. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +8 -2
  54. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  55. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  56. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  57. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +5 -8
  58. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +1 -2
  59. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +1 -1
  60. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +15 -1
  61. package/Microsoft.ReactNative/IReactContext.cpp +2 -2
  62. package/Microsoft.ReactNative/IReactContext.h +1 -1
  63. package/Microsoft.ReactNative/IReactContext.idl +2 -2
  64. package/Microsoft.ReactNative/IReactPackageBuilder.idl +3 -3
  65. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +97 -87
  66. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +4 -0
  67. package/Microsoft.ReactNative/Modules/AlertModule.cpp +9 -4
  68. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +1 -1
  69. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +32 -35
  70. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h +7 -4
  71. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +1 -1
  72. package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +2 -2
  73. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +2 -2
  74. package/Microsoft.ReactNative/Modules/ClipboardModule.cpp +1 -1
  75. package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
  76. package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +3 -3
  77. package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +1 -1
  78. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +7 -5
  79. package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -1
  80. package/Microsoft.ReactNative/Modules/Timing.cpp +2 -2
  81. package/Microsoft.ReactNative/ReactHost/IReactInstance.h +5 -0
  82. package/Microsoft.ReactNative/ReactHost/React.h +0 -3
  83. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +36 -12
  84. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  85. package/Microsoft.ReactNative/ReactNativeHost.cpp +9 -4
  86. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  87. package/Microsoft.ReactNative/ReactPackageBuilder.cpp +3 -3
  88. package/Microsoft.ReactNative/ReactPackageBuilder.h +4 -4
  89. package/Microsoft.ReactNative/Utils/Helpers.cpp +0 -2
  90. package/Microsoft.ReactNative/Views/DevMenu.cpp +6 -6
  91. package/Microsoft.ReactNative/Views/DevMenu.h +1 -1
  92. package/Microsoft.ReactNative/XamlUIService.cpp +13 -7
  93. package/Microsoft.ReactNative/XamlUIService.h +4 -1
  94. package/Microsoft.ReactNative/XamlUIService.idl +2 -0
  95. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +6 -2
  96. package/Microsoft.ReactNative.Cxx/NativeModules.h +29 -0
  97. package/Microsoft.ReactNative.Cxx/ReactContext.h +1 -1
  98. package/Microsoft.ReactNative.Cxx/XamlUtils.h +12 -0
  99. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  100. package/PropertySheets/React.Cpp.props +3 -0
  101. package/PropertySheets/WebView2.props +1 -1
  102. package/PropertySheets/WinUI.props +5 -4
  103. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  104. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  105. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +39 -35
  106. package/Shared/InspectorPackagerConnection.cpp +2 -5
  107. package/Shared/InspectorPackagerConnection.h +2 -2
  108. package/Shared/Networking/WinRTWebSocketResource.cpp +369 -7
  109. package/Shared/Networking/WinRTWebSocketResource.h +118 -0
  110. package/Shared/Shared.vcxitems +12 -5
  111. package/Shared/Shared.vcxitems.filters +11 -4
  112. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +91 -97
  113. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +212 -0
  114. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +295 -0
  115. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +200 -0
  116. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +224 -0
  117. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +250 -0
  118. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +267 -0
  119. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +234 -0
  120. package/codegen/react/components/rnwcore/InputAccessory.g.h +200 -0
  121. package/codegen/react/components/rnwcore/ModalHostView.g.h +279 -0
  122. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +246 -0
  123. package/codegen/react/components/rnwcore/SafeAreaView.g.h +197 -0
  124. package/codegen/react/components/rnwcore/Switch.g.h +263 -0
  125. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +200 -0
  126. package/codegen/rnwcoreJSI-generated.cpp +0 -6
  127. package/codegen/rnwcoreJSI.h +0 -9
  128. package/jest/setup.js +5 -1
  129. package/just-task.js +1 -1
  130. package/package.json +11 -11
  131. package/src/private/featureflags/ReactNativeFeatureFlags.js +1 -6
  132. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +1 -2
  133. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +0 -191
  134. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  135. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  136. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -0,0 +1,212 @@
1
+
2
+ /*
3
+ * This file is auto-generated from ActivityIndicatorViewNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <NativeModules.h>
9
+
10
+ #ifdef RNW_NEW_ARCH
11
+ #include <JSValueComposition.h>
12
+
13
+ #include <winrt/Microsoft.ReactNative.Composition.h>
14
+ #include <winrt/Microsoft.UI.Composition.h>
15
+ #endif // #ifdef RNW_NEW_ARCH
16
+
17
+ #ifdef RNW_NEW_ARCH
18
+
19
+ namespace Microsoft::ReactNativeSpecs {
20
+
21
+ REACT_STRUCT(ActivityIndicatorViewProps)
22
+ struct ActivityIndicatorViewProps : winrt::implements<ActivityIndicatorViewProps, winrt::Microsoft::ReactNative::IComponentProps> {
23
+ ActivityIndicatorViewProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
24
+ : ViewProps(props)
25
+ {
26
+ if (cloneFrom) {
27
+ auto cloneFromProps = cloneFrom.as<ActivityIndicatorViewProps>();
28
+ hidesWhenStopped = cloneFromProps->hidesWhenStopped;
29
+ animating = cloneFromProps->animating;
30
+ color = cloneFromProps->color;
31
+ size = cloneFromProps->size;
32
+ }
33
+ }
34
+
35
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
36
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
37
+ }
38
+
39
+ REACT_FIELD(hidesWhenStopped)
40
+ bool hidesWhenStopped{true};
41
+
42
+ REACT_FIELD(animating)
43
+ bool animating{true};
44
+
45
+ REACT_FIELD(color)
46
+ winrt::Microsoft::ReactNative::Color color{nullptr};
47
+
48
+ REACT_FIELD(size)
49
+ std::optional<std::string> size;
50
+
51
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
52
+ };
53
+
54
+ struct ActivityIndicatorViewEventEmitter {
55
+ ActivityIndicatorViewEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
56
+ : m_eventEmitter(eventEmitter) {}
57
+
58
+ private:
59
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
60
+ };
61
+
62
+ template<typename TUserData>
63
+ struct BaseActivityIndicatorView {
64
+
65
+ virtual void UpdateProps(
66
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
67
+ const winrt::com_ptr<ActivityIndicatorViewProps> &newProps,
68
+ const winrt::com_ptr<ActivityIndicatorViewProps> &/*oldProps*/) noexcept {
69
+ m_props = newProps;
70
+ }
71
+
72
+ // UpdateLayoutMetrics will only be called if this method is overridden
73
+ virtual void UpdateLayoutMetrics(
74
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
75
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
76
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
77
+ }
78
+
79
+ // UpdateState will only be called if this method is overridden
80
+ virtual void UpdateState(
81
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
82
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
83
+ }
84
+
85
+ virtual void UpdateEventEmitter(const std::shared_ptr<ActivityIndicatorViewEventEmitter> &eventEmitter) noexcept {
86
+ m_eventEmitter = eventEmitter;
87
+ }
88
+
89
+ // MountChildComponentView will only be called if this method is overridden
90
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
91
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
92
+ }
93
+
94
+ // UnmountChildComponentView will only be called if this method is overridden
95
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
96
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
97
+ }
98
+
99
+ // Initialize will only be called if this method is overridden
100
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
101
+ }
102
+
103
+ // CreateVisual will only be called if this method is overridden
104
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
105
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
106
+ }
107
+
108
+ // FinalizeUpdate will only be called if this method is overridden
109
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
110
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
111
+ }
112
+
113
+
114
+
115
+ const std::shared_ptr<ActivityIndicatorViewEventEmitter>& EventEmitter() const { return m_eventEmitter; }
116
+ const winrt::com_ptr<ActivityIndicatorViewProps>& Props() const { return m_props; }
117
+
118
+ private:
119
+ winrt::com_ptr<ActivityIndicatorViewProps> m_props;
120
+ std::shared_ptr<ActivityIndicatorViewEventEmitter> m_eventEmitter;
121
+ };
122
+
123
+ template <typename TUserData>
124
+ void RegisterActivityIndicatorViewNativeComponent(
125
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
126
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
127
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
128
+ L"ActivityIndicatorView", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
129
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
130
+
131
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
132
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
133
+ return winrt::make<ActivityIndicatorViewProps>(props, cloneFrom);
134
+ });
135
+
136
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
137
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
138
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
139
+ auto userData = view.UserData().as<TUserData>();
140
+ userData->UpdateProps(view, newProps ? newProps.as<ActivityIndicatorViewProps>() : nullptr, oldProps ? oldProps.as<ActivityIndicatorViewProps>() : nullptr);
141
+ });
142
+
143
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
144
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
145
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
146
+ auto userData = view.UserData().as<TUserData>();
147
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
148
+ });
149
+
150
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
151
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
152
+ auto userData = view.UserData().as<TUserData>();
153
+ userData->UpdateEventEmitter(std::make_shared<ActivityIndicatorViewEventEmitter>(eventEmitter));
154
+ });
155
+
156
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseActivityIndicatorView<TUserData>::FinalizeUpdate) {
157
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
158
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
159
+ auto userData = view.UserData().as<TUserData>();
160
+ userData->FinalizeUpdate(view, mask);
161
+ });
162
+ }
163
+
164
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseActivityIndicatorView<TUserData>::UpdateState) {
165
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
166
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
167
+ auto userData = view.UserData().as<TUserData>();
168
+ userData->UpdateState(view, newState);
169
+ });
170
+ }
171
+
172
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseActivityIndicatorView<TUserData>::MountChildComponentView) {
173
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
174
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
175
+ auto userData = view.UserData().as<TUserData>();
176
+ return userData->MountChildComponentView(view, args);
177
+ });
178
+ }
179
+
180
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseActivityIndicatorView<TUserData>::UnmountChildComponentView) {
181
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
182
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
183
+ auto userData = view.UserData().as<TUserData>();
184
+ return userData->UnmountChildComponentView(view, args);
185
+ });
186
+ }
187
+
188
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
189
+ auto userData = winrt::make_self<TUserData>();
190
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseActivityIndicatorView<TUserData>::Initialize) {
191
+ userData->Initialize(view);
192
+ }
193
+ view.UserData(*userData);
194
+ });
195
+
196
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseActivityIndicatorView<TUserData>::CreateVisual) {
197
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
198
+ auto userData = view.UserData().as<TUserData>();
199
+ return userData->CreateVisual(view);
200
+ });
201
+ }
202
+
203
+ // Allow app to further customize the builder
204
+ if (builderCallback) {
205
+ builderCallback(compBuilder);
206
+ }
207
+ });
208
+ }
209
+
210
+ } // namespace Microsoft::ReactNativeSpecs
211
+
212
+ #endif // #ifdef RNW_NEW_ARCH
@@ -0,0 +1,295 @@
1
+
2
+ /*
3
+ * This file is auto-generated from AndroidDrawerLayoutNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <NativeModules.h>
9
+
10
+ #ifdef RNW_NEW_ARCH
11
+ #include <JSValueComposition.h>
12
+
13
+ #include <winrt/Microsoft.ReactNative.Composition.h>
14
+ #include <winrt/Microsoft.UI.Composition.h>
15
+ #endif // #ifdef RNW_NEW_ARCH
16
+
17
+ #ifdef RNW_NEW_ARCH
18
+
19
+ namespace Microsoft::ReactNativeSpecs {
20
+
21
+ REACT_STRUCT(AndroidDrawerLayoutProps)
22
+ struct AndroidDrawerLayoutProps : winrt::implements<AndroidDrawerLayoutProps, winrt::Microsoft::ReactNative::IComponentProps> {
23
+ AndroidDrawerLayoutProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
24
+ : ViewProps(props)
25
+ {
26
+ if (cloneFrom) {
27
+ auto cloneFromProps = cloneFrom.as<AndroidDrawerLayoutProps>();
28
+ keyboardDismissMode = cloneFromProps->keyboardDismissMode;
29
+ drawerBackgroundColor = cloneFromProps->drawerBackgroundColor;
30
+ drawerPosition = cloneFromProps->drawerPosition;
31
+ drawerWidth = cloneFromProps->drawerWidth;
32
+ drawerLockMode = cloneFromProps->drawerLockMode;
33
+ statusBarBackgroundColor = cloneFromProps->statusBarBackgroundColor;
34
+ }
35
+ }
36
+
37
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
38
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
39
+ }
40
+
41
+ REACT_FIELD(keyboardDismissMode)
42
+ std::optional<std::string> keyboardDismissMode;
43
+
44
+ REACT_FIELD(drawerBackgroundColor)
45
+ winrt::Microsoft::ReactNative::Color drawerBackgroundColor{nullptr};
46
+
47
+ REACT_FIELD(drawerPosition)
48
+ std::optional<std::string> drawerPosition;
49
+
50
+ REACT_FIELD(drawerWidth)
51
+ std::optional<float> drawerWidth{};
52
+
53
+ REACT_FIELD(drawerLockMode)
54
+ std::optional<std::string> drawerLockMode;
55
+
56
+ REACT_FIELD(statusBarBackgroundColor)
57
+ winrt::Microsoft::ReactNative::Color statusBarBackgroundColor{nullptr};
58
+
59
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
60
+ };
61
+
62
+ REACT_STRUCT(AndroidDrawerLayout_OnDrawerSlide)
63
+ struct AndroidDrawerLayout_OnDrawerSlide {
64
+ REACT_FIELD(offset)
65
+ float offset{};
66
+ };
67
+
68
+ REACT_STRUCT(AndroidDrawerLayout_OnDrawerStateChanged)
69
+ struct AndroidDrawerLayout_OnDrawerStateChanged {
70
+ REACT_FIELD(drawerState)
71
+ int32_t drawerState{};
72
+ };
73
+
74
+ REACT_STRUCT(AndroidDrawerLayout_OnDrawerOpen)
75
+ struct AndroidDrawerLayout_OnDrawerOpen {
76
+ };
77
+
78
+ REACT_STRUCT(AndroidDrawerLayout_OnDrawerClose)
79
+ struct AndroidDrawerLayout_OnDrawerClose {
80
+ };
81
+
82
+ struct AndroidDrawerLayoutEventEmitter {
83
+ AndroidDrawerLayoutEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
84
+ : m_eventEmitter(eventEmitter) {}
85
+
86
+ using OnDrawerSlide = AndroidDrawerLayout_OnDrawerSlide;
87
+ using OnDrawerStateChanged = AndroidDrawerLayout_OnDrawerStateChanged;
88
+ using OnDrawerOpen = AndroidDrawerLayout_OnDrawerOpen;
89
+ using OnDrawerClose = AndroidDrawerLayout_OnDrawerClose;
90
+
91
+ void onDrawerSlide(OnDrawerSlide &value) const {
92
+ m_eventEmitter.DispatchEvent(L"drawerSlide", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
93
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
94
+ });
95
+ }
96
+
97
+ void onDrawerStateChanged(OnDrawerStateChanged &value) const {
98
+ m_eventEmitter.DispatchEvent(L"drawerStateChanged", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
99
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
100
+ });
101
+ }
102
+
103
+ void onDrawerOpen(OnDrawerOpen &value) const {
104
+ m_eventEmitter.DispatchEvent(L"drawerOpen", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
105
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
106
+ });
107
+ }
108
+
109
+ void onDrawerClose(OnDrawerClose &value) const {
110
+ m_eventEmitter.DispatchEvent(L"drawerClose", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
111
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
112
+ });
113
+ }
114
+
115
+ private:
116
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
117
+ };
118
+
119
+ template<typename TUserData>
120
+ struct BaseAndroidDrawerLayout {
121
+
122
+ virtual void UpdateProps(
123
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
124
+ const winrt::com_ptr<AndroidDrawerLayoutProps> &newProps,
125
+ const winrt::com_ptr<AndroidDrawerLayoutProps> &/*oldProps*/) noexcept {
126
+ m_props = newProps;
127
+ }
128
+
129
+ // UpdateLayoutMetrics will only be called if this method is overridden
130
+ virtual void UpdateLayoutMetrics(
131
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
132
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
133
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
134
+ }
135
+
136
+ // UpdateState will only be called if this method is overridden
137
+ virtual void UpdateState(
138
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
139
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
140
+ }
141
+
142
+ virtual void UpdateEventEmitter(const std::shared_ptr<AndroidDrawerLayoutEventEmitter> &eventEmitter) noexcept {
143
+ m_eventEmitter = eventEmitter;
144
+ }
145
+
146
+ // MountChildComponentView will only be called if this method is overridden
147
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
148
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
149
+ }
150
+
151
+ // UnmountChildComponentView will only be called if this method is overridden
152
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
153
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
154
+ }
155
+
156
+ // Initialize will only be called if this method is overridden
157
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
158
+ }
159
+
160
+ // CreateVisual will only be called if this method is overridden
161
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
162
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
163
+ }
164
+
165
+ // FinalizeUpdate will only be called if this method is overridden
166
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
167
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
168
+ }
169
+
170
+ // You must provide an implementation of this method to handle the "openDrawer" command
171
+ virtual void HandleOpenDrawerCommand() noexcept = 0;
172
+
173
+ // You must provide an implementation of this method to handle the "closeDrawer" command
174
+ virtual void HandleCloseDrawerCommand() noexcept = 0;
175
+
176
+ void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
177
+ auto userData = view.UserData().as<TUserData>();
178
+ auto commandName = args.CommandName();
179
+ if (commandName == L"openDrawer") {
180
+
181
+ userData->HandleOpenDrawerCommand();
182
+ return;
183
+ }
184
+
185
+ if (commandName == L"closeDrawer") {
186
+
187
+ userData->HandleCloseDrawerCommand();
188
+ return;
189
+ }
190
+ }
191
+
192
+ const std::shared_ptr<AndroidDrawerLayoutEventEmitter>& EventEmitter() const { return m_eventEmitter; }
193
+ const winrt::com_ptr<AndroidDrawerLayoutProps>& Props() const { return m_props; }
194
+
195
+ private:
196
+ winrt::com_ptr<AndroidDrawerLayoutProps> m_props;
197
+ std::shared_ptr<AndroidDrawerLayoutEventEmitter> m_eventEmitter;
198
+ };
199
+
200
+ template <typename TUserData>
201
+ void RegisterAndroidDrawerLayoutNativeComponent(
202
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
203
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
204
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
205
+ L"AndroidDrawerLayout", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
206
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
207
+
208
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
209
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
210
+ return winrt::make<AndroidDrawerLayoutProps>(props, cloneFrom);
211
+ });
212
+
213
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
214
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
215
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
216
+ auto userData = view.UserData().as<TUserData>();
217
+ userData->UpdateProps(view, newProps ? newProps.as<AndroidDrawerLayoutProps>() : nullptr, oldProps ? oldProps.as<AndroidDrawerLayoutProps>() : nullptr);
218
+ });
219
+
220
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
221
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
222
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
223
+ auto userData = view.UserData().as<TUserData>();
224
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
225
+ });
226
+
227
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
228
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
229
+ auto userData = view.UserData().as<TUserData>();
230
+ userData->UpdateEventEmitter(std::make_shared<AndroidDrawerLayoutEventEmitter>(eventEmitter));
231
+ });
232
+
233
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseAndroidDrawerLayout<TUserData>::FinalizeUpdate) {
234
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
235
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
236
+ auto userData = view.UserData().as<TUserData>();
237
+ userData->FinalizeUpdate(view, mask);
238
+ });
239
+ }
240
+
241
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseAndroidDrawerLayout<TUserData>::UpdateState) {
242
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
243
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
244
+ auto userData = view.UserData().as<TUserData>();
245
+ userData->UpdateState(view, newState);
246
+ });
247
+ }
248
+
249
+ builder.SetCustomCommandHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
250
+ const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
251
+ auto userData = view.UserData().as<TUserData>();
252
+ userData->HandleCommand(view, args);
253
+ });
254
+
255
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseAndroidDrawerLayout<TUserData>::MountChildComponentView) {
256
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
257
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
258
+ auto userData = view.UserData().as<TUserData>();
259
+ return userData->MountChildComponentView(view, args);
260
+ });
261
+ }
262
+
263
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseAndroidDrawerLayout<TUserData>::UnmountChildComponentView) {
264
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
265
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
266
+ auto userData = view.UserData().as<TUserData>();
267
+ return userData->UnmountChildComponentView(view, args);
268
+ });
269
+ }
270
+
271
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
272
+ auto userData = winrt::make_self<TUserData>();
273
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseAndroidDrawerLayout<TUserData>::Initialize) {
274
+ userData->Initialize(view);
275
+ }
276
+ view.UserData(*userData);
277
+ });
278
+
279
+ if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseAndroidDrawerLayout<TUserData>::CreateVisual) {
280
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
281
+ auto userData = view.UserData().as<TUserData>();
282
+ return userData->CreateVisual(view);
283
+ });
284
+ }
285
+
286
+ // Allow app to further customize the builder
287
+ if (builderCallback) {
288
+ builderCallback(compBuilder);
289
+ }
290
+ });
291
+ }
292
+
293
+ } // namespace Microsoft::ReactNativeSpecs
294
+
295
+ #endif // #ifdef RNW_NEW_ARCH