Add resource system for doric,start with android
This commit is contained in:
31
doric-js/lib/src/util/resource.d.ts
vendored
Normal file
31
doric-js/lib/src/util/resource.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Modeling } from "./types";
|
||||
export declare abstract class Resource implements Modeling {
|
||||
type: string;
|
||||
identifier: string;
|
||||
constructor(type: string, identifier: string);
|
||||
toModel(): {
|
||||
type: string;
|
||||
identifier: string;
|
||||
};
|
||||
}
|
||||
export declare class FileResource extends Resource {
|
||||
constructor(path: string);
|
||||
}
|
||||
export declare class RemoteResource extends Resource {
|
||||
constructor(url: string);
|
||||
}
|
||||
/**
|
||||
* This is for android platform
|
||||
*/
|
||||
export declare class DrawableResource extends Resource {
|
||||
constructor(url: string);
|
||||
}
|
||||
export declare class AssetResource extends Resource {
|
||||
constructor(path: string);
|
||||
}
|
||||
/**
|
||||
* This is for iOS platform
|
||||
*/
|
||||
export declare class MainBundleResource extends Resource {
|
||||
constructor(path: string);
|
||||
}
|
43
doric-js/lib/src/util/resource.js
Normal file
43
doric-js/lib/src/util/resource.js
Normal file
@@ -0,0 +1,43 @@
|
||||
export class Resource {
|
||||
constructor(type, identifier) {
|
||||
this.type = type;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
toModel() {
|
||||
return {
|
||||
type: this.type,
|
||||
identifier: this.identifier,
|
||||
};
|
||||
}
|
||||
}
|
||||
export class FileResource extends Resource {
|
||||
constructor(path) {
|
||||
super("file", path);
|
||||
}
|
||||
}
|
||||
export class RemoteResource extends Resource {
|
||||
constructor(url) {
|
||||
super("remote", url);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is for android platform
|
||||
*/
|
||||
export class DrawableResource extends Resource {
|
||||
constructor(url) {
|
||||
super("drawable", url);
|
||||
}
|
||||
}
|
||||
export class AssetResource extends Resource {
|
||||
constructor(path) {
|
||||
super("assets", path);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is for iOS platform
|
||||
*/
|
||||
export class MainBundleResource extends Resource {
|
||||
constructor(path) {
|
||||
super("mainBundle", path);
|
||||
}
|
||||
}
|
5
doric-js/lib/src/widget/image.d.ts
vendored
5
doric-js/lib/src/widget/image.d.ts
vendored
@@ -1,12 +1,17 @@
|
||||
import { View } from "../ui/view";
|
||||
import { Color } from "../util/color";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { Resource } from "../util/resource";
|
||||
export declare enum ScaleType {
|
||||
ScaleToFill = 0,
|
||||
ScaleAspectFit = 1,
|
||||
ScaleAspectFill = 2
|
||||
}
|
||||
export declare class Image extends View {
|
||||
/**
|
||||
* This could be loaded by customized resource loader
|
||||
*/
|
||||
image?: Resource;
|
||||
imageUrl?: string;
|
||||
/**
|
||||
* Read image from local file system.
|
||||
|
@@ -25,6 +25,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
import { View, Property } from "../ui/view";
|
||||
import { layoutConfig } from "../util/layoutconfig";
|
||||
import { Color } from "../util/color";
|
||||
import { Resource } from "../util/resource";
|
||||
export var ScaleType;
|
||||
(function (ScaleType) {
|
||||
ScaleType[ScaleType["ScaleToFill"] = 0] = "ScaleToFill";
|
||||
@@ -42,6 +43,10 @@ export class Image extends View {
|
||||
return this.nativeChannel(context, "stopAnimating")();
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", Resource)
|
||||
], Image.prototype, "image", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
|
Reference in New Issue
Block a user