How to use the platform.device function in platform

To help you get started, we’ve selected a few platform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linfaservice / cloudgallery / app / pages / gallery / gallery.component.ts View on Github external
private page: Page,
	    private util: Util,
      private fonticon: TNSFontIconService,
      private modalService: ModalDialogService, 
      private vcRef: ViewContainerRef,
      private translate: TranslateService,
      private cache: GalleryCache
    )  {

      appversion.getVersionName().then((v: string)=> {
          this.version = "Version " + v;
      });

      this.language = Platform.device.language;
      this.translate.setDefaultLang("en");
      this.translate.use(Platform.device.language.split("-")[0]).subscribe(()=> {
        this.host = Settings.getString("host");
        this.username = Settings.getString("username");
        this.password = Settings.getString("password");
        this.rootdir = Settings.getString("rootdir");  
        this.rootdir = (this.rootdir==null)? "":this.rootdir;
        this.headers = { 
          "OCS-APIREQUEST": "true",
          "Authorization": "Basic "+Base64.encode(this.username+':'+this.password)
        }            

        this.cache.images = new Array();
        this.home();
      });
    }
github linfaservice / cloudgallery / app / pages / gallery / image-modal.component.js View on Github external
function ImageModalComponent(params, page, translate, fonticon, util) {
        this.params = params;
        this.page = page;
        this.translate = translate;
        this.fonticon = fonticon;
        this.util = util;
        this.language = Platform.device.language;
        this.translate.setDefaultLang("en");
        this.translate.use(Platform.device.language.split("-")[0]);
        this.host = Settings.getString("host");
        this.username = Settings.getString("username");
        this.password = Settings.getString("password");
        this.rootdir = Settings.getString("rootdir");
        this.rootdir = (this.rootdir == null) ? "" : this.rootdir;
        this.headers = {
            "OCS-APIREQUEST": "true",
            "Authorization": "Basic " + Base64.encode(this.username + ':' + this.password)
        };
        this.item = params.context.item;
        this.loader = params.context.loader;
    }
    ImageModalComponent.prototype.ngOnInit = function () {
github NativeScript / nativescript-app-templates / packages / template-hello-world / tns_modules / ui / builder / component-builder.js View on Github external
}
        }
        instanceModule = require(moduleId);
        var instanceType = instanceModule[elementName] || Object;
        instance = new instanceType();
    }
    catch (ex) {
        throw new Error("Cannot create module " + moduleId + ". " + ex + ". StackTrace: " + ex.stack);
    }
    if (instance && instanceModule) {
        var bindings = new Array();
        for (var attr in attributes) {
            var attrValue = attributes[attr];
            if (attr.indexOf(":") !== -1) {
                var platformName = attr.split(":")[0].trim();
                if (platformName.toLowerCase() === platform.device.os.toLowerCase()) {
                    attr = attr.split(":")[1].trim();
                }
                else {
                    continue;
                }
            }
            if (attr.indexOf(".") !== -1) {
                var subObj = instance;
                var properties = attr.split(".");
                var subPropName = properties[properties.length - 1];
                var i;
                for (i = 0; i < properties.length - 1; i++) {
                    if (types.isDefined(subObj)) {
                        subObj = subObj[properties[i]];
                    }
                }
github NativeScript / nativescript-app-templates / packages / template-hello-world / tns_modules / ui / frame / frame-common.js View on Github external
function resolveFilePath(path, ext) {
    if (!fileNameResolver) {
        fileNameResolver = new fileResolverModule.FileNameResolver({
            width: platform.screen.mainScreen.widthDIPs,
            height: platform.screen.mainScreen.heightDIPs,
            os: platform.device.os,
            deviceType: platform.device.deviceType
        });
    }
    return fileNameResolver.resolveFileName(path, ext);
}
function pageFromBuilder(moduleNamePath, moduleExports) {
github bradyhouse / house / fiddles / nativeScript / fiddle-0001-PageNavigation / pagenavigation / platforms / android / build / intermediates / assets / F0 / debug / app / tns_modules / ui / layouts / stack-layout / stack-layout-common.js View on Github external
var platform = require("platform");
var layout_base_1 = require("ui/layouts/layout-base");
var enums_1 = require("ui/enums");
var proxy_1 = require("ui/core/proxy");
var dependency_observable_1 = require("ui/core/dependency-observable");
var AffectsLayout = platform.device.os === platform.platformNames.android ? dependency_observable_1.PropertyMetadataSettings.None : dependency_observable_1.PropertyMetadataSettings.AffectsLayout;
function validateOrientation(value) {
    return value === enums_1.Orientation.vertical || value === enums_1.Orientation.horizontal;
}
var StackLayout = (function (_super) {
    __extends(StackLayout, _super);
    function StackLayout() {
        _super.apply(this, arguments);
    }
    Object.defineProperty(StackLayout.prototype, "orientation", {
        get: function () {
            return this._getValue(StackLayout.orientationProperty);
        },
        set: function (value) {
            this._setValue(StackLayout.orientationProperty, value);
        },
        enumerable: true,
github argonjs / argon-app / app / components / common / util.ts View on Github external
if (platform.device.os === platform.platformNames.android) {
    var backgroundDrawable = nativeView.getBackground(),
      LINEAR_GRADIENT = 0;

    colors.forEach(function (c:Color) {
      _colors.push(c.android);
    });

    if (!(backgroundDrawable instanceof android.graphics.drawable.GradientDrawable)) {
      backgroundDrawable = new android.graphics.drawable.GradientDrawable();
      backgroundDrawable.setColors(_colors);
      backgroundDrawable.setGradientType(LINEAR_GRADIENT);
      nativeView.setBackgroundDrawable(backgroundDrawable);
    }
  } else if (platform.device.os === platform.platformNames.ios) {
    var iosView:UIView = view.ios;
    var colorsArray = NSMutableArray.alloc().initWithCapacity(2);
    colors.forEach(function (c:Color) {
      colorsArray.addObject(interop.types.id(c.ios.CGColor));
    });
    var gradientLayer = CAGradientLayer.layer();
    gradientLayer.colors = colorsArray;
    gradientLayer.frame = iosView.bounds;
    iosView.layer.insertSublayerAtIndex(gradientLayer, 0);
  }
}