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