Skip to content

Commit

Permalink
[iOS][macOS] Remove more superflous version checks
Browse files Browse the repository at this point in the history
Context: dotnet#461

Checks for macOS High Sierra 10.13 and lower have been removed.  The
macOS Mojave check has been updated to use `IsMacCatalystVersionAtLeast`
or `IsMacOSVersionAtLeast`.

Some other checks for iOS 10 and lower have also been removed as they
should not be needed.
  • Loading branch information
pjcollins committed Feb 25, 2022
1 parent 2b568a4 commit d1d6967
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,7 @@ public FormsUITableViewController(ListView element, bool usingLargeTitles)
? UITableViewStyle.Plain
: UITableViewStyle.Grouped)
{
if (PlatformVersion.IsAtLeast(9))
TableView.CellLayoutMarginsFollowReadableWidth = false;
TableView.CellLayoutMarginsFollowReadableWidth = false;

_usingLargeTitles = usingLargeTitles;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,7 @@ void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
{
// Setting TabBarItem.Title in iOS 10 causes rendering bugs
// Work around this by creating a new UITabBarItem on each change
if (e.PropertyName == Page.TitleProperty.PropertyName && !PlatformVersion.IsAtLeast(10))
{
var page = (Page)sender;
var renderer = page.ToHandler(_mauiContext);
if (renderer == null)
return;

if (renderer.ViewController.TabBarItem != null)
renderer.ViewController.TabBarItem.Title = page.Title;
}
else if (e.PropertyName == Page.IconImageSourceProperty.PropertyName || e.PropertyName == Page.TitleProperty.PropertyName && PlatformVersion.IsAtLeast(10))
if (e.PropertyName == Page.IconImageSourceProperty.PropertyName || e.PropertyName == Page.TitleProperty.PropertyName)
{
var page = (Page)sender;

Expand Down Expand Up @@ -445,23 +435,13 @@ void UpdateSelectedTabColors()

if (Tabbed.IsSet(TabbedPage.SelectedTabColorProperty) && Tabbed.SelectedTabColor != null)
{
if (PlatformVersion.IsAtLeast(10))
TabBar.TintColor = Tabbed.SelectedTabColor.ToPlatform();
else
TabBar.SelectedImageTintColor = Tabbed.SelectedTabColor.ToPlatform();

TabBar.TintColor = Tabbed.SelectedTabColor.ToPlatform();
}
else
{
if (PlatformVersion.IsAtLeast(10))
TabBar.TintColor = UITabBar.Appearance.TintColor;
else
TabBar.SelectedImageTintColor = UITabBar.Appearance.SelectedImageTintColor;
TabBar.TintColor = UITabBar.Appearance.TintColor;
}

if (!PlatformVersion.IsAtLeast(10))
return;

if (Tabbed.IsSet(TabbedPage.UnselectedTabColorProperty) && Tabbed.UnselectedTabColor != null)
TabBar.UnselectedItemTintColor = Tabbed.UnselectedTabColor.ToPlatform();
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
_originalBackgroundView = tv.BackgroundView;

SetNativeControl(tv);
if (PlatformVersion.IsAtLeast(9))
tv.CellLayoutMarginsFollowReadableWidth = false;
tv.CellLayoutMarginsFollowReadableWidth = false;

_insetTracker = new KeyboardInsetTracker(tv, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
{
Expand Down
25 changes: 1 addition & 24 deletions src/Compatibility/Core/src/iOS/Forms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,6 @@ internal static bool RespondsToSetNeedsUpdateOfHomeIndicatorAutoHidden
}
}
#else
static bool? s_isSierraOrNewer;

internal static bool IsSierraOrNewer
{
get
{
if (!s_isSierraOrNewer.HasValue)
s_isSierraOrNewer = NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(new NSOperatingSystemVersion(10, 12, 0));
return s_isSierraOrNewer.Value;
}
}

static bool? s_isHighSierraOrNewer;

internal static bool IsHighSierraOrNewer
{
get
{
if (!s_isHighSierraOrNewer.HasValue)
s_isHighSierraOrNewer = NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(new NSOperatingSystemVersion(10, 13, 0));
return s_isHighSierraOrNewer.Value;
}
}

static bool? s_isMojaveOrNewer;

Expand All @@ -148,7 +125,7 @@ internal static bool IsMojaveOrNewer
get
{
if (!s_isMojaveOrNewer.HasValue)
s_isMojaveOrNewer = NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(new NSOperatingSystemVersion(10, 14, 0));
s_isMojaveOrNewer = OperatingSystem.IsMacCatalystVersionAtLeast (10, 14) || OperatingSystem.IsMacOSVersionAtLeast (10, 14);
return s_isMojaveOrNewer.Value;
}
}
Expand Down
13 changes: 0 additions & 13 deletions src/Core/src/Platform/iOS/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,6 @@ public static int IndexOfSubview(this UIView platformView, UIView subview)

public static UIImage? ConvertToImage(this UIView view)
{
if (!PlatformVersion.IsAtLeast(10))
{
UIGraphics.BeginImageContext(view.Frame.Size);
view.Layer.RenderInContext(UIGraphics.GetCurrentContext());
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();

if (image.CGImage == null)
return null;

return new UIImage(image.CGImage);
}

var imageRenderer = new UIGraphicsImageRenderer(view.Bounds.Size);

return imageRenderer.CreateImage((a) =>
Expand Down

0 comments on commit d1d6967

Please sign in to comment.