upodate flexnode settings

This commit is contained in:
pengfei.zhou 2020-04-10 20:41:43 +08:00 committed by osborn
parent b266fdaa20
commit c70e1cb20c
10 changed files with 59 additions and 38 deletions

View File

@ -1,48 +1,60 @@
import { Group, Panel, text, gravity, Color, LayoutSpec, vlayout, hlayout, scroller, IVLayout, IHLayout, layoutConfig, stack, Gravity, flexlayout } from "doric"; import { Group, Panel, text, gravity, Color, LayoutSpec, vlayout, hlayout, scroller, IVLayout, IHLayout, layoutConfig, stack, Gravity, flexlayout } from "doric";
import { FlexDirection, Wrap, Justify, Align, FlexTypedValue } from "doric/lib/src/util/flexbox"; import { FlexDirection, Wrap, Justify, Align, FlexTypedValue, OverFlow } from "doric/lib/src/util/flexbox";
import { colors } from "./utils"; import { colors } from "./utils";
@Entry @Entry
class LayoutDemo extends Panel { class LayoutDemo extends Panel {
build(root: Group) { build(root: Group) {
flexlayout( stack(
[ [
stack([], { scroller(
flexConfig: { flexlayout(
width: 100, [
height: 100, stack([],
}, {
backgroundColor: colors[0] backgroundColor: colors[1],
}), flexConfig: {
stack([], { width: 300,
flexConfig: { height: 100,
width: 100, }
height: 100, }),
}, stack([],
backgroundColor: colors[1], {
}), backgroundColor: colors[2],
stack([], { flexConfig: {
flexConfig: { width: 100,
width: 100, height: 100,
height: 100, }
}, }),
backgroundColor: colors[2], stack([],
}), {
backgroundColor: colors[3],
flexConfig: {
width: 100,
height: 100,
}
}),
],
{
flexConfig: {
flexDirection: FlexDirection.COLUMN,
},
backgroundColor: colors[4]
}),
{
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.FIT
},
backgroundColor: colors[0],
})
], ],
{ {
layoutConfig: layoutConfig().fit(), layoutConfig: layoutConfig().just(),
backgroundColor: Color.GRAY, width: 250,
flexConfig: { height: 250,
flexDirection: FlexDirection.COLUMN,
justifyContent: Justify.SPACE_EVENLY,
alignContent: Align.CENTER,
flexWrap: Wrap.WRAP,
width: FlexTypedValue.Auto,
height: FlexTypedValue.Auto,
}
} }
) ).in(root)
.in(root)
} }
} }

View File

@ -34,6 +34,7 @@ - (CGSize)sizeThatFits:(CGSize)size {
@implementation DoricFlexNode @implementation DoricFlexNode
- (UIView *)build { - (UIView *)build {
return [[DoricFlexView new] also:^(DoricFlexView *it) { return [[DoricFlexView new] also:^(DoricFlexView *it) {
it.clipsToBounds = YES;
[it configureLayoutWithBlock:^(YGLayout *_Nonnull layout) { [it configureLayoutWithBlock:^(YGLayout *_Nonnull layout) {
layout.isEnabled = YES; layout.isEnabled = YES;
}]; }];

View File

@ -38,9 +38,11 @@ - (void)setContentView:(UIView *)contentView {
- (CGSize)sizeThatFits:(CGSize)size { - (CGSize)sizeThatFits:(CGSize)size {
if (self.contentView) { if (self.contentView) {
if (!self.contentView.doricLayout.resolved) { if (!self.contentView.doricLayout.resolved) {
[self.contentView.doricLayout apply:self.frame.size]; [self.contentView.doricLayout apply:size];
} }
return self.contentView.frame.size; return CGSizeMake(
MIN(size.width, self.contentView.doricLayout.measuredWidth),
MIN(size.height, self.contentView.doricLayout.measuredHeight));
} }
return CGSizeZero; return CGSizeZero;
} }

View File

@ -878,6 +878,7 @@ var FlexLayout = /** @class */ (function (_super) {
function flexlayout(views, config) { function flexlayout(views, config) {
var e_4, _a; var e_4, _a;
var ret = new FlexLayout; var ret = new FlexLayout;
ret.layoutConfig = layoutConfig().fit();
try { try {
for (var views_4 = __values$1(views), views_4_1 = views_4.next(); !views_4_1.done; views_4_1 = views_4.next()) { for (var views_4 = __values$1(views), views_4_1 = views_4.next(); !views_4_1.done; views_4_1 = views_4.next()) {
var v = views_4_1.value; var v = views_4_1.value;

View File

@ -654,6 +654,7 @@ class FlexLayout extends Group {
} }
function flexlayout(views, config) { function flexlayout(views, config) {
const ret = new FlexLayout; const ret = new FlexLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) { for (let v of views) {
ret.addChild(v); ret.addChild(v);
} }

View File

@ -2113,6 +2113,7 @@ class FlexLayout extends Group {
} }
function flexlayout(views, config) { function flexlayout(views, config) {
const ret = new FlexLayout; const ret = new FlexLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) { for (let v of views) {
ret.addChild(v); ret.addChild(v);
} }

View File

@ -86,6 +86,7 @@ export class FlexLayout extends Group {
} }
export function flexlayout(views, config) { export function flexlayout(views, config) {
const ret = new FlexLayout; const ret = new FlexLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) { for (let v of views) {
ret.addChild(v); ret.addChild(v);
} }

View File

@ -100,6 +100,7 @@ export class FlexLayout extends Group {
export function flexlayout(views: View[], config: IView) { export function flexlayout(views: View[], config: IView) {
const ret = new FlexLayout const ret = new FlexLayout
ret.layoutConfig = layoutConfig().fit()
for (let v of views) { for (let v of views) {
ret.addChild(v) ret.addChild(v)
} }

View File

@ -2171,6 +2171,7 @@ class FlexLayout extends Group {
} }
function flexlayout(views, config) { function flexlayout(views, config) {
const ret = new FlexLayout; const ret = new FlexLayout;
ret.layoutConfig = layoutConfig().fit();
for (let v of views) { for (let v of views) {
ret.addChild(v); ret.addChild(v);
} }

File diff suppressed because one or more lines are too long