UNPKG

nativescript-ar

Version:

NativeScript Augmented Reality plugin. ARKit on iOS and (with the help of Sceneform) ARCore on Android.

59 lines (58 loc) 2.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils = require("tns-core-modules/utils/utils"); var arcommon_1 = require("./arcommon"); var ARUIView = (function (_super) { __extends(ARUIView, _super); function ARUIView() { return _super !== null && _super.apply(this, arguments) || this; } ARUIView.create = function (options, fragment) { var _this = this; return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { var node, context, container, view, label, customUI; return __generator(this, function (_a) { node = arcommon_1.ARCommonNode.createNode(options, fragment); context = utils.ad.getApplicationContext(); container = new android.widget.LinearLayout(context); container.setOrientation(android.widget.LinearLayout.VERTICAL); view = options.view; if (!view) { label = new android.widget.TextView(context); label.setText("Hello World"); label.setShadowLayer(4, 0, 0, android.graphics.Color.WHITE); label.setTextColor(android.graphics.Color.BLACK); container.addView(label); } else { if (view.android && view.android.getParent()) { view.android.getParent().removeView(view.android); } if (!view.android) { view._setupUI(context); view.loadView(view); view.requestLayout(); } container.addView(view.android); } customUI = com.google.ar.sceneform.rendering.ViewRenderable.builder() .setView(context, container) .build() .thenAccept(new java.util.function.Consumer({ accept: function (renderable) { console.log(">> accepted2, renderable: " + renderable); renderable.setVerticalAlignment(com.google.ar.sceneform.rendering.ViewRenderable.VerticalAlignment.BOTTOM); node.setRenderable(renderable); resolve(new ARUIView(options, node)); } })) .exceptionally(new java.util.function.Function({ apply: function (error) { return reject(error); } })); return [2]; }); }); }); }; return ARUIView; }(arcommon_1.ARCommonNode)); exports.ARUIView = ARUIView;