uicore-ts
Version:
UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework tha
178 lines (177 loc) • 5.75 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var UIDialogView_exports = {};
__export(UIDialogView_exports, {
UIDialogView: () => UIDialogView
});
module.exports = __toCommonJS(UIDialogView_exports);
var import_ClientCheckers = require("./ClientCheckers");
var import_UIColor = require("./UIColor");
var import_UICore = require("./UICore");
var import_UINativeScrollView = require("./UINativeScrollView");
var import_UIObject = require("./UIObject");
var import_UIScrollView = require("./UIScrollView");
var import_UIView = require("./UIView");
class UIDialogView extends import_UIView.UIView {
constructor(elementID, viewHTMLElement) {
super(elementID, viewHTMLElement);
this._isAUIDialogView = import_UIObject.YES;
this._view = new import_UIView.UIView();
this.animationDuration = 0.25;
this._zIndex = 100;
this.isVisible = import_UIObject.NO;
this.dismissesOnTapOutside = import_UIObject.YES;
this.addTargetForControlEvent(
import_UIView.UIView.controlEvent.PointerTap,
function(sender, event) {
this.didDetectTapOutside(sender, event);
}.bind(this)
);
this.backgroundColor = import_UIColor.UIColor.colorWithRGBA(0, 10, 25).colorWithAlpha(0.75);
this.zIndex = this._zIndex;
}
didDetectTapOutside(sender, event) {
if (event.target == this.viewHTMLElement && this.dismissesOnTapOutside) {
this.dismiss(this._appearedAnimated);
}
}
set zIndex(zIndex) {
this._zIndex = zIndex;
this.style.zIndex = "" + zIndex;
}
get zIndex() {
return this._zIndex;
}
set view(view) {
var _a;
(_a = this._view) == null ? void 0 : _a.removeFromSuperview();
this._view = view;
this.addSubview(view);
}
get view() {
return this._view;
}
willAppear(animated = import_UIObject.NO) {
if (animated) {
this.style.opacity = "0";
}
this.style.height = "";
this._frame = import_UIObject.nil;
}
animateAppearing() {
this.style.opacity = "1";
}
animateDisappearing() {
this.style.opacity = "0";
}
showInView(containerView, animated) {
animated = animated && !import_ClientCheckers.IS_FIREFOX;
this._appearedAnimated = animated;
this.willAppear(animated);
containerView.addSubview(this);
if (animated) {
this.layoutSubviews();
import_UIView.UIView.animateViewOrViewsWithDurationDelayAndFunction(
this,
this.animationDuration,
0,
void 0,
() => this.animateAppearing(),
import_UIObject.nil
);
} else {
this.setNeedsLayout();
}
this.isVisible = import_UIObject.YES;
}
showInRootView(animated) {
this.showInView(import_UICore.UICore.main.rootViewController.view, animated);
}
dismiss(animated) {
if (!this.isVisible) {
return;
}
animated = animated && !import_ClientCheckers.IS_FIREFOX;
if (animated == void 0) {
animated = this._appearedAnimated;
}
if (animated) {
import_UIView.UIView.animateViewOrViewsWithDurationDelayAndFunction(
this,
this.animationDuration,
0,
void 0,
(() => {
this.animateDisappearing();
}).bind(this),
() => {
if (this.isVisible == import_UIObject.NO) {
this.removeFromSuperview();
}
}
);
} else {
this.removeFromSuperview();
}
this.isVisible = import_UIObject.NO;
}
didReceiveBroadcastEvent(event) {
super.didReceiveBroadcastEvent(event);
if (event.name == import_UICore.UICore.broadcastEventName.WindowDidResize) {
this.setNeedsLayout();
}
}
layoutSubviews() {
var _a, _b;
if (!(0, import_UIObject.IS)(this.view)) {
return;
}
this.setPosition(0, 0, 0, 0, 0, "100%");
this.setPosition(
0,
0,
0,
0,
(0, import_UIObject.FIRST)(
(0, import_UIObject.IF)((_a = this.superview) == null ? void 0 : _a.isKindOfClass(import_UINativeScrollView.UINativeScrollView))(() => {
var _a2, _b2;
return (_b2 = (_a2 = this.superview) == null ? void 0 : _a2.scrollSize.height) != null ? _b2 : 0;
}).ELSE_IF((_b = this.superview) == null ? void 0 : _b.isKindOfClass(import_UIScrollView.UIScrollView))(() => {
var _a2, _b2;
return (_b2 = (_a2 = this.superview) == null ? void 0 : _a2.scrollSize.height) != null ? _b2 : 0;
}).ELSE(() => {
var _a2, _b2;
return (_b2 = (_a2 = this.superview) == null ? void 0 : _a2.frame.height) != null ? _b2 : 0;
}),
import_UIView.UIView.pageHeight
) / import_UIView.UIView.pageScale,
"100%"
);
const bounds = this.bounds;
const margin = 20;
this.view.style.position = "relative";
this.view.style.zIndex = "" + this.zIndex;
super.layoutSubviews();
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
UIDialogView
});
//# sourceMappingURL=UIDialogView.js.map