iOS:add ListItem actions api
This commit is contained in:
@@ -113,7 +113,7 @@ export class View {
|
||||
newV = this.callback2Id(newV);
|
||||
}
|
||||
else {
|
||||
newV = obj2Model(newV);
|
||||
newV = obj2Model(newV, (v) => this.callback2Id(v));
|
||||
}
|
||||
this.__dirty_props__[propKey] = newV;
|
||||
}
|
||||
|
2
doric-js/lib/src/util/types.d.ts
vendored
2
doric-js/lib/src/util/types.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
export interface Modeling {
|
||||
toModel(): Model;
|
||||
}
|
||||
export declare function obj2Model(obj: Model): Model;
|
||||
export declare function obj2Model(obj: Model, convertor: (v: Function) => string): Model;
|
||||
declare type _M = string | number | boolean | Modeling | {
|
||||
[index: string]: Model;
|
||||
} | undefined;
|
||||
|
@@ -1,6 +1,9 @@
|
||||
export function obj2Model(obj) {
|
||||
if (obj instanceof Array) {
|
||||
return obj.map(e => obj2Model(e));
|
||||
export function obj2Model(obj, convertor) {
|
||||
if (obj instanceof Function) {
|
||||
return convertor(obj);
|
||||
}
|
||||
else if (obj instanceof Array) {
|
||||
return obj.map(e => obj2Model(e, convertor));
|
||||
}
|
||||
else if (obj instanceof Object) {
|
||||
if (Reflect.has(obj, 'toModel') && Reflect.get(obj, 'toModel') instanceof Function) {
|
||||
@@ -10,7 +13,7 @@ export function obj2Model(obj) {
|
||||
else {
|
||||
for (let key in obj) {
|
||||
const val = Reflect.get(obj, key);
|
||||
Reflect.set(obj, key, obj2Model(val));
|
||||
Reflect.set(obj, key, obj2Model(val, convertor));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
6
doric-js/lib/src/widget/list.d.ts
vendored
6
doric-js/lib/src/widget/list.d.ts
vendored
@@ -1,11 +1,17 @@
|
||||
import { View, Superview, NativeViewModel } from "../ui/view";
|
||||
import { Stack } from "./layouts";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { Color } from "../util/color";
|
||||
export declare class ListItem extends Stack {
|
||||
/**
|
||||
* Set to reuse native view
|
||||
*/
|
||||
identifier?: string;
|
||||
actions?: {
|
||||
title: string;
|
||||
backgroundColor?: Color;
|
||||
callback: () => void;
|
||||
}[];
|
||||
}
|
||||
export declare class List extends Superview {
|
||||
private cachedViews;
|
||||
|
@@ -31,6 +31,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", String)
|
||||
], ListItem.prototype, "identifier", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", Array)
|
||||
], ListItem.prototype, "actions", void 0);
|
||||
export class List extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
Reference in New Issue
Block a user