style: format code
This commit is contained in:
+50
-54
@@ -6,72 +6,68 @@ import flash.Lib;
|
||||
import hw.signal.Signal;
|
||||
|
||||
enum abstract Platform(String) from String to String {
|
||||
var ANDROID = "android";
|
||||
var LINUX = "linux";
|
||||
var WINDOWS = "windows";
|
||||
var FLASH = "flash";
|
||||
var HTML5 = "html5";
|
||||
var UNKNOWN = "unknown";
|
||||
var ANDROID = "android";
|
||||
var LINUX = "linux";
|
||||
var WINDOWS = "windows";
|
||||
var FLASH = "flash";
|
||||
var HTML5 = "html5";
|
||||
var UNKNOWN = "unknown";
|
||||
}
|
||||
|
||||
class Device {
|
||||
public static var platform(get, null):Platform;
|
||||
|
||||
public static var platform(get, null):Platform;
|
||||
private static function get_platform():Platform {
|
||||
#if android
|
||||
return ANDROID;
|
||||
#elseif linux
|
||||
return LINUX;
|
||||
#elseif windows
|
||||
return WINDOWS;
|
||||
#elseif flash
|
||||
return FLASH;
|
||||
#elseif html5
|
||||
return HTML5;
|
||||
#else
|
||||
return UNKNOWN;
|
||||
#end
|
||||
}
|
||||
|
||||
private static function get_platform():Platform {
|
||||
#if android
|
||||
return ANDROID;
|
||||
#elseif linux
|
||||
return LINUX;
|
||||
#elseif windows
|
||||
return WINDOWS;
|
||||
#elseif flash
|
||||
return FLASH;
|
||||
#elseif html5
|
||||
return HTML5;
|
||||
#else
|
||||
return UNKNOWN;
|
||||
#end
|
||||
}
|
||||
private static var MOBILES(default, never):Array<String> = ["Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",];
|
||||
|
||||
private static var MOBILES(default, never):Array<String> = [
|
||||
"Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",
|
||||
];
|
||||
|
||||
public static function isMobile():Bool {
|
||||
#if android
|
||||
public static function isMobile():Bool {
|
||||
#if android
|
||||
return true;
|
||||
#elseif js
|
||||
var userAgent = js.Browser.navigator.userAgent;
|
||||
for (mobile in MOBILES) {
|
||||
if (userAgent.indexOf(mobile) > -1) {
|
||||
return true;
|
||||
#elseif js
|
||||
var userAgent = js.Browser.navigator.userAgent;
|
||||
for (mobile in MOBILES) {
|
||||
if (userAgent.indexOf(mobile) > -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#end
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#end
|
||||
}
|
||||
|
||||
public static var fullScreenSignal(get, null):Signal<Bool>;
|
||||
public static var fullScreenSignal(get, null):Signal<Bool>;
|
||||
|
||||
private static function get_fullScreenSignal():Signal<Bool> {
|
||||
if (fullScreenSignal == null) {
|
||||
fullScreenSignal = new Signal();
|
||||
Lib.current.stage.addEventListener(FullScreenEvent.FULL_SCREEN, (event:FullScreenEvent) -> fullScreenSignal.emit(event.fullScreen));
|
||||
}
|
||||
return fullScreenSignal;
|
||||
private static function get_fullScreenSignal():Signal<Bool> {
|
||||
if (fullScreenSignal == null) {
|
||||
fullScreenSignal = new Signal();
|
||||
Lib.current.stage.addEventListener(FullScreenEvent.FULL_SCREEN, (event:FullScreenEvent) -> fullScreenSignal.emit(event.fullScreen));
|
||||
}
|
||||
return fullScreenSignal;
|
||||
}
|
||||
|
||||
public static var fullScreenSupport(get, never):Bool;
|
||||
public static var fullScreenSupport(get, never):Bool;
|
||||
|
||||
public static function get_fullScreenSupport():Bool {
|
||||
return Lib.current.stage.allowsFullScreen;
|
||||
}
|
||||
public static function get_fullScreenSupport():Bool {
|
||||
return Lib.current.stage.allowsFullScreen;
|
||||
}
|
||||
|
||||
public static function toggleFullScreen():Void {
|
||||
Lib.current.stage.displayState = Lib.current.stage.displayState == StageDisplayState.NORMAL ?
|
||||
StageDisplayState.FULL_SCREEN : StageDisplayState.NORMAL;
|
||||
}
|
||||
public static function toggleFullScreen():Void {
|
||||
Lib.current.stage.displayState = Lib.current.stage.displayState == StageDisplayState.NORMAL ? StageDisplayState.FULL_SCREEN : StageDisplayState.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user