Skip to content

Commit

Permalink
Match Catalyst Template to iOS for Shell Flyout Items (#25056)
Browse files Browse the repository at this point in the history
* Match Catalyst Template to iOS

* - NS Fixes
  • Loading branch information
PureWeen authored Oct 3, 2024
1 parent 1e26161 commit 6d1f2a4
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/Controls/src/Core/Shell/BaseShellItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
IgnoreSafeArea = true
};
if (DeviceInfo.Platform == DevicePlatform.WinUI)
if (OperatingSystem.IsWindows())
grid.ColumnSpacing = grid.RowSpacing = 0;
grid.Resources = new ResourceDictionary();
Expand Down Expand Up @@ -387,7 +387,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
var selectedState = new VisualState();
selectedState.Name = "Selected";
if (DeviceInfo.Platform != DevicePlatform.WinUI)
if (!OperatingSystem.IsWindows())
{
selectedState.Setters.Add(new Setter
{
Expand All @@ -406,19 +406,19 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
defaultGridClass.Setters.Add(new Setter { Property = VisualStateManager.VisualStateGroupsProperty, Value = groups });
if (DeviceInfo.Platform == DevicePlatform.Android)
if (OperatingSystem.IsAndroid())
defaultGridClass.Setters.Add(new Setter { Property = Grid.HeightRequestProperty, Value = 50 });
else
defaultGridClass.Setters.Add(new Setter { Property = Grid.HeightRequestProperty, Value = 44 });
ColumnDefinitionCollection columnDefinitions = new ColumnDefinitionCollection();
if (DeviceInfo.Platform == DevicePlatform.Android)
if (OperatingSystem.IsAndroid())
columnDefinitions.Add(new ColumnDefinition { Width = 54 });
else if (DeviceInfo.Platform == DevicePlatform.iOS)
else if (OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst())
columnDefinitions.Add(new ColumnDefinition { Width = 50 });
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
else if (OperatingSystem.IsWindows())
columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
else if (DeviceInfo.Platform == DevicePlatform.Tizen)
columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
Expand All @@ -432,11 +432,11 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
var image = new Image();
double sizeRequest = -1;
if (DeviceInfo.Platform == DevicePlatform.Android)
if (OperatingSystem.IsAndroid())
sizeRequest = 24;
else if (DeviceInfo.Platform == DevicePlatform.iOS)
else if (OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst())
sizeRequest = 22;
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
else if (OperatingSystem.IsWindows())
sizeRequest = 16;
else if (DeviceInfo.Platform == DevicePlatform.Tizen)
sizeRequest = 25;
Expand All @@ -447,7 +447,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
defaultImageClass.Setters.Add(new Setter() { Property = Image.WidthRequestProperty, Value = sizeRequest });
}
if (DeviceInfo.Platform == DevicePlatform.WinUI)
if (OperatingSystem.IsWindows())
{
defaultImageClass.Setters.Add(new Setter { Property = Image.HorizontalOptionsProperty, Value = LayoutOptions.Start });
defaultImageClass.Setters.Add(new Setter { Property = Image.MarginProperty, Value = new Thickness(12, 0, 12, 0) });
Expand All @@ -464,7 +464,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
grid.Add(label, 1, 0);
if (DeviceInfo.Platform == DevicePlatform.Android)
if (OperatingSystem.IsAndroid())
{
object textColor;
Expand All @@ -482,12 +482,12 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontFamilyProperty, Value = "sans-serif-medium" });
defaultLabelClass.Setters.Add(new Setter { Property = Label.MarginProperty, Value = new Thickness(20, 0, 0, 0) });
}
else if (DeviceInfo.Platform == DevicePlatform.iOS)
else if (OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst())
{
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = 14 });
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontAttributesProperty, Value = FontAttributes.Bold });
}
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
else if (OperatingSystem.IsWindows())
{
defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalOptionsProperty, Value = LayoutOptions.Start });
defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalTextAlignmentProperty, Value = TextAlignment.Start });
Expand Down Expand Up @@ -537,6 +537,16 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
return grid;
});
}

#if NETSTANDARD
sealed class OperatingSystem
{
public static bool IsAndroid() => false;
public static bool IsIOS() => false;
public static bool IsMacCatalyst() => false;
public static bool IsWindows() => false;
}
#endif
}

public interface IQueryAttributable
Expand Down

0 comments on commit 6d1f2a4

Please sign in to comment.