react-native-windows 0.74.3 → 0.74.5

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 (39) hide show
  1. package/Libraries/Components/TextInput/TextInput.windows.js +6 -2
  2. package/Libraries/Components/View/View.windows.js +3 -0
  3. package/Microsoft.ReactNative/CompositionComponentView.idl +17 -7
  4. package/Microsoft.ReactNative/CompositionRootView.idl +1 -0
  5. package/Microsoft.ReactNative/CompositionUIService.idl +4 -0
  6. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +2 -1
  7. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +106 -19
  8. package/Microsoft.ReactNative/Fabric/AbiViewProps.h +45 -13
  9. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +28 -64
  10. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +7 -11
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +4 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +2 -0
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +4 -0
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +12 -0
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.h +4 -0
  16. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +6 -0
  17. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +27 -16
  18. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +13 -4
  19. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -0
  20. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +49 -95
  21. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +11 -15
  22. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +16 -31
  23. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +5 -8
  24. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +24 -81
  25. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -13
  26. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +1 -0
  27. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +53 -68
  28. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +5 -7
  29. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +38 -84
  30. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +6 -10
  31. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +52 -104
  32. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -13
  33. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -0
  34. package/Microsoft.ReactNative/ViewProps.idl +37 -3
  35. package/Microsoft.ReactNative.Cxx/JSValueComposition.h +4 -0
  36. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  37. package/PropertySheets/JSEngine.props +1 -1
  38. package/Shared/HermesRuntimeHolder.cpp +8 -0
  39. package/package.json +1 -1
@@ -1346,9 +1346,13 @@ function InternalTextInput(props: Props): React.Node {
1346
1346
  );
1347
1347
  }
1348
1348
  },
1349
- // TODO: Fix this returning true on null === null, when no input is focused
1350
1349
  isFocused(): boolean {
1351
- return TextInputState.currentlyFocusedInput() === inputRef.current;
1350
+ const currentlyFocusedInput =
1351
+ TextInputState.currentlyFocusedInput();
1352
+ return (
1353
+ currentlyFocusedInput !== null &&
1354
+ currentlyFocusedInput === inputRef.current
1355
+ );
1352
1356
  },
