Skip to content
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

Update layoutDirection in calls to ReactNativeIsland::Arrange #2248

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@callstack/react-native-visionos": "^0.75.0",
"@react-native-webapis/web-storage": "^0.3.0",
"@react-native-webapis/web-storage": "^0 .3.0",
"react": "^18.2.0",
"react-native": "^0.75.0",
"react-native-macos": "^0.75.2",
Expand Down
5 changes: 4 additions & 1 deletion windows/Win32/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ namespace

auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(window.Id());
auto scaleFactor = ScaleFactor(hwnd);
winrt::Microsoft::ReactNative::LayoutConstraints constraints;
winrt::Size size{window.ClientSize().Width / scaleFactor,
window.ClientSize().Height / scaleFactor};
rootView.Arrange({size, size, winrt::LayoutDirection::Undefined}, {0, 0});
constraints.MinimumSize = constraints.MaximumSize = size;
constraints.LayoutDirection = winrt::LayoutDirection::LeftToRight;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really odd. I looked at react-native-windows and cannot see LayoutDirection being set at all: https://github.com/search?q=repo%3Amicrosoft%2Freact-native-windows+UpdateRootViewSizeToAppWindow&type=code

How does this work upstream? I'm not sure hard-coding left-to-right is the correct thing to do here.

Copy link
Member

@tido64 tido64 Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acoates-ms: What's the right fix here? It looks like the playground app hard-codes it to winrt::LayoutDirection::LeftToRight, but should it be read from somewhere?

rootView.Arrange(constraints, {0, 0});
}

winrt::ReactViewOptions MakeReactViewOptions(ReactApp::Component const &component)
Expand Down
4 changes: 4 additions & 0 deletions windows/test-app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ export function generateSolution(destPath, options, fs = nodefs) {
...templateView,
name: path.basename(projectFileName, path.extname(projectFileName)),
useExperimentalNuget: info.useExperimentalNuGet,
rnwPathFromProjectRoot: path.relative(
path.dirname(projectManifest),
rnWindowsPath
),
})
// The current version of this template (v0.63.18) assumes that
// `react-native-windows` is always installed in
Expand Down
21 changes: 0 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3073,26 +3073,6 @@ __metadata:
languageName: node
linkType: hard

"@react-native-webapis/web-storage@npm:^0.3.0":
version: 0.3.0
resolution: "@react-native-webapis/web-storage@npm:0.3.0"
peerDependencies:
"@callstack/react-native-visionos": ">=0.73"
react: ">=18.2.0"
react-native: ">=0.72"
react-native-macos: ">=0.72"
react-native-windows: ">=0.72"
peerDependenciesMeta:
"@callstack/react-native-visionos":
optional: true
react-native-macos:
optional: true
react-native-windows:
optional: true
checksum: 10c0/beb7d762abce424dca060c9af53c2c65fa5033098cc7ad552fa0d75d588046da1027d7f776d4fb2d90ee4c445890e229d9fd3c167ed8f9e8d7c5bf189043560d
languageName: node
linkType: hard

"@react-native-windows/cli@npm:0.75.1":
version: 0.75.1
resolution: "@react-native-windows/cli@npm:0.75.1"
Expand Down Expand Up @@ -7553,7 +7533,6 @@ __metadata:
"@babel/preset-env": "npm:^7.20.0"
"@callstack/react-native-visionos": "npm:^0.75.0"
"@react-native-community/cli": "npm:^14.0.0"
"@react-native-webapis/web-storage": "npm:^0.3.0"
"@react-native/babel-preset": "npm:^0.75.0"
"@react-native/metro-config": "npm:^0.75.0"
"@rnx-kit/metro-config": "npm:^2.0.0"
Expand Down
Loading