Created
January 17, 2018 23:19
-
-
Save jchri853/fa3c73677e8f13ec90995900b7519bfb to your computer and use it in GitHub Desktop.
iPhone X StatusBar Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
tabBarVisible="false" title="{data.title}" viewActivate="init(event)" | |
backKeyPressed="backPressedHandler(event)" actionBarVisible="false" > | |
<fx:Script> | |
<![CDATA[ | |
import mx.core.FlexGlobals; | |
import mx.events.FlexEvent; | |
import spark.events.ViewNavigatorEvent; | |
private var myStageWebView:StageWebView; | |
private var lds:LocalDataSingleton = LocalDataSingleton.getInstance(); | |
[Bindable] private var application:Object = FlexGlobals.topLevelApplication; | |
[Bindable] public var isIphoneX:Boolean; | |
protected function init(event:ViewNavigatorEvent):void { | |
isIphoneX = (lds.iosDevice == "iPhone X" ? true : false); | |
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE; | |
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, resize); | |
myStageWebView = new StageWebView(true); | |
if(isIphoneX) { | |
myStageWebView.viewPort = new Rectangle(0,230, stage.stageWidth, stage.stageHeight - 200); | |
}else { | |
myStageWebView.viewPort = new Rectangle(0, 150, stage.stageWidth, stage.stageHeight - 150); | |
} | |
myStageWebView.stage = this.stage; | |
myStageWebView.loadURL("https://www.youtube.com/embed/"+ data.url); | |
} | |
protected function goBack():void{ | |
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL; | |
myStageWebView.dispose(); | |
stage.removeEventListener(Event.RESIZE, resize); | |
navigator.popView(); | |
} | |
protected function resize(event:StageOrientationEvent):void { | |
if(lds.deviceState == "Phonelandscape" || lds.deviceState == "landscape") { | |
if(isIphoneX) { | |
myStageWebView.viewPort = new Rectangle(0,230, stage.stageWidth, stage.stageHeight - 200); | |
} | |
else { | |
myStageWebView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight ); | |
} | |
} | |
//If its portrait | |
else { | |
if(isIphoneX) { | |
myStageWebView.viewPort = new Rectangle(0,230, stage.stageWidth, stage.stageHeight - 200); | |
} else { | |
myStageWebView.viewPort = new Rectangle(0, 150, stage.stageWidth, stage.stageHeight - 150); | |
} | |
} | |
} | |
protected function backPressedHandler(event:FlexEvent):void { | |
event.preventDefault(); | |
} | |
]]> | |
</fx:Script> | |
<s:states> | |
<s:State name="portrait"/> | |
<s:State name="landscape"/> | |
<s:State name="Phonelandscape"/> | |
<s:State name="Phoneportrait"/> | |
</s:states> | |
<s:VGroup height="100%" width="100%" > | |
<s:HGroup width="100%" paddingTop="10" includeInLayout.landscape="false" visible.landscape="false" includeInLayout.Phonelandscape="false" visible.Phonelandscape="false" height="{isIphoneX ? 40 : 30}" paddingLeft="8" verticalCenter="0" click="goBack()"> | |
<s:BitmapImage left="-1" height="25" width="33" verticalCenter="0" horizontalAlign="left" scaleMode="letterbox" source="@Embed('/assets/backBtnGray.png')"/> | |
<s:Spacer width="100%"/> | |
</s:HGroup> | |
</s:VGroup> | |
</s:View> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment