rename layoutconfig
This commit is contained in:
parent
919ec7aeb7
commit
4bc81a9ca9
@ -17,9 +17,9 @@ import { Gravity } from "./gravity";
|
||||
import { Modeling } from "./types";
|
||||
|
||||
export enum LayoutSpec {
|
||||
EXACTLY = 0,
|
||||
WRAP_CONTENT = 1,
|
||||
AT_MOST = 2,
|
||||
JUST = 0,
|
||||
FIT = 1,
|
||||
MOST = 2,
|
||||
}
|
||||
|
||||
export interface LayoutConfig {
|
||||
@ -49,35 +49,35 @@ export class LayoutConfigImpl implements LayoutConfig, Modeling {
|
||||
//Only affective in VLayout or HLayout
|
||||
weight?: number
|
||||
|
||||
wrap() {
|
||||
this.widthSpec = LayoutSpec.WRAP_CONTENT
|
||||
this.heightSpec = LayoutSpec.WRAP_CONTENT
|
||||
fit() {
|
||||
this.widthSpec = LayoutSpec.FIT
|
||||
this.heightSpec = LayoutSpec.FIT
|
||||
return this
|
||||
}
|
||||
|
||||
atmost() {
|
||||
this.widthSpec = LayoutSpec.AT_MOST
|
||||
this.heightSpec = LayoutSpec.AT_MOST
|
||||
most() {
|
||||
this.widthSpec = LayoutSpec.MOST
|
||||
this.heightSpec = LayoutSpec.MOST
|
||||
return this
|
||||
}
|
||||
|
||||
exactly() {
|
||||
this.widthSpec = LayoutSpec.EXACTLY
|
||||
this.heightSpec = LayoutSpec.EXACTLY
|
||||
just() {
|
||||
this.widthSpec = LayoutSpec.JUST
|
||||
this.heightSpec = LayoutSpec.JUST
|
||||
return this
|
||||
}
|
||||
|
||||
w(w: LayoutSpec) {
|
||||
configWidth(w: LayoutSpec) {
|
||||
this.widthSpec = w
|
||||
return this
|
||||
}
|
||||
|
||||
h(h: LayoutSpec) {
|
||||
configHeight(h: LayoutSpec) {
|
||||
this.heightSpec = h
|
||||
return this
|
||||
}
|
||||
|
||||
m(m: {
|
||||
configMargin(m: {
|
||||
left?: number,
|
||||
right?: number,
|
||||
top?: number,
|
||||
@ -87,12 +87,12 @@ export class LayoutConfigImpl implements LayoutConfig, Modeling {
|
||||
return this
|
||||
}
|
||||
|
||||
a(a: Gravity) {
|
||||
configAligmnet(a: Gravity) {
|
||||
this.alignment = a
|
||||
return this
|
||||
}
|
||||
|
||||
wg(w: number) {
|
||||
configWeight(w: number) {
|
||||
this.weight = w
|
||||
return this
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ export function flowlayout(config: IFlowLayout) {
|
||||
|
||||
export function flowItem(item: View) {
|
||||
return (new FlowLayoutItem).also((it) => {
|
||||
it.layoutConfig = layoutConfig().wrap()
|
||||
it.layoutConfig = layoutConfig().fit()
|
||||
it.addChild(item)
|
||||
})
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export class Image extends View implements IImage {
|
||||
|
||||
export function image(config: IImage) {
|
||||
const ret = new Image
|
||||
ret.layoutConfig = layoutConfig().wrap()
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export class HLayout extends LinearLayout implements IHLayout {
|
||||
|
||||
export function stack(views: View[]) {
|
||||
const ret = new Stack
|
||||
ret.layoutConfig = layoutConfig().wrap()
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let v of views) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
@ -62,7 +62,7 @@ export function stack(views: View[]) {
|
||||
|
||||
export function hlayout(views: View[]) {
|
||||
const ret = new HLayout
|
||||
ret.layoutConfig = layoutConfig().wrap()
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let v of views) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
@ -71,7 +71,7 @@ export function hlayout(views: View[]) {
|
||||
|
||||
export function vlayout(views: View[]) {
|
||||
const ret = new VLayout
|
||||
ret.layoutConfig = layoutConfig().wrap()
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let v of views) {
|
||||
ret.addChild(v)
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ export function list(config: IList) {
|
||||
|
||||
export function listItem(item: View) {
|
||||
return (new ListItem).also((it) => {
|
||||
it.layoutConfig = layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT)
|
||||
it.layoutConfig = layoutConfig().most().configHeight(LayoutSpec.FIT)
|
||||
it.addChild(item)
|
||||
})
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ export class Refreshable extends Superview implements IRefreshable {
|
||||
|
||||
export function refreshable(config: IRefreshable) {
|
||||
const ret = new Refreshable
|
||||
ret.layoutConfig = layoutConfig().wrap()
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import { layoutConfig } from '../util/layoutconfig'
|
||||
|
||||
export function scroller(content: View) {
|
||||
return (new Scroller).also(v => {
|
||||
v.layoutConfig = layoutConfig().wrap()
|
||||
v.layoutConfig = layoutConfig().fit()
|
||||
v.content = content
|
||||
})
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export class Slider extends Superview implements ISlider {
|
||||
|
||||
export function slideItem(item: View) {
|
||||
return (new SlideItem).also((it) => {
|
||||
it.layoutConfig = layoutConfig().wrap()
|
||||
it.layoutConfig = layoutConfig().fit()
|
||||
it.addChild(item)
|
||||
})
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ export class Text extends View implements IText {
|
||||
|
||||
export function text(config: IText) {
|
||||
const ret = new Text
|
||||
ret.layoutConfig = layoutConfig().wrap()
|
||||
ret.layoutConfig = layoutConfig().fit()
|
||||
for (let key in config) {
|
||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||
}
|
||||
|
Reference in New Issue
Block a user