iOS:add FlexLayoutNode
This commit is contained in:
7
doric-js/lib/src/ui/view.d.ts
vendored
7
doric-js/lib/src/ui/view.d.ts
vendored
@@ -3,6 +3,7 @@ import { Modeling, Model } from "../util/types";
|
||||
import { BridgeContext } from "../runtime/global";
|
||||
import { LayoutConfig } from '../util/layoutconfig';
|
||||
import { IAnimation } from "./animation";
|
||||
import { FlexConfig } from "../util/flexbox";
|
||||
export declare function Property(target: Object, propKey: string): void;
|
||||
export interface IView {
|
||||
width?: number;
|
||||
@@ -56,6 +57,11 @@ export interface IView {
|
||||
* rotation*PI
|
||||
*/
|
||||
rotation?: number;
|
||||
/**----------transform----------*/
|
||||
/**
|
||||
* Only affected when its superview or itself is FlexLayout.
|
||||
*/
|
||||
flexConfig?: FlexConfig;
|
||||
}
|
||||
export declare type NativeViewModel = {
|
||||
id: string;
|
||||
@@ -149,6 +155,7 @@ export declare abstract class View implements Modeling, IView {
|
||||
pivotY?: number;
|
||||
rotation?: number;
|
||||
/**----------transform----------*/
|
||||
flexConfig?: FlexConfig;
|
||||
doAnimation(context: BridgeContext, animation: IAnimation): Promise<void>;
|
||||
}
|
||||
export declare abstract class Superview extends View {
|
||||
|
@@ -177,7 +177,6 @@ export class View {
|
||||
getLocationOnScreen(context) {
|
||||
return this.nativeChannel(context, "getLocationOnScreen")();
|
||||
}
|
||||
/**----------transform----------*/
|
||||
doAnimation(context, animation) {
|
||||
return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => {
|
||||
for (let key in args) {
|
||||
@@ -267,6 +266,10 @@ __decorate([
|
||||
Property,
|
||||
__metadata("design:type", Number)
|
||||
], View.prototype, "rotation", void 0);
|
||||
__decorate([
|
||||
Property,
|
||||
__metadata("design:type", Object)
|
||||
], View.prototype, "flexConfig", void 0);
|
||||
export class Superview extends View {
|
||||
subviewById(id) {
|
||||
for (let v of this.allSubviews()) {
|
||||
|
121
doric-js/lib/src/util/flexbox.d.ts
vendored
Normal file
121
doric-js/lib/src/util/flexbox.d.ts
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
import { Modeling } from "./types";
|
||||
declare enum ValueType {
|
||||
Undefined = 0,
|
||||
Point = 1,
|
||||
Percent = 2,
|
||||
Auto = 3
|
||||
}
|
||||
export declare class FlexTypedValue implements Modeling {
|
||||
type: ValueType;
|
||||
value: number;
|
||||
static Auto: FlexTypedValue;
|
||||
static percent(v: number): FlexTypedValue;
|
||||
static point(v: number): FlexTypedValue;
|
||||
toModel(): {
|
||||
type: ValueType;
|
||||
value: number;
|
||||
};
|
||||
}
|
||||
export declare enum FlexDirection {
|
||||
COLUMN = 0,
|
||||
COLUMN_REVERSE = 1,
|
||||
ROW = 2,
|
||||
ROW_REVERSE = 3
|
||||
}
|
||||
export declare enum Align {
|
||||
AUTO = 0,
|
||||
FLEX_START = 1,
|
||||
CENTER = 2,
|
||||
FLEX_END = 3,
|
||||
STRETCH = 4,
|
||||
BASELINE = 5,
|
||||
SPACE_BETWEEN = 6,
|
||||
SPACE_AROUND = 7
|
||||
}
|
||||
export declare enum Justify {
|
||||
FLEX_START = 0,
|
||||
CENTER = 1,
|
||||
FLEX_END = 2,
|
||||
SPACE_BETWEEN = 3,
|
||||
SPACE_AROUND = 4,
|
||||
SPACE_EVENLY = 5
|
||||
}
|
||||
export declare enum Direction {
|
||||
INHERIT = 0,
|
||||
LTR = 1,
|
||||
RTL = 2
|
||||
}
|
||||
export declare enum PositionType {
|
||||
RELATIVE = 0,
|
||||
ABSOLUTE = 1
|
||||
}
|
||||
export declare enum Wrap {
|
||||
NO_WRAP = 0,
|
||||
WRAP = 1,
|
||||
WRAP_REVERSE = 2
|
||||
}
|
||||
export declare enum OverFlow {
|
||||
VISIBLE = 0,
|
||||
HIDDEN = 1,
|
||||
SCROLL = 2
|
||||
}
|
||||
export declare enum Display {
|
||||
FLEX = 0,
|
||||
NONE = 1
|
||||
}
|
||||
export declare type FlexValue = FlexTypedValue | number;
|
||||
export interface FlexConfig {
|
||||
direction?: Direction;
|
||||
flexDirection?: FlexDirection;
|
||||
justifyContent?: Justify;
|
||||
alignContent?: Align;
|
||||
alignItems?: Align;
|
||||
alignSelf?: Align;
|
||||
positionType?: PositionType;
|
||||
flexWrap?: Wrap;
|
||||
overFlow?: OverFlow;
|
||||
display?: Display;
|
||||
flex?: number;
|
||||
flexGrow?: number;
|
||||
flexShrink?: number;
|
||||
flexBasis?: FlexValue;
|
||||
marginLeft?: FlexValue;
|
||||
marginRight?: FlexValue;
|
||||
marginTop?: FlexValue;
|
||||
marginBottom?: FlexValue;
|
||||
marginStart?: FlexValue;
|
||||
marginEnd?: FlexValue;
|
||||
marginHorizontal?: FlexValue;
|
||||
marginVertical?: FlexValue;
|
||||
margin?: FlexValue;
|
||||
paddingLeft?: FlexValue;
|
||||
paddingRight?: FlexValue;
|
||||
paddingTop?: FlexValue;
|
||||
paddingBottom?: FlexValue;
|
||||
paddingStart?: FlexValue;
|
||||
paddingEnd?: FlexValue;
|
||||
paddingHorizontal?: FlexValue;
|
||||
paddingVertical?: FlexValue;
|
||||
padding?: FlexValue;
|
||||
borderLeftWidth?: number;
|
||||
borderRightWidth?: number;
|
||||
borderTopWidth?: number;
|
||||
borderBottomWidth?: number;
|
||||
borderStartWidth?: number;
|
||||
borderEndWidth?: number;
|
||||
borderWidth?: number;
|
||||
left?: FlexValue;
|
||||
right?: FlexValue;
|
||||
top?: FlexValue;
|
||||
bottom?: FlexValue;
|
||||
start?: FlexValue;
|
||||
end?: FlexValue;
|
||||
width?: FlexValue;
|
||||
height?: FlexValue;
|
||||
minWidth?: FlexValue;
|
||||
minHeight?: FlexValue;
|
||||
maxWidth?: FlexValue;
|
||||
maxHeight?: FlexValue;
|
||||
aspectRatio?: number;
|
||||
}
|
||||
export {};
|
87
doric-js/lib/src/util/flexbox.js
Normal file
87
doric-js/lib/src/util/flexbox.js
Normal file
@@ -0,0 +1,87 @@
|
||||
var ValueType;
|
||||
(function (ValueType) {
|
||||
ValueType[ValueType["Undefined"] = 0] = "Undefined";
|
||||
ValueType[ValueType["Point"] = 1] = "Point";
|
||||
ValueType[ValueType["Percent"] = 2] = "Percent";
|
||||
ValueType[ValueType["Auto"] = 3] = "Auto";
|
||||
})(ValueType || (ValueType = {}));
|
||||
export class FlexTypedValue {
|
||||
constructor() {
|
||||
this.type = ValueType.Auto;
|
||||
this.value = 0;
|
||||
}
|
||||
static percent(v) {
|
||||
const ret = new FlexTypedValue;
|
||||
ret.type = ValueType.Percent;
|
||||
ret.value = v;
|
||||
return ret;
|
||||
}
|
||||
static point(v) {
|
||||
const ret = new FlexTypedValue;
|
||||
ret.type = ValueType.Point;
|
||||
ret.value = v;
|
||||
return ret;
|
||||
}
|
||||
toModel() {
|
||||
return {
|
||||
type: this.type,
|
||||
value: this.value,
|
||||
};
|
||||
}
|
||||
}
|
||||
FlexTypedValue.Auto = new FlexTypedValue;
|
||||
export var FlexDirection;
|
||||
(function (FlexDirection) {
|
||||
FlexDirection[FlexDirection["COLUMN"] = 0] = "COLUMN";
|
||||
FlexDirection[FlexDirection["COLUMN_REVERSE"] = 1] = "COLUMN_REVERSE";
|
||||
FlexDirection[FlexDirection["ROW"] = 2] = "ROW";
|
||||
FlexDirection[FlexDirection["ROW_REVERSE"] = 3] = "ROW_REVERSE";
|
||||
})(FlexDirection || (FlexDirection = {}));
|
||||
export var Align;
|
||||
(function (Align) {
|
||||
Align[Align["AUTO"] = 0] = "AUTO";
|
||||
Align[Align["FLEX_START"] = 1] = "FLEX_START";
|
||||
Align[Align["CENTER"] = 2] = "CENTER";
|
||||
Align[Align["FLEX_END"] = 3] = "FLEX_END";
|
||||
Align[Align["STRETCH"] = 4] = "STRETCH";
|
||||
Align[Align["BASELINE"] = 5] = "BASELINE";
|
||||
Align[Align["SPACE_BETWEEN"] = 6] = "SPACE_BETWEEN";
|
||||
Align[Align["SPACE_AROUND"] = 7] = "SPACE_AROUND";
|
||||
})(Align || (Align = {}));
|
||||
export var Justify;
|
||||
(function (Justify) {
|
||||
Justify[Justify["FLEX_START"] = 0] = "FLEX_START";
|
||||
Justify[Justify["CENTER"] = 1] = "CENTER";
|
||||
Justify[Justify["FLEX_END"] = 2] = "FLEX_END";
|
||||
Justify[Justify["SPACE_BETWEEN"] = 3] = "SPACE_BETWEEN";
|
||||
Justify[Justify["SPACE_AROUND"] = 4] = "SPACE_AROUND";
|
||||
Justify[Justify["SPACE_EVENLY"] = 5] = "SPACE_EVENLY";
|
||||
})(Justify || (Justify = {}));
|
||||
export var Direction;
|
||||
(function (Direction) {
|
||||
Direction[Direction["INHERIT"] = 0] = "INHERIT";
|
||||
Direction[Direction["LTR"] = 1] = "LTR";
|
||||
Direction[Direction["RTL"] = 2] = "RTL";
|
||||
})(Direction || (Direction = {}));
|
||||
export var PositionType;
|
||||
(function (PositionType) {
|
||||
PositionType[PositionType["RELATIVE"] = 0] = "RELATIVE";
|
||||
PositionType[PositionType["ABSOLUTE"] = 1] = "ABSOLUTE";
|
||||
})(PositionType || (PositionType = {}));
|
||||
export var Wrap;
|
||||
(function (Wrap) {
|
||||
Wrap[Wrap["NO_WRAP"] = 0] = "NO_WRAP";
|
||||
Wrap[Wrap["WRAP"] = 1] = "WRAP";
|
||||
Wrap[Wrap["WRAP_REVERSE"] = 2] = "WRAP_REVERSE";
|
||||
})(Wrap || (Wrap = {}));
|
||||
export var OverFlow;
|
||||
(function (OverFlow) {
|
||||
OverFlow[OverFlow["VISIBLE"] = 0] = "VISIBLE";
|
||||
OverFlow[OverFlow["HIDDEN"] = 1] = "HIDDEN";
|
||||
OverFlow[OverFlow["SCROLL"] = 2] = "SCROLL";
|
||||
})(OverFlow || (OverFlow = {}));
|
||||
export var Display;
|
||||
(function (Display) {
|
||||
Display[Display["FLEX"] = 0] = "FLEX";
|
||||
Display[Display["NONE"] = 1] = "NONE";
|
||||
})(Display || (Display = {}));
|
3
doric-js/lib/src/widget/layouts.d.ts
vendored
3
doric-js/lib/src/widget/layouts.d.ts
vendored
@@ -25,4 +25,7 @@ export declare class HLayout extends LinearLayout implements IHLayout {
|
||||
export declare function stack(views: View[], config?: IStack): Stack;
|
||||
export declare function hlayout(views: View[], config?: IHLayout): HLayout;
|
||||
export declare function vlayout(views: View[], config?: IVLayout): VLayout;
|
||||
export declare class FlexLayout extends Group {
|
||||
}
|
||||
export declare function flexlayout(views: View[], config: IView): FlexLayout;
|
||||
export {};
|
||||
|
@@ -82,3 +82,17 @@ export function vlayout(views, config) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
export class FlexLayout extends Group {
|
||||
}
|
||||
export function flexlayout(views, config) {
|
||||
const ret = new FlexLayout;
|
||||
for (let v of views) {
|
||||
ret.addChild(v);
|
||||
}
|
||||
if (config) {
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user