UNPKG

nativescript-wear-os-layout

Version:

Base layout for Wear OS apps built with NativeScript

73 lines 2.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var platform_1 = require("tns-core-modules/platform"); var view_1 = require("tns-core-modules/ui/core/view"); var utils_1 = require("tns-core-modules/utils/utils"); var WearOsLayout = (function (_super) { __extends(WearOsLayout, _super); function WearOsLayout() { return _super.call(this) || this; } Object.defineProperty(WearOsLayout.prototype, "android", { get: function () { return this._android; }, enumerable: true, configurable: true }); WearOsLayout.prototype.createNativeView = function () { this._android = new android.widget.ScrollView(this._context); this._holder = new android.widget.LinearLayout(this._context); if (!this._androidViewId) { this._androidViewId = android.view.View.generateViewId(); } this._android.setId(this._androidViewId); this._holder.setOrientation(android.widget.LinearLayout.VERTICAL); this._holder.setGravity(android.view.Gravity.FILL_VERTICAL); this._holder.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT)); var inset = this._adjustInset(); if (inset) { this._holder.setPadding(inset, inset, inset, inset); } this._android.addView(this._holder); return this._android; }; WearOsLayout.prototype.initNativeView = function () { _super.prototype.initNativeView.call(this); }; WearOsLayout.prototype.disposeNativeView = function () { _super.prototype.disposeNativeView.call(this); }; WearOsLayout.prototype.onLoaded = function () { var _this = this; _super.prototype.onLoaded.call(this); this._childViews.forEach(function (value) { _this._addView(value); _this._holder.addView(value.nativeView); }); }; WearOsLayout.prototype._addChildFromBuilder = function (name, value) { if (!this._childViews) { this._childViews = new Map(); } if (!value.parent) { this._childViews.set(value._domId, value); } }; WearOsLayout.prototype._adjustInset = function () { var result = null; var androidConfig = utils_1.ad.getApplicationContext() .getResources() .getConfiguration(); var isCircleWatch = androidConfig.isScreenRound(); if (isCircleWatch) { result = WearOsLayout.SCALE_FACTOR * platform_1.screen.mainScreen.widthPixels; console.log('inset', result); } return result; }; WearOsLayout.SCALE_FACTOR = 0.146467; return WearOsLayout; }(view_1.View)); exports.WearOsLayout = WearOsLayout; //# sourceMappingURL=index.android.js.map