-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Add Platform Specific features for PrefersStatusBarHidden/UIStatusBarAnimation #463
Conversation
return true; | ||
case (StatusBarHiddenMode.False): | ||
return false; | ||
case (StatusBarHiddenMode.Default): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is unnecessary in switch default. I could see similar things in other switch blocks.
if (Device.info.CurrentOrientation.IsLandscape()) | ||
return true; | ||
else | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be turned into a ternary statement.
{ | ||
Default, | ||
True, | ||
False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULLABLE BOOL !!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like this API more so user understands that Default is default .. and not null ..
Needs rebase |
097675c
to
edd0553
Compare
Rebased |
@pauldipietro this is failing , please check the build logs. and make sure this builds ok :) |
} | ||
|
||
public override UIViewController ChildViewControllerForStatusBarHidden() | ||
{ | ||
return (UIViewController)Platform.GetRenderer(((MasterDetailPage)Element).Detail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure there always a detail renderer at this time?
i wonder if while switching detail pages could have a case where the renderer isn't created yet for the Detail element, this will blow up with NRE.
Maybe add a check and return base if no renderer is there.
@@ -234,6 +235,11 @@ public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, d | |||
base.WillRotate(toInterfaceOrientation, duration); | |||
} | |||
|
|||
public override UIViewController ChildViewControllerForStatusBarHidden() | |||
{ | |||
return (UIViewController)Platform.GetRenderer(((MasterDetailPage)Element).Detail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
{ | ||
Default, | ||
True, | ||
False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like this API more so user understands that Default is default .. and not null ..
edd0553
to
30a46ad
Compare
Description of Change
This is a Platform Specific feature which enables setting the visibility of the iOS status bar on a per-view basis. See some examples below:
This is accomplished through the
StatusBarHiddenMode
andUIStatusBarAnimation
enumerators, which contain the following values:StatusBarHiddenMode.Default
StatusBarHiddenMode.True
StatusBarHiddenMode.False
UIStatusBarAnimation.None
UIStatusBarAnimation.Fade
UIStatusBarAnimation.Slide
Per Apple's documentation, since iOS 8 the
prefersStatusBarHidden
method returns true on vertically compact environments. This represents theStatusBarHiddenMode.Default
value, while the latter two apply the respective values to both the vertical and landscape orientations. This can be set as follows, for example:page.On<iOS>().PrefersStatusBarHidden(StatusBarHiddenMode.True)
As one might guess, the
UIStatusBarAnimation
values represent the three possible manners by which the status bar can enter or leave the view. If aFade
orSlide
value is set, a 0.25 second animation of setNeedsStatusBarAppearanceUpdate will execute. That can be used like so:page.On<iOS>().SetPreferredStatusBarUpdateAnimation(UIStatusBarAnimation.Fade)
Starting with the
Page
value on thePlatform
(which has been subsequently marked as internal in order for thePlatformRenderer
to get at it), childViewControllerForStatusBarHidden is utilized to redirect the views down toPageRenderer
as a baseline for setting the values on a per-view basis. An exception is that in aTabbedPage
, setting thePrefersStatusBarHidden
value directly on that page will update all of its contained pages.As of this submission, tests can still be added, though they may be somewhat complex due to the need to check the status bar -- screenshots might be preferable.
Bugs Fixed
This was technically not a bug, per se, but was reported under https://bugzilla.xamarin.com/show_bug.cgi?id=44803.
API Changes
Added:
Changed:
Behavioral Changes
N/A
PR Checklist