add layout config

This commit is contained in:
pengfei.zhou
2019-07-16 19:50:12 +08:00
parent ea2145da69
commit de08866eb4
2 changed files with 62 additions and 9 deletions

View File

@@ -80,27 +80,73 @@ export abstract class View implements IWatcher, Modeling {
toModel() {
return this.__dirty_props__ || {}
}
@Property
padding?: {
left?: number,
right?: number,
top?: number,
bottom?: number,
}
@Property
config?: Config
}
export class Group extends View {
export enum Alignment {
center = 0,
start,
end,
}
export enum Gravity {
center = 0,
left,
right,
top,
bottom,
}
export interface Config {
margin?: {
left?: number,
right?: number,
top?: number,
bottom?: number,
}
alignment?: Alignment
}
export interface StackConfig extends Config {
}
export interface LayoutConfig extends Config {
weight?: number
}
export abstract class Group extends View {
@Property
children: View[] = []
add(v: View) {
this.children.push(v)
}
}
export class Stack extends Group {
@Property
gravity?: number
}
export class VLayout extends Group {
class LinearLayout extends Group {
@Property
space?: number
@Property
gravity?: number
}
export class HLayout extends Group {
export class VLayout extends LinearLayout {
}
export class HLayout extends LinearLayout {
}
export class Text extends View {