Fixed FlowDirection property not working on Drawable control and GraphicsView#34557
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34557Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34557" |
There was a problem hiding this comment.
Pull request overview
This PR fixes FlowDirection support for Shape-based drawables (e.g., BoxView/ShapeView) and GraphicsView by ensuring RTL flow direction results in a mirrored drawing surface across Android/iOS/Windows, and adds UI test coverage for issue #34402.
Changes:
- Mirror
PlatformGraphicsViewdrawing output in RTL mode on Android, iOS, and Windows. - Add
FlowDirectionmapping toShapeViewHandlerso shape-backed controls react toFlowDirectionchanges. - Add a HostApp repro page + Appium screenshot tests (and snapshots) for issue #34402.
Reviewed changes
Copilot reviewed 7 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Graphics/src/Graphics/Platforms/Android/PlatformGraphicsView.cs | Mirrors the Android canvas in RTL by translating + scaling before drawing. |
| src/Graphics/src/Graphics/Platforms/iOS/PlatformGraphicsView.cs | Mirrors the CoreGraphics context in RTL using TranslateCTM + ScaleCTM, scoped with save/restore. |
| src/Graphics/src/Graphics/Platforms/Windows/PlatformGraphicsView.cs | Applies a Win2D transform (scale + translation) in RTL before drawing. |
| src/Core/src/Handlers/ShapeView/ShapeViewHandler.cs | Adds a FlowDirection mapper to ensure shape views update and invalidate when flow direction changes. |
| src/Core/src/Handlers/ShapeView/ShapeViewHandler.Standard.cs | Adds the corresponding stub mapper for non-platform builds. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue34402.cs | Adds a HostApp page to reproduce and visually validate LTR↔RTL mirroring for BoxView and GraphicsView. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34402.cs | Adds Appium tests that validate the mirroring via screenshot baselines. |
| src/Controls/tests/TestCases.Android.Tests/snapshots/android/GraphicsView_RTL_AfterButton.png | Adds/updates an Android screenshot baseline for the new test. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
kubaflo
left a comment
There was a problem hiding this comment.
Could you please look at the AI's summary?
The gate failure on Android appears to be environment-related — one leg was blocked by an ADB0010 broken pipe error (infra issue, not a test failure), and the secondary ~2.08% GraphicsViewFlowDirectionShouldMirrorOnRTL screenshot drift is consistent with emulator rendering noise; the test passes consistently in local runs. |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
ba0d53d to
9a7da44
Compare
|
Validated the AI summary concerns and confirmed that the concerns are invalid. |
Code Review — PR #34557Independent AssessmentWhat this changes: Three-pronged fix for
Inferred motivation: When Reconciliation with PR NarrativeAuthor claims: ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring. Correction: The base Findings
|
…hicsView (dotnet#34557) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView. When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior. ### Root Cause ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring. ### Description of Change **Android**: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method. **iOS**: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode. **Windows**: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content. ### Validated the behaviour in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed: Fixes dotnet#34402 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/62bec2c7-dbe5-4696-9f78-d2d1b4bcdaec"> | <video src="https://github.com/user-attachments/assets/d143819d-b525-455b-adeb-d589171de61e"> |
…hicsView (#34557) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView. When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior. ### Root Cause ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring. ### Description of Change **Android**: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method. **iOS**: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode. **Windows**: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content. ### Validated the behaviour in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed: Fixes #34402 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/62bec2c7-dbe5-4696-9f78-d2d1b4bcdaec"> | <video src="https://github.com/user-attachments/assets/d143819d-b525-455b-adeb-d589171de61e"> |
…hicsView (#34557) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView. When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior. ### Root Cause ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring. ### Description of Change **Android**: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method. **iOS**: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode. **Windows**: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content. ### Validated the behaviour in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed: Fixes #34402 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/62bec2c7-dbe5-4696-9f78-d2d1b4bcdaec"> | <video src="https://github.com/user-attachments/assets/d143819d-b525-455b-adeb-d589171de61e"> |
…hicsView (#34557) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView. When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior. ### Root Cause ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring. ### Description of Change **Android**: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method. **iOS**: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode. **Windows**: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content. ### Validated the behaviour in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed: Fixes #34402 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/62bec2c7-dbe5-4696-9f78-d2d1b4bcdaec"> | <video src="https://github.com/user-attachments/assets/d143819d-b525-455b-adeb-d589171de61e"> |
…hicsView (#34557) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView. When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior. ### Root Cause ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring. ### Description of Change **Android**: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method. **iOS**: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode. **Windows**: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content. ### Validated the behaviour in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed: Fixes #34402 ### Screenshots | Before | After | |---------|--------| | <video src="https://github.com/user-attachments/assets/62bec2c7-dbe5-4696-9f78-d2d1b4bcdaec"> | <video src="https://github.com/user-attachments/assets/d143819d-b525-455b-adeb-d589171de61e"> |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details
The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView.
When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior.
Root Cause
ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring.
Description of Change
Android: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method.
iOS: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode.
Windows: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #34402
Screenshots
34402_BeforeChange.mov
34402_AfterChanges.mov