1353
1357
  getNativeRef(): ?React.ElementRef<HostComponent<mixed>> {
1354
1358
  return inputRef.current;
@@ -175,6 +175,9 @@ const View: React.AbstractComponent<
175
175
  // [Windows
176
176
  // $FlowFixMe - children typing
177
177
  const childrenWithImportantForAccessibility = children => {
178
+ if (children == null) {
179
+ return children;
180
+ }
178
181
  const updatedChildren = React.Children.map(children, child => {
179
182
  if (React.isValidElement(child)) {
180
183
  // $FlowFixMe[incompatible-use]
@@ -26,6 +26,15 @@ namespace Microsoft.ReactNative.Composition
26
26
  Default = 0x00000007, // ShadowProps | NativeBorder | Background
27
27
  };
28
28
 
29
+ namespace Experimental {
30
+ [webhosthidden]
31
+ [experimental]
32
+ interface IInternalCreateComponentViewArgs
33
+ {
34
+ ICompositionContext CompositionContext { get; };
35
+ }
36
+ }
37
+
29
38
  [experimental]
30
39
  [webhosthidden]
31
40
  runtimeclass CreateCompositionComponentViewArgs : Microsoft.ReactNative.CreateComponentViewArgs {
@@ -72,7 +81,7 @@ namespace Microsoft.ReactNative.Composition
72
81
  [experimental]
73
82
  [webhosthidden]
74
83
  [default_interface]
75
- unsealed runtimeclass SwitchComponentView : ComponentView {
84
+ unsealed runtimeclass SwitchComponentView : ViewComponentView {
76
85
  };
77
86
 
78
87
  [experimental]
@@ -90,31 +99,32 @@ namespace Microsoft.ReactNative.Composition
90
99
  [experimental]
91
100
  [webhosthidden]
92
101
  [default_interface]
93
- unsealed runtimeclass ActivityIndicatorComponentView : ComponentView {
102
+ unsealed runtimeclass ActivityIndicatorComponentView : ViewComponentView {
94
103
  };
95
104
 
96
105
  [experimental]
97
106
  [webhosthidden]
98
107
  [default_interface]
99
- unsealed runtimeclass WindowsModalHostComponentView : ComponentView {
108
+ unsealed runtimeclass WindowsModalHostComponentView : ViewComponentView {
100
109
  };
101
110
 
102
111
  [experimental]
103
112
  [webhosthidden]
104
113
  [default_interface]
105
- unsealed runtimeclass ImageComponentView : ComponentView {
114
+ unsealed runtimeclass ImageComponentView : ViewComponentView {
115
+ Microsoft.ReactNative.ImageProps ViewProps { get; };
106
116
  };
107
117
 
108
118
  [experimental]
109
119
  [webhosthidden]
110
120
  [default_interface]
111
- unsealed runtimeclass ParagraphComponentView : ComponentView {
121
+ unsealed runtimeclass ParagraphComponentView : ViewComponentView {
112
122
  };
113
123
 
114
124
  [experimental]
115
125
  [webhosthidden]
116
126
  [default_interface]
117
- unsealed runtimeclass ScrollViewComponentView : ComponentView {
127
+ unsealed runtimeclass ScrollViewComponentView : ViewComponentView {
118
128
  };
119
129
 
120
130
  [experimental]
@@ -126,7 +136,7 @@ namespace Microsoft.ReactNative.Composition
126
136
  [experimental]
127
137
  [webhosthidden]
128
138
  [default_interface]
129
- unsealed runtimeclass WindowsTextInputComponentView : ComponentView {
139
+ unsealed runtimeclass WindowsTextInputComponentView : ViewComponentView {
130
140
  };
131
141
 
132
142
  } // namespace Microsoft.ReactNative
@@ -99,6 +99,7 @@ namespace Microsoft.ReactNative
99
99
  Microsoft.ReactNative.Composition.ICustomResourceLoader Resources;
100
100
 
101
101
  Microsoft.ReactNative.Composition.Theme Theme { get; };
102
+ Int64 RootTag { get; };
102
103
 
103
104
  #ifdef USE_WINUI3
104
105
  Microsoft.UI.Content.ContentIsland Island { get; };
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  import "ReactInstanceSettings.idl";
5
+ import "ComponentView.idl";
5
6
 
6
7
  #include "DocString.h"
7
8
 
@@ -22,5 +23,8 @@ namespace Microsoft.ReactNative.Composition
22
23
  "Gets the Compositor used by this ReactNative instance.")
23
24
  static Microsoft.UI.Composition.Compositor GetCompositor(Microsoft.ReactNative.IReactPropertyBag properties);
24
25
 
26
+ DOC_STRING("Gets the ComponentView from a react tag.")
27
+ static Microsoft.ReactNative.ComponentView ComponentFromReactTag(Microsoft.ReactNative.IReactContext context, Int64 reactTag);
28
+
25
29
  }
26
30
  } // namespace Microsoft.ReactNative.Composition
@@ -99,7 +99,8 @@ facebook::react::Props::Shared AbiViewComponentDescriptor::cloneProps(
99
99
  // auto shadowNodeProps = std::make_shared<ShadowNodeT::Props>(context, rawProps, props);
100
100
  auto shadowNodeProps = std::make_shared<AbiViewProps>(
101
101
  context, props ? static_cast<AbiViewProps const &>(*props) : *ShadowNodeT::defaultSharedProps(), rawProps);
102
- auto viewProps = winrt::make<winrt::Microsoft::ReactNative::implementation::UserViewProps>(shadowNodeProps);
102
+ auto viewProps =
103
+ winrt::make<winrt::Microsoft::ReactNative::implementation::ViewProps>(shadowNodeProps, false /*holdRef*/);
103
104
  auto userProps =
104
105
  winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
105
106
  ->CreateProps(viewProps);
@@ -7,10 +7,12 @@
7
7
 
8
8
  #include <Fabric/Composition/Theme.h>
9
9
  #include <JSValueReader.h>
10
+ #include <react/renderer/components/image/ImageProps.h>
11
+ #include <winrt/Microsoft.ReactNative.h>
12
+ #include <winrt/Windows.Foundation.h>
10
13
 
11
- #if __has_include("Color.g.cpp")
12
14
  #include "Color.g.cpp"
13
- #endif
15
+ #include "ImageSource.g.cpp"
14
16
 
15
17
  namespace Microsoft::ReactNative {
16
18
 
@@ -21,24 +23,24 @@ AbiViewProps::AbiViewProps(
21
23
  : facebook::react::ViewProps(context, sourceProps, rawProps) {}
22
24
 
23
25
  AbiViewProps::~AbiViewProps() {
24
- if (m_userProps) {
25
- winrt::get_self<winrt::Microsoft::ReactNative::implementation::UserViewProps>(m_userProps)->Disconnect();
26
+ if (m_innerProps) {
27
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ViewProps>(m_innerProps)->Disconnect();
26
28
  }
27
29
  }
28
30
 
29
31
  void AbiViewProps::SetUserProps(
30
- winrt::Microsoft::ReactNative::IComponentProps componentProps,
31
- winrt::Microsoft::ReactNative::ViewProps userProps) noexcept {
32
- m_componentProps = componentProps;
32
+ winrt::Microsoft::ReactNative::IComponentProps userProps,
33
+ winrt::Microsoft::ReactNative::ViewProps innerProps) noexcept {
33
34
  m_userProps = userProps;
35
+ m_innerProps = innerProps;
34
36
  }
35
37
 
36
38
  winrt::Microsoft::ReactNative::IComponentProps AbiViewProps::UserProps() const noexcept {
37
- return m_componentProps;
39
+ return m_userProps;
38
40
  }
39
41
 
40
42
  winrt::Microsoft::ReactNative::ViewProps AbiViewProps::ViewProps() const noexcept {
41
- return m_userProps;
43
+ return m_innerProps;
42
44
  }
43
45
 
44
46
  } // namespace Microsoft::ReactNative
@@ -124,29 +126,114 @@ winrt::Microsoft::ReactNative::Color Color::White() noexcept {
124
126
  return winrt::make<Color>(facebook::react::whiteColor());
125
127
  }
126
128
 
127
- UserViewProps::UserViewProps(std::shared_ptr<::Microsoft::ReactNative::AbiViewProps const> viewProps) noexcept
128
- : m_viewProps(viewProps.get()) {}
129
+ ImageSource::ImageSource(const facebook::react::ImageSource &imageSource) : m_imageSource(imageSource) {}
130
+
131
+ ImageSourceType ImageSource::Type() noexcept {
132
+ static_assert(
133
+ winrt::Microsoft::ReactNative::ImageSourceType::Invalid ==
134
+ static_cast<winrt::Microsoft::ReactNative::ImageSourceType>(facebook::react::ImageSource::Type::Invalid));
135
+ static_assert(
136
+ winrt::Microsoft::ReactNative::ImageSourceType::Remote ==
137
+ static_cast<winrt::Microsoft::ReactNative::ImageSourceType>(facebook::react::ImageSource::Type::Remote));
138
+ static_assert(
139
+ winrt::Microsoft::ReactNative::ImageSourceType::Local ==
140
+ static_cast<winrt::Microsoft::ReactNative::ImageSourceType>(facebook::react::ImageSource::Type::Local));
141
+ return static_cast<winrt::Microsoft::ReactNative::ImageSourceType>(m_imageSource.type);
142
+ }
143
+
144
+ winrt::hstring ImageSource::Uri() noexcept {
145
+ return winrt::to_hstring(m_imageSource.uri);
146
+ }
129
147
 
130
- void UserViewProps::Disconnect() noexcept {
148
+ winrt::hstring ImageSource::Bundle() noexcept {
149
+ return winrt::to_hstring(m_imageSource.bundle);
150
+ }
151
+
152
+ float ImageSource::Scale() noexcept {
153
+ return m_imageSource.scale;
154
+ }
155
+
156
+ winrt::Windows::Foundation::Size ImageSource::Size() noexcept {
157
+ return {m_imageSource.size.width, m_imageSource.size.height};
158
+ }
159
+
160
+ winrt::Microsoft::ReactNative::ImageSource ImageSource::ReadValue(
161
+ const winrt::Microsoft::ReactNative::IJSValueReader &reader) noexcept {
162
+ facebook::react::ImageSource imageSource;
163
+ switch (reader.ValueType()) {
164
+ case JSValueType::String: {
165
+ imageSource.type = facebook::react::ImageSource::Type::Remote;
166
+ imageSource.uri = winrt::to_string(reader.GetString());
167
+ break;
168
+ }
169
+ case JSValueType::Object: {
170
+ imageSource.type = facebook::react::ImageSource::Type::Remote;
171
+
172
+ winrt::hstring propertyName;
173
+ while (reader.GetNextObjectProperty(/*out*/ propertyName)) {
174
+ if (propertyName == L"__packager_asset") {
175
+ imageSource.type = facebook::react::ImageSource::Type::Local;
176
+ } else if (propertyName == L"width") {
177
+ imageSource.size.width = static_cast<float>(reader.GetDouble());
178
+ } else if (propertyName == L"height") {
179
+ imageSource.size.height = static_cast<float>(reader.GetDouble());
180
+ } else if (propertyName == L"scale") {
181
+ imageSource.scale = static_cast<float>(reader.GetDouble());
182
+ } else if (propertyName == L"uri") {
183
+ imageSource.uri = winrt::to_string(reader.GetString());
184
+ } else if (propertyName == L"url") {
185
+ imageSource.uri = winrt::to_string(reader.GetString());
186
+ } else if (propertyName == L"bundle") {
187
+ imageSource.bundle = winrt::to_string(reader.GetString());
188
+ imageSource.type = facebook::react::ImageSource::Type::Local;
189
+ }
190
+ }
191
+ break;
192
+ }
193
+ default: {
194
+ imageSource.type = facebook::react::ImageSource::Type::Invalid;
195
+ break;
196
+ }
197
+ }
198
+ return winrt::make<ImageSource>(imageSource);
199
+ }
200
+
201
+ ViewProps::ViewProps(facebook::react::SharedViewProps props, bool holdRef) noexcept
202
+ : m_props(holdRef ? props : nullptr), m_viewProps(static_cast<const facebook::react::ViewProps *>(props.get())) {}
203
+
204
+ void ViewProps::Disconnect() noexcept {
131
205
  m_viewProps = nullptr;
132
206
  }
133
207
 
134
- float UserViewProps::Opacity() noexcept {
208
+ float ViewProps::Opacity() noexcept {
135
209
  return m_viewProps ? m_viewProps->opacity : 1.0f;
136
210
  }
137
211
 
138
- winrt::Microsoft::ReactNative::Color UserViewProps::BackgroundColor() noexcept {
212
+ winrt::Microsoft::ReactNative::Color ViewProps::BackgroundColor() noexcept {
139
213
  return winrt::make<Color>(m_viewProps ? m_viewProps->backgroundColor : facebook::react::clearColor());
140
214
  }
141
215
 
142
- ViewProps::ViewProps(facebook::react::SharedViewProps props) noexcept : m_props(props) {}
216
+ winrt::hstring ViewProps::TestId() noexcept {
217
+ return m_viewProps ? winrt::to_hstring(m_viewProps->testId) : winrt::hstring{};
218
+ }
143
219
 
144
- float ViewProps::Opacity() noexcept {
145
- return m_props->opacity;
220
+ winrt::hstring ViewProps::AccessibilityLabel() noexcept {
221
+ return m_viewProps ? winrt::to_hstring(m_viewProps->accessibilityLabel) : winrt::hstring{};
146
222
  }
147
223
 
148
- winrt::Microsoft::ReactNative::Color ViewProps::BackgroundColor() noexcept {
149
- return winrt::make<Color>(m_props->backgroundColor);
224
+ ImageProps::ImageProps(facebook::react::SharedViewProps props) noexcept : Super(props) {}
225
+
226
+ winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::ReactNative::ImageSource>
227
+ ImageProps::Sources() noexcept {
228
+ winrt::Windows::Foundation::Collections::IVector<winrt::Microsoft::ReactNative::ImageSource> sources{
229
+ winrt::single_threaded_vector<winrt::Microsoft::ReactNative::ImageSource>()};
230
+ const auto imageProps = std::static_pointer_cast<const facebook::react::ImageProps>(m_props);
231
+
232
+ for (const auto &source : imageProps->sources) {
233
+ sources.Append(winrt::make<ImageSource>(source));
234
+ }
235
+
236
+ return sources.GetView();
150
237
  }
151
238
 
152
239
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -4,9 +4,12 @@
4
4
  #pragma once
5
5
 
6
6
  #include "Color.g.h"
7
+ #include "ImageProps.g.h"
8
+ #include "ImageSource.g.h"
7
9
  #include "ViewProps.g.h"
8
10
 
9
11
  #include <react/renderer/components/view/ViewProps.h>
12
+ #include <react/renderer/imagemanager/primitives.h>
10
13
  #include "winrt/Microsoft.ReactNative.Composition.Experimental.h"
11
14
  #include "winrt/Microsoft.ReactNative.h"
12
15
 
@@ -22,14 +25,14 @@ class AbiViewProps final : public facebook::react::ViewProps {
22
25
  ~AbiViewProps();
23
26
 
24
27
  void SetUserProps(
25
- winrt::Microsoft::ReactNative::IComponentProps componentProps,
26
- winrt::Microsoft::ReactNative::ViewProps userProps) noexcept;
28
+ winrt::Microsoft::ReactNative::IComponentProps userProps,
29
+ winrt::Microsoft::ReactNative::ViewProps innerProps) noexcept;
27
30
  winrt::Microsoft::ReactNative::IComponentProps UserProps() const noexcept;
28
31
  winrt::Microsoft::ReactNative::ViewProps ViewProps() const noexcept;
29
32
 
30
33
  private:
31
- winrt::Microsoft::ReactNative::IComponentProps m_componentProps{nullptr};
32
- winrt::Microsoft::ReactNative::ViewProps m_userProps{nullptr};
34
+ winrt::Microsoft::ReactNative::IComponentProps m_userProps{nullptr};
35
+ winrt::Microsoft::ReactNative::ViewProps m_innerProps{nullptr};
33
36
  };
34
37
 
35
38
  } // namespace Microsoft::ReactNative
@@ -60,27 +63,55 @@ struct Color : ColorT<Color, Composition::Experimental::IInternalColor> {
60
63
  facebook::react::SharedColor m_color;
61
64
  };
62
65
 
63
- struct UserViewProps : ViewPropsT<UserViewProps> {
64
- UserViewProps(std::shared_ptr<::Microsoft::ReactNative::AbiViewProps const> viewProps) noexcept;
66
+ struct ImageSource : ImageSourceT<ImageSource> {
67
+ ImageSource(const facebook::react::ImageSource &imageSource);
65
68
 
66
- float Opacity() noexcept;
67
- winrt::Microsoft::ReactNative::Color BackgroundColor() noexcept;
69
+ ImageSourceType Type() noexcept;
70
+ winrt::hstring Uri() noexcept;
71
+ winrt::hstring Bundle() noexcept;
72
+ float Scale() noexcept;
73
+ winrt::Windows::Foundation::Size Size() noexcept;
68
74
 
69
- void Disconnect() noexcept;
75
+ static winrt::Microsoft::ReactNative::ImageSource ReadValue(
76
+ const winrt::Microsoft::ReactNative::IJSValueReader &reader) noexcept;
77
+
78
+ static void WriteValue(
79
+ const winrt::Microsoft::ReactNative::IJSValueWriter &writer,
80
+ const winrt::Microsoft::ReactNative::ImageSource &value) noexcept;
70
81
 
71
82
  private:
72
- // Use a raw pointer here to avoid a ref cycle with AbiViewProps. ~AbiViewProps will clear this pointer
73
- ::Microsoft::ReactNative::AbiViewProps const *m_viewProps{nullptr};
83
+ const facebook::react::ImageSource m_imageSource;
74
84
  };
75
85
 
86
+ /**
87
+ * When providing a external ViewProps object on a normal ComponentView, ViewProps will hold a reference to the internal
88
+ * facebook::react::ViewProps object since the ComponentView could release the object at any time. However, when
89
+ * providing a ViewProps object on a custom ComponentView that has a custom app provided props, the AbiViewProps object
90
+ * will already be holding a reference to this object, so we only hold onto a weak reference.
91
+ */
76
92
  struct ViewProps : ViewPropsT<ViewProps> {
77
- ViewProps(facebook::react::SharedViewProps props) noexcept;
93
+ ViewProps(facebook::react::SharedViewProps props, bool holdRef = true) noexcept;
94
+
95
+ // Notification when the owning AbiViewProps is going away.
96
+ void Disconnect() noexcept;
78
97
 
79
98
  float Opacity() noexcept;
80
99
  winrt::Microsoft::ReactNative::Color BackgroundColor() noexcept;
100
+ winrt::hstring TestId() noexcept;
101
+ winrt::hstring AccessibilityLabel() noexcept;
81
102
 
82
- private:
103
+ protected:
83
104
  facebook::react::SharedViewProps m_props;
105
+
106
+ // Use a raw pointer here to avoid a ref cycle with AbiViewProps. ~AbiViewProps will clear this pointer
107
+ facebook::react::ViewProps const *m_viewProps{nullptr};
108
+ };
109
+
110
+ struct ImageProps : ImagePropsT<ImageProps, ViewProps> {
111
+ using Super = ImagePropsT<ImageProps, ViewProps>;
112
+ ImageProps(facebook::react::SharedViewProps props) noexcept;
113
+
114
+ winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::ReactNative::ImageSource> Sources() noexcept;
84
115
  };
85
116
 
86
117
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -88,5 +119,6 @@ struct ViewProps : ViewPropsT<ViewProps> {
88
119
  namespace winrt::Microsoft::ReactNative::factory_implementation {
89
120
 
90
121
  struct Color : ColorT<Color, implementation::Color> {};
122
+ struct ImageSource : ImageSourceT<ImageSource, implementation::ImageSource> {};
91
123
 
92
124
  } // namespace winrt::Microsoft::ReactNative::factory_implementation
@@ -24,9 +24,13 @@ ActivityIndicatorComponentView::ActivityIndicatorComponentView(
24
24
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
25
25
  facebook::react::Tag tag,
26
26
  winrt::Microsoft::ReactNative::ReactContext const &reactContext)
27
- : Super(compContext, tag, reactContext, ComponentViewFeatures::Default, false) {
28
- m_props = std::make_shared<facebook::react::ActivityIndicatorViewProps const>();
29
- }
27
+ : Super(
28
+ ActivityIndicatorComponentView::defaultProps(),
29
+ compContext,
30
+ tag,
31
+ reactContext,
32
+ ComponentViewFeatures::Default,
33
+ false) {}
30
34
 
31
35
  void ActivityIndicatorComponentView::MountChildComponentView(
32
36
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
@@ -53,14 +57,11 @@ void ActivityIndicatorComponentView::updateProgressColor(const facebook::react::
53
57
  void ActivityIndicatorComponentView::updateProps(
54
58
  facebook::react::Props::Shared const &props,
55
59
  facebook::react::Props::Shared const &oldProps) noexcept {
56
- const auto oldViewProps = std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(m_props);
60
+ const auto oldViewProps =
61
+ std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(oldProps ? oldProps : viewProps());
57
62
  const auto newViewProps = std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(props);
58
63
 
59
- ensureVisual();
60
-
61
- if (newViewProps->testId != oldViewProps->testId) {
62
- m_visual.Comment(winrt::to_hstring(newViewProps->testId));
63
- }
64
+ Super::updateProps(props, oldProps);
64
65
 
65
66
  // update color if needed
66
67
  if (!oldProps || newViewProps->color != oldViewProps->color) {
@@ -70,10 +71,6 @@ void ActivityIndicatorComponentView::updateProps(
70
71
  if (newViewProps->animating != oldViewProps->animating) {
71
72
  m_ActivityIndicatorVisual.IsVisible(newViewProps->animating);
72
73
  }
73
-
74
- Super::updateProps(props, oldProps);
75
-
76
- m_props = std::static_pointer_cast<facebook::react::ViewProps const>(props);
77
74
  }
78
75
 
79
76
  void ActivityIndicatorComponentView::FinalizeUpdates(
@@ -81,8 +78,7 @@ void ActivityIndicatorComponentView::FinalizeUpdates(
81
78
  static constexpr float radiusSmall = 10.0f;
82
79
  static constexpr float radiusLarge = 18.0f;
83
80
 
84
- if (std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(m_props)->size ==
85
- facebook::react::ActivityIndicatorViewSize::Small) {
81
+ if (activityIndicatorViewProps().size == facebook::react::ActivityIndicatorViewSize::Small) {
86
82
  m_ActivityIndicatorVisual.Size(radiusSmall * m_layoutMetrics.pointScaleFactor);
87
83
  } else {
88
84
  m_ActivityIndicatorVisual.Size(radiusLarge * m_layoutMetrics.pointScaleFactor);
@@ -96,67 +92,35 @@ void ActivityIndicatorComponentView::updateState(
96
92
  void ActivityIndicatorComponentView::updateLayoutMetrics(
97
93
  facebook::react::LayoutMetrics const &layoutMetrics,
98
94
  facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
99
- // Set Position & Size Properties
100
- ensureVisual();
101
-
102
- if ((layoutMetrics.displayType != m_layoutMetrics.displayType)) {
103
- OuterVisual().IsVisible(layoutMetrics.displayType != facebook::react::DisplayType::None);
104
- }
105
-
106
95
  Super::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
107
- m_visual.Size(
108
- {layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
109
- layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
110
96
  }
111
97
 
112
- void ActivityIndicatorComponentView::prepareForRecycle() noexcept {}
98
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual
99
+ ActivityIndicatorComponentView::createVisual() noexcept {
100
+ auto visual = m_compContext.CreateSpriteVisual();
101
+ m_ActivityIndicatorVisual = m_compContext.CreateActivityVisual();
113
102
 
114
- facebook::react::SharedViewProps ActivityIndicatorComponentView::viewProps() noexcept {
115
- return m_props;
116
- }
117
-
118
- void ActivityIndicatorComponentView::ensureVisual() noexcept {
119
- if (!m_visual) {
120
- m_visual = m_compContext.CreateSpriteVisual();
121
- m_ActivityIndicatorVisual = m_compContext.CreateActivityVisual();
122
-
123
- OuterVisual().InsertAt(m_ActivityIndicatorVisual, 0);
124
- OuterVisual().InsertAt(m_visual, 0);
125
- }
126
- }
127
-
128
- facebook::react::Tag ActivityIndicatorComponentView::hitTest(
129
- facebook::react::Point pt,
130
- facebook::react::Point &localPt,
131
- bool ignorePointerEvents) const noexcept {
132
- facebook::react::Point ptLocal{pt.x - m_layoutMetrics.frame.origin.x, pt.y - m_layoutMetrics.frame.origin.y};
133
-
134
- if ((ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
135
- m_props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
136
- ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 &&
137
- ptLocal.y <= m_layoutMetrics.frame.size.height) {
138
- localPt = ptLocal;
139
- return Tag();
140
- }
141
- return -1;
142
- }
143
-
144
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual ActivityIndicatorComponentView::Visual()
145
- const noexcept {
146
- return m_visual;
103
+ OuterVisual().InsertAt(m_ActivityIndicatorVisual, 0);
104
+ return visual;
147
105
  }
148
106
 
149
107
  void ActivityIndicatorComponentView::onThemeChanged() noexcept {
150
- updateProgressColor(std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(m_props)->color);
108
+ updateProgressColor(activityIndicatorViewProps().color);
151
109
  Super::onThemeChanged();
152
110
  }
153
111
 
154
- bool ActivityIndicatorComponentView::focusable() const noexcept {
155
- return false;
156
- }
157
-
158
112
  std::string ActivityIndicatorComponentView::DefaultControlType() const noexcept {
159
113
  return "progressbar";
160
114
  }
161
115
 
116
+ facebook::react::SharedViewProps ActivityIndicatorComponentView::defaultProps() noexcept {
117
+ static auto const defaultProps = std::make_shared<facebook::react::ActivityIndicatorViewProps const>();
118
+ return defaultProps;
119
+ }
120
+
121
+ const facebook::react::ActivityIndicatorViewProps &ActivityIndicatorComponentView::activityIndicatorViewProps()
122
+ const noexcept {
123
+ return *std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(viewProps());
124
+ }
125
+
162
126
  } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -13,8 +13,9 @@
13
13
 
14
14
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
15
15
 
16
- struct ActivityIndicatorComponentView : ActivityIndicatorComponentViewT<ActivityIndicatorComponentView, ComponentView> {
17
- using Super = ActivityIndicatorComponentViewT<ActivityIndicatorComponentView, ComponentView>;
16
+ struct ActivityIndicatorComponentView
17
+ : ActivityIndicatorComponentViewT<ActivityIndicatorComponentView, ViewComponentView> {
18
+ using Super = ActivityIndicatorComponentViewT<ActivityIndicatorComponentView, ViewComponentView>;
18
19
 
19
20
  [[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
20
21
  const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
@@ -35,14 +36,8 @@ struct ActivityIndicatorComponentView : ActivityIndicatorComponentViewT<Activity
35
36
  facebook::react::LayoutMetrics const &layoutMetrics,
36
37
  facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
37
38
  void FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept override;
38
- void prepareForRecycle() noexcept override;
39
- facebook::react::SharedViewProps viewProps() noexcept override;
40
- bool focusable() const noexcept override;
41
39
  void onThemeChanged() noexcept override;
42
40
 
43
- facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
44
- const noexcept override;
45
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual Visual() const noexcept override;
46
41
  virtual std::string DefaultControlType() const noexcept;
47
42
 
48
43
  ActivityIndicatorComponentView(
@@ -50,14 +45,15 @@ struct ActivityIndicatorComponentView : ActivityIndicatorComponentViewT<Activity
50
45
  facebook::react::Tag tag,
51
46
  winrt::Microsoft::ReactNative::ReactContext const &reactContext);
52
47
 
48
+ static facebook::react::SharedViewProps defaultProps() noexcept;
49
+ const facebook::react::ActivityIndicatorViewProps &activityIndicatorViewProps() const noexcept;
50
+ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual createVisual() noexcept override;
51
+
53
52
  private:
54
- void ensureVisual() noexcept;
55
53
  void updateVisualSize() noexcept;
56
54
  void updateProgressColor(const facebook::react::SharedColor &color) noexcept;
57
55
 
58
- winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
59
56
  winrt::Microsoft::ReactNative::Composition::Experimental::IActivityVisual m_ActivityIndicatorVisual{nullptr};
60
- facebook::react::SharedViewProps m_props;
61
57
  };
62
58
 
63
59
  } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -247,6 +247,10 @@ void CompositionRootView::ScaleFactor(float value) noexcept {
247
247
  }
248
248
  }
249
249
 
250
+ int64_t CompositionRootView::RootTag() const noexcept {
251
+ return m_rootTag;
252
+ }
253
+
250
254
  winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader CompositionRootView::Resources() noexcept {
251
255
  return m_resources;
252
256
  }
@@ -88,6 +88,8 @@ struct CompositionRootView
88
88
 
89
89
  winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *GetComponentView() noexcept;
90
90
 
91
+ int64_t RootTag() const noexcept;
92
+
91
93
  IInspectable GetUiaProvider() noexcept;
92
94
 
93
95
  // When driving the rootview without an island
@@ -96,6 +96,10 @@ int64_t CompositionRootView::GetTag() const noexcept {
96
96
  return 0;
97
97
  }
98
98
 
99
+ int64_t CompositionRootView::RootTag() const noexcept {
100
+ return 0;
101
+ }
102
+
99
103
  void CompositionRootView::SetTag(int64_t) noexcept {}
100
104
 
101
105
  void CompositionRootView::SetWindow(uint64_t) noexcept {}
@@ -4,6 +4,7 @@
4
4
  #include "pch.h"
5
5
  #include "CompositionUIService.h"
6
6
  #include "Composition.CompositionUIService.g.cpp"
7
+ #include <Fabric/FabricUIManagerModule.h>
7
8
  #include <QuirkSettings.h>
8
9
 
9
10
  #include <ReactPropertyBag.h>
@@ -39,4 +40,15 @@ Experimental::ICompositionContext CompositionUIService::GetCompositionContext(
39
40
  return ReactPropertyBag(properties).Get(CompositionContextPropertyId());
40
41
  }
41
42
 
43
+ winrt::Microsoft::ReactNative::ComponentView CompositionUIService::ComponentFromReactTag(
44
+ const winrt::Microsoft::ReactNative::IReactContext &context,
45
+ int64_t reactTag) noexcept {
46
+ if (std::shared_ptr<::Microsoft::ReactNative::FabricUIManager> fabricuiManager =
47
+ ::Microsoft::ReactNative::FabricUIManager::FromProperties(ReactPropertyBag(context.Properties()))) {
48
+ return fabricuiManager->GetViewRegistry().findComponentViewWithTag(static_cast<facebook::react::Tag>(reactTag));
49
+ }
50
+
51
+ return nullptr;
52
+ }
53
+
42
54
  } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -16,6 +16,10 @@ struct CompositionUIService : CompositionUIServiceT<CompositionUIService> {
16
16
  static winrt::Microsoft::UI::Composition::Compositor GetCompositor(const IReactPropertyBag &properties) noexcept;
17
17
 
18
18
  static Experimental::ICompositionContext GetCompositionContext(const IReactPropertyBag &properties) noexcept;
19
+
20
+ static winrt::Microsoft::ReactNative::ComponentView ComponentFromReactTag(
21
+ const winrt::Microsoft::ReactNative::IReactContext &context,
22
+ int64_t reactTag) noexcept;
19
23
  };
20
24
 
21
25
  } // namespace winrt::Microsoft::ReactNative::Composition::implementation