Skip to content

Commit

Permalink
Restore and fix tvOS checks and annotations
Browse files Browse the repository at this point in the history
Some of them got lost in #6237
  • Loading branch information
akoeplinger committed Apr 28, 2022
1 parent b50ed56 commit 59c06ab
Show file tree
Hide file tree
Showing 35 changed files with 78 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ public static void TestKeyboardFlags(this UITextAutocapitalizationType currentVa
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios14.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos14.0")]
public class ExtendedEntryCellRenderer : Handlers.Compatibility.EntryCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public UIViewController ViewController

//TODO: this was deprecated in iOS8.0 and is not called in 9.0+
[UnsupportedOSPlatform("ios8.0")]
[UnsupportedOSPlatform("tvos")]
public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate(fromInterfaceOrientation);
Expand Down Expand Up @@ -1029,6 +1030,7 @@ public Page Child
public event EventHandler Appearing;

[UnsupportedOSPlatform("ios8.0")]
[UnsupportedOSPlatform("tvos")]
public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate(fromInterfaceOrientation);
Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/iOS/Renderers/PageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public override void ViewDidLayoutSubviews()
}

[SupportedOSPlatform("ios11.0")]
[SupportedOSPlatform("tvos11.0")]
public override void ViewSafeAreaInsetsDidChange()
{
_safeAreasSet = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public override void ViewDidLoad()
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios8.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, double duration)
{
if (!FlyoutPageController.ShouldShowSplitMode && _presented)
Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/iOS/Renderers/TabbedRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public UIViewController ViewController
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios8.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate(fromInterfaceOrientation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public override void ViewDidLoad()
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios8.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, double duration)
{
if (!FlyoutPageController.ShouldShowSplitMode && _presented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public EntryCellRenderer()
}

[UnsupportedOSPlatform("ios14.0")]
[UnsupportedOSPlatform("tvos14.0")]
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var entryCell = (EntryCell)item;
Expand Down Expand Up @@ -56,6 +57,7 @@ public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell,
}

[UnsupportedOSPlatform("ios14.0")]
[UnsupportedOSPlatform("tvos14.0")]
static void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
{
var entryCell = (EntryCell)sender;
Expand Down Expand Up @@ -101,6 +103,7 @@ static void UpdateHorizontalTextAlignment(EntryCellTableViewCell cell, EntryCell
}

[UnsupportedOSPlatform("ios14.0")]
[UnsupportedOSPlatform("tvos14.0")]
static void UpdateIsEnabled(EntryCellTableViewCell cell, EntryCell entryCell)
{
cell.UserInteractionEnabled = entryCell.IsEnabled;
Expand All @@ -115,12 +118,14 @@ static void UpdateKeyboard(EntryCellTableViewCell cell, EntryCell entryCell)
}

[UnsupportedOSPlatform("ios14.0")]
[UnsupportedOSPlatform("tvos14.0")]
static void UpdateLabel(EntryCellTableViewCell cell, EntryCell entryCell)
{
cell.TextLabel.Text = entryCell.Label;
}

[UnsupportedOSPlatform("ios14.0")]
[UnsupportedOSPlatform("tvos14.0")]
static void UpdateLabelColor(EntryCellTableViewCell cell, EntryCell entryCell)
{
cell.TextLabel.TextColor = entryCell.LabelColor?.ToPlatform() ?? DefaultTextColor.ToPlatform();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
if (Control == null)
{
if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
{
var parentNav = e.NewElement.FindParentOfType<NavigationPage>();
_usingLargeTitles = (parentNav != null && parentNav.OnThisPlatform().PrefersLargeTitles());
}
_tableViewController = new FormsUITableViewController(e.NewElement, _usingLargeTitles);
SetNativeControl(_tableViewController.TableView);

if (OperatingSystem.IsIOSVersionAtLeast(15))
if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15))
_tableViewController.TableView.SectionHeaderTopPadding = new nfloat(0);

_backgroundUIView = _tableViewController.TableView.BackgroundView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected virtual void HandlePropertyChanged(object sender, PropertyChangedEvent
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios14.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos14.0")]
static void UpdateIsEnabled(CellTableViewCell cell, TextCell entryCell)
{
cell.UserInteractionEnabled = entryCell.IsEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public UIViewController ViewController

//TODO: this was deprecated in iOS8.0 and is not called in 9.0+
[System.Runtime.Versioning.UnsupportedOSPlatform("ios8.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate(fromInterfaceOrientation);
Expand Down Expand Up @@ -467,7 +468,7 @@ void UpdateHideNavigationBarSeparator()
if (_defaultNavBarShadowImage == null)
_defaultNavBarShadowImage = NavigationBar.ShadowImage;

if (OperatingSystem.IsIOSVersionAtLeast(13))
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
{
if (shouldHide)
{
Expand All @@ -490,7 +491,7 @@ void UpdateHideNavigationBarSeparator()
NavigationBar.ShadowImage = _defaultNavBarShadowImage;
}

if (!OperatingSystem.IsIOSVersionAtLeast(11))
if (!(OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11)))
{
// For iOS 10 and lower, you need to set the background image.
// If you set this for iOS11, you'll remove the background color.
Expand Down Expand Up @@ -629,7 +630,7 @@ void UpdateBarBackground()
{
var barBackgroundColor = NavPage.BarBackgroundColor;

if (OperatingSystem.IsIOSVersionAtLeast(13))
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
{
var navigationBarAppearance = NavigationBar.StandardAppearance;

Expand Down Expand Up @@ -729,7 +730,7 @@ void SetStatusBarStyle()
if (statusBarColorMode == StatusBarTextColorMode.DoNotAdjust || barTextColor?.GetLuminosity() <= 0.5)
{
// Use dark text color for status bar
if (OperatingSystem.IsIOSVersionAtLeast(13))
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
{
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.DarkContent;
}
Expand Down Expand Up @@ -1024,6 +1025,7 @@ public Page Child
public event EventHandler Appearing;

[System.Runtime.Versioning.UnsupportedOSPlatform("ios8.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate(fromInterfaceOrientation);
Expand Down Expand Up @@ -1187,7 +1189,7 @@ void HandleChildPropertyChanged(object sender, PropertyChangedEventArgs e)

internal void SetupDefaultNavigationBarAppearance()
{
if (!OperatingSystem.IsIOSVersionAtLeast(13))
if (!(OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13)))
return;

if (!_navigation.TryGetTarget(out NavigationRenderer navigationRenderer))
Expand Down Expand Up @@ -1491,6 +1493,7 @@ public override bool ShouldAutorotate()
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios6.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
{
if (Child?.Handler is IPlatformViewHandler ivh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public virtual void SetAppearance(UITabBarController controller, ShellAppearance
_defaultUnselectedTint = tabBar.UnselectedItemTintColor;
}

if (OperatingSystem.IsIOSVersionAtLeast(15))
if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15))
UpdateiOS15TabBarAppearance(controller, appearance);
else
UpdateTabBarAppearance(controller, appearance);
Expand All @@ -65,6 +65,7 @@ public void Dispose()
#endregion

[System.Runtime.Versioning.SupportedOSPlatform("ios15.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos15.0")]
void UpdateiOS15TabBarAppearance(UITabBarController controller, ShellAppearance appearance)
{
IShellAppearanceElement appearanceElement = appearance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private set
else if (ContentView is IPlatformViewHandler ver && ver.PlatformView is UIScrollView uIScroll)
ScrollView = uIScroll;

if (ScrollView != null && OperatingSystem.IsIOSVersionAtLeast(11))
if (ScrollView != null && (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11)))
ScrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;

LayoutParallax();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void SetAppearance(UINavigationController controller, ShellAppearance app
_defaultTitleAttributes = navBar.TitleTextAttributes;
}

if (OperatingSystem.IsIOSVersionAtLeast(15))
if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15))
UpdateiOS15NavigationBarAppearance(controller, appearance);
else
UpdateNavigationBarAppearance(controller, appearance);
Expand Down Expand Up @@ -85,7 +85,8 @@ public virtual void SetHasShadow(UINavigationController controller, bool hasShad

#endregion

[SupportedOSPlatform("ios13.0")]
[SupportedOSPlatform("ios15.0")]
[SupportedOSPlatform("tvos15.0")]
void UpdateiOS15NavigationBarAppearance(UINavigationController controller, ShellAppearance appearance)
{
var navBar = controller.NavigationBar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected virtual void OnRendererSet()
{
NavigationItem = ViewController.NavigationItem;

if (!OperatingSystem.IsIOSVersionAtLeast(11))
if (!(OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11)))
{
ViewController.AutomaticallyAdjustsScrollViewInsets = false;
}
Expand Down Expand Up @@ -417,7 +417,7 @@ public TitleViewContainer(View view) : base(view)
{
MatchHeight = true;

if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
{
TranslatesAutoresizingMaskIntoConstraints = false;
}
Expand All @@ -433,7 +433,7 @@ public override CGRect Frame
get => base.Frame;
set
{
if (!OperatingSystem.IsIOSVersionAtLeast(11) && Superview != null)
if (!(OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11)) && Superview != null)
{
value.Y = Superview.Bounds.Y;
value.Height = Superview.Bounds.Height;
Expand All @@ -447,7 +447,7 @@ public override void WillMoveToSuperview(UIView newSuper)
{
if (newSuper != null)
{
if (!OperatingSystem.IsIOSVersionAtLeast(11))
if (!(OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11)))
Frame = new CGRect(Frame.X, newSuper.Bounds.Y, Frame.Width, newSuper.Bounds.Height);

Height = newSuper.Bounds.Height;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void OnLayoutSubviews()
if (!_isInShell)
return;

if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
{
var newBounds = _scrollView.AdjustedContentInset.InsetRect(_scrollView.Bounds).ToRectangle();
newBounds.X = 0;
Expand Down Expand Up @@ -108,7 +108,7 @@ void UpdateContentInset(Thickness inset, double tabThickness)
{
_lastInset = inset;
_tabThickness = tabThickness;
if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
{
if (ShellSectionController.GetItems().Count > 1 && _isInItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override void ViewDidLoad()
base.ViewDidLoad();

_containerArea = new UIView();
if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
_containerArea.InsetsLayoutMarginsFromSafeArea = false;

View.AddSubview(_containerArea);
Expand Down Expand Up @@ -112,6 +112,7 @@ public override void ViewWillAppear(bool animated)
}

[System.Runtime.Versioning.SupportedOSPlatform("ios11.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos11.0")]
public override void ViewSafeAreaInsetsDidChange()
{
if (_isDisposed)
Expand Down Expand Up @@ -507,7 +508,7 @@ void LayoutHeader()
if (_header != null)
{
tabThickness = HeaderHeight;
var headerTop = OperatingSystem.IsIOSVersionAtLeast(11) ? View.SafeAreaInsets.Top : TopLayoutGuide.Length;
var headerTop = (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11)) ? View.SafeAreaInsets.Top : TopLayoutGuide.Length;
CGRect frame = new CGRect(View.Bounds.X, headerTop, View.Bounds.Width, HeaderHeight);
_blurView.Frame = frame;
_header.ViewController.View.Frame = frame;
Expand All @@ -517,7 +518,7 @@ void LayoutHeader()
nfloat top;
nfloat right;
nfloat bottom;
if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
{
left = View.SafeAreaInsets.Left;
top = View.SafeAreaInsets.Top;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ public override void ViewDidLoad()
base.ViewDidLoad();

TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
if (OperatingSystem.IsIOSVersionAtLeast(11))
if (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsTvOSVersionAtLeast(11))
TableView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;

TableView.Source = _source;
ShellFlyoutContentManager.ViewDidLoad();
}

[System.Runtime.Versioning.SupportedOSPlatform("ios11.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos11.0")]
public override void ViewSafeAreaInsetsDidChange()
{
ShellFlyoutContentManager.SetHeaderContentInset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public UIViewController ViewController
}

[System.Runtime.Versioning.UnsupportedOSPlatform("ios8.0")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
{
base.DidRotate(fromInterfaceOrientation);
Expand Down Expand Up @@ -327,7 +328,7 @@ void UpdateBarBackgroundColor()
if (!isDefaultColor)
_barBackgroundColorWasSet = true;

if (OperatingSystem.IsIOSVersionAtLeast(15))
if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15))
UpdateiOS15TabBarAppearance();
else
TabBar.BarTintColor = isDefaultColor ? _defaultBarColor : barBackgroundColor.ToPlatform();
Expand Down Expand Up @@ -379,7 +380,7 @@ void UpdateBarTextColor()

// set TintColor for selected icon
// setting the unselected icon tint is not supported by iOS
if (OperatingSystem.IsIOSVersionAtLeast(15))
if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15))
UpdateiOS15TabBarAppearance();
else
TabBar.TintColor = isDefaultColor ? _defaultBarTextColor : barTextColor.ToPlatform();
Expand Down Expand Up @@ -455,7 +456,7 @@ void UpdateSelectedTabColors()
TabBar.TintColor = UITabBar.Appearance.TintColor;
}

if (OperatingSystem.IsIOSVersionAtLeast(15))
if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15))
UpdateiOS15TabBarAppearance();
else
{
Expand Down Expand Up @@ -490,6 +491,7 @@ protected virtual Task<Tuple<UIImage, UIImage>> GetIcon(Page page)
}

[System.Runtime.Versioning.SupportedOSPlatform("ios15.0")]
[System.Runtime.Versioning.SupportedOSPlatform("tvos15.0")]
void UpdateiOS15TabBarAppearance()
{
TabBar.UpdateiOS15TabBarAppearance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.MacOS
[Obsolete]
[Preserve(AllMembers = true)]
[UnsupportedOSPlatform("ios14.0")]
[UnsupportedOSPlatform("tvos14.0")]
internal class ResourcesProvider : ISystemResourcesProvider
{
ResourceDictionary _dictionary;
Expand Down
Loading

0 comments on commit 59c06ab

Please sign in to comment.