@nativescript/core 9.0.21-next.2 → 9.0.21-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/application/application.ios.js +5 -2
- package/application/application.ios.js.map +1 -1
- package/core-types/index.d.ts +2 -2
- package/css/CSS3Parser.js +3 -2
- package/css/CSS3Parser.js.map +1 -1
- package/data/observable/index.js +37 -9
- package/data/observable/index.js.map +1 -1
- package/debugger/dom-types.js +1 -1
- package/debugger/dom-types.js.map +1 -1
- package/fetch/index.mjs +2 -2
- package/file-system/file-system-access.ios.js +18 -10
- package/file-system/file-system-access.ios.js.map +1 -1
- package/file-system/index.d.ts +3 -3
- package/index.d.ts +1 -0
- package/inspector_modules.js +1 -1
- package/inspector_modules.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/widgets-release.aar +0 -0
- package/platforms/ios/TNSWidgets.xcframework/Info.plist +14 -14
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +7 -7
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +7 -7
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/Resources/Info.plist +7 -7
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +1 -1
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +1 -1
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +78 -78
- package/platforms/ios/TNSWidgets.xcframework/xros-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +78 -78
- package/trace/index.d.ts +2 -2
- package/ui/action-bar/action-bar-common.js +0 -1
- package/ui/action-bar/action-bar-common.js.map +1 -1
- package/ui/animation/keyframe-animation.d.ts +1 -1
- package/ui/core/properties/property-shared.js +11 -2
- package/ui/core/properties/property-shared.js.map +1 -1
- package/ui/core/view/index.android.js +21 -1
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.d.ts +16 -0
- package/ui/core/view/index.ios.js +6 -2
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/view-common.d.ts +4 -0
- package/ui/core/view/view-common.js +30 -0
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/view-helper-common.js +21 -3
- package/ui/core/view/view-helper/view-helper-common.js.map +1 -1
- package/ui/core/view-base/index.d.ts +6 -1
- package/ui/core/view-base/index.js +37 -22
- package/ui/core/view-base/index.js.map +1 -1
- package/ui/frame/index.android.js +28 -0
- package/ui/frame/index.android.js.map +1 -1
- package/ui/image/image-common.js +1 -1
- package/ui/image/image-common.js.map +1 -1
- package/ui/image/index.android.js +13 -1
- package/ui/image/index.android.js.map +1 -1
- package/ui/layouts/absolute-layout/index.ios.js +3 -0
- package/ui/layouts/absolute-layout/index.ios.js.map +1 -1
- package/ui/layouts/dock-layout/index.ios.js +3 -0
- package/ui/layouts/dock-layout/index.ios.js.map +1 -1
- package/ui/layouts/flexbox-layout/flexbox-layout-common.d.ts +7 -0
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js +18 -0
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js.map +1 -1
- package/ui/layouts/flexbox-layout/index.android.d.ts +5 -0
- package/ui/layouts/flexbox-layout/index.android.js +15 -0
- package/ui/layouts/flexbox-layout/index.android.js.map +1 -1
- package/ui/layouts/flexbox-layout/index.d.ts +19 -1
- package/ui/layouts/flexbox-layout/index.ios.d.ts +2 -0
- package/ui/layouts/flexbox-layout/index.ios.js +244 -193
- package/ui/layouts/flexbox-layout/index.ios.js.map +1 -1
- package/ui/layouts/grid-layout/index.ios.js +3 -0
- package/ui/layouts/grid-layout/index.ios.js.map +1 -1
- package/ui/layouts/stack-layout/index.ios.js +3 -0
- package/ui/layouts/stack-layout/index.ios.js.map +1 -1
- package/ui/layouts/wrap-layout/index.ios.js +3 -0
- package/ui/layouts/wrap-layout/index.ios.js.map +1 -1
- package/ui/page/index.ios.d.ts +2 -1
- package/ui/page/index.ios.js +11 -5
- package/ui/page/index.ios.js.map +1 -1
- package/ui/styling/css-selector.d.ts +4 -5
- package/ui/styling/css-selector.js +90 -28
- package/ui/styling/css-selector.js.map +1 -1
- package/ui/styling/style/index.d.ts +5 -0
- package/ui/styling/style/index.js.map +1 -1
- package/ui/styling/style-properties.d.ts +4 -0
- package/ui/styling/style-properties.js +116 -63
- package/ui/styling/style-properties.js.map +1 -1
- package/ui/styling/style-scope.d.ts +1 -1
- package/ui/styling/style-scope.js +26 -7
- package/ui/styling/style-scope.js.map +1 -1
- package/ui/switch/index.ios.js +2 -1
- package/ui/switch/index.ios.js.map +1 -1
- package/ui/tab-view/index.android.d.ts +3 -1
- package/ui/tab-view/index.android.js +56 -46
- package/ui/tab-view/index.android.js.map +1 -1
- package/ui/tab-view/index.ios.js +1 -0
- package/ui/tab-view/index.ios.js.map +1 -1
- package/ui/tab-view/tab-view-common.d.ts +1 -0
- package/ui/tab-view/tab-view-common.js +12 -3
- package/ui/tab-view/tab-view-common.js.map +1 -1
- package/ui/text-base/index.android.d.ts +1 -1
- package/ui/text-base/index.android.js +8 -8
- package/ui/text-base/index.android.js.map +1 -1
- package/ui/text-base/index.ios.js +5 -3
- package/ui/text-base/index.ios.js.map +1 -1
- package/utils/layout-helper/index.ios.js +11 -3
- package/utils/layout-helper/index.ios.js.map +1 -1
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import { FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent, FlexboxLayoutBase, FlexBasisPercent, orderProperty, flexGrowProperty, flexShrinkProperty, flexWrapBeforeProperty, alignSelfProperty } from './flexbox-layout-common';
|
|
2
2
|
import { View } from '../../core/view';
|
|
3
3
|
import { layout } from '../../../utils';
|
|
4
|
+
import { CoreTypes } from '../../../core-types';
|
|
4
5
|
export * from './flexbox-layout-common';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
6
|
+
const EXACTLY = layout.EXACTLY;
|
|
7
|
+
const AT_MOST = layout.AT_MOST;
|
|
8
|
+
const UNSPECIFIED = layout.UNSPECIFIED;
|
|
9
|
+
const MEASURED_STATE_TOO_SMALL = layout.MEASURED_STATE_TOO_SMALL;
|
|
10
|
+
const MATCH_PARENT = -1;
|
|
11
|
+
const WRAP_CONTENT = -2;
|
|
12
|
+
const View_sUseZeroUnspecifiedMeasureSpec = true; // NOTE: android version < M
|
|
13
|
+
const makeMeasureSpec = layout.makeMeasureSpec;
|
|
14
|
+
const getMeasureSpecMode = layout.getMeasureSpecMode;
|
|
15
|
+
const getMeasureSpecSize = layout.getMeasureSpecSize;
|
|
16
16
|
View.prototype[orderProperty.setNative] = requestFlexboxLayout;
|
|
17
17
|
View.prototype[flexGrowProperty.setNative] = requestFlexboxLayout;
|
|
18
18
|
View.prototype[flexShrinkProperty.setNative] = requestFlexboxLayout;
|
|
19
19
|
View.prototype[flexWrapBeforeProperty.setNative] = requestFlexboxLayout;
|
|
20
20
|
View.prototype[alignSelfProperty.setNative] = requestFlexboxLayout;
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var getMeasureSpecMode = layout.getMeasureSpecMode;
|
|
28
|
-
var getMeasureSpecSize = layout.getMeasureSpecSize;
|
|
29
|
-
import { CoreTypes } from '../../enums';
|
|
21
|
+
function requestFlexboxLayout(_value) {
|
|
22
|
+
const flexbox = this.parent;
|
|
23
|
+
if (flexbox instanceof FlexboxLayoutBase) {
|
|
24
|
+
flexbox.requestLayout();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
30
27
|
// `eachLayoutChild` iterates over children, and we need more - indexed access.
|
|
31
28
|
// This class tries to accomodate that by collecting all children in an
|
|
32
29
|
// array no more than once per measure.
|
|
@@ -52,7 +49,7 @@ class FlexLine {
|
|
|
52
49
|
this._right = Number.MAX_VALUE;
|
|
53
50
|
this._bottom = Number.MAX_VALUE;
|
|
54
51
|
this._mainSize = 0;
|
|
55
|
-
this.
|
|
52
|
+
this._gapLengthInMainSize = 0;
|
|
56
53
|
this._crossSize = 0;
|
|
57
54
|
this._itemCount = 0;
|
|
58
55
|
this._goneItemCount = 0;
|
|
@@ -102,7 +99,6 @@ class Order {
|
|
|
102
99
|
}
|
|
103
100
|
export class FlexboxLayout extends FlexboxLayoutBase {
|
|
104
101
|
constructor() {
|
|
105
|
-
// Omit divider
|
|
106
102
|
super(...arguments);
|
|
107
103
|
this._flexLines = [];
|
|
108
104
|
}
|
|
@@ -145,17 +141,20 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
145
141
|
const orders = this._createOrders(childCount);
|
|
146
142
|
return this._sortOrdersIntoReorderedIndices(childCount, orders);
|
|
147
143
|
}
|
|
148
|
-
_sortOrdersIntoReorderedIndices(
|
|
144
|
+
_sortOrdersIntoReorderedIndices(_childCount, orders) {
|
|
149
145
|
orders.sort((a, b) => a.compareTo(b));
|
|
150
146
|
if (!this._orderCache) {
|
|
151
147
|
this._orderCache = [];
|
|
152
148
|
}
|
|
153
|
-
|
|
149
|
+
else {
|
|
150
|
+
this._orderCache.length = 0;
|
|
151
|
+
}
|
|
154
152
|
const reorderedIndices = [];
|
|
155
|
-
|
|
153
|
+
for (let i = 0, length = orders.length; i < length; i++) {
|
|
154
|
+
const order = orders[i];
|
|
156
155
|
reorderedIndices[i] = order.index;
|
|
157
|
-
this._orderCache[
|
|
158
|
-
}
|
|
156
|
+
this._orderCache[order.index] = order.order;
|
|
157
|
+
}
|
|
159
158
|
return reorderedIndices;
|
|
160
159
|
}
|
|
161
160
|
_createOrders(childCount) {
|
|
@@ -195,91 +194,93 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
195
194
|
const heightMode = getMeasureSpecMode(heightMeasureSpec);
|
|
196
195
|
let childState = 0;
|
|
197
196
|
this._flexLines.length = 0;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (child === null) {
|
|
209
|
-
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
else if (child.isCollapsed) {
|
|
213
|
-
flexLine._itemCount++;
|
|
214
|
-
flexLine._goneItemCount++;
|
|
215
|
-
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
child._updateEffectiveLayoutValues(widthSize, widthMode, heightSize, heightMode);
|
|
219
|
-
const lp = child; // child.style;
|
|
220
|
-
if (FlexboxLayout.getAlignSelf(child) === 'stretch') {
|
|
221
|
-
flexLine._indicesAlignSelfStretch.push(i);
|
|
222
|
-
}
|
|
223
|
-
let childWidth = lp.effectiveWidth;
|
|
224
|
-
if (FlexBasisPercent.DEFAULT /*lp.flexBasisPercent*/ !== FlexBasisPercent.DEFAULT && widthMode === EXACTLY) {
|
|
225
|
-
childWidth = Math.round(widthSize * FlexBasisPercent.DEFAULT /*lp.flexBasisPercent*/);
|
|
226
|
-
}
|
|
227
|
-
const childWidthMeasureSpec = FlexboxLayout.getChildMeasureSpec(widthMeasureSpec, lp.effectivePaddingLeft + lp.effectivePaddingRight + lp.effectiveMarginLeft + lp.effectiveMarginRight, childWidth < 0 ? WRAP_CONTENT : childWidth);
|
|
228
|
-
const childHeightMeasureSpec = FlexboxLayout.getChildMeasureSpec(heightMeasureSpec, lp.effectivePaddingTop + lp.effectivePaddingBottom + lp.effectiveMarginTop + lp.effectiveMarginBottom, lp.effectiveHeight < 0 ? WRAP_CONTENT : lp.effectiveHeight);
|
|
229
|
-
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
|
230
|
-
this._checkSizeConstraints(child);
|
|
231
|
-
childState = View.combineMeasuredStates(childState, child.getMeasuredState());
|
|
232
|
-
largestHeightInRow = Math.max(largestHeightInRow, child.getMeasuredHeight() + lp.effectiveMarginTop + lp.effectiveMarginBottom);
|
|
233
|
-
if (this._isWrapRequired(child, widthMode, widthSize, flexLine._mainSize, child.getMeasuredWidth() + lp.effectiveMarginLeft + lp.effectiveMarginRight, i, indexInFlexLine)) {
|
|
234
|
-
if (flexLine.layoutVisibleItemCount > 0) {
|
|
235
|
-
this._addFlexLine(flexLine);
|
|
236
|
-
}
|
|
237
|
-
flexLine = new FlexLine();
|
|
238
|
-
flexLine._itemCount = 1;
|
|
239
|
-
flexLine._mainSize = paddingStart + paddingEnd;
|
|
240
|
-
largestHeightInRow = child.getMeasuredHeight() + lp.effectiveMarginTop + lp.effectiveMarginBottom;
|
|
241
|
-
indexInFlexLine = 0;
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
flexLine._itemCount++;
|
|
245
|
-
indexInFlexLine++;
|
|
246
|
-
}
|
|
247
|
-
flexLine._mainSize += child.getMeasuredWidth() + lp.effectiveMarginLeft + lp.effectiveMarginRight;
|
|
248
|
-
flexLine._totalFlexGrow += FlexboxLayout.getFlexGrow(child);
|
|
249
|
-
flexLine._totalFlexShrink += FlexboxLayout.getFlexShrink(child);
|
|
250
|
-
flexLine._crossSize = Math.max(flexLine._crossSize, largestHeightInRow);
|
|
251
|
-
// Omit divider
|
|
252
|
-
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
|
253
|
-
flexLine._maxBaseline = Math.max(flexLine._maxBaseline, FlexboxLayout.getBaseline(child) + lp.effectiveMarginTop);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
flexLine._maxBaseline = Math.max(flexLine._maxBaseline, child.getMeasuredHeight() - FlexboxLayout.getBaseline(child) + lp.effectiveMarginBottom);
|
|
257
|
-
}
|
|
197
|
+
const childCount = this.measureContext.childrenCount;
|
|
198
|
+
const paddingStart = FlexboxLayout.getPaddingStart(this);
|
|
199
|
+
const paddingEnd = FlexboxLayout.getPaddingEnd(this);
|
|
200
|
+
let largestHeightInRow = Number.MIN_VALUE;
|
|
201
|
+
let flexLine = new FlexLine();
|
|
202
|
+
let indexInFlexLine = 0;
|
|
203
|
+
flexLine._mainSize = paddingStart + paddingEnd;
|
|
204
|
+
for (let i = 0; i < childCount; i++) {
|
|
205
|
+
const child = this._getReorderedChildAt(i);
|
|
206
|
+
if (child === null) {
|
|
258
207
|
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
else if (child.isCollapsed) {
|
|
211
|
+
flexLine._itemCount++;
|
|
212
|
+
flexLine._goneItemCount++;
|
|
213
|
+
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
child._updateEffectiveLayoutValues(widthSize, widthMode, heightSize, heightMode);
|
|
217
|
+
const lp = child; // child.style;
|
|
218
|
+
if (FlexboxLayout.getAlignSelf(child) === 'stretch') {
|
|
219
|
+
flexLine._indicesAlignSelfStretch.push(i);
|
|
220
|
+
}
|
|
221
|
+
let childWidth = lp.effectiveWidth;
|
|
222
|
+
if (FlexBasisPercent.DEFAULT /*lp.flexBasisPercent*/ !== FlexBasisPercent.DEFAULT && widthMode === EXACTLY) {
|
|
223
|
+
childWidth = Math.round(widthSize * FlexBasisPercent.DEFAULT /*lp.flexBasisPercent*/);
|
|
224
|
+
}
|
|
225
|
+
const childWidthMeasureSpec = FlexboxLayout.getChildMeasureSpec(widthMeasureSpec, lp.effectivePaddingLeft + lp.effectivePaddingRight + lp.effectiveMarginLeft + lp.effectiveMarginRight, childWidth < 0 ? WRAP_CONTENT : childWidth);
|
|
226
|
+
const childHeightMeasureSpec = FlexboxLayout.getChildMeasureSpec(heightMeasureSpec, lp.effectivePaddingTop + lp.effectivePaddingBottom + lp.effectiveMarginTop + lp.effectiveMarginBottom, lp.effectiveHeight < 0 ? WRAP_CONTENT : lp.effectiveHeight);
|
|
227
|
+
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
|
228
|
+
this._checkSizeConstraints(child);
|
|
229
|
+
childState = View.combineMeasuredStates(childState, child.getMeasuredState());
|
|
230
|
+
largestHeightInRow = Math.max(largestHeightInRow, child.getMeasuredHeight() + lp.effectiveMarginTop + lp.effectiveMarginBottom);
|
|
231
|
+
if (this._isWrapRequired(child, widthMode, widthSize, flexLine._mainSize, child.getMeasuredWidth() + lp.effectiveMarginLeft + lp.effectiveMarginRight, i, indexInFlexLine)) {
|
|
232
|
+
if (flexLine.layoutVisibleItemCount > 0) {
|
|
233
|
+
this._addFlexLine(flexLine);
|
|
234
|
+
}
|
|
235
|
+
flexLine = new FlexLine();
|
|
236
|
+
flexLine._itemCount = 1;
|
|
237
|
+
flexLine._mainSize = paddingStart + paddingEnd;
|
|
238
|
+
largestHeightInRow = child.getMeasuredHeight() + lp.effectiveMarginTop + lp.effectiveMarginBottom;
|
|
239
|
+
indexInFlexLine = 0;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
flexLine._itemCount++;
|
|
243
|
+
indexInFlexLine++;
|
|
244
|
+
}
|
|
245
|
+
flexLine._mainSize += child.getMeasuredWidth() + lp.effectiveMarginLeft + lp.effectiveMarginRight;
|
|
246
|
+
flexLine._totalFlexGrow += FlexboxLayout.getFlexGrow(child);
|
|
247
|
+
flexLine._totalFlexShrink += FlexboxLayout.getFlexShrink(child);
|
|
248
|
+
flexLine._crossSize = Math.max(flexLine._crossSize, largestHeightInRow);
|
|
249
|
+
// Check if column gap is required for the flex item
|
|
250
|
+
if (this.effectiveColumnGap > 0 && this._hasPrecedingViews(i, indexInFlexLine)) {
|
|
251
|
+
flexLine._mainSize += this.effectiveColumnGap;
|
|
252
|
+
flexLine._gapLengthInMainSize += this.effectiveColumnGap;
|
|
253
|
+
}
|
|
254
|
+
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
|
255
|
+
flexLine._maxBaseline = Math.max(flexLine._maxBaseline, FlexboxLayout.getBaseline(child) + lp.effectiveMarginTop);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
flexLine._maxBaseline = Math.max(flexLine._maxBaseline, child.getMeasuredHeight() - FlexboxLayout.getBaseline(child) + lp.effectiveMarginBottom);
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
261
|
+
}
|
|
261
262
|
this._determineMainSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec);
|
|
262
263
|
if (this.alignItems === AlignItems.BASELINE) {
|
|
263
264
|
let viewIndex = 0;
|
|
264
|
-
this._flexLines
|
|
265
|
+
for (const fl of this._flexLines) {
|
|
265
266
|
let largestHeightInLine = Number.MIN_VALUE;
|
|
266
|
-
for (let i = viewIndex; i < viewIndex +
|
|
267
|
+
for (let i = viewIndex; i < viewIndex + fl._itemCount; i++) {
|
|
267
268
|
const child = this._getReorderedChildAt(i);
|
|
268
269
|
const lp = child; // .style;
|
|
269
270
|
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
|
270
|
-
let marginTop =
|
|
271
|
+
let marginTop = fl._maxBaseline - FlexboxLayout.getBaseline(child);
|
|
271
272
|
marginTop = Math.max(marginTop, lp.effectiveMarginTop);
|
|
272
273
|
largestHeightInLine = Math.max(largestHeightInLine, child.getMeasuredHeight() + marginTop + lp.effectiveMarginBottom);
|
|
273
274
|
}
|
|
274
275
|
else {
|
|
275
|
-
let marginBottom =
|
|
276
|
+
let marginBottom = fl._maxBaseline - child.getMeasuredHeight() + FlexboxLayout.getBaseline(child);
|
|
276
277
|
marginBottom = Math.max(marginBottom, lp.effectiveMarginBottom);
|
|
277
278
|
largestHeightInLine = Math.max(largestHeightInLine, child.getMeasuredHeight() + lp.effectiveMarginTop + marginBottom);
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
|
-
|
|
281
|
-
viewIndex +=
|
|
282
|
-
}
|
|
281
|
+
fl._crossSize = largestHeightInLine;
|
|
282
|
+
viewIndex += fl.itemCount;
|
|
283
|
+
}
|
|
283
284
|
}
|
|
284
285
|
this._determineCrossSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec, this.effectivePaddingTop + this.effectivePaddingBottom);
|
|
285
286
|
this._stretchViews(this.flexDirection, this.alignItems);
|
|
@@ -345,7 +346,9 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
345
346
|
flexLine._totalFlexGrow += FlexboxLayout.getFlexGrow(child);
|
|
346
347
|
flexLine._totalFlexShrink += FlexboxLayout.getFlexShrink(child);
|
|
347
348
|
flexLine._crossSize = Math.max(flexLine._crossSize, largestWidthInColumn);
|
|
348
|
-
|
|
349
|
+
if (this.effectiveRowGap > 0 && this._hasPrecedingViews(i, indexInFlexLine)) {
|
|
350
|
+
flexLine._mainSize += this.effectiveRowGap;
|
|
351
|
+
}
|
|
349
352
|
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
350
353
|
}
|
|
351
354
|
this._determineMainSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec);
|
|
@@ -363,9 +366,9 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
363
366
|
needsMeasure = true;
|
|
364
367
|
childWidth = minWidth;
|
|
365
368
|
}
|
|
366
|
-
else if (view.getMeasuredWidth() >
|
|
369
|
+
else if (view.getMeasuredWidth() > view.effectiveMaxWidth) {
|
|
367
370
|
needsMeasure = true;
|
|
368
|
-
childWidth =
|
|
371
|
+
childWidth = view.effectiveMaxWidth;
|
|
369
372
|
}
|
|
370
373
|
const minHeight = view.effectiveMinHeight;
|
|
371
374
|
view.effectiveMinHeight = 0;
|
|
@@ -373,9 +376,9 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
373
376
|
needsMeasure = true;
|
|
374
377
|
childHeight = minHeight;
|
|
375
378
|
}
|
|
376
|
-
else if (childHeight >
|
|
379
|
+
else if (childHeight > view.effectiveMaxHeight) {
|
|
377
380
|
needsMeasure = true;
|
|
378
|
-
childHeight =
|
|
381
|
+
childHeight = view.effectiveMaxHeight;
|
|
379
382
|
}
|
|
380
383
|
if (needsMeasure) {
|
|
381
384
|
view.measure(makeMeasureSpec(childWidth, EXACTLY), makeMeasureSpec(childHeight, EXACTLY));
|
|
@@ -389,7 +392,6 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
389
392
|
}
|
|
390
393
|
}
|
|
391
394
|
_addFlexLine(flexLine) {
|
|
392
|
-
// Omit divider
|
|
393
395
|
this._flexLines.push(flexLine);
|
|
394
396
|
}
|
|
395
397
|
_determineMainSize(flexDirection, widthMeasureSpec, heightMeasureSpec) {
|
|
@@ -426,14 +428,14 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
426
428
|
throw new Error('Invalid flex direction: ' + flexDirection);
|
|
427
429
|
}
|
|
428
430
|
let childIndex = 0;
|
|
429
|
-
this._flexLines
|
|
431
|
+
for (const flexLine of this._flexLines) {
|
|
430
432
|
if (flexLine.mainSize < mainSize) {
|
|
431
433
|
childIndex = this._expandFlexItems(flexLine, flexDirection, mainSize, paddingAlongMainAxis, childIndex);
|
|
432
434
|
}
|
|
433
435
|
else {
|
|
434
436
|
childIndex = this._shrinkFlexItems(flexLine, flexDirection, mainSize, paddingAlongMainAxis, childIndex);
|
|
435
437
|
}
|
|
436
|
-
}
|
|
438
|
+
}
|
|
437
439
|
}
|
|
438
440
|
_expandFlexItems(flexLine, flexDirection, maxMainSize, paddingAlongMainAxis, startIndex) {
|
|
439
441
|
let childIndex = startIndex;
|
|
@@ -445,7 +447,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
445
447
|
let needsReexpand = false;
|
|
446
448
|
const pendingSpace = maxMainSize - flexLine._mainSize;
|
|
447
449
|
const unitSpace = pendingSpace / flexLine._totalFlexGrow;
|
|
448
|
-
flexLine._mainSize = paddingAlongMainAxis + flexLine.
|
|
450
|
+
flexLine._mainSize = paddingAlongMainAxis + flexLine._gapLengthInMainSize;
|
|
449
451
|
let accumulatedRoundError = 0;
|
|
450
452
|
for (let i = 0; i < flexLine.itemCount; i++) {
|
|
451
453
|
const child = this._getReorderedChildAt(childIndex);
|
|
@@ -462,10 +464,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
462
464
|
const flexGrow = FlexboxLayout.getFlexGrow(child);
|
|
463
465
|
const rawCalculatedWidth = child.getMeasuredWidth() + unitSpace * flexGrow + accumulatedRoundError;
|
|
464
466
|
let roundedCalculatedWidth = Math.round(rawCalculatedWidth);
|
|
465
|
-
//
|
|
466
|
-
if (roundedCalculatedWidth >
|
|
467
|
+
// Freeze the child once flex-grow would push it past its max-width (Infinity when unconstrained).
|
|
468
|
+
if (roundedCalculatedWidth > child.effectiveMaxWidth) {
|
|
467
469
|
needsReexpand = true;
|
|
468
|
-
roundedCalculatedWidth =
|
|
470
|
+
roundedCalculatedWidth = child.effectiveMaxWidth;
|
|
469
471
|
this._childrenFrozen[childIndex] = true;
|
|
470
472
|
flexLine._totalFlexGrow -= flexGrow;
|
|
471
473
|
}
|
|
@@ -481,10 +483,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
481
483
|
const flexGrow = FlexboxLayout.getFlexGrow(child);
|
|
482
484
|
const rawCalculatedHeight = child.getMeasuredHeight() + unitSpace * flexGrow + accumulatedRoundError;
|
|
483
485
|
let roundedCalculatedHeight = Math.round(rawCalculatedHeight);
|
|
484
|
-
//
|
|
485
|
-
if (roundedCalculatedHeight >
|
|
486
|
+
// Freeze the child once flex-grow would push it past its max-height (Infinity when unconstrained).
|
|
487
|
+
if (roundedCalculatedHeight > child.effectiveMaxHeight) {
|
|
486
488
|
needsReexpand = true;
|
|
487
|
-
roundedCalculatedHeight =
|
|
489
|
+
roundedCalculatedHeight = child.effectiveMaxHeight;
|
|
488
490
|
this._childrenFrozen[childIndex] = true;
|
|
489
491
|
flexLine._totalFlexGrow -= flexGrow;
|
|
490
492
|
}
|
|
@@ -512,7 +514,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
512
514
|
let needsReshrink = false;
|
|
513
515
|
const unitShrink = (flexLine._mainSize - maxMainSize) / flexLine._totalFlexShrink;
|
|
514
516
|
let accumulatedRoundError = 0;
|
|
515
|
-
flexLine._mainSize = paddingAlongMainAxis + flexLine.
|
|
517
|
+
flexLine._mainSize = paddingAlongMainAxis + flexLine._gapLengthInMainSize;
|
|
516
518
|
for (let i = 0; i < flexLine.itemCount; i++) {
|
|
517
519
|
const child = this._getReorderedChildAt(childIndex);
|
|
518
520
|
if (child === null) {
|
|
@@ -605,81 +607,78 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
605
607
|
}
|
|
606
608
|
else if (this._flexLines.length >= 2 && totalCrossSize < size) {
|
|
607
609
|
switch (this.alignContent) {
|
|
608
|
-
case AlignContent.STRETCH:
|
|
609
|
-
(
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
610
|
+
case AlignContent.STRETCH: {
|
|
611
|
+
const freeSpaceUnit = (size - totalCrossSize) / this._flexLines.length;
|
|
612
|
+
let accumulatedError = 0;
|
|
613
|
+
for (let i = 0, flexLinesSize = this._flexLines.length; i < flexLinesSize; i++) {
|
|
614
|
+
const flexLine = this._flexLines[i];
|
|
615
|
+
let newCrossSizeAsFloat = flexLine._crossSize + freeSpaceUnit;
|
|
616
|
+
if (i === this._flexLines.length - 1) {
|
|
617
|
+
newCrossSizeAsFloat += accumulatedError;
|
|
618
|
+
accumulatedError = 0;
|
|
619
|
+
}
|
|
620
|
+
let newCrossSize = Math.round(newCrossSizeAsFloat);
|
|
621
|
+
accumulatedError += newCrossSizeAsFloat - newCrossSize;
|
|
622
|
+
if (accumulatedError > 1) {
|
|
623
|
+
newCrossSize += 1;
|
|
624
|
+
accumulatedError -= 1;
|
|
625
|
+
}
|
|
626
|
+
else if (accumulatedError < -1) {
|
|
627
|
+
newCrossSize -= 1;
|
|
628
|
+
accumulatedError += 1;
|
|
629
|
+
}
|
|
630
|
+
flexLine._crossSize = newCrossSize;
|
|
631
|
+
}
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
case AlignContent.SPACE_AROUND: {
|
|
635
|
+
let spaceTopAndBottom = size - totalCrossSize;
|
|
636
|
+
const numberOfSpaces = this._flexLines.length * 2;
|
|
637
|
+
const newFlexLines = [];
|
|
638
|
+
const dummySpaceFlexLine = new FlexLine();
|
|
639
|
+
spaceTopAndBottom = spaceTopAndBottom / numberOfSpaces;
|
|
640
|
+
dummySpaceFlexLine._crossSize = spaceTopAndBottom;
|
|
641
|
+
for (const flexLine of this._flexLines) {
|
|
642
|
+
newFlexLines.push(dummySpaceFlexLine);
|
|
643
|
+
newFlexLines.push(flexLine);
|
|
644
|
+
newFlexLines.push(dummySpaceFlexLine);
|
|
645
|
+
}
|
|
646
|
+
this._flexLines = newFlexLines;
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
case AlignContent.SPACE_BETWEEN: {
|
|
650
|
+
let spaceBetweenFlexLine = size - totalCrossSize;
|
|
651
|
+
const numberOfSpaces = this._flexLines.length - 1;
|
|
652
|
+
spaceBetweenFlexLine = spaceBetweenFlexLine / numberOfSpaces;
|
|
653
|
+
let accumulatedError = 0;
|
|
654
|
+
const newFlexLines = [];
|
|
655
|
+
for (let i = 0, flexLineSize = this._flexLines.length; i < flexLineSize; i++) {
|
|
656
|
+
const flexLine = this._flexLines[i];
|
|
657
|
+
newFlexLines.push(flexLine);
|
|
658
|
+
if (i !== this._flexLines.length - 1) {
|
|
659
|
+
const dummySpaceFlexLine = new FlexLine();
|
|
660
|
+
if (i === this._flexLines.length - 2) {
|
|
661
|
+
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine + accumulatedError);
|
|
617
662
|
accumulatedError = 0;
|
|
618
663
|
}
|
|
619
|
-
|
|
620
|
-
|
|
664
|
+
else {
|
|
665
|
+
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine);
|
|
666
|
+
}
|
|
667
|
+
accumulatedError += spaceBetweenFlexLine - dummySpaceFlexLine._crossSize;
|
|
621
668
|
if (accumulatedError > 1) {
|
|
622
|
-
|
|
669
|
+
dummySpaceFlexLine._crossSize += 1;
|
|
623
670
|
accumulatedError -= 1;
|
|
624
671
|
}
|
|
625
672
|
else if (accumulatedError < -1) {
|
|
626
|
-
|
|
673
|
+
dummySpaceFlexLine._crossSize -= 1;
|
|
627
674
|
accumulatedError += 1;
|
|
628
675
|
}
|
|
629
|
-
flexLine._crossSize = newCrossSize;
|
|
630
|
-
}
|
|
631
|
-
})();
|
|
632
|
-
break;
|
|
633
|
-
case AlignContent.SPACE_AROUND:
|
|
634
|
-
(() => {
|
|
635
|
-
let spaceTopAndBottom = size - totalCrossSize;
|
|
636
|
-
const numberOfSpaces = this._flexLines.length * 2;
|
|
637
|
-
spaceTopAndBottom = spaceTopAndBottom / numberOfSpaces;
|
|
638
|
-
const newFlexLines = [];
|
|
639
|
-
const dummySpaceFlexLine = new FlexLine();
|
|
640
|
-
dummySpaceFlexLine._crossSize = spaceTopAndBottom;
|
|
641
|
-
this._flexLines.forEach((flexLine) => {
|
|
642
676
|
newFlexLines.push(dummySpaceFlexLine);
|
|
643
|
-
newFlexLines.push(flexLine);
|
|
644
|
-
newFlexLines.push(dummySpaceFlexLine);
|
|
645
|
-
});
|
|
646
|
-
this._flexLines = newFlexLines;
|
|
647
|
-
})();
|
|
648
|
-
break;
|
|
649
|
-
case AlignContent.SPACE_BETWEEN:
|
|
650
|
-
(() => {
|
|
651
|
-
let spaceBetweenFlexLine = size - totalCrossSize;
|
|
652
|
-
const numberOfSpaces = this._flexLines.length - 1;
|
|
653
|
-
spaceBetweenFlexLine = spaceBetweenFlexLine / numberOfSpaces;
|
|
654
|
-
let accumulatedError = 0;
|
|
655
|
-
const newFlexLines = [];
|
|
656
|
-
for (let i = 0, flexLineSize = this._flexLines.length; i < flexLineSize; i++) {
|
|
657
|
-
const flexLine = this._flexLines[i];
|
|
658
|
-
newFlexLines.push(flexLine);
|
|
659
|
-
if (i !== this._flexLines.length - 1) {
|
|
660
|
-
const dummySpaceFlexLine = new FlexLine();
|
|
661
|
-
if (i === this._flexLines.length - 2) {
|
|
662
|
-
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine + accumulatedError);
|
|
663
|
-
accumulatedError = 0;
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine);
|
|
667
|
-
}
|
|
668
|
-
accumulatedError += spaceBetweenFlexLine - dummySpaceFlexLine._crossSize;
|
|
669
|
-
if (accumulatedError > 1) {
|
|
670
|
-
dummySpaceFlexLine._crossSize += 1;
|
|
671
|
-
accumulatedError -= 1;
|
|
672
|
-
}
|
|
673
|
-
else if (accumulatedError < -1) {
|
|
674
|
-
dummySpaceFlexLine._crossSize -= 1;
|
|
675
|
-
accumulatedError += 1;
|
|
676
|
-
}
|
|
677
|
-
newFlexLines.push(dummySpaceFlexLine);
|
|
678
|
-
}
|
|
679
677
|
}
|
|
680
|
-
|
|
681
|
-
|
|
678
|
+
}
|
|
679
|
+
this._flexLines = newFlexLines;
|
|
682
680
|
break;
|
|
681
|
+
}
|
|
683
682
|
case AlignContent.CENTER: {
|
|
684
683
|
let spaceAboveAndBottom = size - totalCrossSize;
|
|
685
684
|
spaceAboveAndBottom = spaceAboveAndBottom / 2;
|
|
@@ -713,7 +712,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
713
712
|
_stretchViews(flexDirection, alignItems) {
|
|
714
713
|
if (alignItems === AlignItems.STRETCH) {
|
|
715
714
|
let viewIndex = 0;
|
|
716
|
-
this._flexLines
|
|
715
|
+
for (const flexLine of this._flexLines) {
|
|
717
716
|
for (let i = 0; i < flexLine.itemCount; i++, viewIndex++) {
|
|
718
717
|
const view = this._getReorderedChildAt(viewIndex);
|
|
719
718
|
const alignSelf = FlexboxLayout.getAlignSelf(view);
|
|
@@ -733,11 +732,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
733
732
|
throw new Error('Invalid flex direction: ' + flexDirection);
|
|
734
733
|
}
|
|
735
734
|
}
|
|
736
|
-
}
|
|
735
|
+
}
|
|
737
736
|
}
|
|
738
737
|
else {
|
|
739
|
-
this._flexLines
|
|
740
|
-
flexLine._indicesAlignSelfStretch
|
|
738
|
+
for (const flexLine of this._flexLines) {
|
|
739
|
+
for (const index of flexLine._indicesAlignSelfStretch) {
|
|
741
740
|
const view = this._getReorderedChildAt(index);
|
|
742
741
|
switch (flexDirection) {
|
|
743
742
|
case FlexDirection.ROW:
|
|
@@ -751,8 +750,8 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
751
750
|
default:
|
|
752
751
|
throw new Error('Invalid flex direction: ' + flexDirection);
|
|
753
752
|
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
756
755
|
}
|
|
757
756
|
}
|
|
758
757
|
_stretchViewVertically(view, crossSize) {
|
|
@@ -854,15 +853,34 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
854
853
|
if (mode === UNSPECIFIED) {
|
|
855
854
|
return false;
|
|
856
855
|
}
|
|
857
|
-
|
|
856
|
+
if (this._isMainAxisDirectionHorizontal(this.flexDirection)) {
|
|
857
|
+
if (this.effectiveColumnGap > 0 && this._hasPrecedingViews(childAbsoluteIndex, childRelativeIndexInFlexLine)) {
|
|
858
|
+
childLength += this.effectiveColumnGap;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
if (this.effectiveRowGap > 0 && this._hasPrecedingViews(childAbsoluteIndex, childRelativeIndexInFlexLine)) {
|
|
863
|
+
childLength += this.effectiveRowGap;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
858
866
|
return maxSize < currentLength + childLength;
|
|
859
867
|
}
|
|
860
868
|
_getLargestMainSize() {
|
|
861
869
|
return this._flexLines.reduce((max, flexLine) => Math.max(max, flexLine.mainSize), Number.MIN_VALUE);
|
|
862
870
|
}
|
|
863
871
|
_getSumOfCrossSize() {
|
|
864
|
-
|
|
865
|
-
|
|
872
|
+
const isHorizontalDirection = this._isMainAxisDirectionHorizontal(this.flexDirection);
|
|
873
|
+
let sum = 0;
|
|
874
|
+
for (let i = 0, length = this._flexLines.length; i < length; i++) {
|
|
875
|
+
const flexLine = this._flexLines[i];
|
|
876
|
+
const gap = isHorizontalDirection ? this.effectiveRowGap : this.effectiveColumnGap;
|
|
877
|
+
// Judge if gap is required
|
|
878
|
+
if (gap > 0 && this._hasPrecedingFlexLines(i)) {
|
|
879
|
+
sum += gap;
|
|
880
|
+
}
|
|
881
|
+
sum += flexLine._crossSize;
|
|
882
|
+
}
|
|
883
|
+
return sum;
|
|
866
884
|
}
|
|
867
885
|
_isMainAxisDirectionHorizontal(flexDirection) {
|
|
868
886
|
return flexDirection === FlexDirection.ROW || flexDirection === FlexDirection.ROW_REVERSE;
|
|
@@ -907,8 +925,12 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
907
925
|
let childBottom = height - paddingBottom;
|
|
908
926
|
let childTop = paddingTop;
|
|
909
927
|
let childRight;
|
|
910
|
-
this._flexLines.
|
|
911
|
-
|
|
928
|
+
for (let i = 0, length = this._flexLines.length; i < length; i++) {
|
|
929
|
+
const flexLine = this._flexLines[i];
|
|
930
|
+
if (this.effectiveRowGap > 0 && this._hasPrecedingFlexLines(i)) {
|
|
931
|
+
childBottom -= this.effectiveRowGap;
|
|
932
|
+
childTop += this.effectiveRowGap;
|
|
933
|
+
}
|
|
912
934
|
let spaceBetweenItem = 0.0;
|
|
913
935
|
switch (this.justifyContent) {
|
|
914
936
|
case JustifyContent.FLEX_START:
|
|
@@ -956,7 +978,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
956
978
|
const lp = child; // .style;
|
|
957
979
|
childLeft += lp.effectiveMarginLeft;
|
|
958
980
|
childRight -= lp.effectiveMarginRight;
|
|
959
|
-
|
|
981
|
+
if (this.effectiveColumnGap > 0 && this._hasPrecedingViews(currentViewIndex, j)) {
|
|
982
|
+
childLeft += this.effectiveColumnGap;
|
|
983
|
+
childRight -= this.effectiveColumnGap;
|
|
984
|
+
}
|
|
960
985
|
if (this.flexWrap === FlexWrap.WRAP_REVERSE) {
|
|
961
986
|
if (isRtl) {
|
|
962
987
|
this._layoutSingleChildHorizontal(child, flexLine, this.flexWrap, this.alignItems, Math.round(childRight) - child.getMeasuredWidth(), childBottom - child.getMeasuredHeight(), Math.round(childRight), childBottom);
|
|
@@ -984,7 +1009,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
984
1009
|
}
|
|
985
1010
|
childTop += flexLine._crossSize;
|
|
986
1011
|
childBottom -= flexLine._crossSize;
|
|
987
|
-
}
|
|
1012
|
+
}
|
|
988
1013
|
}
|
|
989
1014
|
_layoutSingleChildHorizontal(view, flexLine, flexWrap, alignItems, left, top, right, bottom) {
|
|
990
1015
|
const lp = view; // .style;
|
|
@@ -1047,8 +1072,12 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1047
1072
|
let childRight = width - paddingRight;
|
|
1048
1073
|
let childTop;
|
|
1049
1074
|
let childBottom;
|
|
1050
|
-
this._flexLines.
|
|
1051
|
-
|
|
1075
|
+
for (let i = 0, length = this._flexLines.length; i < length; i++) {
|
|
1076
|
+
const flexLine = this._flexLines[i];
|
|
1077
|
+
if (this.effectiveColumnGap > 0 && this._hasPrecedingFlexLines(i)) {
|
|
1078
|
+
childLeft += this.effectiveColumnGap;
|
|
1079
|
+
childRight -= this.effectiveColumnGap;
|
|
1080
|
+
}
|
|
1052
1081
|
let spaceBetweenItem = 0.0;
|
|
1053
1082
|
switch (this.justifyContent) {
|
|
1054
1083
|
case JustifyContent.FLEX_START:
|
|
@@ -1096,7 +1125,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1096
1125
|
const lp = child; // .style;
|
|
1097
1126
|
childTop += lp.effectiveMarginTop;
|
|
1098
1127
|
childBottom -= lp.effectiveMarginBottom;
|
|
1099
|
-
|
|
1128
|
+
if (this.effectiveRowGap > 0 && this._hasPrecedingViews(currentViewIndex, j)) {
|
|
1129
|
+
childTop += this.effectiveRowGap;
|
|
1130
|
+
childBottom -= this.effectiveRowGap;
|
|
1131
|
+
}
|
|
1100
1132
|
if (isRtl) {
|
|
1101
1133
|
if (fromBottomToTop) {
|
|
1102
1134
|
this._layoutSingleChildVertical(child, flexLine, true, this.alignItems, childRight - child.getMeasuredWidth(), Math.round(childBottom) - child.getMeasuredHeight(), childRight, Math.round(childBottom));
|
|
@@ -1124,7 +1156,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1124
1156
|
}
|
|
1125
1157
|
childLeft += flexLine.crossSize;
|
|
1126
1158
|
childRight -= flexLine.crossSize;
|
|
1127
|
-
}
|
|
1159
|
+
}
|
|
1128
1160
|
}
|
|
1129
1161
|
_layoutSingleChildVertical(view, flexLine, isRtl, alignItems, left, top, right, bottom) {
|
|
1130
1162
|
const lp = view; // .style;
|
|
@@ -1166,7 +1198,26 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1166
1198
|
}
|
|
1167
1199
|
}
|
|
1168
1200
|
}
|
|
1169
|
-
|
|
1201
|
+
_hasPrecedingViews(childAbsoluteIndex, childRelativeIndexInFlexLine) {
|
|
1202
|
+
for (let i = 1; i <= childRelativeIndexInFlexLine; i++) {
|
|
1203
|
+
const view = this._getReorderedChildAt(childAbsoluteIndex - i);
|
|
1204
|
+
if (view != null && !view.isCollapsed) {
|
|
1205
|
+
return true;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return false;
|
|
1209
|
+
}
|
|
1210
|
+
_hasPrecedingFlexLines(flexLineIndex) {
|
|
1211
|
+
if (flexLineIndex < 0 || flexLineIndex >= this._flexLines.length) {
|
|
1212
|
+
return false;
|
|
1213
|
+
}
|
|
1214
|
+
for (let i = 0; i < flexLineIndex; i++) {
|
|
1215
|
+
if (this._flexLines[i].layoutVisibleItemCount > 0) {
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1170
1221
|
// requestLayout on set flexDirection, set flexWrap, set justifyContent, set alignItems, set alignContent
|
|
1171
1222
|
// NOTE Consider moving to View if frequently used
|
|
1172
1223
|
static getChildMeasureSpec(spec, padding, childDimension) {
|