Skip to content

Commit 6d1f2a4

Browse files
authored
Match Catalyst Template to iOS for Shell Flyout Items (#25056)
* Match Catalyst Template to iOS * - NS Fixes
1 parent 1e26161 commit 6d1f2a4

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/Controls/src/Core/Shell/BaseShellItem.cs

+23-13
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
348348
IgnoreSafeArea = true
349349
};
350350

351-
if (DeviceInfo.Platform == DevicePlatform.WinUI)
351+
if (OperatingSystem.IsWindows())
352352
grid.ColumnSpacing = grid.RowSpacing = 0;
353353

354354
grid.Resources = new ResourceDictionary();
@@ -387,7 +387,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
387387
var selectedState = new VisualState();
388388
selectedState.Name = "Selected";
389389

390-
if (DeviceInfo.Platform != DevicePlatform.WinUI)
390+
if (!OperatingSystem.IsWindows())
391391
{
392392
selectedState.Setters.Add(new Setter
393393
{
@@ -406,19 +406,19 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
406406

407407
defaultGridClass.Setters.Add(new Setter { Property = VisualStateManager.VisualStateGroupsProperty, Value = groups });
408408

409-
if (DeviceInfo.Platform == DevicePlatform.Android)
409+
if (OperatingSystem.IsAndroid())
410410
defaultGridClass.Setters.Add(new Setter { Property = Grid.HeightRequestProperty, Value = 50 });
411411
else
412412
defaultGridClass.Setters.Add(new Setter { Property = Grid.HeightRequestProperty, Value = 44 });
413413

414414

415415
ColumnDefinitionCollection columnDefinitions = new ColumnDefinitionCollection();
416416

417-
if (DeviceInfo.Platform == DevicePlatform.Android)
417+
if (OperatingSystem.IsAndroid())
418418
columnDefinitions.Add(new ColumnDefinition { Width = 54 });
419-
else if (DeviceInfo.Platform == DevicePlatform.iOS)
419+
else if (OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst())
420420
columnDefinitions.Add(new ColumnDefinition { Width = 50 });
421-
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
421+
else if (OperatingSystem.IsWindows())
422422
columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
423423
else if (DeviceInfo.Platform == DevicePlatform.Tizen)
424424
columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
@@ -432,11 +432,11 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
432432
var image = new Image();
433433

434434
double sizeRequest = -1;
435-
if (DeviceInfo.Platform == DevicePlatform.Android)
435+
if (OperatingSystem.IsAndroid())
436436
sizeRequest = 24;
437-
else if (DeviceInfo.Platform == DevicePlatform.iOS)
437+
else if (OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst())
438438
sizeRequest = 22;
439-
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
439+
else if (OperatingSystem.IsWindows())
440440
sizeRequest = 16;
441441
else if (DeviceInfo.Platform == DevicePlatform.Tizen)
442442
sizeRequest = 25;
@@ -447,7 +447,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
447447
defaultImageClass.Setters.Add(new Setter() { Property = Image.WidthRequestProperty, Value = sizeRequest });
448448
}
449449

450-
if (DeviceInfo.Platform == DevicePlatform.WinUI)
450+
if (OperatingSystem.IsWindows())
451451
{
452452
defaultImageClass.Setters.Add(new Setter { Property = Image.HorizontalOptionsProperty, Value = LayoutOptions.Start });
453453
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
464464

465465
grid.Add(label, 1, 0);
466466

467-
if (DeviceInfo.Platform == DevicePlatform.Android)
467+
if (OperatingSystem.IsAndroid())
468468
{
469469
object textColor;
470470

@@ -482,12 +482,12 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
482482
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontFamilyProperty, Value = "sans-serif-medium" });
483483
defaultLabelClass.Setters.Add(new Setter { Property = Label.MarginProperty, Value = new Thickness(20, 0, 0, 0) });
484484
}
485-
else if (DeviceInfo.Platform == DevicePlatform.iOS)
485+
else if (OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst())
486486
{
487487
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = 14 });
488488
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontAttributesProperty, Value = FontAttributes.Bold });
489489
}
490-
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
490+
else if (OperatingSystem.IsWindows())
491491
{
492492
defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalOptionsProperty, Value = LayoutOptions.Start });
493493
defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalTextAlignmentProperty, Value = TextAlignment.Start });
@@ -537,6 +537,16 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
537537
return grid;
538538
});
539539
}
540+
541+
#if NETSTANDARD
542+
sealed class OperatingSystem
543+
{
544+
public static bool IsAndroid() => false;
545+
public static bool IsIOS() => false;
546+
public static bool IsMacCatalyst() => false;
547+
public static bool IsWindows() => false;
548+
}
549+
#endif
540550
}
541551

542552
public interface IQueryAttributable

0 commit comments

Comments
 (0)