[Android] fixes Right-to-Left Hamburger icon in MasterDetailPage (#4716) fixes #2818
authorPavel Yakovlev <v-payako@microsoft.com>
Thu, 10 Jan 2019 17:56:11 +0000 (20:56 +0300)
committerRui Marinho <me@ruimarinho.net>
Thu, 10 Jan 2019 17:56:11 +0000 (17:56 +0000)
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2818.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2818.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2818.cs
new file mode 100644 (file)
index 0000000..2b6ca3f
--- /dev/null
@@ -0,0 +1,46 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Github, 2818, "Right-to-Left MasterDetail in Xamarin.Forms Hamburger icon issue", PlatformAffected.Android)]
+       public class Issue2818 : MasterDetailPage
+       {
+               public Issue2818()
+               {
+                       FlowDirection = FlowDirection.RightToLeft;
+
+                       Master = new ContentPage
+                       {
+                               Title = "Master",
+                               BackgroundColor = Color.SkyBlue,
+                               Icon = "menuIcon"
+                       };
+
+                       Detail = new NavigationPage(new ContentPage
+                       {
+                               Title = "Detail",
+                               Content = new StackLayout
+                               {
+                                       Children = {
+                                               new Label
+                                               {
+                                                       Text = "The page must be with RightToLeft FlowDirection. Hamburger icon in main page must be going to right side."
+                                               },
+                                               new Button
+                                               {
+                                                       Text = "Set RightToLeft",
+                                                       Command = new Command(() => FlowDirection = FlowDirection.RightToLeft)
+                                               },
+                                               new Button
+                                               {
+                                                       Text = "Set LeftToRight",
+                                                       Command = new Command(() => FlowDirection = FlowDirection.LeftToRight)
+                                               }
+                                       }
+                               }
+                       });
+               }
+       }
+}
index 5c21157..4cf0fc0 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)Issue3525.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue3275.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue3884.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Issue2818.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue2831.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue4040.xaml.cs">
       <DependentUpon>Issue4040.xaml</DependentUpon>
index 5d49718..d279d5d 100644 (file)
@@ -57,6 +57,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
                        }
                }
 
+               public void UpdateFlowDirection() => _pageContainer?.UpdateFlowDirection(_parent);
+
                protected override void AddChildView(VisualElement childView)
                {
                        _pageContainer = null;
@@ -100,6 +102,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
                                fc?.SetOnCreateCallback(pc =>
                                {
                                        _pageContainer = pc;
+                                       UpdateFlowDirection();
                                        SetDefaultBackgroundColor(pc.Child);
                                });
 
index 2d02e6a..de1b0c4 100644 (file)
@@ -401,6 +401,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
                void UpdateFlowDirection()
                {
                        this.UpdateFlowDirection(Element);
+                       _detailLayout.UpdateFlowDirection();
                }
 
                void UpdateIsPresented()