Commit f9cb43f2 authored by rockyl's avatar rockyl

toast增加更多参数

parent 6a30b259
......@@ -17298,6 +17298,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
return StackContainer;
}(Node$1));
//# sourceMappingURL=StackContainer.js.map
var colorName = {
"aliceblue": [240, 248, 255],
......@@ -20185,14 +20186,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Toast.prototype.show = function (props) {
if (props === void 0) { props = {}; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
var contentView, lab, text, _a, padding, _b, duration, _c, showDuration, _d, hideDuration;
var contentView, lab, text, _a, padding, paddingH, paddingV, _b, duration, _c, showDuration, _d, hideDuration;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
case 0:
if (!props.text) {
return [2];
}
return [4, this.getContent(props.viewName)];
return [4, this.getContent(props.viewName, props)];
case 1:
contentView = _e.sent();
lab = contentView.getChildByName('lab');
......@@ -20200,11 +20201,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
console.warn('[lab] child no exists on toast view');
return [2];
}
text = props.text, _a = props.padding, padding = _a === void 0 ? 10 : _a, _b = props.duration, duration = _b === void 0 ? 1000 : _b, _c = props.showDuration, showDuration = _c === void 0 ? 300 : _c, _d = props.hideDuration, hideDuration = _d === void 0 ? 200 : _d;
text = props.text, _a = props.padding, padding = _a === void 0 ? 10 : _a, paddingH = props.paddingH, paddingV = props.paddingV, _b = props.duration, duration = _b === void 0 ? 1000 : _b, _c = props.showDuration, showDuration = _c === void 0 ? 300 : _c, _d = props.hideDuration, hideDuration = _d === void 0 ? 200 : _d;
lab.text = text;
lab.x = lab.y = padding;
this.width = contentView.width = lab.width + padding * 2;
this.height = contentView.height = lab.height + padding * 2;
lab.x = paddingH || padding;
lab.y = paddingV || padding;
this.width = contentView.width = lab.width + (paddingH || padding) * 2;
this.height = contentView.height = lab.height + (paddingV || padding) * 2;
if (!contentView.visible) {
contentView.visible = true;
contentView.alpha = 0;
......@@ -20240,33 +20242,34 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this.removeChild(this._content);
this._content = null;
};
Toast.prototype.getContent = function (viewName) {
Toast.prototype.getContent = function (viewName, props) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var view, bg, lab;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
var view, _a, borderRadius, _b, labColor, _c, labSize, _d, bgColor, _e, bgAlpha, bg, lab;
return tslib_1.__generator(this, function (_f) {
switch (_f.label) {
case 0:
if (!(this.children.length == 0)) return [3, 3];
if (!viewName) return [3, 2];
return [4, this._gameStage.instantiateView(viewName)];
case 1:
view = _a.sent();
_a.label = 2;
view = _f.sent();
_f.label = 2;
case 2:
if (!view) {
if (!this._contentSample) {
_a = props.borderRadius, borderRadius = _a === void 0 ? 10 : _a, _b = props.labColor, labColor = _b === void 0 ? 'white' : _b, _c = props.labSize, labSize = _c === void 0 ? 30 : _c, _d = props.bgColor, bgColor = _d === void 0 ? 'black' : _d, _e = props.bgAlpha, bgAlpha = _e === void 0 ? 0.7 : _e;
this._contentSample = new Node$1();
bg = new Rect();
bg.borderRadius = 10;
bg.borderRadius = borderRadius;
bg.percentWidth = 100;
bg.percentHeight = 100;
bg.fillColor = 'black';
bg.alpha = 0.7;
bg.fillColor = bgColor;
bg.alpha = bgAlpha;
this._contentSample.addChild(bg);
lab = new Label();
lab.name = 'lab';
lab.fillColor = 'white';
lab.size = 30;
lab.fillColor = labColor;
lab.size = labSize;
this._contentSample.addChild(lab);
}
view = this._contentSample;
......@@ -20276,7 +20279,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return [3, 4];
case 3:
view = this.getChildAt(0);
_a.label = 4;
_f.label = 4;
case 4: return [2, view];
}
});
......@@ -20284,7 +20287,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
return Toast;
}(Node$1));
//# sourceMappingURL=Toast.js.map
function createEvalFunc(exp) {
var func;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{"id":"engine","url":"engine.50f2306185a286c24568fc87ef21dd4070b56456.js"}
\ No newline at end of file
{"id":"engine","url":"engine.68ebcc028b764acc0a822ad13fce52e3f9744bcb.js"}
\ No newline at end of file
......@@ -28,18 +28,19 @@ export class Toast extends Node {
return;
}
let contentView = await this.getContent(props.viewName);
let contentView = await this.getContent(props.viewName, props);
let lab = contentView.getChildByName('lab');
if (!lab) {
console.warn('[lab] child no exists on toast view');
return;
}
const {text, padding = 10, duration = 1000, showDuration = 300, hideDuration = 200} = props;
const {text, padding = 10, paddingH, paddingV, duration = 1000, showDuration = 300, hideDuration = 200} = props;
lab.text = text;
lab.x = lab.y = padding;
this.width = contentView.width = lab.width + padding * 2;
this.height = contentView.height = lab.height + padding * 2;
lab.x = paddingH || padding;
lab.y = paddingV || padding;
this.width = contentView.width = lab.width + (paddingH || padding) * 2;
this.height = contentView.height = lab.height + (paddingV || padding) * 2;
if (!contentView.visible) {
contentView.visible = true;
......@@ -55,11 +56,11 @@ export class Toast extends Node {
hide(animation = true, hideDuration = 200) {
if (this._content) {
const contentView = this._content;
if(animation){
if (animation) {
Tween.get(contentView, null, null, true)
.to({alpha: 0}, hideDuration)
.call(this.removeContentView, this)
}else{
} else {
Tween.removeTweens(contentView);
this.removeContentView();
}
......@@ -72,7 +73,7 @@ export class Toast extends Node {
this._content = null;
}
private async getContent(viewName) {
private async getContent(viewName, props) {
let view;
if (this.children.length == 0) {
......@@ -81,18 +82,20 @@ export class Toast extends Node {
}
if (!view) {
if (!this._contentSample) {
const {borderRadius = 10, labColor = 'white', labSize = 30, bgColor = 'black', bgAlpha = 0.7} = props;
this._contentSample = new Node();
let bg = new Rect();
bg.borderRadius = 10;
bg.borderRadius = borderRadius;
bg.percentWidth = 100;
bg.percentHeight = 100;
bg.fillColor = 'black';
bg.alpha = 0.7;
bg.fillColor = bgColor;
bg.alpha = bgAlpha;
this._contentSample.addChild(bg);
let lab = new Label();
lab.name = 'lab';
lab.fillColor = 'white';
lab.size = 30;
lab.fillColor = labColor;
lab.size = labSize;
this._contentSample.addChild(lab);
}
view = this._contentSample;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment