react-native-windows 0.74.28 → 0.74.30

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 (71) 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 +225 -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 +10 -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 +5 -2
  11. package/Libraries/Components/View/ViewPropTypes.windows.js +3 -0
  12. package/Libraries/Image/Image.windows.js +7 -0
  13. package/Libraries/Text/Text.windows.js +11 -1
  14. package/Libraries/Text/TextProps.windows.js +3 -0
  15. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  16. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -2
  17. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  18. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +293 -9
  20. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +28 -1
  21. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +13 -32
  22. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -3
  23. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +1 -1
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +18 -5
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +1 -1
  27. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +191 -329
  28. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  29. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +66 -0
  30. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +21 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -4
  33. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +79 -19
  34. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  35. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +71 -17
  36. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +16 -0
  37. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
  38. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +1 -1
  39. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +62 -33
  40. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +5 -2
  41. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  42. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  43. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  44. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +5 -0
  45. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +19 -1
  46. package/Microsoft.ReactNative/ReactNativeHost.cpp +5 -0
  47. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  48. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +6 -2
  49. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  50. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  51. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  52. package/Shared/Shared.vcxitems +3 -2
  53. package/Shared/Shared.vcxitems.filters +2 -3
  54. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +204 -0
  55. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +287 -0
  56. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +192 -0
  57. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +216 -0
  58. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +242 -0
  59. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +259 -0
  60. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +226 -0
  61. package/codegen/react/components/rnwcore/InputAccessory.g.h +192 -0
  62. package/codegen/react/components/rnwcore/ModalHostView.g.h +271 -0
  63. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +238 -0
  64. package/codegen/react/components/rnwcore/SafeAreaView.g.h +189 -0
  65. package/codegen/react/components/rnwcore/Switch.g.h +255 -0
  66. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +192 -0
  67. package/just-task.js +1 -1
  68. package/package.json +1 -1
  69. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  70. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  71. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -0,0 +1,271 @@
