From e3a3cf183c2fd262fa829aea319605fbbbe90041 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Wed, 2 Oct 2024 13:21:26 -0500 Subject: [PATCH 1/2] Match Catalyst Template to iOS --- src/Controls/src/Core/Shell/BaseShellItem.cs | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Controls/src/Core/Shell/BaseShellItem.cs b/src/Controls/src/Core/Shell/BaseShellItem.cs index 25aa1605e65c..4f5988e9d4ee 100644 --- a/src/Controls/src/Core/Shell/BaseShellItem.cs +++ b/src/Controls/src/Core/Shell/BaseShellItem.cs @@ -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(); @@ -406,7 +406,7 @@ 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 }); @@ -414,11 +414,11 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str 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 }); @@ -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; @@ -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) }); @@ -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; @@ -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 }); From e7edabda620e4afa8f3e3b9c1efbdaeecdf9c91b Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Wed, 2 Oct 2024 14:21:24 -0500 Subject: [PATCH 2/2] - NS Fixes --- src/Controls/src/Core/Shell/BaseShellItem.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Shell/BaseShellItem.cs b/src/Controls/src/Core/Shell/BaseShellItem.cs index 4f5988e9d4ee..2e677cb1a70c 100644 --- a/src/Controls/src/Core/Shell/BaseShellItem.cs +++ b/src/Controls/src/Core/Shell/BaseShellItem.cs @@ -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 { @@ -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