react-native-windows 0.74.29 → 0.74.31

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 (70) 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/PropertySheets/Generated/PackageVersion.g.props +3 -3
  49. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  50. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  51. package/Shared/Shared.vcxitems +3 -2
  52. package/Shared/Shared.vcxitems.filters +2 -3
  53. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +204 -0
  54. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +287 -0
  55. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +192 -0
  56. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +216 -0
  57. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +242 -0
  58. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +259 -0
  59. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +226 -0
  60. package/codegen/react/components/rnwcore/InputAccessory.g.h +192 -0
  61. package/codegen/react/components/rnwcore/ModalHostView.g.h +271 -0
  62. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +238 -0
  63. package/codegen/react/components/rnwcore/SafeAreaView.g.h +189 -0
  64. package/codegen/react/components/rnwcore/Switch.g.h +255 -0
  65. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +192 -0
  66. package/just-task.js +1 -1
  67. package/package.json +1 -1
  68. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  69. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  70. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -0,0 +1,192 @@
1
+
2
+ /*
3
+ * This file is auto-generated from AndroidHorizontalScrollContentViewNativeComponent 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(AndroidHorizontalScrollContentViewProps)
16
+ struct AndroidHorizontalScrollContentViewProps : winrt::implements<AndroidHorizontalScrollContentViewProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ AndroidHorizontalScrollContentViewProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<AndroidHorizontalScrollContentViewProps>();
22
+ removeClippedSubviews = cloneFromProps->removeClippedSubviews;
23
+ }
24
+ }
25
+
26
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
27
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
28
+ }
29
+
30
+ REACT_FIELD(removeClippedSubviews)
31
+ std::optional<bool> removeClippedSubviews{};
32
+
33
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
34
+ };
35
+
36
+ struct AndroidHorizontalScrollContentViewEventEmitter {
37
+ AndroidHorizontalScrollContentViewEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
38
+ : m_eventEmitter(eventEmitter) {}
39
+
40
+ private:
41
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
42
+ };
43
+
44
+ template<typename TUserData>
45
+ struct BaseAndroidHorizontalScrollContentView {
46
+
47
+ virtual void UpdateProps(
48
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
49
+ const winrt::com_ptr<AndroidHorizontalScrollContentViewProps> &newProps,
50
+ const winrt::com_ptr<AndroidHorizontalScrollContentViewProps> &/*oldProps*/) noexcept {
51
+ m_props = newProps;
52
+ }
53
+
54
+ // UpdateLayoutMetrics will only be called if this method is overridden
55
+ virtual void UpdateLayoutMetrics(
56
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
57
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
58
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
59
+ }
60
+
61
+ // UpdateState will only be called if this method is overridden
62
+ virtual void UpdateState(
63
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
64
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
65
+ }
66
+
67
+ virtual void UpdateEventEmitter(const std::shared_ptr<AndroidHorizontalScrollContentViewEventEmitter> &eventEmitter) noexcept {
68
+ m_eventEmitter = eventEmitter;
69
+ }
70
+
71
+ // MountChildComponentView will only be called if this method is overridden
72
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
73
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
74
+ }
75
+
76
+ // UnmountChildComponentView will only be called if this method is overridden
77
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
78
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
79
+ }
80
+
81
+ // Initialize will only be called if this method is overridden
82
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
83
+ }
84
+
85
+ // CreateVisual will only be called if this method is overridden
86
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
87
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
88
+ }
89
+
90
+ // FinalizeUpdate will only be called if this method is overridden
91
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
92
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
93
+ }
94
+
95
+
96
+
97
+ const std::shared_ptr<AndroidHorizontalScrollContentViewEventEmitter>& EventEmitter() const { return m_eventEmitter; }
98
+ const winrt::com_ptr<AndroidHorizontalScrollContentViewProps>& Props() const { return m_props; }
99
+
100
+ private:
101
+ winrt::com_ptr<AndroidHorizontalScrollContentViewProps> m_props;
102
+ std::shared_ptr<AndroidHorizontalScrollContentViewEventEmitter> m_eventEmitter;
103
+ };
104
+
105
+ template <typename TUserData>
106
+ void RegisterAndroidHorizontalScrollContentViewNativeComponent(
107
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
108
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
109
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
110
+ L"AndroidHorizontalScrollContentView", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
111
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
112
+
113
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
114
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
115
+ return winrt::make<AndroidHorizontalScrollContentViewProps>(props, cloneFrom);
116
+ });
117
+
118
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
119
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
120
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
121
+ auto userData = view.UserData().as<TUserData>();
122
+ userData->UpdateProps(view, newProps ? newProps.as<AndroidHorizontalScrollContentViewProps>() : nullptr, oldProps ? oldProps.as<AndroidHorizontalScrollContentViewProps>() : nullptr);
123
+ });
124
+
125
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
126
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
127
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
128
+ auto userData = view.UserData().as<TUserData>();
129
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
130
+ });
131
+
132
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
133
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
134
+ auto userData = view.UserData().as<TUserData>();
135
+ userData->UpdateEventEmitter(std::make_shared<AndroidHorizontalScrollContentViewEventEmitter>(eventEmitter));
136
+ });
137
+
138
+ if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidHorizontalScrollContentView<TUserData>::FinalizeUpdate) {
139
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
140
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
141
+ auto userData = view.UserData().as<TUserData>();
142
+ userData->FinalizeUpdate(view, mask);
143
+ });
144
+ }
145
+
146
+ if constexpr (&TUserData::UpdateState != &BaseAndroidHorizontalScrollContentView<TUserData>::UpdateState) {
147
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
148
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
149
+ auto userData = view.UserData().as<TUserData>();
150
+ userData->member(view, newState);
151
+ });
152
+ }
153
+
154
+ if constexpr (&TUserData::MountChildComponentView != &BaseAndroidHorizontalScrollContentView<TUserData>::MountChildComponentView) {
155
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
156
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
157
+ auto userData = view.UserData().as<TUserData>();
158
+ return userData->MountChildComponentView(view, args);
159
+ });
160
+ }
161
+
162
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidHorizontalScrollContentView<TUserData>::UnmountChildComponentView) {
163
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
164
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
165
+ auto userData = view.UserData().as<TUserData>();
166
+ return userData->UnmountChildComponentView(view, args);
167
+ });
168
+ }
169
+
170
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
171
+ auto userData = winrt::make_self<TUserData>();
172
+ if constexpr (&TUserData::Initialize != &BaseAndroidHorizontalScrollContentView<TUserData>::Initialize) {
173
+ userData->Initialize(view);
174
+ }
175
+ view.UserData(*userData);
176
+ });
177
+
178
+ if constexpr (&TUserData::CreateVisual != &BaseAndroidHorizontalScrollContentView<TUserData>::CreateVisual) {
179
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
180
+ auto userData = view.UserData().as<TUserData>();
181
+ return userData->CreateVisual(view);
182
+ });
183
+ }
184
+
185
+ // Allow app to further customize the builder
186
+ if (builderCallback) {
187
+ builderCallback(compBuilder);
188
+ }
189
+ });
190
+ }
191
+
192
+ } // namespace Microsoft::ReactNativeSpecs
@@ -0,0 +1,216 @@
1
+
2
+ /*
3
+ * This file is auto-generated from AndroidProgressBarNativeComponent 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(AndroidProgressBarProps)
16
+ struct AndroidProgressBarProps : winrt::implements<AndroidProgressBarProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ AndroidProgressBarProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<AndroidProgressBarProps>();
22
+ styleAttr = cloneFromProps->styleAttr;
23
+ typeAttr = cloneFromProps->typeAttr;
24
+ indeterminate = cloneFromProps->indeterminate;
25
+ progress = cloneFromProps->progress;
26
+ animating = cloneFromProps->animating;
27
+ color = cloneFromProps->color;
28
+ testID = cloneFromProps->testID;
29
+ }
30
+ }
31
+
32
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
33
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
34
+ }
35
+
36
+ REACT_FIELD(styleAttr)
37
+ std::optional<std::string> styleAttr;
38
+
39
+ REACT_FIELD(typeAttr)
40
+ std::optional<std::string> typeAttr;
41
+
42
+ REACT_FIELD(indeterminate)
43
+ bool indeterminate{};
44
+
45
+ REACT_FIELD(progress)
46
+ std::optional<double> progress{};
47
+
48
+ REACT_FIELD(animating)
49
+ bool animating{true};
50
+
51
+ REACT_FIELD(color)
52
+ winrt::Microsoft::ReactNative::Color color{nullptr};
53
+
54
+ REACT_FIELD(testID)
55
+ std::optional<std::string> testID;
56
+
57
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
58
+ };
59
+
60
+ struct AndroidProgressBarEventEmitter {
61
+ AndroidProgressBarEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
62
+ : m_eventEmitter(eventEmitter) {}
63
+
64
+ private:
65
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
66
+ };
67
+
68
+ template<typename TUserData>
69
+ struct BaseAndroidProgressBar {
70
+
71
+ virtual void UpdateProps(
72
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
73
+ const winrt::com_ptr<AndroidProgressBarProps> &newProps,
74
+ const winrt::com_ptr<AndroidProgressBarProps> &/*oldProps*/) noexcept {
75
+ m_props = newProps;
76
+ }
77
+
78
+ // UpdateLayoutMetrics will only be called if this method is overridden
79
+ virtual void UpdateLayoutMetrics(
80
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
81
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
82
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
83
+ }
84
+
85
+ // UpdateState will only be called if this method is overridden
86
+ virtual void UpdateState(
87
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
88
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
89
+ }
90
+
91
+ virtual void UpdateEventEmitter(const std::shared_ptr<AndroidProgressBarEventEmitter> &eventEmitter) noexcept {
92
+ m_eventEmitter = eventEmitter;
93
+ }
94
+
95
+ // MountChildComponentView will only be called if this method is overridden
96
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
97
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
98
+ }
99
+
100
+ // UnmountChildComponentView will only be called if this method is overridden
101
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
102
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
103
+ }
104
+
105
+ // Initialize will only be called if this method is overridden
106
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
107
+ }
108
+
109
+ // CreateVisual will only be called if this method is overridden
110
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
111
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
112
+ }
113
+
114
+ // FinalizeUpdate will only be called if this method is overridden
115
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
116
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
117
+ }
118
+
119
+
120
+
121
+ const std::shared_ptr<AndroidProgressBarEventEmitter>& EventEmitter() const { return m_eventEmitter; }
122
+ const winrt::com_ptr<AndroidProgressBarProps>& Props() const { return m_props; }
123
+
124
+ private:
125
+ winrt::com_ptr<AndroidProgressBarProps> m_props;
126
+ std::shared_ptr<AndroidProgressBarEventEmitter> m_eventEmitter;
127
+ };
128
+
129
+ template <typename TUserData>
130
+ void RegisterAndroidProgressBarNativeComponent(
131
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
132
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
133
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
134
+ L"AndroidProgressBar", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
135
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
136
+
137
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
138
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
139
+ return winrt::make<AndroidProgressBarProps>(props, cloneFrom);
140
+ });
141
+
142
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
143
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
144
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
145
+ auto userData = view.UserData().as<TUserData>();
146
+ userData->UpdateProps(view, newProps ? newProps.as<AndroidProgressBarProps>() : nullptr, oldProps ? oldProps.as<AndroidProgressBarProps>() : nullptr);
147
+ });
148
+
149
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
150
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
151
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
152
+ auto userData = view.UserData().as<TUserData>();
153
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
154
+ });
155
+
156
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
157
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
158
+ auto userData = view.UserData().as<TUserData>();
159
+ userData->UpdateEventEmitter(std::make_shared<AndroidProgressBarEventEmitter>(eventEmitter));
160
+ });
161
+
162
+ if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidProgressBar<TUserData>::FinalizeUpdate) {
163
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
164
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
165
+ auto userData = view.UserData().as<TUserData>();
166
+ userData->FinalizeUpdate(view, mask);
167
+ });
168
+ }
169
+
170
+ if constexpr (&TUserData::UpdateState != &BaseAndroidProgressBar<TUserData>::UpdateState) {
171
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
172
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
173
+ auto userData = view.UserData().as<TUserData>();
174
+ userData->member(view, newState);
175
+ });
176
+ }
177
+
178
+ if constexpr (&TUserData::MountChildComponentView != &BaseAndroidProgressBar<TUserData>::MountChildComponentView) {
179
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
180
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
181
+ auto userData = view.UserData().as<TUserData>();
182
+ return userData->MountChildComponentView(view, args);
183
+ });
184
+ }
185
+
186
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidProgressBar<TUserData>::UnmountChildComponentView) {
187
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
188
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
189
+ auto userData = view.UserData().as<TUserData>();
190
+ return userData->UnmountChildComponentView(view, args);
191
+ });
192
+ }
193
+
194
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
195
+ auto userData = winrt::make_self<TUserData>();
196
+ if constexpr (&TUserData::Initialize != &BaseAndroidProgressBar<TUserData>::Initialize) {
197
+ userData->Initialize(view);
198
+ }
199
+ view.UserData(*userData);
200
+ });
201
+
202
+ if constexpr (&TUserData::CreateVisual != &BaseAndroidProgressBar<TUserData>::CreateVisual) {
203
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
204
+ auto userData = view.UserData().as<TUserData>();
205
+ return userData->CreateVisual(view);
206
+ });
207
+ }
208
+
209
+ // Allow app to further customize the builder
210
+ if (builderCallback) {
211
+ builderCallback(compBuilder);
212
+ }
213
+ });
214
+ }
215
+
216
+ } // namespace Microsoft::ReactNativeSpecs
@@ -0,0 +1,242 @@
1
+
2
+ /*
3
+ * This file is auto-generated from AndroidSwipeRefreshLayoutNativeComponent 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(AndroidSwipeRefreshLayoutProps)
16
+ struct AndroidSwipeRefreshLayoutProps : winrt::implements<AndroidSwipeRefreshLayoutProps, winrt::Microsoft::ReactNative::IComponentProps> {
17
+ AndroidSwipeRefreshLayoutProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
18
+ : ViewProps(props)
19
+ {
20
+ if (cloneFrom) {
21
+ auto cloneFromProps = cloneFrom.as<AndroidSwipeRefreshLayoutProps>();
22
+ enabled = cloneFromProps->enabled;
23
+ colors = cloneFromProps->colors;
24
+ progressBackgroundColor = cloneFromProps->progressBackgroundColor;
25
+ size = cloneFromProps->size;
26
+ progressViewOffset = cloneFromProps->progressViewOffset;
27
+ refreshing = cloneFromProps->refreshing;
28
+ }
29
+ }
30
+
31
+ void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
32
+ winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
33
+ }
34
+
35
+ REACT_FIELD(enabled)
36
+ bool enabled{true};
37
+
38
+ REACT_FIELD(colors)
39
+ std::optional<std::vector<winrt::Microsoft::ReactNative::Color>> colors;
40
+
41
+ REACT_FIELD(progressBackgroundColor)
42
+ winrt::Microsoft::ReactNative::Color progressBackgroundColor{nullptr};
43
+
44
+ REACT_FIELD(size)
45
+ std::optional<std::string> size;
46
+
47
+ REACT_FIELD(progressViewOffset)
48
+ std::optional<float> progressViewOffset{};
49
+
50
+ REACT_FIELD(refreshing)
51
+ bool refreshing{};
52
+
53
+ const winrt::Microsoft::ReactNative::ViewProps ViewProps;
54
+ };
55
+
56
+ REACT_STRUCT(AndroidSwipeRefreshLayout_OnRefresh)
57
+ struct AndroidSwipeRefreshLayout_OnRefresh {
58
+ };
59
+
60
+ struct AndroidSwipeRefreshLayoutEventEmitter {
61
+ AndroidSwipeRefreshLayoutEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter)
62
+ : m_eventEmitter(eventEmitter) {}
63
+
64
+ using OnRefresh = AndroidSwipeRefreshLayout_OnRefresh;
65
+
66
+ void onRefresh(OnRefresh &value) const {
67
+ m_eventEmitter.DispatchEvent(L"refresh", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) {
68
+ winrt::Microsoft::ReactNative::WriteValue(writer, value);
69
+ });
70
+ }
71
+
72
+ private:
73
+ winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr};
74
+ };
75
+
76
+ template<typename TUserData>
77
+ struct BaseAndroidSwipeRefreshLayout {
78
+
79
+ virtual void UpdateProps(
80
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
81
+ const winrt::com_ptr<AndroidSwipeRefreshLayoutProps> &newProps,
82
+ const winrt::com_ptr<AndroidSwipeRefreshLayoutProps> &/*oldProps*/) noexcept {
83
+ m_props = newProps;
84
+ }
85
+
86
+ // UpdateLayoutMetrics will only be called if this method is overridden
87
+ virtual void UpdateLayoutMetrics(
88
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
89
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/,
90
+ const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept {
91
+ }
92
+
93
+ // UpdateState will only be called if this method is overridden
94
+ virtual void UpdateState(
95
+ const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
96
+ const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept {
97
+ }
98
+
99
+ virtual void UpdateEventEmitter(const std::shared_ptr<AndroidSwipeRefreshLayoutEventEmitter> &eventEmitter) noexcept {
100
+ m_eventEmitter = eventEmitter;
101
+ }
102
+
103
+ // MountChildComponentView will only be called if this method is overridden
104
+ virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
105
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept {
106
+ }
107
+
108
+ // UnmountChildComponentView will only be called if this method is overridden
109
+ virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
110
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept {
111
+ }
112
+
113
+ // Initialize will only be called if this method is overridden
114
+ virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept {
115
+ }
116
+
117
+ // CreateVisual will only be called if this method is overridden
118
+ virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
119
+ return view.as<winrt::Microsoft::ReactNative::Composition::ComponentView>().Compositor().CreateSpriteVisual();
120
+ }
121
+
122
+ // FinalizeUpdate will only be called if this method is overridden
123
+ virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/,
124
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept {
125
+ }
126
+
127
+ // You must provide an implementation of this method to handle the "setNativeRefreshing" command
128
+ virtual void HandleSetNativeRefreshingCommand(bool value) noexcept = 0;
129
+
130
+ void HandleCommand(const winrt::Microsoft::ReactNative::ComponentView &view, const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
131
+ auto userData = view.UserData().as<TUserData>();
132
+ auto commandName = args.CommandName();
133
+ if (commandName == L"setNativeRefreshing") {
134
+ bool value;
135
+ winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), value);
136
+ userData->HandleSetNativeRefreshingCommand(value);
137
+ return;
138
+ }
139
+ }
140
+
141
+ const std::shared_ptr<AndroidSwipeRefreshLayoutEventEmitter>& EventEmitter() const { return m_eventEmitter; }
142
+ const winrt::com_ptr<AndroidSwipeRefreshLayoutProps>& Props() const { return m_props; }
143
+
144
+ private:
145
+ winrt::com_ptr<AndroidSwipeRefreshLayoutProps> m_props;
146
+ std::shared_ptr<AndroidSwipeRefreshLayoutEventEmitter> m_eventEmitter;
147
+ };
148
+
149
+ template <typename TUserData>
150
+ void RegisterAndroidSwipeRefreshLayoutNativeComponent(
151
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder,
152
+ std::function<void(const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder&)> builderCallback) noexcept {
153
+ packageBuilder.as<winrt::Microsoft::ReactNative::IReactPackageBuilderFabric>().AddViewComponent(
154
+ L"AndroidSwipeRefreshLayout", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
155
+ auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
156
+
157
+ builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
158
+ const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
159
+ return winrt::make<AndroidSwipeRefreshLayoutProps>(props, cloneFrom);
160
+ });
161
+
162
+ builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
163
+ const winrt::Microsoft::ReactNative::IComponentProps &newProps,
164
+ const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept {
165
+ auto userData = view.UserData().as<TUserData>();
166
+ userData->UpdateProps(view, newProps ? newProps.as<AndroidSwipeRefreshLayoutProps>() : nullptr, oldProps ? oldProps.as<AndroidSwipeRefreshLayoutProps>() : nullptr);
167
+ });
168
+
169
+ compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
170
+ const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics,
171
+ const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept {
172
+ auto userData = view.UserData().as<TUserData>();
173
+ userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics);
174
+ });
175
+
176
+ builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
177
+ const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept {
178
+ auto userData = view.UserData().as<TUserData>();
179
+ userData->UpdateEventEmitter(std::make_shared<AndroidSwipeRefreshLayoutEventEmitter>(eventEmitter));
180
+ });
181
+
182
+ if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidSwipeRefreshLayout<TUserData>::FinalizeUpdate) {
183
+ builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
184
+ winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
185
+ auto userData = view.UserData().as<TUserData>();
186
+ userData->FinalizeUpdate(view, mask);
187
+ });
188
+ }
189
+
190
+ if constexpr (&TUserData::UpdateState != &BaseAndroidSwipeRefreshLayout<TUserData>::UpdateState) {
191
+ builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
192
+ const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
193
+ auto userData = view.UserData().as<TUserData>();
194
+ userData->member(view, newState);
195
+ });
196
+ }
197
+
198
+ builder.SetCustomCommandHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
199
+ const winrt::Microsoft::ReactNative::HandleCommandArgs& args) noexcept {
200
+ auto userData = view.UserData().as<TUserData>();
201
+ userData->HandleCommand(view, args);
202
+ });
203
+
204
+ if constexpr (&TUserData::MountChildComponentView != &BaseAndroidSwipeRefreshLayout<TUserData>::MountChildComponentView) {
205
+ builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
206
+ const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
207
+ auto userData = view.UserData().as<TUserData>();
208
+ return userData->MountChildComponentView(view, args);
209
+ });
210
+ }
211
+
212
+ if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidSwipeRefreshLayout<TUserData>::UnmountChildComponentView) {
213
+ builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
214
+ const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
215
+ auto userData = view.UserData().as<TUserData>();
216
+ return userData->UnmountChildComponentView(view, args);
217
+ });
218
+ }
219
+
220
+ compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
221
+ auto userData = winrt::make_self<TUserData>();
222
+ if constexpr (&TUserData::Initialize != &BaseAndroidSwipeRefreshLayout<TUserData>::Initialize) {
223
+ userData->Initialize(view);
224
+ }
225
+ view.UserData(*userData);
226
+ });
227
+
228
+ if constexpr (&TUserData::CreateVisual != &BaseAndroidSwipeRefreshLayout<TUserData>::CreateVisual) {
229
+ compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
230
+ auto userData = view.UserData().as<TUserData>();
231
+ return userData->CreateVisual(view);
232
+ });
233
+ }
234
+
235
+ // Allow app to further customize the builder
236
+ if (builderCallback) {
237
+ builderCallback(compBuilder);
238
+ }
239
+ });
240
+ }
241
+
242
+ } // namespace Microsoft::ReactNativeSpecs