react-native-windows 0.0.0-canary.463 → 0.0.0-canary.464
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/Pressability/Pressability.windows.js +5 -5
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -0
- package/Microsoft.ReactNative/Fabric/ComponentViewRegistry.cpp +8 -1
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +29 -1
- package/Microsoft.ReactNative/Fabric/SliderComponentView.cpp +107 -0
- package/Microsoft.ReactNative/Fabric/SliderComponentView.h +51 -0
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.cpp +109 -0
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.h +52 -0
- package/Microsoft.ReactNative/Fabric/ViewComponentView.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/ViewComponentView.h +1 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/rncore/EventEmitters.h +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/rncore/Props.h +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/slider/SliderMeasurementsManager.cpp +35 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/slider/SliderMeasurementsManager.h +30 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +50 -49
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +3 -0
- package/Microsoft.ReactNative/IViewManager.idl +10 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +6 -0
- package/Microsoft.ReactNative/Views/SliderViewManager.cpp +12 -4
- package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +22 -13
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +2 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -0
- package/PropertySheets/Generated/PackageVersion.g.props +1 -1
- package/PropertySheets/OutputMSBuildProperties.targets +31 -0
- package/codegen/react/components/rnwcore/EventEmitters.cpp +149 -0
- package/package.json +3 -3
|
@@ -486,7 +486,6 @@ export default class Pressability {
|
|
|
486
486
|
|
|
487
487
|
onResponderGrant: (event: PressEvent): void => {
|
|
488
488
|
event.persist();
|
|
489
|
-
|
|
490
489
|
this._cancelPressOutDelayTimeout();
|
|
491
490
|
|
|
492
491
|
this._responderID = event.currentTarget;
|
|
@@ -771,7 +770,8 @@ export default class Pressability {
|
|
|
771
770
|
this._deactivate(event);
|
|
772
771
|
}
|
|
773
772
|
const {onLongPress, onPress, android_disableSound} = this._config;
|
|
774
|
-
|
|
773
|
+
|
|
774
|
+
if (onPress != null && getTouchFromPressEvent(event).button === 0) {
|
|
775
775
|
const isPressCanceledByLongPress =
|
|
776
776
|
onLongPress != null &&
|
|
777
777
|
prevState === 'RESPONDER_ACTIVE_LONG_PRESS_IN' &&
|
|
@@ -790,17 +790,17 @@ export default class Pressability {
|
|
|
790
790
|
|
|
791
791
|
_activate(event: PressEvent): void {
|
|
792
792
|
const {onPressIn} = this._config;
|
|
793
|
-
const {pageX, pageY} = getTouchFromPressEvent(event);
|
|
793
|
+
const {pageX, pageY, button} = getTouchFromPressEvent(event);
|
|
794
794
|
this._touchActivatePosition = {pageX, pageY};
|
|
795
795
|
this._touchActivateTime = Date.now();
|
|
796
|
-
if (onPressIn != null) {
|
|
796
|
+
if (onPressIn != null && button === 0) {
|
|
797
797
|
onPressIn(event);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
|
|
801
801
|
_deactivate(event: PressEvent): void {
|
|
802
802
|
const {onPressOut} = this._config;
|
|
803
|
-
if (onPressOut != null) {
|
|
803
|
+
if (onPressOut != null && getTouchFromPressEvent(event).button === 0) {
|
|
804
804
|
const minPressDuration = normalizeDelay(
|
|
805
805
|
this._config.minPressDuration,
|
|
806
806
|
0,
|
|
@@ -39,6 +39,7 @@ struct IComponentView {
|
|
|
39
39
|
virtual void finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept = 0;
|
|
40
40
|
virtual void prepareForRecycle() noexcept = 0;
|
|
41
41
|
virtual facebook::react::SharedProps props() noexcept = 0;
|
|
42
|
+
virtual void handleCommand(std::string const &commandName, folly::dynamic const &arg) noexcept = 0;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
} // namespace Microsoft::ReactNative
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#include <react/components/rnwcore/ShadowNodes.h>
|
|
14
14
|
#include <react/renderer/components/image/ImageShadowNode.h>
|
|
15
15
|
#include <react/renderer/components/root/RootShadowNode.h>
|
|
16
|
+
#include <react/renderer/components/slider/SliderShadowNode.h>
|
|
16
17
|
#include <react/renderer/components/text/ParagraphShadowNode.h>
|
|
17
18
|
#include <react/renderer/components/text/RawTextShadowNode.h>
|
|
18
19
|
#include <react/renderer/components/text/TextShadowNode.h>
|
|
@@ -23,6 +24,8 @@
|
|
|
23
24
|
#include "ImageComponentView.h"
|
|
24
25
|
#include "ParagraphComponentView.h"
|
|
25
26
|
#include "ScrollViewComponentView.h"
|
|
27
|
+
#include "SliderComponentView.h"
|
|
28
|
+
#include "SwitchComponentView.h"
|
|
26
29
|
#include "TextComponentView.h"
|
|
27
30
|
#include "ViewComponentView.h"
|
|
28
31
|
#include "XamlView.h"
|
|
@@ -48,6 +51,10 @@ ComponentViewDescriptor const &ComponentViewRegistry::dequeueComponentViewWithCo
|
|
|
48
51
|
view = std::make_shared<ScrollViewComponentView>();
|
|
49
52
|
} else if (componentHandle == facebook::react::ImageShadowNode::Handle()) {
|
|
50
53
|
view = std::make_shared<ImageComponentView>(m_context);
|
|
54
|
+
} else if (componentHandle == facebook::react::SliderShadowNode::Handle()) {
|
|
55
|
+
view = std::make_shared<SliderComponentView>(m_context);
|
|
56
|
+
} else if (componentHandle == facebook::react::SwitchShadowNode::Handle()) {
|
|
57
|
+
view = std::make_shared<SwitchComponentView>(m_context);
|
|
51
58
|
} else if (componentHandle == facebook::react::ActivityIndicatorViewShadowNode::Handle()) {
|
|
52
59
|
view = std::make_shared<ActivityIndicatorComponentView>();
|
|
53
60
|
} else {
|
|
@@ -80,6 +87,6 @@ void ComponentViewRegistry::enqueueComponentViewWithComponentHandle(
|
|
|
80
87
|
assert(m_registry.find(tag) != m_registry.end());
|
|
81
88
|
|
|
82
89
|
m_registry.erase(tag);
|
|
83
|
-
SetTag(static_cast<ViewComponentView &>(*componentViewDescriptor.view).Element(),
|
|
90
|
+
SetTag(static_cast<ViewComponentView &>(*componentViewDescriptor.view).Element(), InvalidTag);
|
|
84
91
|
}
|
|
85
92
|
} // namespace Microsoft::ReactNative
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#include <react/components/rnwcore/ComponentDescriptors.h>
|
|
18
18
|
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
19
19
|
#include <react/renderer/components/image/ImageComponentDescriptor.h>
|
|
20
|
+
#include <react/renderer/components/slider/SliderComponentDescriptor.h>
|
|
20
21
|
#include <react/renderer/components/text/ParagraphComponentDescriptor.h>
|
|
21
22
|
#include <react/renderer/components/text/RawTextComponentDescriptor.h>
|
|
22
23
|
#include <react/renderer/components/text/TextComponentDescriptor.h>
|
|
@@ -142,6 +143,10 @@ std::shared_ptr<facebook::react::ComponentDescriptorProviderRegistry const> shar
|
|
|
142
143
|
facebook::react::concreteComponentDescriptorProvider<facebook::react::RawTextComponentDescriptor>());
|
|
143
144
|
providerRegistry->add(
|
|
144
145
|
facebook::react::concreteComponentDescriptorProvider<facebook::react::ScrollViewComponentDescriptor>());
|
|
146
|
+
providerRegistry->add(
|
|
147
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::SliderComponentDescriptor>());
|
|
148
|
+
providerRegistry->add(
|
|
149
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::SwitchComponentDescriptor>());
|
|
145
150
|
providerRegistry->add(
|
|
146
151
|
facebook::react::concreteComponentDescriptorProvider<facebook::react::TextComponentDescriptor>());
|
|
147
152
|
providerRegistry->add(
|
|
@@ -200,6 +205,9 @@ void FabricUIManager::installFabricUIManager() noexcept {
|
|
|
200
205
|
toolbox.runtimeExecutor = runtimeExecutor;
|
|
201
206
|
toolbox.synchronousEventBeatFactory = synchronousBeatFactory;
|
|
202
207
|
toolbox.asynchronousEventBeatFactory = asynchronousBeatFactory;
|
|
208
|
+
// We currently rely on using XAML elements to perform measure/layout,
|
|
209
|
+
// which requires that the background thread also be the UI thread
|
|
210
|
+
/*
|
|
203
211
|
toolbox.backgroundExecutor = [context = m_context,
|
|
204
212
|
dispatcher = Mso::DispatchQueue::MakeLooperQueue()](std::function<void()> &&callback) {
|
|
205
213
|
if (context.UIDispatcher().HasThreadAccess()) {
|
|
@@ -209,6 +217,15 @@ void FabricUIManager::installFabricUIManager() noexcept {
|
|
|
209
217
|
|
|
210
218
|
dispatcher.Post(std::move(callback));
|
|
211
219
|
};
|
|
220
|
+
*/
|
|
221
|
+
toolbox.backgroundExecutor = [context = m_context](std::function<void()> &&callback) {
|
|
222
|
+
if (context.UIDispatcher().HasThreadAccess()) {
|
|
223
|
+
callback();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
context.UIDispatcher().Post(std::move(callback));
|
|
228
|
+
};
|
|
212
229
|
|
|
213
230
|
m_scheduler = std::make_shared<facebook::react::Scheduler>(
|
|
214
231
|
toolbox, (/*animationDriver_ ? animationDriver_.get() :*/ nullptr), this);
|
|
@@ -477,7 +494,18 @@ void FabricUIManager::schedulerDidDispatchCommand(
|
|
|
477
494
|
facebook::react::ShadowView const &shadowView,
|
|
478
495
|
std::string const &commandName,
|
|
479
496
|
folly::dynamic const &arg) {
|
|
480
|
-
|
|
497
|
+
if (m_context.UIDispatcher().HasThreadAccess()) {
|
|
498
|
+
auto descriptor = m_registry.componentViewDescriptorWithTag(shadowView.tag);
|
|
499
|
+
descriptor.view->handleCommand(commandName, arg);
|
|
500
|
+
} else {
|
|
501
|
+
m_context.UIDispatcher().Post(
|
|
502
|
+
[wkThis = weak_from_this(), commandName, tag = shadowView.tag, args = folly::dynamic(arg)]() {
|
|
503
|
+
if (auto pThis = wkThis.lock()) {
|
|
504
|
+
auto descriptor = pThis->m_registry.componentViewDescriptorWithTag(tag);
|
|
505
|
+
descriptor.view->handleCommand(commandName, args);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
481
509
|
}
|
|
482
510
|
|
|
483
511
|
void FabricUIManager::schedulerDidSetIsJSResponder(
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "SliderComponentView.h"
|
|
8
|
+
|
|
9
|
+
#include <UI.Xaml.Controls.Primitives.h>
|
|
10
|
+
#include <Utils/ValueUtils.h>
|
|
11
|
+
|
|
12
|
+
#include <IReactContext.h>
|
|
13
|
+
|
|
14
|
+
#include <react/renderer/components/rnwcore/EventEmitters.h>
|
|
15
|
+
|
|
16
|
+
namespace Microsoft::ReactNative {
|
|
17
|
+
|
|
18
|
+
SliderComponentView::SliderComponentView(winrt::Microsoft::ReactNative::ReactContext const &reactContext)
|
|
19
|
+
: m_context(reactContext), m_element(xaml::Controls::Slider()) {
|
|
20
|
+
m_valueChangedRevoker = m_element.ValueChanged(winrt::auto_revoke, [this](auto sender, auto args) {
|
|
21
|
+
if (m_props->value != m_element.Value()) {
|
|
22
|
+
if (m_eventEmitter) {
|
|
23
|
+
auto emitter = std::static_pointer_cast<const facebook::react::SliderEventEmitter>(m_eventEmitter);
|
|
24
|
+
facebook::react::SliderEventEmitter::OnValueChange onValueChangeArgs;
|
|
25
|
+
onValueChangeArgs.value = m_element.Value();
|
|
26
|
+
emitter->onValueChange(onValueChangeArgs);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
static auto const defaultProps = std::make_shared<facebook::react::SliderProps const>();
|
|
32
|
+
m_props = defaultProps;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::vector<facebook::react::ComponentDescriptorProvider>
|
|
36
|
+
SliderComponentView::supplementalComponentDescriptorProviders() noexcept {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void SliderComponentView::mountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept {
|
|
41
|
+
assert(false);
|
|
42
|
+
// m_element->Children().InsertAt(index, static_cast<const BaseComponentView &>(childComponentView).Element());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void SliderComponentView::unmountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept {
|
|
46
|
+
assert(false);
|
|
47
|
+
// m_element->Children().RemoveAt(index);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void SliderComponentView::updateProps(
|
|
51
|
+
facebook::react::Props::Shared const &props,
|
|
52
|
+
facebook::react::Props::Shared const &oldProps) noexcept {
|
|
53
|
+
const auto &oldSliderProps = *std::static_pointer_cast<const facebook::react::SliderProps>(m_props);
|
|
54
|
+
const auto &newSliderProps = *std::static_pointer_cast<const facebook::react::SliderProps>(props);
|
|
55
|
+
|
|
56
|
+
if (oldSliderProps.value != newSliderProps.value) {
|
|
57
|
+
m_element.Value(newSliderProps.value);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (oldSliderProps.maximumValue != newSliderProps.maximumValue) {
|
|
61
|
+
m_element.Maximum(newSliderProps.maximumValue);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (oldSliderProps.minimumValue != newSliderProps.minimumValue) {
|
|
65
|
+
m_element.Minimum(newSliderProps.minimumValue);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (oldSliderProps.disabled != newSliderProps.disabled) {
|
|
69
|
+
m_element.IsEnabled(!newSliderProps.disabled);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// TODO tint colors
|
|
73
|
+
|
|
74
|
+
m_props = std::static_pointer_cast<facebook::react::SliderProps const>(props);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void SliderComponentView::updateState(
|
|
78
|
+
facebook::react::State::Shared const &state,
|
|
79
|
+
facebook::react::State::Shared const &oldState) noexcept {}
|
|
80
|
+
|
|
81
|
+
void SliderComponentView::updateLayoutMetrics(
|
|
82
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
83
|
+
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
|
|
84
|
+
// Set Position & Size Properties
|
|
85
|
+
|
|
86
|
+
m_layoutMetrics = layoutMetrics;
|
|
87
|
+
|
|
88
|
+
winrt::Microsoft::ReactNative::ViewPanel::SetLeft(m_element, layoutMetrics.frame.origin.x);
|
|
89
|
+
winrt::Microsoft::ReactNative::ViewPanel::SetTop(m_element, layoutMetrics.frame.origin.y);
|
|
90
|
+
|
|
91
|
+
m_element.Width(layoutMetrics.frame.size.width);
|
|
92
|
+
m_element.Height(layoutMetrics.frame.size.height);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
void SliderComponentView::finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept {}
|
|
96
|
+
|
|
97
|
+
void SliderComponentView::prepareForRecycle() noexcept {}
|
|
98
|
+
facebook::react::SharedProps SliderComponentView::props() noexcept {
|
|
99
|
+
assert(false);
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const xaml::FrameworkElement SliderComponentView::Element() const noexcept {
|
|
104
|
+
return m_element;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "ComponentView.h"
|
|
8
|
+
|
|
9
|
+
#include <Microsoft.ReactNative.Cxx/ReactContext.h>
|
|
10
|
+
#include <UI.Xaml.Controls.h>
|
|
11
|
+
#include <react/renderer/components/rnwcore/Props.h>
|
|
12
|
+
#include "ViewComponentView.h"
|
|
13
|
+
|
|
14
|
+
#pragma warning(push)
|
|
15
|
+
#pragma warning(disable : 4244 4305)
|
|
16
|
+
//#include <react/renderer/components/view/ViewProps.h>
|
|
17
|
+
#pragma warning(pop)
|
|
18
|
+
|
|
19
|
+
namespace Microsoft::ReactNative {
|
|
20
|
+
|
|
21
|
+
struct SliderComponentView : BaseComponentView {
|
|
22
|
+
using Super = BaseComponentView;
|
|
23
|
+
SliderComponentView(winrt::Microsoft::ReactNative::ReactContext const &reactContext);
|
|
24
|
+
|
|
25
|
+
std::vector<facebook::react::ComponentDescriptorProvider> supplementalComponentDescriptorProviders() noexcept
|
|
26
|
+
override;
|
|
27
|
+
void mountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept override;
|
|
28
|
+
void unmountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept override;
|
|
29
|
+
void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
|
|
30
|
+
override;
|
|
31
|
+
void updateState(facebook::react::State::Shared const &state, facebook::react::State::Shared const &oldState) noexcept
|
|
32
|
+
override;
|
|
33
|
+
void updateLayoutMetrics(
|
|
34
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
35
|
+
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
36
|
+
void finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept override;
|
|
37
|
+
void prepareForRecycle() noexcept override;
|
|
38
|
+
facebook::react::SharedProps props() noexcept override;
|
|
39
|
+
|
|
40
|
+
const xaml::FrameworkElement Element() const noexcept override;
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
bool m_needsOnLoadStart{false};
|
|
44
|
+
std::shared_ptr<facebook::react::SliderProps const> m_props;
|
|
45
|
+
facebook::react::LayoutMetrics m_layoutMetrics;
|
|
46
|
+
xaml::Controls::Slider m_element;
|
|
47
|
+
xaml::Controls::Slider::ValueChanged_revoker m_valueChangedRevoker;
|
|
48
|
+
winrt::Microsoft::ReactNative::ReactContext m_context;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "SwitchComponentView.h"
|
|
8
|
+
|
|
9
|
+
#include <Utils/ValueUtils.h>
|
|
10
|
+
|
|
11
|
+
#include <IReactContext.h>
|
|
12
|
+
|
|
13
|
+
#include <react/renderer/components/rnwcore/EventEmitters.h>
|
|
14
|
+
|
|
15
|
+
namespace Microsoft::ReactNative {
|
|
16
|
+
|
|
17
|
+
SwitchComponentView::SwitchComponentView(winrt::Microsoft::ReactNative::ReactContext const &reactContext)
|
|
18
|
+
: m_context(reactContext), m_element(xaml::Controls::ToggleSwitch()) {
|
|
19
|
+
m_element.OnContent(nullptr);
|
|
20
|
+
m_element.OffContent(nullptr);
|
|
21
|
+
|
|
22
|
+
m_toggledRevoker = m_element.Toggled(winrt::auto_revoke, [this](auto sender, auto args) {
|
|
23
|
+
if (m_props->value != m_element.IsOn()) {
|
|
24
|
+
if (m_eventEmitter) {
|
|
25
|
+
auto emitter = std::static_pointer_cast<const facebook::react::SwitchEventEmitter>(m_eventEmitter);
|
|
26
|
+
facebook::react::SwitchEventEmitter::OnChange onChangeArgs;
|
|
27
|
+
onChangeArgs.value = m_element.IsOn();
|
|
28
|
+
emitter->onChange(onChangeArgs);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
static auto const defaultProps = std::make_shared<facebook::react::SwitchProps const>();
|
|
34
|
+
m_props = defaultProps;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void SwitchComponentView::handleCommand(std::string const &commandName, folly::dynamic const &arg) noexcept {
|
|
38
|
+
if (commandName == "setValue") {
|
|
39
|
+
m_element.IsOn(arg[0].asBool());
|
|
40
|
+
} else {
|
|
41
|
+
Super::handleCommand(commandName, arg);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
std::vector<facebook::react::ComponentDescriptorProvider>
|
|
46
|
+
SwitchComponentView::supplementalComponentDescriptorProviders() noexcept {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void SwitchComponentView::mountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept {
|
|
51
|
+
assert(false);
|
|
52
|
+
// m_element->Children().InsertAt(index, static_cast<const BaseComponentView &>(childComponentView).Element());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void SwitchComponentView::unmountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept {
|
|
56
|
+
assert(false);
|
|
57
|
+
// m_element->Children().RemoveAt(index);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void SwitchComponentView::updateProps(
|
|
61
|
+
facebook::react::Props::Shared const &props,
|
|
62
|
+
facebook::react::Props::Shared const &oldProps) noexcept {
|
|
63
|
+
const auto &oldSwitchProps = *std::static_pointer_cast<const facebook::react::SwitchProps>(m_props);
|
|
64
|
+
const auto &newSwitchProps = *std::static_pointer_cast<const facebook::react::SwitchProps>(props);
|
|
65
|
+
|
|
66
|
+
if (oldSwitchProps.value != newSwitchProps.value) {
|
|
67
|
+
m_element.IsOn(newSwitchProps.value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (oldSwitchProps.disabled != newSwitchProps.disabled) {
|
|
71
|
+
m_element.IsEnabled(!newSwitchProps.disabled);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// TODO tint colors
|
|
75
|
+
|
|
76
|
+
m_props = std::static_pointer_cast<facebook::react::SwitchProps const>(props);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void SwitchComponentView::updateState(
|
|
80
|
+
facebook::react::State::Shared const &state,
|
|
81
|
+
facebook::react::State::Shared const &oldState) noexcept {}
|
|
82
|
+
|
|
83
|
+
void SwitchComponentView::updateLayoutMetrics(
|
|
84
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
85
|
+
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
|
|
86
|
+
// Set Position & Size Properties
|
|
87
|
+
|
|
88
|
+
m_layoutMetrics = layoutMetrics;
|
|
89
|
+
|
|
90
|
+
winrt::Microsoft::ReactNative::ViewPanel::SetLeft(m_element, layoutMetrics.frame.origin.x);
|
|
91
|
+
winrt::Microsoft::ReactNative::ViewPanel::SetTop(m_element, layoutMetrics.frame.origin.y);
|
|
92
|
+
|
|
93
|
+
m_element.Width(layoutMetrics.frame.size.width);
|
|
94
|
+
m_element.Height(layoutMetrics.frame.size.height);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void SwitchComponentView::finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept {}
|
|
98
|
+
|
|
99
|
+
void SwitchComponentView::prepareForRecycle() noexcept {}
|
|
100
|
+
facebook::react::SharedProps SwitchComponentView::props() noexcept {
|
|
101
|
+
assert(false);
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const xaml::FrameworkElement SwitchComponentView::Element() const noexcept {
|
|
106
|
+
return m_element;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "ComponentView.h"
|
|
8
|
+
|
|
9
|
+
#include <Microsoft.ReactNative.Cxx/ReactContext.h>
|
|
10
|
+
#include <UI.Xaml.Controls.h>
|
|
11
|
+
#include <react/renderer/components/rnwcore/Props.h>
|
|
12
|
+
#include "ViewComponentView.h"
|
|
13
|
+
|
|
14
|
+
#pragma warning(push)
|
|
15
|
+
#pragma warning(disable : 4244 4305)
|
|
16
|
+
//#include <react/renderer/components/view/ViewProps.h>
|
|
17
|
+
#pragma warning(pop)
|
|
18
|
+
|
|
19
|
+
namespace Microsoft::ReactNative {
|
|
20
|
+
|
|
21
|
+
struct SwitchComponentView : BaseComponentView {
|
|
22
|
+
using Super = BaseComponentView;
|
|
23
|
+
SwitchComponentView(winrt::Microsoft::ReactNative::ReactContext const &reactContext);
|
|
24
|
+
|
|
25
|
+
std::vector<facebook::react::ComponentDescriptorProvider> supplementalComponentDescriptorProviders() noexcept
|
|
26
|
+
override;
|
|
27
|
+
void mountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept override;
|
|
28
|
+
void unmountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept override;
|
|
29
|
+
void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
|
|
30
|
+
override;
|
|
31
|
+
void updateState(facebook::react::State::Shared const &state, facebook::react::State::Shared const &oldState) noexcept
|
|
32
|
+
override;
|
|
33
|
+
void updateLayoutMetrics(
|
|
34
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
35
|
+
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
36
|
+
void finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept override;
|
|
37
|
+
void prepareForRecycle() noexcept override;
|
|
38
|
+
facebook::react::SharedProps props() noexcept override;
|
|
39
|
+
void handleCommand(std::string const &commandName, folly::dynamic const &arg) noexcept override;
|
|
40
|
+
|
|
41
|
+
const xaml::FrameworkElement Element() const noexcept override;
|
|
42
|
+
|
|
43
|
+
private:
|
|
44
|
+
bool m_needsOnLoadStart{false};
|
|
45
|
+
std::shared_ptr<facebook::react::SwitchProps const> m_props;
|
|
46
|
+
facebook::react::LayoutMetrics m_layoutMetrics;
|
|
47
|
+
xaml::Controls::ToggleSwitch m_element;
|
|
48
|
+
xaml::Controls::ToggleSwitch::Toggled_revoker m_toggledRevoker;
|
|
49
|
+
winrt::Microsoft::ReactNative::ReactContext m_context;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -20,6 +20,10 @@ const facebook::react::SharedViewEventEmitter &BaseComponentView::GetEventEmitte
|
|
|
20
20
|
return m_eventEmitter;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
void BaseComponentView::handleCommand(std::string const &commandName, folly::dynamic const &arg) noexcept {
|
|
24
|
+
assert(false); // Unhandled command
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
ViewComponentView::ViewComponentView() {
|
|
24
28
|
static auto const defaultProps = std::make_shared<facebook::react::ViewProps const>();
|
|
25
29
|
m_props = defaultProps;
|
|
@@ -14,6 +14,7 @@ struct BaseComponentView : IComponentView {
|
|
|
14
14
|
virtual const xaml::FrameworkElement Element() const noexcept = 0;
|
|
15
15
|
void updateEventEmitter(facebook::react::EventEmitter::Shared const &eventEmitter) noexcept override;
|
|
16
16
|
const facebook::react::SharedViewEventEmitter &GetEventEmitter() const noexcept;
|
|
17
|
+
void handleCommand(std::string const &commandName, folly::dynamic const &arg) noexcept override;
|
|
17
18
|
|
|
18
19
|
protected:
|
|
19
20
|
facebook::react::SharedViewEventEmitter m_eventEmitter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "SliderMeasurementsManager.h"
|
|
9
|
+
|
|
10
|
+
#include <react/renderer/core/conversions.h>
|
|
11
|
+
#include <winrt/Windows.Foundation.Collections.h>
|
|
12
|
+
#include <winrt/Windows.UI.Xaml.Interop.h>
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
Size SliderMeasurementsManager::measure(SurfaceId surfaceId, LayoutConstraints layoutConstraints) const {
|
|
17
|
+
if (!m_slider) {
|
|
18
|
+
m_slider = xaml::Controls::Slider();
|
|
19
|
+
xaml::Style sliderStyle;
|
|
20
|
+
xaml::Application::Current()
|
|
21
|
+
.Resources()
|
|
22
|
+
.TryLookup(winrt::box_value(winrt::xaml_typename<xaml::Controls::Slider>()))
|
|
23
|
+
.as(sliderStyle);
|
|
24
|
+
m_slider.Style(sliderStyle);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
winrt::Windows::Foundation::Size availiableSize(
|
|
28
|
+
layoutConstraints.maximumSize.width, layoutConstraints.maximumSize.height);
|
|
29
|
+
|
|
30
|
+
m_slider.Measure(availiableSize);
|
|
31
|
+
auto size = m_slider.DesiredSize();
|
|
32
|
+
return {static_cast<float>(size.Width), static_cast<float>(size.Height)};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <CppWinrtIncludes.h>
|
|
4
|
+
#include <UI.Xaml.Controls.h>
|
|
5
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
6
|
+
#include <react/renderer/core/LayoutConstraints.h>
|
|
7
|
+
#include <react/utils/ContextContainer.h>
|
|
8
|
+
|
|
9
|
+
namespace facebook::react {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Class that manages slider measurements across platforms.
|
|
13
|
+
* On iOS it is a noop, since the height is passed in from JS on iOS only.
|
|
14
|
+
*/
|
|
15
|
+
class SliderMeasurementsManager {
|
|
16
|
+
public:
|
|
17
|
+
SliderMeasurementsManager(const ContextContainer::Shared &contextContainer) : m_contextContainer(contextContainer) {}
|
|
18
|
+
|
|
19
|
+
static inline bool shouldMeasureSlider() {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Size measure(SurfaceId surfaceId, LayoutConstraints layoutConstraints) const;
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
ContextContainer::Shared m_contextContainer;
|
|
27
|
+
mutable xaml::Controls::Slider m_slider{nullptr};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace facebook::react
|
package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp
CHANGED
|
@@ -5,67 +5,69 @@
|
|
|
5
5
|
|
|
6
6
|
#include "pch.h"
|
|
7
7
|
|
|
8
|
-
#include "TextLayoutManager.h"
|
|
9
|
-
|
|
10
8
|
#include <dwrite.h>
|
|
9
|
+
#include "TextLayoutManager.h"
|
|
11
10
|
|
|
11
|
+
#include <CppWinrtIncludes.h>
|
|
12
|
+
#include <UI.Xaml.Controls.h>
|
|
12
13
|
#include <unicode.h>
|
|
13
14
|
|
|
14
|
-
namespace facebook {
|
|
15
|
-
namespace react {
|
|
15
|
+
namespace facebook::react {
|
|
16
16
|
|
|
17
17
|
TextLayoutManager::~TextLayoutManager() {}
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
19
|
+
// Ideally we'd be able to measure Text either without creating a XAML element,
|
|
20
|
+
// or we'd be able to create a XAML element on a background thread.
|
|
21
|
+
//
|
|
22
|
+
// For now we've forced the background executor to be the UI thread, so that we can use
|
|
23
|
+
// TextBlocks within the measure call.
|
|
24
|
+
//
|
|
25
|
+
// There will be inconsistencies with layout if any property that affects layout is set differently here vs in the
|
|
26
|
+
// actual view component. -- Any properties that rely on the context from the UI tree should be set directly on the
|
|
27
|
+
// TextBlock here and in the view component.
|
|
23
28
|
TextMeasurement TextLayoutManager::measure(
|
|
24
29
|
AttributedStringBox attributedStringBox,
|
|
25
30
|
ParagraphAttributes paragraphAttributes,
|
|
26
31
|
LayoutConstraints layoutConstraints) const {
|
|
27
|
-
winrt::com_ptr<IDWriteFactory> spDWriteFactory;
|
|
28
|
-
DWriteCreateFactory(
|
|
29
|
-
DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(spDWriteFactory.put()));
|
|
30
|
-
|
|
31
32
|
for (auto &fragment : attributedStringBox.getValue().getFragments()) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
fragment.textAttributes.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
33
|
+
if (!m_textBlock) {
|
|
34
|
+
m_textBlock = xaml::Controls::TextBlock();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
auto textblock = xaml::Controls::TextBlock();
|
|
38
|
+
m_textBlock.Text(winrt::to_hstring(fragment.string));
|
|
39
|
+
m_textBlock.FontSize(fragment.textAttributes.fontSize);
|
|
40
|
+
m_textBlock.FontWeight(
|
|
41
|
+
winrt::Windows::UI::Text::FontWeight{static_cast<uint16_t>(fragment.textAttributes.fontWeight.value_or(
|
|
42
|
+
static_cast<facebook::react::FontWeight>(DWRITE_FONT_WEIGHT_REGULAR)))});
|
|
43
|
+
|
|
44
|
+
switch (fragment.textAttributes.fontStyle.value_or(facebook::react::FontStyle::Normal)) {
|
|
45
|
+
case facebook::react::FontStyle::Italic:
|
|
46
|
+
m_textBlock.FontStyle(winrt::Windows::UI::Text::FontStyle::Italic);
|
|
47
|
+
break;
|
|
48
|
+
case facebook::react::FontStyle::Normal:
|
|
49
|
+
m_textBlock.FontStyle(winrt::Windows::UI::Text::FontStyle::Normal);
|
|
50
|
+
break;
|
|
51
|
+
case facebook::react::FontStyle::Oblique:
|
|
52
|
+
m_textBlock.FontStyle(winrt::Windows::UI::Text::FontStyle::Oblique);
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
assert(false);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (fragment.textAttributes.fontFamily.empty())
|
|
59
|
+
m_textBlock.FontFamily(xaml::Media::FontFamily(L"Segoe UI"));
|
|
60
|
+
else
|
|
61
|
+
m_textBlock.FontFamily(
|
|
62
|
+
xaml::Media::FontFamily(Microsoft::Common::Unicode::Utf8ToUtf16(fragment.textAttributes.fontFamily)));
|
|
63
|
+
|
|
64
|
+
winrt::Windows::Foundation::Size availableSize(
|
|
65
|
+
layoutConstraints.maximumSize.width, layoutConstraints.maximumSize.height);
|
|
66
|
+
m_textBlock.Measure(availableSize);
|
|
64
67
|
TextMeasurement tm;
|
|
68
|
+
auto size = m_textBlock.DesiredSize();
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
spTextLayout->GetMetrics(&dtm);
|
|
68
|
-
tm.size = {dtm.width, dtm.height};
|
|
70
|
+
tm.size = {static_cast<float>(size.Width), static_cast<float>(size.Height)};
|
|
69
71
|
return tm;
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -86,5 +88,4 @@ void *TextLayoutManager::getNativeTextLayoutManager() const {
|
|
|
86
88
|
return (void *)this;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
} // namespace react
|
|
90
|
-
} // namespace facebook
|
|
91
|
+
} // namespace facebook::react
|
package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
+
#include <CppWinrtIncludes.h>
|
|
7
|
+
#include <UI.Xaml.Controls.h>
|
|
6
8
|
#include <react/renderer/attributedstring/AttributedString.h>
|
|
7
9
|
#include <react/renderer/attributedstring/AttributedStringBox.h>
|
|
8
10
|
#include <react/renderer/attributedstring/ParagraphAttributes.h>
|
|
@@ -54,6 +56,7 @@ class TextLayoutManager {
|
|
|
54
56
|
|
|
55
57
|
private:
|
|
56
58
|
ContextContainer::Shared m_contextContainer;
|
|
59
|
+
mutable xaml::Controls::TextBlock m_textBlock{nullptr};
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
} // namespace react
|
|
@@ -88,10 +88,18 @@ namespace Microsoft.ReactNative
|
|
|
88
88
|
)
|
|
89
89
|
void OnPointerEvent(Object view, ReactPointerEventArgs args);
|
|
90
90
|
};
|
|
91
|
+
|
|
92
|
+
[webhosthidden]
|
|
93
|
+
DOC_STRING(
|
|
94
|
+
"Enables view managers to track when views are"
|
|
95
|
+
"removed from their shadow trees. "
|
|
96
|
+
)
|
|
91
97
|
interface IViewManagerWithDropViewInstance {
|
|
92
98
|
DOC_STRING(
|
|
93
|
-
"
|
|
94
|
-
"
|
|
99
|
+
"Invoked when React has removed the view "
|
|
100
|
+
"from its shadow tree. Note this method call is distinct from "
|
|
101
|
+
"the XAML Unloaded event, which is asynchronously triggered "
|
|
102
|
+
"from when the removal of the view from the UI tree happens. "
|
|
95
103
|
)
|
|
96
104
|
void OnDropViewInstance(XAML_NAMESPACE.FrameworkElement view);
|
|
97
105
|
};
|
|
@@ -417,6 +417,8 @@
|
|
|
417
417
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\scrollview\ScrollViewProps.cpp" DisableSpecificWarnings="4018;4305;4715;%(DisableSpecificWarnings)" />
|
|
418
418
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\scrollview\ScrollViewShadowNode.cpp" DisableSpecificWarnings="4305;%(DisableSpecificWarnings)" />
|
|
419
419
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\scrollview\ScrollViewState.cpp" />
|
|
420
|
+
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\slider\SliderShadowNode.cpp" />
|
|
421
|
+
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\slider\SliderState.cpp" />
|
|
420
422
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\text\TextProps.cpp" />
|
|
421
423
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\text\BaseTextProps.cpp" />
|
|
422
424
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\text\BaseTextShadowNode.cpp" />
|
|
@@ -490,6 +492,7 @@
|
|
|
490
492
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\uimanager\SurfaceRegistryBinding.cpp" DisableSpecificWarnings="4715;%(DisableSpecificWarnings)" />
|
|
491
493
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\uimanager\UIManager.cpp" />
|
|
492
494
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\uimanager\UIManagerBinding.cpp" DisableSpecificWarnings="4389;4715;%(DisableSpecificWarnings)" />
|
|
495
|
+
<ClCompile Include="$(ReactNativeWindowsDir)codegen\react\components\rnwcore\EventEmitters.cpp" DisableSpecificWarnings="4715;%(DisableSpecificWarnings)" />
|
|
493
496
|
<ClCompile Include="$(ReactNativeWindowsDir)codegen\react\components\rnwcore\Props.cpp" DisableSpecificWarnings="4018;%(DisableSpecificWarnings)">
|
|
494
497
|
<ObjectFileName>$(IntDir)\codegenRnwCoreProps.obj</ObjectFileName>
|
|
495
498
|
</ClCompile>
|
|
@@ -502,9 +505,12 @@
|
|
|
502
505
|
<ClCompile Include="Fabric\ImageRequest.cpp" />
|
|
503
506
|
<ClCompile Include="Fabric\ParagraphComponentView.cpp" />
|
|
504
507
|
<ClCompile Include="Fabric\platform\react\renderer\textlayoutmanager\TextLayoutManager.cpp" />
|
|
508
|
+
<ClCompile Include="Fabric\platform\react\renderer\components\slider\SliderMeasurementsManager.cpp" />
|
|
505
509
|
<ClCompile Include="Fabric\platform\react\renderer\graphics\Color.cpp" />
|
|
506
510
|
<ClCompile Include="Fabric\ReactNativeConfigProperties.cpp" />
|
|
507
511
|
<ClCompile Include="Fabric\ScrollViewComponentView.cpp" />
|
|
512
|
+
<ClCompile Include="Fabric\SliderComponentView.cpp" />
|
|
513
|
+
<ClCompile Include="Fabric\SwitchComponentView.cpp" />
|
|
508
514
|
<ClCompile Include="Fabric\TextComponentView.cpp" />
|
|
509
515
|
<ClCompile Include="Fabric\ViewComponentView.cpp" />
|
|
510
516
|
<ClCompile Include="SchedulerSettings.cpp" />
|
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
#include <UI.Xaml.Controls.Primitives.h>
|
|
15
15
|
#include <UI.Xaml.Controls.h>
|
|
16
16
|
|
|
17
|
-
namespace winrt {
|
|
18
|
-
using ToggleButton = xaml::Controls::Primitives::ToggleButton;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
17
|
namespace Microsoft::ReactNative {
|
|
22
18
|
|
|
23
19
|
class SliderShadowNode : public ShadowNodeBase {
|
|
@@ -80,6 +76,18 @@ bool SliderViewManager::UpdateProperty(
|
|
|
80
76
|
slider.Value(propertyValue.AsDouble());
|
|
81
77
|
else if (propertyValue.IsNull())
|
|
82
78
|
slider.Value(0);
|
|
79
|
+
} else if (propertyName == "maximumValue") {
|
|
80
|
+
if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
|
|
81
|
+
propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
|
|
82
|
+
slider.Maximum(propertyValue.AsDouble());
|
|
83
|
+
else if (propertyValue.IsNull())
|
|
84
|
+
slider.Maximum(100);
|
|
85
|
+
} else if (propertyName == "minimumValue") {
|
|
86
|
+
if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double ||
|
|
87
|
+
propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64)
|
|
88
|
+
slider.Minimum(propertyValue.AsDouble());
|
|
89
|
+
else if (propertyValue.IsNull())
|
|
90
|
+
slider.Minimum(0);
|
|
83
91
|
} else {
|
|
84
92
|
return Super::UpdateProperty(nodeToUpdate, propertyName, propertyValue);
|
|
85
93
|
}
|
|
@@ -129,11 +129,7 @@ void TouchEventHandler::OnPointerPressed(
|
|
|
129
129
|
|
|
130
130
|
size_t pointerIndex = AddReactPointer(args, tag, sourceElement);
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
// Finger and pen taps will also set isLeftButton.
|
|
134
|
-
if (m_pointers[pointerIndex].isLeftButton) {
|
|
135
|
-
DispatchTouchEvent(eventType, pointerIndex);
|
|
136
|
-
}
|
|
132
|
+
DispatchTouchEvent(eventType, pointerIndex);
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
135
|
|
|
@@ -211,14 +207,12 @@ void TouchEventHandler::OnPointerConcluded(TouchEventType eventType, const winrt
|
|
|
211
207
|
if (PropagatePointerEventAndFindReactSourceBranch(reactArgs, &tagsForBranch, &sourceElement))
|
|
212
208
|
UpdateReactPointer(m_pointers[*optPointerIndex], args, sourceElement);
|
|
213
209
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
DispatchTouchEvent(adjustedEventType, *optPointerIndex);
|
|
221
|
-
}
|
|
210
|
+
// In case a PointerCaptureLost event should be treated as an "end" event,
|
|
211
|
+
// check the ReactPointerEventArgs Kind property before emitting the event.
|
|
212
|
+
const auto adjustedEventType = reactArgs.Kind() == winrt::Microsoft::ReactNative::PointerEventKind::End
|
|
213
|
+
? TouchEventType::End
|
|
214
|
+
: TouchEventType::Cancel;
|
|
215
|
+
DispatchTouchEvent(adjustedEventType, *optPointerIndex);
|
|
222
216
|
|
|
223
217
|
m_pointers.erase(cbegin(m_pointers) + *optPointerIndex);
|
|
224
218
|
if (m_pointers.size() == 0)
|
|
@@ -368,7 +362,21 @@ void TouchEventHandler::UpdatePointersInViews(
|
|
|
368
362
|
}
|
|
369
363
|
}
|
|
370
364
|
|
|
365
|
+
// defines button payload, follows https://developer.mozilla.org/docs/Web/API/MouseEvent/button
|
|
366
|
+
enum class MouseEventButtonKind { None = -1, Main = 0, Auxiliary = 1, Secondary = 2, Eraser = 5 };
|
|
367
|
+
|
|
371
368
|
winrt::Microsoft::ReactNative::JSValue TouchEventHandler::GetPointerJson(const ReactPointer &pointer, int64_t target) {
|
|
369
|
+
MouseEventButtonKind button = MouseEventButtonKind::None;
|
|
370
|
+
if (pointer.isLeftButton) {
|
|
371
|
+
button = MouseEventButtonKind::Main;
|
|
372
|
+
} else if (pointer.isMiddleButton) {
|
|
373
|
+
button = MouseEventButtonKind::Auxiliary;
|
|
374
|
+
} else if (pointer.isRightButton || pointer.isBarrelButton) {
|
|
375
|
+
button = MouseEventButtonKind::Secondary;
|
|
376
|
+
} else if (pointer.isEraser) {
|
|
377
|
+
button = MouseEventButtonKind::Eraser;
|
|
378
|
+
}
|
|
379
|
+
|
|
372
380
|
return winrt::Microsoft::ReactNative::JSValueObject{
|
|
373
381
|
{"target", target},
|
|
374
382
|
{"identifier", pointer.identifier},
|
|
@@ -390,6 +398,7 @@ winrt::Microsoft::ReactNative::JSValue TouchEventHandler::GetPointerJson(const R
|
|
|
390
398
|
{"isEraser", pointer.isEraser},
|
|
391
399
|
{"shiftKey", pointer.shiftKey},
|
|
392
400
|
{"ctrlKey", pointer.ctrlKey},
|
|
401
|
+
{"button", static_cast<int>(button)},
|
|
393
402
|
{"altKey", pointer.altKey}};
|
|
394
403
|
}
|
|
395
404
|
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\CppAppConsumeCSharpModule.targets" />
|
|
48
48
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\RequireSolution.targets" />
|
|
49
49
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\FixupRoslynCscWarnings.targets" />
|
|
50
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\OutputMSBuildProperties.targets" />
|
|
50
51
|
|
|
51
52
|
<ItemDefinitionGroup>
|
|
52
53
|
<Reference>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.0.0-canary.
|
|
13
|
+
<ReactNativeWindowsVersion>0.0.0-canary.464</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
|
|
16
16
|
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
Licensed under the MIT License..
|
|
5
|
+
-->
|
|
6
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
7
|
+
|
|
8
|
+
<Target Name="OutputMSBuildProperties" AfterTargets="PrepareForBuild">
|
|
9
|
+
<PropertyGroup>
|
|
10
|
+
<!--
|
|
11
|
+
These are the properties we will report in telemetry. Do NOT add properties that may contain PII.
|
|
12
|
+
You can add new properties following the format "PropertyName": "$(PropertyName)",
|
|
13
|
+
-->
|
|
14
|
+
<MSBuildPropertiesJSON>
|
|
15
|
+
{
|
|
16
|
+
"WinUIPackageName": "$(WinUIPackageName)",
|
|
17
|
+
"WinUIPackageVersion": "$(WinUIPackageVersion)",
|
|
18
|
+
"WindowsTargetPlatformVersion": "$(WindowsTargetPlatformVersion)",
|
|
19
|
+
"UseExperimentalNuGet": "$(UseExperimentalNuGet)",
|
|
20
|
+
"UseHermes": "$(UseHermes)",
|
|
21
|
+
"UseWinUI3": "$(UseWinUI3)"
|
|
22
|
+
}
|
|
23
|
+
</MSBuildPropertiesJSON>
|
|
24
|
+
</PropertyGroup>
|
|
25
|
+
<WriteLinesToFile
|
|
26
|
+
File="$([MSBuild]::NormalizePath($(ProjectDir)\Generated Files))\msbuildproperties.g.json"
|
|
27
|
+
Overwrite="true"
|
|
28
|
+
Lines="$(MSBuildPropertiesJSON)" />
|
|
29
|
+
</Target>
|
|
30
|
+
|
|
31
|
+
</Project>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/rnwcore/EventEmitters.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook {
|
|
14
|
+
namespace react {
|
|
15
|
+
|
|
16
|
+
void ModalHostViewEventEmitter::onRequestClose(OnRequestClose event) const {
|
|
17
|
+
dispatchEvent("requestClose", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
18
|
+
auto payload = jsi::Object(runtime);
|
|
19
|
+
|
|
20
|
+
return payload;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
void ModalHostViewEventEmitter::onShow(OnShow event) const {
|
|
24
|
+
dispatchEvent("show", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
25
|
+
auto payload = jsi::Object(runtime);
|
|
26
|
+
|
|
27
|
+
return payload;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
void ModalHostViewEventEmitter::onDismiss(OnDismiss event) const {
|
|
31
|
+
dispatchEvent("dismiss", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
32
|
+
auto payload = jsi::Object(runtime);
|
|
33
|
+
|
|
34
|
+
return payload;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
void ModalHostViewEventEmitter::onOrientationChange(OnOrientationChange event) const {
|
|
38
|
+
dispatchEvent("orientationChange", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
39
|
+
auto payload = jsi::Object(runtime);
|
|
40
|
+
payload.setProperty(runtime, "orientation", toString(event.orientation));
|
|
41
|
+
return payload;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void DatePickerEventEmitter::onChange(OnChange event) const {
|
|
46
|
+
dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
47
|
+
auto payload = jsi::Object(runtime);
|
|
48
|
+
payload.setProperty(runtime, "timestamp", event.timestamp);
|
|
49
|
+
return payload;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
void AndroidDrawerLayoutEventEmitter::onDrawerSlide(OnDrawerSlide event) const {
|
|
53
|
+
dispatchEvent("drawerSlide", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
54
|
+
auto payload = jsi::Object(runtime);
|
|
55
|
+
payload.setProperty(runtime, "offset", event.offset);
|
|
56
|
+
return payload;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
void AndroidDrawerLayoutEventEmitter::onDrawerStateChanged(OnDrawerStateChanged event) const {
|
|
60
|
+
dispatchEvent("drawerStateChanged", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
61
|
+
auto payload = jsi::Object(runtime);
|
|
62
|
+
payload.setProperty(runtime, "drawerState", event.drawerState);
|
|
63
|
+
return payload;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
void AndroidDrawerLayoutEventEmitter::onDrawerOpen(OnDrawerOpen event) const {
|
|
67
|
+
dispatchEvent("drawerOpen", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
68
|
+
auto payload = jsi::Object(runtime);
|
|
69
|
+
|
|
70
|
+
return payload;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
void AndroidDrawerLayoutEventEmitter::onDrawerClose(OnDrawerClose event) const {
|
|
74
|
+
dispatchEvent("drawerClose", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
75
|
+
auto payload = jsi::Object(runtime);
|
|
76
|
+
|
|
77
|
+
return payload;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
void AndroidSwipeRefreshLayoutEventEmitter::onRefresh(OnRefresh event) const {
|
|
84
|
+
dispatchEvent("refresh", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
85
|
+
auto payload = jsi::Object(runtime);
|
|
86
|
+
|
|
87
|
+
return payload;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
void PullToRefreshViewEventEmitter::onRefresh(OnRefresh event) const {
|
|
91
|
+
dispatchEvent("refresh", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
92
|
+
auto payload = jsi::Object(runtime);
|
|
93
|
+
|
|
94
|
+
return payload;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
void RCTSegmentedControlEventEmitter::onChange(OnChange event) const {
|
|
100
|
+
dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
101
|
+
auto payload = jsi::Object(runtime);
|
|
102
|
+
payload.setProperty(runtime, "value", event.value);
|
|
103
|
+
payload.setProperty(runtime, "selectedSegmentIndex", event.selectedSegmentIndex);
|
|
104
|
+
return payload;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
void SliderEventEmitter::onChange(OnChange event) const {
|
|
108
|
+
dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
109
|
+
auto payload = jsi::Object(runtime);
|
|
110
|
+
payload.setProperty(runtime, "value", event.value);
|
|
111
|
+
payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
112
|
+
return payload;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
void SliderEventEmitter::onValueChange(OnValueChange event) const {
|
|
116
|
+
dispatchEvent("valueChange", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
117
|
+
auto payload = jsi::Object(runtime);
|
|
118
|
+
payload.setProperty(runtime, "value", event.value);
|
|
119
|
+
payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
120
|
+
return payload;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
void SliderEventEmitter::onSlidingComplete(OnSlidingComplete event) const {
|
|
124
|
+
dispatchEvent("slidingComplete", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
125
|
+
auto payload = jsi::Object(runtime);
|
|
126
|
+
payload.setProperty(runtime, "value", event.value);
|
|
127
|
+
payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
128
|
+
return payload;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
void AndroidSwitchEventEmitter::onChange(OnChange event) const {
|
|
132
|
+
dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
133
|
+
auto payload = jsi::Object(runtime);
|
|
134
|
+
payload.setProperty(runtime, "value", event.value);
|
|
135
|
+
return payload;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
void SwitchEventEmitter::onChange(OnChange event) const {
|
|
139
|
+
dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
140
|
+
auto payload = jsi::Object(runtime);
|
|
141
|
+
payload.setProperty(runtime, "value", event.value);
|
|
142
|
+
return payload;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
} // namespace react
|
|
149
|
+
} // namespace facebook
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.464",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-community/cli": "^7.0.1",
|
|
27
27
|
"@react-native-community/cli-platform-android": "^7.0.1",
|
|
28
28
|
"@react-native-community/cli-platform-ios": "^7.0.1",
|
|
29
|
-
"@react-native-windows/cli": "0.0.0-canary.
|
|
29
|
+
"@react-native-windows/cli": "0.0.0-canary.118",
|
|
30
30
|
"@react-native-windows/virtualized-list": "0.0.0-canary.30",
|
|
31
31
|
"@react-native/assets": "1.0.0",
|
|
32
32
|
"@react-native/normalize-color": "2.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"ws": "^6.1.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@react-native-windows/codegen": "0.0.0-canary.
|
|
60
|
+
"@react-native-windows/codegen": "0.0.0-canary.27",
|
|
61
61
|
"@rnw-scripts/eslint-config": "1.1.11",
|
|
62
62
|
"@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.0.5",
|
|
63
63
|
"@rnw-scripts/metro-dev-config": "0.0.0",
|