xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

SHAPES and GEOMETRIES don't respect FlowDirection Property #11536

Open hamiddd1980 opened 4 years ago

hamiddd1980 commented 4 years ago

Description

SHAPES and GEOMETRIES don't respect FlowDirection Property

Steps to Reproduce

For Shapes:

  1. Define a Shape like Polygon in page
  2. change Flowdirection of page from LeftToRight to RightToLeft
  3. Shape is not drawn from Right To Left.In Fact the Shape is in fixed position and always drawn relative to TOP-LEFT corner.(despite the FlowDirection property).in WPF ,the Shape is drawn relative to TOP-Right Corner.
<Page FlowDirection="RightToLeft">
<Grid>
         <Polygon Points="30,30 80,30 80,10 120,50 80,80 80,60 30,60"
         Fill="Orange"
         Stroke="Green"
         StrokeThickness="5" />
</Grid>
</Page>

Steps to Reproduce

For Geometries as Clip: 1.define a Grid as container for an Image view 2.put Image view inside Grid. 3.Define a simple Geometry like Rectangle 4.set Grid Clip property to mentioned Rectangle 5.change Flowdirection of page from LeftToRight to RightToLeft 6.The Geometry location is always calculated relative to TOP-LEFT corner , so despite the fact that flowdirection is RightToLeft,Geometry clips the Left side if Image.

<Page FlowDirection="RightToLeft">
<Grid HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Orange">
            <Image Source="picture1.jpg" HorizontalOptions="Center" VerticalOptions="Center"/>
            <Grid.Clip>
                <RectangleGeometry Rect="0,0,150,200"/>
            </Grid.Clip>
 </Grid>
</Page>

Expected Behavior

when FlowDirection is LeftToRight every thing is OK. in page with FlowDirection set to RightToLeft , it is expected that the shapes and Geometries (like other VIEWS) also respect the flow direction and mirrored and laid out from Right side of it's parent.(it's coordinate center must be TOP-RIGHT like WPF)

Actual Behavior

when FlowDirection is RightToLeft the Shape and Geometry Views Don't get Mirrored.In fact the position of points in these elements are always calculated and drawn relative to TOP-LEFT point.

Basic Information

Screenshots

WPF shows Shapes and Geometries Correctly. I use it just to Show the problem in iOS and Android Comparing FlowDirection in WPF and Xamarin.Forms(Android and iOS): for SHAPES and GEOMETRY as Clip 1-WPF Shapes: 1-1)Define a simple shape(here it is polygon): 1-2)Page FlowDirection = LeftToRight wpf shape-LTR1

1-3)Page FlowDirection = RightToLeft wpf shape-RTL1

2-iOS and Android Shape: 2-1)Define a simple shape(here it is polygon): 2-2)Page FlowDirection = LeftToRight ios shape-LTR page1

2-3)Page FlowDirection = RightToLeft ios shape-RTL page1

3-WPF Geometry as Clipping mask: 3-1)Define an image inside a Grid View and set Grid Clip property to a Geometry(Here a Rectangle):

wpf-full image

3-2)Apply a Rectangle Geometry as Clip to Parent Grid -Page FlowDirection=LeftToRight Rectangle Geometry width is half of Image Width to show only half of image. wpf-LTR page1

3-3)Apply a Rectangle Geometry as Clip to Parent Grid -Page FlowDirection = RightToLeft wpf-RTL page1

4)iOS and Android Geometry as Clipping mask: 4-1)Define an image inside a Grid View and set Grid Clip property to a Geometry(Here a Rectangle): ios-full image1

4-2)Apply a Rectangle Geometry as Clip to Parent Grid -Page FlowDirection=LeftToRight Rectangle Geometry width is half of Image Width to show only half of image. ios-LTR page1

4-3)Apply a Rectangle Geometry as Clip to Parent Grid -Page FlowDirection = RightToLeft ios-RTL page1

Reproduction Link

I would appreciate it if you would consider this problem and solve it in next Releases.Because in languages like Arabic ,Hebrew...(Cultures with Right To Left language) the views must be laid out from Right To Left and if this problem persists, it will be Difficult or Impossible to utilize these new useful features (Shapes and Geometry) in apps written for countries with Right To Left language. In fact I spent a long time to learn Xamarin Forms , but when I want to use it in business as a JOB ,Problems related to Right To Left flow direction(Like item mentioned above) ,prevent me from satisfying my customers requirements. Thank you for taking this into consideration.

hamiddd1980 commented 4 years ago

to depict the problem, please consider the following example and video: suppose we have a Grid with 4 buttons in 4 Rows which a Geometry like Trapezius is applied to its Clip property , when you change the flow direction from LeftToRight to RightToLeft , the Grid itself respect the flowdirection and is laid out from Right side of page , but the Clipping Geometry (Trapezius ) doesn’t act so and stays fix in its position. this causes the child buttons in Grid become invisible in RightToLeft flow direction. Rec 0005