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

fix: primarycommand text theme changing #1342

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,45 +135,45 @@ protected override void Render()

if (_isInOverflow)
{
native.SetTitle(null);
native.SetActionView(null);
native.SetIcon(null);
native.SetTitle(null);
}
else
{
var iconOrContent = element.Icon ?? element.Content;
switch (iconOrContent)
var iconOrContent = element.Icon ?? element.Content ?? element.Label;

if (iconOrContent is string || (iconOrContent is FrameworkElement fe && fe.Visibility == Visibility.Visible))
{
case string text:
native.SetIcon(null);
native.SetActionView(null);
native.SetTitle(text);
break;

case FrameworkElement fe:
if (fe.Visibility == Visibility.Visible && _appBarButtonWrapper is { } wrapper)
{
wrapper.Child = element;
if (_appBarButtonWrapper is { } wrapper)
{
wrapper.Child = element;

//Restore the original parent if any, as we
// want the DataContext to flow properly from the
// CommandBar.
element.SetParent(_elementParent);
// Restore the original parent if any, as we
// want the DataContext to flow properly from the
// CommandBar.
element.SetParent(_elementParent);

native.SetIcon(null);
native.SetActionView(wrapper);
if (iconOrContent is string text)
{
wrapper.Child = (UIElement)native.SetTitle(text);
}
else
{
native.SetTitle(null);
}
break;

default:
native.SetIcon(null);
native.SetActionView(null);
native.SetTitle(null);
break;
native.SetActionView(wrapper);
}
}
else
{
native.SetActionView(null);
native.SetTitle(null);
}
}

native.SetIcon(null);

// IsEnabled
native.SetEnabled(element.IsEnabled);
// According to the Material Design guidelines, the opacity inactive icons should be:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ protected override void Render()
var native = Native;
var element = Element ?? throw new InvalidOperationException("Element is null.");

var iconOrContent = element.Icon ?? element.Content;
switch (iconOrContent)
{
case string text:
native.Image = null;
native.ClearCustomView();
native.Title = text;
break;
var iconOrContent = element.Icon ?? element.Content ?? element.Label;

case FrameworkElement fe:
if (iconOrContent is string || (iconOrContent is FrameworkElement fe && fe.Visibility == Visibility.Visible))
{
if (_appBarButtonWrapper is { } wrapper)
{
var currentParent = element.Parent;
_appBarButtonWrapper.Child = element;

Expand All @@ -136,19 +132,19 @@ protected override void Render()
element.SetParent(currentParent);

native.Image = null;
native.CustomView = fe.Visibility == Visibility.Visible ? _appBarButtonWrapper : null;
native.CustomView = _appBarButtonWrapper;
// iOS doesn't add the UIBarButtonItem to the native logical tree unless it has an Image or Title set.
// We default to an empty string to ensure it is added, in order to support late-bound Content.
native.Title = string.Empty;
break;

default:
native.Image = null;
native.ClearCustomView();
// iOS doesn't add the UIBarButtonItem to the native logical tree unless it has an Image or Title set.
// We default to an empty string to ensure it is added.
native.Title = string.Empty;
break;
native.Title = iconOrContent is string text ? text : string.Empty;
}
}
else
{
native.Image = null;
native.ClearCustomView();
// iOS doesn't add the UIBarButtonItem to the native logical tree unless it has an Image or Title set.
// We default to an empty string to ensure it is added.
native.Title = string.Empty;
}

// Label
Expand Down
Loading