feat: modular add test case

This commit is contained in:
pengfei.zhou 2021-05-13 16:26:48 +08:00 committed by osborn
parent c27a9bd672
commit 546af79534
14 changed files with 358 additions and 57 deletions

View File

@ -59,7 +59,7 @@ public class ModalPlugin extends DoricJavaPlugin {
gravity = gravityVal.asNumber().toInt(); gravity = gravityVal.asNumber().toInt();
} }
Toast toast = Toast.makeText(getDoricContext().getContext(), Toast toast = Toast.makeText(getDoricContext().getContext(),
jsObject.getProperty("msg").asString().value(), msg,
Toast.LENGTH_SHORT); Toast.LENGTH_SHORT);
if ((gravity & Gravity.TOP) == Gravity.TOP) { if ((gravity & Gravity.TOP) == Gravity.TOP) {
toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, DoricUtils.dp2px(50)); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, DoricUtils.dp2px(50));
@ -67,7 +67,6 @@ public class ModalPlugin extends DoricJavaPlugin {
toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, DoricUtils.dp2px(50)); toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, DoricUtils.dp2px(50));
} else { } else {
toast.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0); toast.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0);
} }
toast.show(); toast.show();
} catch (Exception e) { } catch (Exception e) {

View File

@ -27,12 +27,12 @@ class CounterView extends ViewHolder {
build(root: Group) { build(root: Group) {
vlayout( vlayout(
[ [
text({ this.number = text({
textSize: 40, textSize: 40,
tag: "tvNumber", tag: "tvNumber",
}), }),
text({ this.counter = text({
text: "Click To Count 1", text: "Click To Count 1",
textSize: 20, textSize: 20,
tag: "tvCounter", tag: "tvCounter",
@ -44,8 +44,6 @@ class CounterView extends ViewHolder {
space: 20, space: 20,
} }
).in(root); ).in(root);
this.number = root.findViewByTag("tvNumber")!;
this.counter = root.findViewByTag("tvCounter")!;
} }
} }

View File

@ -0,0 +1,81 @@
import { Color, Gravity, Group, layoutConfig, LayoutSpec, ModularPanel, Panel, scroller, text, vlayout } from "doric";
import { CounterPage } from "./Counter";
class Module1 extends Panel {
build(root: Group) {
vlayout(
[
text({
text: "First Module",
textColor: Color.WHITE,
}),
],
{
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT
},
padding: {
top: 20,
bottom: 20
},
gravity: Gravity.Center,
backgroundColor: Color.parse("#3498db")
}
).in(root)
}
}
class Module2 extends Panel {
build(root: Group) {
vlayout(
[
text({
text: "Second Module",
textColor: Color.WHITE,
}),
],
{
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT
},
padding: {
top: 20,
bottom: 20
},
gravity: Gravity.Center,
backgroundColor: Color.parse("#f39c12")
}
).in(root)
}
}
@Entry
class ModularDemo extends ModularPanel {
setupModules() {
return [
Module1,
Module2,
CounterPage,
]
}
setupShelf(root: Group) {
const shelf = vlayout(
[],
{
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT
}
}
)
scroller(
shelf,
{
layoutConfig: layoutConfig().most()
}).in(root)
return shelf
}
}

View File

@ -139,7 +139,7 @@ function logw() {
nativeLog('w', out); nativeLog('w', out);
} }
var __extends$e = (undefined && undefined.__extends) || (function () { var __extends$f = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -521,7 +521,7 @@ var View = /** @class */ (function () {
return View; return View;
}()); }());
var Superview = /** @class */ (function (_super) { var Superview = /** @class */ (function (_super) {
__extends$e(Superview, _super); __extends$f(Superview, _super);
function Superview() { function Superview() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -611,7 +611,7 @@ var Superview = /** @class */ (function (_super) {
return Superview; return Superview;
}(View)); }(View));
var Group = /** @class */ (function (_super) { var Group = /** @class */ (function (_super) {
__extends$e(Group, _super); __extends$f(Group, _super);
function Group() { function Group() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.children = []; _this.children = [];
@ -786,7 +786,7 @@ function layoutConfig() {
return new LayoutConfigImpl; return new LayoutConfigImpl;
} }
var __extends$d = (undefined && undefined.__extends) || (function () { var __extends$e = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -822,21 +822,21 @@ var __values$4 = (undefined && undefined.__values) || function(o) {
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}; };
var Stack = /** @class */ (function (_super) { var Stack = /** @class */ (function (_super) {
__extends$d(Stack, _super); __extends$e(Stack, _super);
function Stack() { function Stack() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
return Stack; return Stack;
}(Group)); }(Group));
var Root = /** @class */ (function (_super) { var Root = /** @class */ (function (_super) {
__extends$d(Root, _super); __extends$e(Root, _super);
function Root() { function Root() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
return Root; return Root;
}(Stack)); }(Stack));
var LinearLayout = /** @class */ (function (_super) { var LinearLayout = /** @class */ (function (_super) {
__extends$d(LinearLayout, _super); __extends$e(LinearLayout, _super);
function LinearLayout() { function LinearLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -851,14 +851,14 @@ var LinearLayout = /** @class */ (function (_super) {
return LinearLayout; return LinearLayout;
}(Group)); }(Group));
var VLayout = /** @class */ (function (_super) { var VLayout = /** @class */ (function (_super) {
__extends$d(VLayout, _super); __extends$e(VLayout, _super);
function VLayout() { function VLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
return VLayout; return VLayout;
}(LinearLayout)); }(LinearLayout));
var HLayout = /** @class */ (function (_super) { var HLayout = /** @class */ (function (_super) {
__extends$d(HLayout, _super); __extends$e(HLayout, _super);
function HLayout() { function HLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -937,7 +937,7 @@ function vlayout(views, config) {
return ret; return ret;
} }
var FlexLayout = /** @class */ (function (_super) { var FlexLayout = /** @class */ (function (_super) {
__extends$d(FlexLayout, _super); __extends$e(FlexLayout, _super);
function FlexLayout() { function FlexLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -1325,7 +1325,7 @@ var Panel = /** @class */ (function () {
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var __extends$c = (undefined && undefined.__extends) || (function () { var __extends$d = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -1440,7 +1440,7 @@ var Animation = /** @class */ (function () {
return Animation; return Animation;
}()); }());
var ScaleAnimation = /** @class */ (function (_super) { var ScaleAnimation = /** @class */ (function (_super) {
__extends$c(ScaleAnimation, _super); __extends$d(ScaleAnimation, _super);
function ScaleAnimation() { function ScaleAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.scaleXChangeable = { _this.scaleXChangeable = {
@ -1500,7 +1500,7 @@ var ScaleAnimation = /** @class */ (function (_super) {
return ScaleAnimation; return ScaleAnimation;
}(Animation)); }(Animation));
var TranslationAnimation = /** @class */ (function (_super) { var TranslationAnimation = /** @class */ (function (_super) {
__extends$c(TranslationAnimation, _super); __extends$d(TranslationAnimation, _super);
function TranslationAnimation() { function TranslationAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.translationXChangeable = { _this.translationXChangeable = {
@ -1560,7 +1560,7 @@ var TranslationAnimation = /** @class */ (function (_super) {
return TranslationAnimation; return TranslationAnimation;
}(Animation)); }(Animation));
var RotationAnimation = /** @class */ (function (_super) { var RotationAnimation = /** @class */ (function (_super) {
__extends$c(RotationAnimation, _super); __extends$d(RotationAnimation, _super);
function RotationAnimation() { function RotationAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.rotationChaneable = { _this.rotationChaneable = {
@ -1594,7 +1594,7 @@ var RotationAnimation = /** @class */ (function (_super) {
return RotationAnimation; return RotationAnimation;
}(Animation)); }(Animation));
var RotationXAnimation = /** @class */ (function (_super) { var RotationXAnimation = /** @class */ (function (_super) {
__extends$c(RotationXAnimation, _super); __extends$d(RotationXAnimation, _super);
function RotationXAnimation() { function RotationXAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.rotationChaneable = { _this.rotationChaneable = {
@ -1628,7 +1628,7 @@ var RotationXAnimation = /** @class */ (function (_super) {
return RotationXAnimation; return RotationXAnimation;
}(Animation)); }(Animation));
var RotationYAnimation = /** @class */ (function (_super) { var RotationYAnimation = /** @class */ (function (_super) {
__extends$c(RotationYAnimation, _super); __extends$d(RotationYAnimation, _super);
function RotationYAnimation() { function RotationYAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.rotationChaneable = { _this.rotationChaneable = {
@ -1769,7 +1769,7 @@ exports.GradientOrientation = void 0;
GradientOrientation[GradientOrientation["TL_BR"] = 7] = "TL_BR"; GradientOrientation[GradientOrientation["TL_BR"] = 7] = "TL_BR";
})(exports.GradientOrientation || (exports.GradientOrientation = {})); })(exports.GradientOrientation || (exports.GradientOrientation = {}));
var __extends$b = (undefined && undefined.__extends) || (function () { var __extends$c = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -1801,7 +1801,7 @@ exports.TruncateAt = void 0;
TruncateAt[TruncateAt["Clip"] = 3] = "Clip"; TruncateAt[TruncateAt["Clip"] = 3] = "Clip";
})(exports.TruncateAt || (exports.TruncateAt = {})); })(exports.TruncateAt || (exports.TruncateAt = {}));
var Text = /** @class */ (function (_super) { var Text = /** @class */ (function (_super) {
__extends$b(Text, _super); __extends$c(Text, _super);
function Text() { function Text() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -1872,7 +1872,7 @@ function text(config) {
return ret; return ret;
} }
var __extends$a = (undefined && undefined.__extends) || (function () { var __extends$b = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -1903,7 +1903,7 @@ exports.ScaleType = void 0;
ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill"; ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill";
})(exports.ScaleType || (exports.ScaleType = {})); })(exports.ScaleType || (exports.ScaleType = {}));
var Image = /** @class */ (function (_super) { var Image = /** @class */ (function (_super) {
__extends$a(Image, _super); __extends$b(Image, _super);
function Image() { function Image() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -1998,7 +1998,7 @@ function image(config) {
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var __extends$9 = (undefined && undefined.__extends) || (function () { var __extends$a = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2044,7 +2044,7 @@ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, fr
return to; return to;
}; };
var ListItem = /** @class */ (function (_super) { var ListItem = /** @class */ (function (_super) {
__extends$9(ListItem, _super); __extends$a(ListItem, _super);
function ListItem() { function ListItem() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2059,7 +2059,7 @@ var ListItem = /** @class */ (function (_super) {
return ListItem; return ListItem;
}(Stack)); }(Stack));
var List = /** @class */ (function (_super) { var List = /** @class */ (function (_super) {
__extends$9(List, _super); __extends$a(List, _super);
function List() { function List() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
@ -2174,7 +2174,7 @@ function listItem(item, config) {
}); });
} }
var __extends$8 = (undefined && undefined.__extends) || (function () { var __extends$9 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2199,7 +2199,7 @@ var __metadata$7 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var SlideItem = /** @class */ (function (_super) { var SlideItem = /** @class */ (function (_super) {
__extends$8(SlideItem, _super); __extends$9(SlideItem, _super);
function SlideItem() { function SlideItem() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2210,7 +2210,7 @@ var SlideItem = /** @class */ (function (_super) {
return SlideItem; return SlideItem;
}(Stack)); }(Stack));
var Slider = /** @class */ (function (_super) { var Slider = /** @class */ (function (_super) {
__extends$8(Slider, _super); __extends$9(Slider, _super);
function Slider() { function Slider() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
@ -2297,7 +2297,7 @@ function slideItem(item, config) {
}); });
} }
var __extends$7 = (undefined && undefined.__extends) || (function () { var __extends$8 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2333,7 +2333,7 @@ function scroller(content, config) {
}); });
} }
var Scroller = /** @class */ (function (_super) { var Scroller = /** @class */ (function (_super) {
__extends$7(Scroller, _super); __extends$8(Scroller, _super);
function Scroller() { function Scroller() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2373,7 +2373,7 @@ var Scroller = /** @class */ (function (_super) {
return Scroller; return Scroller;
}(Superview)); }(Superview));
var __extends$6 = (undefined && undefined.__extends) || (function () { var __extends$7 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2398,7 +2398,7 @@ var __metadata$5 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var Refreshable = /** @class */ (function (_super) { var Refreshable = /** @class */ (function (_super) {
__extends$6(Refreshable, _super); __extends$7(Refreshable, _super);
function Refreshable() { function Refreshable() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2534,7 +2534,7 @@ exports.Display = void 0;
Display[Display["NONE"] = 1] = "NONE"; Display[Display["NONE"] = 1] = "NONE";
})(exports.Display || (exports.Display = {})); })(exports.Display || (exports.Display = {}));
var __extends$5 = (undefined && undefined.__extends) || (function () { var __extends$6 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2580,7 +2580,7 @@ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from
return to; return to;
}; };
var FlowLayoutItem = /** @class */ (function (_super) { var FlowLayoutItem = /** @class */ (function (_super) {
__extends$5(FlowLayoutItem, _super); __extends$6(FlowLayoutItem, _super);
function FlowLayoutItem() { function FlowLayoutItem() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2591,7 +2591,7 @@ var FlowLayoutItem = /** @class */ (function (_super) {
return FlowLayoutItem; return FlowLayoutItem;
}(Stack)); }(Stack));
var FlowLayout = /** @class */ (function (_super) { var FlowLayout = /** @class */ (function (_super) {
__extends$5(FlowLayout, _super); __extends$6(FlowLayout, _super);
function FlowLayout() { function FlowLayout() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
@ -2711,7 +2711,7 @@ function flowItem(item, config) {
}); });
} }
var __extends$4 = (undefined && undefined.__extends) || (function () { var __extends$5 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2736,7 +2736,7 @@ var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var Input = /** @class */ (function (_super) { var Input = /** @class */ (function (_super) {
__extends$4(Input, _super); __extends$5(Input, _super);
function Input() { function Input() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2823,7 +2823,7 @@ function input(config) {
return ret; return ret;
} }
var __extends$3 = (undefined && undefined.__extends) || (function () { var __extends$4 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2848,7 +2848,7 @@ var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var NestedSlider = /** @class */ (function (_super) { var NestedSlider = /** @class */ (function (_super) {
__extends$3(NestedSlider, _super); __extends$4(NestedSlider, _super);
function NestedSlider() { function NestedSlider() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2877,7 +2877,7 @@ var NestedSlider = /** @class */ (function (_super) {
return NestedSlider; return NestedSlider;
}(Group)); }(Group));
var __extends$2 = (undefined && undefined.__extends) || (function () { var __extends$3 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2902,7 +2902,7 @@ var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var Draggable = /** @class */ (function (_super) { var Draggable = /** @class */ (function (_super) {
__extends$2(Draggable, _super); __extends$3(Draggable, _super);
function Draggable() { function Draggable() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2931,7 +2931,7 @@ function draggable(views, config) {
return ret; return ret;
} }
var __extends$1 = (undefined && undefined.__extends) || (function () { var __extends$2 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2956,7 +2956,7 @@ var __metadata = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var Switch = /** @class */ (function (_super) { var Switch = /** @class */ (function (_super) {
__extends$1(Switch, _super); __extends$2(Switch, _super);
function Switch() { function Switch() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -3546,7 +3546,7 @@ var Provider = /** @class */ (function () {
return Provider; return Provider;
}()); }());
var __extends = (undefined && undefined.__extends) || (function () { var __extends$1 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -3589,7 +3589,7 @@ var ViewModel = /** @class */ (function () {
return ViewModel; return ViewModel;
}()); }());
var VMPanel = /** @class */ (function (_super) { var VMPanel = /** @class */ (function (_super) {
__extends(VMPanel, _super); __extends$1(VMPanel, _super);
function VMPanel() { function VMPanel() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -3605,6 +3605,70 @@ var VMPanel = /** @class */ (function (_super) {
return VMPanel; return VMPanel;
}(Panel)); }(Panel));
var __extends = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
{ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); }
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var ModularPanel = /** @class */ (function (_super) {
__extends(ModularPanel, _super);
function ModularPanel() {
var _this = _super.call(this) || this;
_this.modules = _this.setupModules().map(function (e) { return new e; });
return _this;
}
ModularPanel.prototype.build = function (root) {
var groupView = this.setupShelf(root);
this.modules.forEach(function (e) {
Reflect.set(e, "__root__", groupView);
e.build(groupView);
});
};
ModularPanel.prototype.onCreate = function () {
var _this = this;
_super.prototype.onCreate.call(this);
this.modules.forEach(function (e) {
e.context = _this.context;
e.onCreate();
});
};
ModularPanel.prototype.onDestroy = function () {
_super.prototype.onDestroy.call(this);
this.modules.forEach(function (e) {
e.onDestroy();
});
};
ModularPanel.prototype.onShow = function () {
_super.prototype.onShow.call(this);
this.modules.forEach(function (e) {
e.onShow();
});
};
ModularPanel.prototype.onHidden = function () {
_super.prototype.onHidden.call(this);
this.modules.forEach(function (e) {
e.onHidden();
});
};
ModularPanel.prototype.onRenderFinished = function () {
_super.prototype.onRenderFinished.call(this);
this.modules.forEach(function (e) {
e.onRenderFinished();
});
};
return ModularPanel;
}(Panel));
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.BOTTOM = BOTTOM; exports.BOTTOM = BOTTOM;
exports.CENTER = CENTER; exports.CENTER = CENTER;
@ -3626,6 +3690,7 @@ exports.LEFT = LEFT;
exports.LayoutConfigImpl = LayoutConfigImpl; exports.LayoutConfigImpl = LayoutConfigImpl;
exports.List = List; exports.List = List;
exports.ListItem = ListItem; exports.ListItem = ListItem;
exports.ModularPanel = ModularPanel;
exports.Mutable = Mutable; exports.Mutable = Mutable;
exports.NativeCall = NativeCall; exports.NativeCall = NativeCall;
exports.NestedSlider = NestedSlider; exports.NestedSlider = NestedSlider;

View File

@ -2788,6 +2788,51 @@ class VMPanel extends Panel {
} }
} }
class ModularPanel extends Panel {
constructor() {
super();
this.modules = this.setupModules().map(e => new e);
}
build(root) {
const groupView = this.setupShelf(root);
this.modules.forEach(e => {
Reflect.set(e, "__root__", groupView);
e.build(groupView);
});
}
onCreate() {
super.onCreate();
this.modules.forEach(e => {
e.context = this.context;
e.onCreate();
});
}
onDestroy() {
super.onDestroy();
this.modules.forEach(e => {
e.onDestroy();
});
}
onShow() {
super.onShow();
this.modules.forEach(e => {
e.onShow();
});
}
onHidden() {
super.onHidden();
this.modules.forEach(e => {
e.onHidden();
});
}
onRenderFinished() {
super.onRenderFinished();
this.modules.forEach(e => {
e.onRenderFinished();
});
}
}
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.BOTTOM = BOTTOM; exports.BOTTOM = BOTTOM;
exports.CENTER = CENTER; exports.CENTER = CENTER;
@ -2809,6 +2854,7 @@ exports.LEFT = LEFT;
exports.LayoutConfigImpl = LayoutConfigImpl; exports.LayoutConfigImpl = LayoutConfigImpl;
exports.List = List; exports.List = List;
exports.ListItem = ListItem; exports.ListItem = ListItem;
exports.ModularPanel = ModularPanel;
exports.Mutable = Mutable; exports.Mutable = Mutable;
exports.NativeCall = NativeCall; exports.NativeCall = NativeCall;
exports.NestedSlider = NestedSlider; exports.NestedSlider = NestedSlider;

View File

@ -4309,6 +4309,51 @@ class VMPanel extends Panel {
} }
} }
class ModularPanel extends Panel {
constructor() {
super();
this.modules = this.setupModules().map(e => new e);
}
build(root) {
const groupView = this.setupShelf(root);
this.modules.forEach(e => {
Reflect.set(e, "__root__", groupView);
e.build(groupView);
});
}
onCreate() {
super.onCreate();
this.modules.forEach(e => {
e.context = this.context;
e.onCreate();
});
}
onDestroy() {
super.onDestroy();
this.modules.forEach(e => {
e.onDestroy();
});
}
onShow() {
super.onShow();
this.modules.forEach(e => {
e.onShow();
});
}
onHidden() {
super.onHidden();
this.modules.forEach(e => {
e.onHidden();
});
}
onRenderFinished() {
super.onRenderFinished();
this.modules.forEach(e => {
e.onRenderFinished();
});
}
}
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@ -4571,6 +4616,7 @@ exports.LEFT = LEFT;
exports.LayoutConfigImpl = LayoutConfigImpl; exports.LayoutConfigImpl = LayoutConfigImpl;
exports.List = List; exports.List = List;
exports.ListItem = ListItem; exports.ListItem = ListItem;
exports.ModularPanel = ModularPanel;
exports.Mutable = Mutable; exports.Mutable = Mutable;
exports.NativeCall = NativeCall; exports.NativeCall = NativeCall;
exports.NestedSlider = NestedSlider; exports.NestedSlider = NestedSlider;

18
doric-js/index.d.ts vendored
View File

@ -118,6 +118,7 @@ declare module 'doric/lib/src/pattern/index.pattern' {
export * from 'doric/lib/src/pattern/candies'; export * from 'doric/lib/src/pattern/candies';
export * from 'doric/lib/src/pattern/provider'; export * from 'doric/lib/src/pattern/provider';
export * from 'doric/lib/src/pattern/mvvm'; export * from 'doric/lib/src/pattern/mvvm';
export * from 'doric/lib/src/pattern/modular';
} }
declare module 'doric/lib/src/ui/panel' { declare module 'doric/lib/src/ui/panel' {
@ -1410,6 +1411,23 @@ declare module 'doric/lib/src/pattern/mvvm' {
} }
} }
declare module 'doric/lib/src/pattern/modular' {
import { Panel } from "doric/lib/src/ui/panel";
import { Group } from "doric/lib/src/ui/view";
import { ClassType } from "doric/lib/src/util/types";
export abstract class ModularPanel extends Panel {
constructor();
abstract setupModules(): ClassType<Panel>[];
abstract setupShelf(root: Group): Group;
build(root: Group): void;
onCreate(): void;
onDestroy(): void;
onShow(): void;
onHidden(): void;
onRenderFinished(): void;
}
}
declare module '*.png' { declare module '*.png' {
const value: any; const value: any;
export default value; export default value;

View File

@ -1,3 +1,4 @@
export * from './candies'; export * from './candies';
export * from './provider'; export * from './provider';
export * from './mvvm'; export * from './mvvm';
export * from './modular';

View File

@ -16,3 +16,4 @@
export * from './candies'; export * from './candies';
export * from './provider'; export * from './provider';
export * from './mvvm'; export * from './mvvm';
export * from './modular';

View File

@ -1,9 +1,10 @@
import { Panel } from "../ui/panel"; import { Panel } from "../ui/panel";
import { Group } from "../ui/view"; import { Group } from "../ui/view";
import { ClassType } from "../util/types";
export declare abstract class ModularPanel extends Panel { export declare abstract class ModularPanel extends Panel {
private modules; private modules;
constructor(modules: Panel[]); constructor();
abstract setupModules(): Panel[]; abstract setupModules(): ClassType<Panel>[];
abstract setupShelf(root: Group): Group; abstract setupShelf(root: Group): Group;
build(root: Group): void; build(root: Group): void;
onCreate(): void; onCreate(): void;

View File

@ -1,9 +1,8 @@
import { Panel } from "../ui/panel"; import { Panel } from "../ui/panel";
export class ModularPanel extends Panel { export class ModularPanel extends Panel {
constructor(modules) { constructor() {
super(); super();
this.modules = []; this.modules = this.setupModules().map(e => new e);
this.modules = modules;
} }
build(root) { build(root) {
const groupView = this.setupShelf(root); const groupView = this.setupShelf(root);
@ -15,6 +14,7 @@ export class ModularPanel extends Panel {
onCreate() { onCreate() {
super.onCreate(); super.onCreate();
this.modules.forEach(e => { this.modules.forEach(e => {
e.context = this.context;
e.onCreate(); e.onCreate();
}); });
} }

View File

@ -4,7 +4,6 @@ import { ClassType } from "../util/types"
export abstract class ModularPanel extends Panel { export abstract class ModularPanel extends Panel {
private modules: Panel[] private modules: Panel[]
constructor() { constructor() {
super() super()
this.modules = this.setupModules().map(e => new e) this.modules = this.setupModules().map(e => new e)
@ -14,7 +13,6 @@ export abstract class ModularPanel extends Panel {
abstract setupShelf(root: Group): Group abstract setupShelf(root: Group): Group
build(root: Group) { build(root: Group) {
root.children.length = 0
const groupView = this.setupShelf(root) const groupView = this.setupShelf(root)
this.modules.forEach(e => { this.modules.forEach(e => {
Reflect.set(e, "__root__", groupView) Reflect.set(e, "__root__", groupView)
@ -25,6 +23,7 @@ export abstract class ModularPanel extends Panel {
onCreate() { onCreate() {
super.onCreate() super.onCreate()
this.modules.forEach(e => { this.modules.forEach(e => {
e.context = this.context
e.onCreate() e.onCreate()
}) })
} }

View File

@ -4363,6 +4363,51 @@ class VMPanel extends Panel {
} }
} }
class ModularPanel extends Panel {
constructor() {
super();
this.modules = this.setupModules().map(e => new e);
}
build(root) {
const groupView = this.setupShelf(root);
this.modules.forEach(e => {
Reflect.set(e, "__root__", groupView);
e.build(groupView);
});
}
onCreate() {
super.onCreate();
this.modules.forEach(e => {
e.context = this.context;
e.onCreate();
});
}
onDestroy() {
super.onDestroy();
this.modules.forEach(e => {
e.onDestroy();
});
}
onShow() {
super.onShow();
this.modules.forEach(e => {
e.onShow();
});
}
onHidden() {
super.onHidden();
this.modules.forEach(e => {
e.onHidden();
});
}
onRenderFinished() {
super.onRenderFinished();
this.modules.forEach(e => {
e.onRenderFinished();
});
}
}
exports.AnimationSet = AnimationSet; exports.AnimationSet = AnimationSet;
exports.BOTTOM = BOTTOM; exports.BOTTOM = BOTTOM;
exports.CENTER = CENTER; exports.CENTER = CENTER;
@ -4384,6 +4429,7 @@ exports.LEFT = LEFT;
exports.LayoutConfigImpl = LayoutConfigImpl; exports.LayoutConfigImpl = LayoutConfigImpl;
exports.List = List; exports.List = List;
exports.ListItem = ListItem; exports.ListItem = ListItem;
exports.ModularPanel = ModularPanel;
exports.Mutable = Mutable; exports.Mutable = Mutable;
exports.NativeCall = NativeCall; exports.NativeCall = NativeCall;
exports.NestedSlider = NestedSlider; exports.NestedSlider = NestedSlider;

File diff suppressed because one or more lines are too long