Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Force a redraw for right toolbar items. (#8454)
Browse files Browse the repository at this point in the history
fixes #5596
  • Loading branch information
sanyandreichuk authored and samhouts committed Jan 13, 2020
1 parent 1b169f4 commit 3807910
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 5596, "Previous page's toolbar item being grayed out when canceling swipe to previous page then navigating back", PlatformAffected.iOS)]
public class Issue5596 : TestContentPage
{

protected override void Init()
{
ToolbarItems.Add(new ToolbarItem { Text = "Next Page", Command = new Command(async () => await Navigation.PushAsync(new MyTestPage())) });


Content = new Label
{
Margin = 10,
Text = "Click 'Next Page', start a swipe gesture to go back to the previous page but cancel it before it completes. Swipe again or click the back button on the upper left to go back. The toolbar item should not be grayed out."
};
}

private class MyTestPage : ContentPage
{

}
}
}
12 changes: 12 additions & 0 deletions Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,18 @@ public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);

// force a redraw for right toolbar items by resetting TintColor to prevent
// toolbar items being grayed out when canceling swipe to a previous page
foreach (var item in NavigationItem?.RightBarButtonItems)
{
if (item.Image != null)
continue;

var tintColor = item.TintColor;
item.TintColor = tintColor == null ? UIColor.Clear : null;
item.TintColor = tintColor;
}

Disappearing?.Invoke(this, EventArgs.Empty);
}

Expand Down

0 comments on commit 3807910

Please sign in to comment.