1
+
2
+ /*
3
+ * This file is auto-generated from ModalHostViewNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <JSValueComposition.h>
9
+ #include <NativeModules.h>
10
+ #include <winrt/Microsoft.ReactNative.Composition.h>
11
+ #include <winrt/Microsoft.UI.Composition.h>
12
+
13
+ namespace Microsoft::ReactNativeSpecs {
14
+
15
+ REACT_STRUCT(ModalHostViewProps)
16
+ struct ModalHostViewProps : winrt::implements<ModalHostViewProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ ModalHostViewProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<ModalHostViewProps>();
22
+ animationType = cloneFromProps->animationType;
23
+ presentationStyle = cloneFromProps->presentationStyle;
24
+ transparent = cloneFromProps->transparent;
25
+ statusBarTranslucent = cloneFromProps->statusBarTranslucent;
26
+ hardwareAccelerated = cloneFromProps->hardwareAccelerated;
27
+ visible = cloneFromProps->visible;
28
+ animated = cloneFromProps->animated;
29
+ supportedOrientations = cloneFromProps->supportedOrientations;
30
+ identifier = cloneFromProps->identifier;
31
+ }
32
+ }
33
+
34
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
35
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
36
+ }
37
+
38
+ REACT_FIELD(animationType)
39
+ std::optional<std::string> animationType;
40
+
41
+ REACT_FIELD(presentationStyle)
42
+ std::optional<std::string> presentationStyle;
43
+
44
+ REACT_FIELD(transparent)
45
+ std::optional<bool> transparent{};
46
+
47
+ REACT_FIELD(statusBarTranslucent)
48
+ std::optional<bool> statusBarTranslucent{};
49
+
50
+ REACT_FIELD(hardwareAccelerated)
51
+ std::optional<bool> hardwareAccelerated{};
52
+
53
+ REACT_FIELD(visible)
54
+ std::optional<bool> visible{};
55
+
56
+ REACT_FIELD(animated)
57
+ std::optional<bool> animated{};
58
+
59
+ REACT_FIELD(supportedOrientations)
60
+ std::optional<std::vector<std::string>> supportedOrientations;
61
+
62
+ REACT_FIELD(identifier)
63
+ std::optional<int32_t> identifier{};
64
+
65
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
66
+ };
67
+
68
+ REACT_STRUCT(ModalHostView_OnRequestClose)
69
+ struct ModalHostView_OnRequestClose {
70
+ };
71
+
72
+ REACT_STRUCT(ModalHostView_OnShow)
73
+ struct ModalHostView_OnShow {
74
+ };
75
+
76
+ REACT_STRUCT(ModalHostView_OnDismiss)
77
+ struct ModalHostView_OnDismiss {
78
+ };
79
+
80
+ REACT_STRUCT(ModalHostView_OnOrientationChange)
81
+ struct ModalHostView_OnOrientationChange {
82
+ REACT_FIELD(orientation)
83
+ std::string orientation;
84
+ };
85
+
86
+ struct ModalHostViewEventEmitter {
87
+ ModalHostViewEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
88
+ : m_eventEmitter(eventEmitter) {}
89
+
90
+ using OnRequestClose = ModalHostView_OnRequestClose;
91
+ using OnShow = ModalHostView_OnShow;
92
+ using OnDismiss = ModalHostView_OnDismiss;
93
+ using OnOrientationChange = ModalHostView_OnOrientationChange;
94
+
95
+ void onRequestClose(OnRequestClose &value) const {
96
+ m_eventEmitter.DispatchEvent(L"requestClose", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
97
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
98
+ });
99
+ }
100
+
101
+ void onShow(OnShow &value) const {
102
+ m_eventEmitter.DispatchEvent(L"show", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
103
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
104
+ });
105
+ }
106
+
107
+ void onDismiss(OnDismiss &value) const {
108
+ m_eventEmitter.DispatchEvent(L"dismiss", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
109
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
110
+ });
111
+ }
112
+
113
+ void onOrientationChange(OnOrientationChange &value) const {
114
+ m_eventEmitter.DispatchEvent(L"orientationChange", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
115
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
116
+ });
117
+ }
118
+
119
+ private:
120
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
121
+ };
122
+
123
+ template<typename TUserData>
124
+ struct BaseModalHostView {
125
+
126
+ virtual void UpdateProps(
127
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
128
+ const winrt::com_ptr<ModalHostViewProps> &newProps,
129
+ const winrt::com_ptr<ModalHostViewProps> &/*oldProps*/) noexcept {
130
+ m_props = newProps;
131
+ }
132
+
133
+ // UpdateLayoutMetrics will only be called if this method is overridden
134
+ virtual void UpdateLayoutMetrics(
135
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
136
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
137
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
138
+ }
139
+
140
+ // UpdateState will only be called if this method is overridden
141
+ virtual void UpdateState(
142
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
143
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
144
+ }
145
+
146
+ virtual void UpdateEventEmitter(const std::shared_ptr<ModalHostViewEventEmitter> &eventEmitter) noexcept {
147
+ m_eventEmitter = eventEmitter;
148
+ }
149
+
150
+ // MountChildComponentView will only be called if this method is overridden
151
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
152
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
153
+ }
154
+
155
+ // UnmountChildComponentView will only be called if this method is overridden
156
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
157
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
158
+ }
159
+
160
+ // Initialize will only be called if this method is overridden
161
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
162
+ }
163
+
164
+ // CreateVisual will only be called if this method is overridden
165
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
166
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
167
+ }
168
+
169
+ // FinalizeUpdate will only be called if this method is overridden
170
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
171
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
172
+ }
173
+
174
+
175
+
176
+ const std::shared_ptr<ModalHostViewEventEmitter>& EventEmitter() const { return m_eventEmitter; }
177
+ const winrt::com_ptr<ModalHostViewProps>& Props() const { return m_props; }
178
+
179
+ private:
180
+ winrt::com_ptr<ModalHostViewProps> m_props;
181
+ std::shared_ptr<ModalHostViewEventEmitter> m_eventEmitter;
182
+ };
183
+
184
+ template <typename TUserData>
185
+ void RegisterModalHostViewNativeComponent(
186
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
187
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
188
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
189
+ L"ModalHostView", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
190
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
191
+
192
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
193
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
194
+ return winrt::make<ModalHostViewProps>(props, cloneFrom);
195
+ });
196
+
197
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
198
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
199
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
200
+ auto userData = view.UserData().as<TUserData>();
201
+ userData->UpdateProps(view, newProps ? newProps.as<ModalHostViewProps>() : nullptr, oldProps ? oldProps.as<ModalHostViewProps>() : nullptr);
202
+ });
203
+
204
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
205
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
206
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
207
+ auto userData = view.UserData().as<TUserData>();
208
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
209
+ });
210
+
211
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
212
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
213
+ auto userData = view.UserData().as<TUserData>();
214
+ userData->UpdateEventEmitter(std::make_shared<ModalHostViewEventEmitter>(eventEmitter));
215
+ });
216
+
217
+ if constexpr (&TUserData::FinalizeUpdate != &BaseModalHostView<TUserData>::FinalizeUpdate) {
218
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
219
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
220
+ auto userData = view.UserData().as<TUserData>();
221
+ userData->FinalizeUpdate(view, mask);
222
+ });
223
+ }
224
+
225
+ if constexpr (&TUserData::UpdateState != &BaseModalHostView<TUserData>::UpdateState) {
226
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
227
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
228
+ auto userData = view.UserData().as<TUserData>();
229
+ userData->member(view, newState);
230
+ });
231
+ }
232
+
233
+ if constexpr (&TUserData::MountChildComponentView != &BaseModalHostView<TUserData>::MountChildComponentView) {
234
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
235
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
236
+ auto userData = view.UserData().as<TUserData>();
237
+ return userData->MountChildComponentView(view, args);
238
+ });
239
+ }
240
+
241
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseModalHostView<TUserData>::UnmountChildComponentView) {
242
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
243
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
244
+ auto userData = view.UserData().as<TUserData>();
245
+ return userData->UnmountChildComponentView(view, args);
246
+ });
247
+ }
248
+
249
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
250
+ auto userData = winrt::make_self<TUserData>();
251
+ if constexpr (&TUserData::Initialize != &BaseModalHostView<TUserData>::Initialize) {
252
+ userData->Initialize(view);
253
+ }
254
+ view.UserData(*userData);
255
+ });
256
+
257
+ if constexpr (&TUserData::CreateVisual != &BaseModalHostView<TUserData>::CreateVisual) {
258
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
259
+ auto userData = view.UserData().as<TUserData>();
260
+ return userData->CreateVisual(view);
261
+ });
262
+ }
263
+
264
+ // Allow app to further customize the builder
265
+ if (builderCallback) {
266
+ builderCallback(compBuilder);
267
+ }
268
+ });
269
+ }
270
+
271
+ } // namespace Microsoft::ReactNativeSpecs
@@ -0,0 +1,238 @@
1
+
2
+ /*
3
+ * This file is auto-generated from PullToRefreshViewNativeComponent spec file in flow / TypeScript.
4
+ */
5
+ // clang-format off
6
+ #pragma once
7
+
8
+ #include <JSValueComposition.h>
9
+ #include <NativeModules.h>
10
+ #include <winrt/Microsoft.ReactNative.Composition.h>
11
+ #include <winrt/Microsoft.UI.Composition.h>
12
+
13
+ namespace Microsoft::ReactNativeSpecs {
14
+
15
+ REACT_STRUCT(PullToRefreshViewProps)
16
+ struct PullToRefreshViewProps : winrt::implements<PullToRefreshViewProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ PullToRefreshViewProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<PullToRefreshViewProps>();
22
+ tintColor = cloneFromProps->tintColor;
23
+ titleColor = cloneFromProps->titleColor;
24
+ title = cloneFromProps->title;
25
+ progressViewOffset = cloneFromProps->progressViewOffset;
26
+ refreshing = cloneFromProps->refreshing;
27
+ }
28
+ }
29
+
30
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
31
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
32
+ }
33
+
34
+ REACT_FIELD(tintColor)
35
+ winrt::Microsoft::ReactNative::Color tintColor{nullptr};
36
+
37
+ REACT_FIELD(titleColor)
38
+ winrt::Microsoft::ReactNative::Color titleColor{nullptr};
39
+
40
+ REACT_FIELD(title)
41
+ std::optional<std::string> title;
42
+
43
+ REACT_FIELD(progressViewOffset)
44
+ std::optional<float> progressViewOffset{};
45
+
46
+ REACT_FIELD(refreshing)
47
+ bool refreshing{};
48
+
49
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
50
+ };
51
+
52
+ REACT_STRUCT(PullToRefreshView_OnRefresh)
53
+ struct PullToRefreshView_OnRefresh {
54
+ };
55
+
56
+ struct PullToRefreshViewEventEmitter {
57
+ PullToRefreshViewEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
58
+ : m_eventEmitter(eventEmitter) {}
59
+
60
+ using OnRefresh = PullToRefreshView_OnRefresh;
61
+
62
+ void onRefresh(OnRefresh &value) const {
63
+ m_eventEmitter.DispatchEvent(L"refresh", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
64
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
65
+ });
66
+ }
67
+
68
+ private:
69
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
70
+ };
71
+
72
+ template<typename TUserData>
73
+ struct BasePullToRefreshView {
74
+
75
+ virtual void UpdateProps(
76
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
77
+ const winrt::com_ptr<PullToRefreshViewProps> &newProps,
78
+ const winrt::com_ptr<PullToRefreshViewProps> &/*oldProps*/) noexcept {
79
+ m_props = newProps;
80
+ }
81
+
82
+ // UpdateLayoutMetrics will only be called if this method is overridden
83
+ virtual void UpdateLayoutMetrics(
84
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
85
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
86
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
87
+ }
88
+
89
+ // UpdateState will only be called if this method is overridden
90
+ virtual void UpdateState(
91
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
92
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
93
+ }
94
+
95
+ virtual void UpdateEventEmitter(const std::shared_ptr<PullToRefreshViewEventEmitter> &eventEmitter) noexcept {
96
+ m_eventEmitter = eventEmitter;
97
+ }
98
+
99
+ // MountChildComponentView will only be called if this method is overridden
100
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
101
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
102
+ }
103
+
104
+ // UnmountChildComponentView will only be called if this method is overridden
105
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
106
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
107
+ }
108
+
109
+ // Initialize will only be called if this method is overridden
110
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
111
+ }
112
+
113
+ // CreateVisual will only be called if this method is overridden
114
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
115
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
116
+ }
117
+
118
+ // FinalizeUpdate will only be called if this method is overridden
119
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
120
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
121
+ }
122
+
123
+ // You must provide an implementation of this method to handle the "setNativeRefreshing" command
124
+ virtual void HandleSetNativeRefreshingCommand(bool refreshing) noexcept = 0;
125
+
126
+ void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
127
+ auto userData = view.UserData().as<TUserData>();
128
+ auto commandName = args.CommandName();
129
+ if (commandName == L"setNativeRefreshing") {
130
+ bool refreshing;
131
+ winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), refreshing);
132
+ userData->HandleSetNativeRefreshingCommand(refreshing);
133
+ return;
134
+ }
135
+ }
136
+
137
+ const std::shared_ptr<PullToRefreshViewEventEmitter>& EventEmitter() const { return m_eventEmitter; }
138
+ const winrt::com_ptr<PullToRefreshViewProps>& Props() const { return m_props; }
139
+
140
+ private:
141
+ winrt::com_ptr<PullToRefreshViewProps> m_props;
142
+ std::shared_ptr<PullToRefreshViewEventEmitter> m_eventEmitter;
143
+ };
144
+
145
+ template <typename TUserData>
146
+ void RegisterPullToRefreshViewNativeComponent(
147
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
148
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
149
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
150
+ L"PullToRefreshView", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
151
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
152
+
153
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
154
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
155
+ return winrt::make<PullToRefreshViewProps>(props, cloneFrom);
156
+ });
157
+
158
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
159
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
160
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
161
+ auto userData = view.UserData().as<TUserData>();
162
+ userData->UpdateProps(view, newProps ? newProps.as<PullToRefreshViewProps>() : nullptr, oldProps ? oldProps.as<PullToRefreshViewProps>() : nullptr);
163
+ });
164
+
165
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
166
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
167
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
168
+ auto userData = view.UserData().as<TUserData>();
169
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
170
+ });
171
+
172
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
173
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
174
+ auto userData = view.UserData().as<TUserData>();
175
+ userData->UpdateEventEmitter(std::make_shared<PullToRefreshViewEventEmitter>(eventEmitter));
176
+ });
177
+
178
+ if constexpr (&TUserData::FinalizeUpdate != &BasePullToRefreshView<TUserData>::FinalizeUpdate) {
179
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
180
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
181
+ auto userData = view.UserData().as<TUserData>();
182
+ userData->FinalizeUpdate(view, mask);
183
+ });
184
+ }
185
+
186
+ if constexpr (&TUserData::UpdateState != &BasePullToRefreshView<TUserData>::UpdateState) {
187
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
188
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
189
+ auto userData = view.UserData().as<TUserData>();
190
+ userData->member(view, newState);
191
+ });
192
+ }
193
+
194
+ builder.SetCustomCommandHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
195
+ const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
196
+ auto userData = view.UserData().as<TUserData>();
197
+ userData->HandleCommand(view, args);
198
+ });
199
+
200
+ if constexpr (&TUserData::MountChildComponentView != &BasePullToRefreshView<TUserData>::MountChildComponentView) {
201
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
202
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
203
+ auto userData = view.UserData().as<TUserData>();
204
+ return userData->MountChildComponentView(view, args);
205
+ });
206
+ }
207
+
208
+ if constexpr (&TUserData::UnmountChildComponentView != &BasePullToRefreshView<TUserData>::UnmountChildComponentView) {
209
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
210
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
211
+ auto userData = view.UserData().as<TUserData>();
212
+ return userData->UnmountChildComponentView(view, args);
213
+ });
214
+ }
215
+
216
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
217
+ auto userData = winrt::make_self<TUserData>();
218
+ if constexpr (&TUserData::Initialize != &BasePullToRefreshView<TUserData>::Initialize) {
219
+ userData->Initialize(view);
220
+ }
221
+ view.UserData(*userData);
222
+ });
223
+
224
+ if constexpr (&TUserData::CreateVisual != &BasePullToRefreshView<TUserData>::CreateVisual) {
225
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
226
+ auto userData = view.UserData().as<TUserData>();
227
+ return userData->CreateVisual(view);
228
+ });
229
+ }
230
+
231
+ // Allow app to further customize the builder
232
+ if (builderCallback) {
233
+ builderCallback(compBuilder);
234
+ }
235
+ });
236
+ }
237
+
238
+ } // namespace Microsoft::ReactNativeSpecs