-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook up fabric view component codegen #7759
Merged
Merged
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f529397
Hook up view component codegen
acoates-ms 290d9ce
Change files
acoates-ms 2d19aab
Dont use relative imports
acoates-ms c7de3b4
format
acoates-ms d6ff54b
Change files
acoates-ms 836fb6f
Run codegen for all the view components
acoates-ms 1c19cbc
fix path
acoates-ms 365d987
change to ignore codegen formatting
acoates-ms 428620a
x86 build fix
acoates-ms 835d3af
Add clang-format override file for codegen
acoates-ms a1dc005
codegen uses LF
acoates-ms 05b3713
yse yargs required
acoates-ms aec74a9
tmp
acoates-ms f33036b
readd codegen'd files using LF
acoates-ms 12f17af
Disable sort includes on the codegen files
acoates-ms bdb4500
updated clang-format file
acoates-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@react-native-windows-codegen-8bf5b93f-6631-4c78-9860-a9e27b71521e.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Hook up view component codegen", | ||
"packageName": "@react-native-windows/codegen", | ||
"email": "30809111+acoates-ms@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@rnw-scripts-format-files-04311b1d-6be6-4a29-a7ad-193f9d1481e8.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Dont format files in codegen", | ||
"packageName": "@rnw-scripts/format-files", | ||
"email": "30809111+acoates-ms@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-5b852b93-ed97-49c0-a263-a649a03c12fa.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Hook up view component codegen", | ||
"packageName": "react-native-windows", | ||
"email": "30809111+acoates-ms@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
vnext/Microsoft.ReactNative/Fabric/ActivityIndicatorComponentView.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include "ActivityIndicatorComponentView.h" | ||
|
||
#include <UI.Xaml.Controls.h> | ||
#include <Utils/ValueUtils.h> | ||
|
||
#include <react/components/rnwcore/Props.h> | ||
|
||
namespace Microsoft::ReactNative { | ||
|
||
ActivityIndicatorComponentView::ActivityIndicatorComponentView() : m_element(xaml::Controls::ProgressRing()) { | ||
static auto const defaultProps = std::make_shared<facebook::react::ActivityIndicatorViewProps const>(); | ||
m_props = defaultProps; | ||
} | ||
|
||
std::vector<facebook::react::ComponentDescriptorProvider> | ||
ActivityIndicatorComponentView::supplementalComponentDescriptorProviders() noexcept { | ||
return {}; | ||
} | ||
|
||
void ActivityIndicatorComponentView::mountChildComponentView( | ||
const IComponentView &childComponentView, | ||
uint32_t index) noexcept { | ||
assert(false); | ||
} | ||
|
||
void ActivityIndicatorComponentView::unmountChildComponentView( | ||
const IComponentView &childComponentView, | ||
uint32_t index) noexcept { | ||
assert(false); | ||
} | ||
|
||
void ActivityIndicatorComponentView::updateProps( | ||
facebook::react::Props::Shared const &props, | ||
facebook::react::Props::Shared const &oldProps) noexcept { | ||
const auto &oldActivityProps = *std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(m_props); | ||
const auto &newActivityProps = *std::static_pointer_cast<const facebook::react::ActivityIndicatorViewProps>(props); | ||
|
||
if (oldActivityProps.animating != newActivityProps.animating) { | ||
m_element.IsActive(newActivityProps.animating); | ||
} | ||
|
||
if (oldActivityProps.color != newActivityProps.color) { | ||
m_element.Foreground(SolidColorBrushFrom(newActivityProps.color)); | ||
} | ||
|
||
m_props = std::static_pointer_cast<facebook::react::ActivityIndicatorViewProps const>(props); | ||
} | ||
|
||
void ActivityIndicatorComponentView::updateState( | ||
facebook::react::State::Shared const &state, | ||
facebook::react::State::Shared const &oldState) noexcept {} | ||
void ActivityIndicatorComponentView::updateLayoutMetrics( | ||
facebook::react::LayoutMetrics const &layoutMetrics, | ||
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept { | ||
// Set Position & Size Properties | ||
|
||
m_layoutMetrics = layoutMetrics; | ||
|
||
winrt::Microsoft::ReactNative::ViewPanel::SetLeft(m_element, layoutMetrics.frame.origin.x); | ||
winrt::Microsoft::ReactNative::ViewPanel::SetTop(m_element, layoutMetrics.frame.origin.y); | ||
|
||
m_element.Width(layoutMetrics.frame.size.width); | ||
m_element.Height(layoutMetrics.frame.size.height); | ||
} | ||
void ActivityIndicatorComponentView::finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept {} | ||
void ActivityIndicatorComponentView::prepareForRecycle() noexcept {} | ||
facebook::react::SharedProps ActivityIndicatorComponentView::props() noexcept { | ||
assert(false); | ||
return {}; | ||
} | ||
|
||
const xaml::FrameworkElement ActivityIndicatorComponentView::Element() const noexcept { | ||
return m_element; | ||
} | ||
|
||
} // namespace Microsoft::ReactNative |
46 changes: 46 additions & 0 deletions
46
vnext/Microsoft.ReactNative/Fabric/ActivityIndicatorComponentView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
#include "ComponentView.h" | ||
|
||
#include <Microsoft.ReactNative.Cxx/ReactContext.h> | ||
#include <UI.Xaml.Controls.h> | ||
#include "ViewComponentView.h" | ||
|
||
#pragma warning(push) | ||
#pragma warning(disable : 4244 4305) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note 4244 is sdl, is this one that's already being fixed in core? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes there is already a PR out for this one. |
||
#include <react/renderer/components/view/ViewProps.h> | ||
#pragma warning(pop) | ||
|
||
namespace Microsoft::ReactNative { | ||
|
||
struct ActivityIndicatorComponentView : BaseComponentView { | ||
ActivityIndicatorComponentView(); | ||
|
||
std::vector<facebook::react::ComponentDescriptorProvider> supplementalComponentDescriptorProviders() noexcept | ||
override; | ||
void mountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept override; | ||
void unmountChildComponentView(const IComponentView &childComponentView, uint32_t index) noexcept override; | ||
void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept | ||
override; | ||
void updateState(facebook::react::State::Shared const &state, facebook::react::State::Shared const &oldState) noexcept | ||
override; | ||
void updateLayoutMetrics( | ||
facebook::react::LayoutMetrics const &layoutMetrics, | ||
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override; | ||
void finalizeUpdates(RNComponentViewUpdateMask updateMask) noexcept override; | ||
void prepareForRecycle() noexcept override; | ||
facebook::react::SharedProps props() noexcept override; | ||
|
||
const xaml::FrameworkElement Element() const noexcept override; | ||
|
||
private: | ||
facebook::react::SharedViewProps m_props; | ||
facebook::react::LayoutMetrics m_layoutMetrics; | ||
xaml::Controls::ProgressRing m_element; | ||
}; | ||
|
||
} // namespace Microsoft::ReactNative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
vnext/Microsoft.ReactNative/Fabric/platform/react/components/image/conversions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// RN has some weird include directory redirections..this forwards the include to the right place | ||
#include <react/renderer/components/image/conversions.h> |
5 changes: 5 additions & 0 deletions
5
vnext/Microsoft.ReactNative/Fabric/platform/react/components/view/ConcreteViewShadowNode.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// RN has some weird include directory redirections..this forwards the include to the right place | ||
#include <react/renderer/components/view/ConcreteViewShadowNode.h> |
5 changes: 5 additions & 0 deletions
5
vnext/Microsoft.ReactNative/Fabric/platform/react/components/view/ViewEventEmitter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// RN has some weird include directory redirections..this forwards the include to the right place | ||
#include <react/renderer/components/view/ViewEventEmitter.h> |
5 changes: 5 additions & 0 deletions
5
vnext/Microsoft.ReactNative/Fabric/platform/react/components/view/ViewProps.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
// RN has some weird include directory redirections..this forwards the include to the right place | ||
#include <react/renderer/components/view/ViewProps.h> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI that we're still on an older version of tscodegen/codegen. Zihan published a new version, with some possible changes, but I hadn't pulled it into RNW yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. I keep wondering if we are going to need to pull tscodegen into rnw repo. Right now it seems to be ok with the older version. but it does worry me.
Do we have RN-core publishing the codegen pacakge in daily builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. Original plan was for me to hookup nightlies for monorepo packages, but code stopped being pulled into separate packages so the urgency dropped off. There is a ready-made tscodegen that is newer than what we have rn though.