iOS:fix when LayoutSpec.MOST and weight both setted

This commit is contained in:
pengfei.zhou 2020-04-10 16:14:27 +08:00 committed by osborn
parent 528e6625b5
commit b266fdaa20
3 changed files with 35 additions and 63 deletions

View File

@ -1,64 +1,34 @@
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";
const colors = [
"#f0932b",
"#eb4d4b",
"#6ab04c",
"#e056fd",
"#686de0",
"#30336b",
]
function box(idx = 0) {
return stack([], {
flexConfig: {
width: 20,
height: 20,
},
backgroundColor: Color.parse(colors[idx || 0])
})
}
function boxStr(str: string, idx = 0) {
return text({
width: 20,
height: 20,
text: str,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
backgroundColor: Color.parse(colors[idx || 0])
})
}
function label(str: string) {
return text({
text: str,
textSize: 16,
})
}
import { colors } from "./utils";
@Entry
class LayoutDemo extends Panel {
build(root: Group) {
flexlayout(
[
box(0),
box(1),
box(2),
box(3),
box(4),
box(0),
box(1),
box(2),
box(3),
box(4),
box(0),
box(1),
box(2),
box(3),
box(4),
stack([], {
flexConfig: {
width: 100,
height: 100,
},
backgroundColor: colors[0]
}),
stack([], {
flexConfig: {
width: 100,
height: 100,
},
backgroundColor: colors[1],
}),
stack([], {
flexConfig: {
width: 100,
height: 100,
},
backgroundColor: colors[2],
}),
],
{
layoutConfig: layoutConfig().fit(),

View File

@ -77,14 +77,22 @@ - (void)measure:(CGSize)targetSize {
CGFloat width;
CGFloat height;
if (self.widthSpec == DoricLayoutMost) {
width = self.measuredWidth = targetSize.width;
if (self.view.superview.doricLayout.layoutType == DoricHLayout && self.weight > 0) {
width = self.measuredWidth = 0;
} else {
width = self.measuredWidth = targetSize.width;
}
} else if (self.widthSpec == DoricLayoutJust) {
width = self.measuredWidth = self.width;
} else {
width = targetSize.width;
}
if (self.heightSpec == DoricLayoutMost) {
height = self.measuredHeight = targetSize.height;
if (self.view.superview.doricLayout.layoutType == DoricVLayout && self.weight > 0) {
height = self.measuredWidth = 0;
} else {
height = self.measuredHeight = targetSize.height;
}
} else if (self.heightSpec == DoricLayoutJust) {
height = self.measuredHeight = self.height;
} else {

View File

@ -1705,7 +1705,7 @@ var doric = (function (exports) {
(module.exports = function (key, value) {
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
})('versions', []).push({
version: '3.6.5',
version: '3.6.4',
mode: 'global',
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
});
@ -6489,13 +6489,7 @@ var doric = (function (exports) {
defer = functionBindContext(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if (
global_1.addEventListener &&
typeof postMessage == 'function' &&
!global_1.importScripts &&
!fails(post) &&
location.protocol !== 'file:'
) {
} else if (global_1.addEventListener && typeof postMessage == 'function' && !global_1.importScripts && !fails(post)) {
defer = post;
global_1.addEventListener('message', listener, false);
// IE8-
@ -9867,7 +9861,7 @@ var doric = (function (exports) {
var INVALID_PORT = 'Invalid port';
var ALPHA = /[A-Za-z]/;
var ALPHANUMERIC = /[\d+-.A-Za-z]/;
var ALPHANUMERIC = /[\d+\-.A-Za-z]/;
var DIGIT = /\d/;
var HEX_START = /^(0x|0X)/;
var OCT = /^[0-7]+$/;