@nativescript/core 9.1.0-alpha.9 → 9.1.0-next.1
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-common.d.ts +0 -1
- package/application/application-common.js +5 -40
- package/application/application-common.js.map +1 -1
- package/application/application.android.d.ts +1 -1
- package/application/application.android.js +4 -8
- package/application/application.android.js.map +1 -1
- package/application/application.ios.d.ts +16 -1
- package/application/application.ios.js +86 -12
- package/application/application.ios.js.map +1 -1
- package/config/config.interface.d.ts +6 -0
- 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 +31 -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/platforms/ios/src/NativeScriptMainWindow.swift +72 -39
- 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/builder/index.js +9 -1
- package/ui/builder/index.js.map +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 +26 -6
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.d.ts +33 -1
- package/ui/core/view/index.ios.js +11 -2
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/view-common.d.ts +18 -0
- package/ui/core/view/view-common.js +47 -0
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/index.ios.d.ts +6 -20
- package/ui/core/view/view-helper/index.ios.js +10 -31
- package/ui/core/view/view-helper/index.ios.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 +13 -8
- package/ui/core/view-base/index.js +48 -33
- package/ui/core/view-base/index.js.map +1 -1
- package/ui/frame/frame-common.js +2 -12
- package/ui/frame/frame-common.js.map +1 -1
- package/ui/frame/frame-helper-for-android.js +12 -3
- package/ui/frame/frame-helper-for-android.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 +4 -5
- package/ui/layouts/absolute-layout/index.ios.js.map +1 -1
- package/ui/layouts/dock-layout/index.ios.js +4 -5
- 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 +245 -198
- package/ui/layouts/flexbox-layout/index.ios.js.map +1 -1
- package/ui/layouts/grid-layout/index.ios.js +4 -5
- package/ui/layouts/grid-layout/index.ios.js.map +1 -1
- package/ui/layouts/layout-base-common.d.ts +1 -0
- package/ui/layouts/layout-base-common.js +21 -0
- package/ui/layouts/layout-base-common.js.map +1 -1
- package/ui/layouts/stack-layout/index.ios.js +4 -5
- package/ui/layouts/stack-layout/index.ios.js.map +1 -1
- package/ui/layouts/wrap-layout/index.ios.js +4 -5
- package/ui/layouts/wrap-layout/index.ios.js.map +1 -1
- package/ui/list-view/index.android.js +3 -2
- package/ui/list-view/index.android.js.map +1 -1
- package/ui/list-view/index.ios.d.ts +2 -2
- package/ui/list-view/index.ios.js +15 -17
- package/ui/list-view/index.ios.js.map +1 -1
- package/ui/list-view/list-view-common.d.ts +1 -0
- package/ui/list-view/list-view-common.js +15 -0
- package/ui/list-view/list-view-common.js.map +1 -1
- package/ui/page/index.android.d.ts +1 -0
- package/ui/page/index.android.js +4 -0
- package/ui/page/index.android.js.map +1 -1
- package/ui/page/index.ios.d.ts +2 -1
- package/ui/page/index.ios.js +8 -5
- package/ui/page/index.ios.js.map +1 -1
- package/ui/scroll-view/index.d.ts +3 -5
- package/ui/scroll-view/index.ios.d.ts +3 -1
- package/ui/scroll-view/index.ios.js +26 -20
- package/ui/scroll-view/index.ios.js.map +1 -1
- package/ui/scroll-view/scroll-view-common.js +1 -1
- package/ui/scroll-view/scroll-view-common.js.map +1 -1
- package/ui/styling/css-selector.d.ts +20 -5
- package/ui/styling/css-selector.js +134 -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 +9 -1
- package/ui/styling/style-scope.js +40 -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/ui/transition/shared-transition.d.ts +1 -0
- package/ui/transition/shared-transition.js +13 -8
- package/ui/transition/shared-transition.js.map +1 -1
- package/utils/layout-helper/index.ios.js +11 -3
- package/utils/layout-helper/index.ios.js.map +1 -1
|
@@ -1,33 +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
|
-
import { IOSHelper } from '../../core/view/view-helper';
|
|
4
3
|
import { layout } from '../../../utils';
|
|
4
|
+
import { CoreTypes } from '../../../core-types';
|
|
5
5
|
export * from './flexbox-layout-common';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
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;
|
|
17
16
|
View.prototype[orderProperty.setNative] = requestFlexboxLayout;
|
|
18
17
|
View.prototype[flexGrowProperty.setNative] = requestFlexboxLayout;
|
|
19
18
|
View.prototype[flexShrinkProperty.setNative] = requestFlexboxLayout;
|
|
20
19
|
View.prototype[flexWrapBeforeProperty.setNative] = requestFlexboxLayout;
|
|
21
20
|
View.prototype[alignSelfProperty.setNative] = requestFlexboxLayout;
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var getMeasureSpecMode = layout.getMeasureSpecMode;
|
|
29
|
-
var getMeasureSpecSize = layout.getMeasureSpecSize;
|
|
30
|
-
import { CoreTypes } from '../../enums';
|
|
21
|
+
function requestFlexboxLayout(_value) {
|
|
22
|
+
const flexbox = this.parent;
|
|
23
|
+
if (flexbox instanceof FlexboxLayoutBase) {
|
|
24
|
+
flexbox.requestLayout();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
31
27
|
// `eachLayoutChild` iterates over children, and we need more - indexed access.
|
|
32
28
|
// This class tries to accomodate that by collecting all children in an
|
|
33
29
|
// array no more than once per measure.
|
|
@@ -53,7 +49,7 @@ class FlexLine {
|
|
|
53
49
|
this._right = Number.MAX_VALUE;
|
|
54
50
|
this._bottom = Number.MAX_VALUE;
|
|
55
51
|
this._mainSize = 0;
|
|
56
|
-
this.
|
|
52
|
+
this._gapLengthInMainSize = 0;
|
|
57
53
|
this._crossSize = 0;
|
|
58
54
|
this._itemCount = 0;
|
|
59
55
|
this._goneItemCount = 0;
|
|
@@ -103,7 +99,6 @@ class Order {
|
|
|
103
99
|
}
|
|
104
100
|
export class FlexboxLayout extends FlexboxLayoutBase {
|
|
105
101
|
constructor() {
|
|
106
|
-
// Omit divider
|
|
107
102
|
super(...arguments);
|
|
108
103
|
this._flexLines = [];
|
|
109
104
|
}
|
|
@@ -146,17 +141,20 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
146
141
|
const orders = this._createOrders(childCount);
|
|
147
142
|
return this._sortOrdersIntoReorderedIndices(childCount, orders);
|
|
148
143
|
}
|
|
149
|
-
_sortOrdersIntoReorderedIndices(
|
|
144
|
+
_sortOrdersIntoReorderedIndices(_childCount, orders) {
|
|
150
145
|
orders.sort((a, b) => a.compareTo(b));
|
|
151
146
|
if (!this._orderCache) {
|
|
152
147
|
this._orderCache = [];
|
|
153
148
|
}
|
|
154
|
-
|
|
149
|
+
else {
|
|
150
|
+
this._orderCache.length = 0;
|
|
151
|
+
}
|
|
155
152
|
const reorderedIndices = [];
|
|
156
|
-
|
|
153
|
+
for (let i = 0, length = orders.length; i < length; i++) {
|
|
154
|
+
const order = orders[i];
|
|
157
155
|
reorderedIndices[i] = order.index;
|
|
158
|
-
this._orderCache[
|
|
159
|
-
}
|
|
156
|
+
this._orderCache[order.index] = order.order;
|
|
157
|
+
}
|
|
160
158
|
return reorderedIndices;
|
|
161
159
|
}
|
|
162
160
|
_createOrders(childCount) {
|
|
@@ -196,91 +194,93 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
196
194
|
const heightMode = getMeasureSpecMode(heightMeasureSpec);
|
|
197
195
|
let childState = 0;
|
|
198
196
|
this._flexLines.length = 0;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (child === null) {
|
|
210
|
-
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
else if (child.isCollapsed) {
|
|
214
|
-
flexLine._itemCount++;
|
|
215
|
-
flexLine._goneItemCount++;
|
|
216
|
-
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
child._updateEffectiveLayoutValues(widthSize, widthMode, heightSize, heightMode);
|
|
220
|
-
const lp = child; // child.style;
|
|
221
|
-
if (FlexboxLayout.getAlignSelf(child) === 'stretch') {
|
|
222
|
-
flexLine._indicesAlignSelfStretch.push(i);
|
|
223
|
-
}
|
|
224
|
-
let childWidth = lp.effectiveWidth;
|
|
225
|
-
if (FlexBasisPercent.DEFAULT /*lp.flexBasisPercent*/ !== FlexBasisPercent.DEFAULT && widthMode === EXACTLY) {
|
|
226
|
-
childWidth = Math.round(widthSize * FlexBasisPercent.DEFAULT /*lp.flexBasisPercent*/);
|
|
227
|
-
}
|
|
228
|
-
const childWidthMeasureSpec = FlexboxLayout.getChildMeasureSpec(widthMeasureSpec, lp.effectivePaddingLeft + lp.effectivePaddingRight + lp.effectiveMarginLeft + lp.effectiveMarginRight, childWidth < 0 ? WRAP_CONTENT : childWidth);
|
|
229
|
-
const childHeightMeasureSpec = FlexboxLayout.getChildMeasureSpec(heightMeasureSpec, lp.effectivePaddingTop + lp.effectivePaddingBottom + lp.effectiveMarginTop + lp.effectiveMarginBottom, lp.effectiveHeight < 0 ? WRAP_CONTENT : lp.effectiveHeight);
|
|
230
|
-
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
|
231
|
-
this._checkSizeConstraints(child);
|
|
232
|
-
childState = View.combineMeasuredStates(childState, child.getMeasuredState());
|
|
233
|
-
largestHeightInRow = Math.max(largestHeightInRow, child.getMeasuredHeight() + lp.effectiveMarginTop + lp.effectiveMarginBottom);
|
|
234
|
-
if (this._isWrapRequired(child, widthMode, widthSize, flexLine._mainSize, child.getMeasuredWidth() + lp.effectiveMarginLeft + lp.effectiveMarginRight, i, indexInFlexLine)) {
|
|
235
|
-
if (flexLine.layoutVisibleItemCount > 0) {
|
|
236
|
-
this._addFlexLine(flexLine);
|
|
237
|
-
}
|
|
238
|
-
flexLine = new FlexLine();
|
|
239
|
-
flexLine._itemCount = 1;
|
|
240
|
-
flexLine._mainSize = paddingStart + paddingEnd;
|
|
241
|
-
largestHeightInRow = child.getMeasuredHeight() + lp.effectiveMarginTop + lp.effectiveMarginBottom;
|
|
242
|
-
indexInFlexLine = 0;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
flexLine._itemCount++;
|
|
246
|
-
indexInFlexLine++;
|
|
247
|
-
}
|
|
248
|
-
flexLine._mainSize += child.getMeasuredWidth() + lp.effectiveMarginLeft + lp.effectiveMarginRight;
|
|
249
|
-
flexLine._totalFlexGrow += FlexboxLayout.getFlexGrow(child);
|
|
250
|
-
flexLine._totalFlexShrink += FlexboxLayout.getFlexShrink(child);
|
|
251
|
-
flexLine._crossSize = Math.max(flexLine._crossSize, largestHeightInRow);
|
|
252
|
-
// Omit divider
|
|
253
|
-
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
|
254
|
-
flexLine._maxBaseline = Math.max(flexLine._maxBaseline, FlexboxLayout.getBaseline(child) + lp.effectiveMarginTop);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
flexLine._maxBaseline = Math.max(flexLine._maxBaseline, child.getMeasuredHeight() - FlexboxLayout.getBaseline(child) + lp.effectiveMarginBottom);
|
|
258
|
-
}
|
|
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) {
|
|
259
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);
|
|
260
259
|
}
|
|
261
|
-
|
|
260
|
+
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
261
|
+
}
|
|
262
262
|
this._determineMainSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec);
|
|
263
263
|
if (this.alignItems === AlignItems.BASELINE) {
|
|
264
264
|
let viewIndex = 0;
|
|
265
|
-
this._flexLines
|
|
265
|
+
for (const fl of this._flexLines) {
|
|
266
266
|
let largestHeightInLine = Number.MIN_VALUE;
|
|
267
|
-
for (let i = viewIndex; i < viewIndex +
|
|
267
|
+
for (let i = viewIndex; i < viewIndex + fl._itemCount; i++) {
|
|
268
268
|
const child = this._getReorderedChildAt(i);
|
|
269
269
|
const lp = child; // .style;
|
|
270
270
|
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
|
271
|
-
let marginTop =
|
|
271
|
+
let marginTop = fl._maxBaseline - FlexboxLayout.getBaseline(child);
|
|
272
272
|
marginTop = Math.max(marginTop, lp.effectiveMarginTop);
|
|
273
273
|
largestHeightInLine = Math.max(largestHeightInLine, child.getMeasuredHeight() + marginTop + lp.effectiveMarginBottom);
|
|
274
274
|
}
|
|
275
275
|
else {
|
|
276
|
-
let marginBottom =
|
|
276
|
+
let marginBottom = fl._maxBaseline - child.getMeasuredHeight() + FlexboxLayout.getBaseline(child);
|
|
277
277
|
marginBottom = Math.max(marginBottom, lp.effectiveMarginBottom);
|
|
278
278
|
largestHeightInLine = Math.max(largestHeightInLine, child.getMeasuredHeight() + lp.effectiveMarginTop + marginBottom);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
viewIndex +=
|
|
283
|
-
}
|
|
281
|
+
fl._crossSize = largestHeightInLine;
|
|
282
|
+
viewIndex += fl.itemCount;
|
|
283
|
+
}
|
|
284
284
|
}
|
|
285
285
|
this._determineCrossSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec, this.effectivePaddingTop + this.effectivePaddingBottom);
|
|
286
286
|
this._stretchViews(this.flexDirection, this.alignItems);
|
|
@@ -346,7 +346,9 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
346
346
|
flexLine._totalFlexGrow += FlexboxLayout.getFlexGrow(child);
|
|
347
347
|
flexLine._totalFlexShrink += FlexboxLayout.getFlexShrink(child);
|
|
348
348
|
flexLine._crossSize = Math.max(flexLine._crossSize, largestWidthInColumn);
|
|
349
|
-
|
|
349
|
+
if (this.effectiveRowGap > 0 && this._hasPrecedingViews(i, indexInFlexLine)) {
|
|
350
|
+
flexLine._mainSize += this.effectiveRowGap;
|
|
351
|
+
}
|
|
350
352
|
this._addFlexLineIfLastFlexItem(i, childCount, flexLine);
|
|
351
353
|
}
|
|
352
354
|
this._determineMainSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec);
|
|
@@ -364,9 +366,9 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
364
366
|
needsMeasure = true;
|
|
365
367
|
childWidth = minWidth;
|
|
366
368
|
}
|
|
367
|
-
else if (view.getMeasuredWidth() >
|
|
369
|
+
else if (view.getMeasuredWidth() > view.effectiveMaxWidth) {
|
|
368
370
|
needsMeasure = true;
|
|
369
|
-
childWidth =
|
|
371
|
+
childWidth = view.effectiveMaxWidth;
|
|
370
372
|
}
|
|
371
373
|
const minHeight = view.effectiveMinHeight;
|
|
372
374
|
view.effectiveMinHeight = 0;
|
|
@@ -374,9 +376,9 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
374
376
|
needsMeasure = true;
|
|
375
377
|
childHeight = minHeight;
|
|
376
378
|
}
|
|
377
|
-
else if (childHeight >
|
|
379
|
+
else if (childHeight > view.effectiveMaxHeight) {
|
|
378
380
|
needsMeasure = true;
|
|
379
|
-
childHeight =
|
|
381
|
+
childHeight = view.effectiveMaxHeight;
|
|
380
382
|
}
|
|
381
383
|
if (needsMeasure) {
|
|
382
384
|
view.measure(makeMeasureSpec(childWidth, EXACTLY), makeMeasureSpec(childHeight, EXACTLY));
|
|
@@ -390,7 +392,6 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
390
392
|
}
|
|
391
393
|
}
|
|
392
394
|
_addFlexLine(flexLine) {
|
|
393
|
-
// Omit divider
|
|
394
395
|
this._flexLines.push(flexLine);
|
|
395
396
|
}
|
|
396
397
|
_determineMainSize(flexDirection, widthMeasureSpec, heightMeasureSpec) {
|
|
@@ -427,14 +428,14 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
427
428
|
throw new Error('Invalid flex direction: ' + flexDirection);
|
|
428
429
|
}
|
|
429
430
|
let childIndex = 0;
|
|
430
|
-
this._flexLines
|
|
431
|
+
for (const flexLine of this._flexLines) {
|
|
431
432
|
if (flexLine.mainSize < mainSize) {
|
|
432
433
|
childIndex = this._expandFlexItems(flexLine, flexDirection, mainSize, paddingAlongMainAxis, childIndex);
|
|
433
434
|
}
|
|
434
435
|
else {
|
|
435
436
|
childIndex = this._shrinkFlexItems(flexLine, flexDirection, mainSize, paddingAlongMainAxis, childIndex);
|
|
436
437
|
}
|
|
437
|
-
}
|
|
438
|
+
}
|
|
438
439
|
}
|
|
439
440
|
_expandFlexItems(flexLine, flexDirection, maxMainSize, paddingAlongMainAxis, startIndex) {
|
|
440
441
|
let childIndex = startIndex;
|
|
@@ -446,7 +447,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
446
447
|
let needsReexpand = false;
|
|
447
448
|
const pendingSpace = maxMainSize - flexLine._mainSize;
|
|
448
449
|
const unitSpace = pendingSpace / flexLine._totalFlexGrow;
|
|
449
|
-
flexLine._mainSize = paddingAlongMainAxis + flexLine.
|
|
450
|
+
flexLine._mainSize = paddingAlongMainAxis + flexLine._gapLengthInMainSize;
|
|
450
451
|
let accumulatedRoundError = 0;
|
|
451
452
|
for (let i = 0; i < flexLine.itemCount; i++) {
|
|
452
453
|
const child = this._getReorderedChildAt(childIndex);
|
|
@@ -463,10 +464,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
463
464
|
const flexGrow = FlexboxLayout.getFlexGrow(child);
|
|
464
465
|
const rawCalculatedWidth = child.getMeasuredWidth() + unitSpace * flexGrow + accumulatedRoundError;
|
|
465
466
|
let roundedCalculatedWidth = Math.round(rawCalculatedWidth);
|
|
466
|
-
//
|
|
467
|
-
if (roundedCalculatedWidth >
|
|
467
|
+
// Freeze the child once flex-grow would push it past its max-width (Infinity when unconstrained).
|
|
468
|
+
if (roundedCalculatedWidth > child.effectiveMaxWidth) {
|
|
468
469
|
needsReexpand = true;
|
|
469
|
-
roundedCalculatedWidth =
|
|
470
|
+
roundedCalculatedWidth = child.effectiveMaxWidth;
|
|
470
471
|
this._childrenFrozen[childIndex] = true;
|
|
471
472
|
flexLine._totalFlexGrow -= flexGrow;
|
|
472
473
|
}
|
|
@@ -482,10 +483,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
482
483
|
const flexGrow = FlexboxLayout.getFlexGrow(child);
|
|
483
484
|
const rawCalculatedHeight = child.getMeasuredHeight() + unitSpace * flexGrow + accumulatedRoundError;
|
|
484
485
|
let roundedCalculatedHeight = Math.round(rawCalculatedHeight);
|
|
485
|
-
//
|
|
486
|
-
if (roundedCalculatedHeight >
|
|
486
|
+
// Freeze the child once flex-grow would push it past its max-height (Infinity when unconstrained).
|
|
487
|
+
if (roundedCalculatedHeight > child.effectiveMaxHeight) {
|
|
487
488
|
needsReexpand = true;
|
|
488
|
-
roundedCalculatedHeight =
|
|
489
|
+
roundedCalculatedHeight = child.effectiveMaxHeight;
|
|
489
490
|
this._childrenFrozen[childIndex] = true;
|
|
490
491
|
flexLine._totalFlexGrow -= flexGrow;
|
|
491
492
|
}
|
|
@@ -513,7 +514,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
513
514
|
let needsReshrink = false;
|
|
514
515
|
const unitShrink = (flexLine._mainSize - maxMainSize) / flexLine._totalFlexShrink;
|
|
515
516
|
let accumulatedRoundError = 0;
|
|
516
|
-
flexLine._mainSize = paddingAlongMainAxis + flexLine.
|
|
517
|
+
flexLine._mainSize = paddingAlongMainAxis + flexLine._gapLengthInMainSize;
|
|
517
518
|
for (let i = 0; i < flexLine.itemCount; i++) {
|
|
518
519
|
const child = this._getReorderedChildAt(childIndex);
|
|
519
520
|
if (child === null) {
|
|
@@ -606,81 +607,78 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
606
607
|
}
|
|
607
608
|
else if (this._flexLines.length >= 2 && totalCrossSize < size) {
|
|
608
609
|
switch (this.alignContent) {
|
|
609
|
-
case AlignContent.STRETCH:
|
|
610
|
-
(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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);
|
|
618
662
|
accumulatedError = 0;
|
|
619
663
|
}
|
|
620
|
-
|
|
621
|
-
|
|
664
|
+
else {
|
|
665
|
+
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine);
|
|
666
|
+
}
|
|
667
|
+
accumulatedError += spaceBetweenFlexLine - dummySpaceFlexLine._crossSize;
|
|
622
668
|
if (accumulatedError > 1) {
|
|
623
|
-
|
|
669
|
+
dummySpaceFlexLine._crossSize += 1;
|
|
624
670
|
accumulatedError -= 1;
|
|
625
671
|
}
|
|
626
672
|
else if (accumulatedError < -1) {
|
|
627
|
-
|
|
673
|
+
dummySpaceFlexLine._crossSize -= 1;
|
|
628
674
|
accumulatedError += 1;
|
|
629
675
|
}
|
|
630
|
-
flexLine._crossSize = newCrossSize;
|
|
631
|
-
}
|
|
632
|
-
})();
|
|
633
|
-
break;
|
|
634
|
-
case AlignContent.SPACE_AROUND:
|
|
635
|
-
(() => {
|
|
636
|
-
let spaceTopAndBottom = size - totalCrossSize;
|
|
637
|
-
const numberOfSpaces = this._flexLines.length * 2;
|
|
638
|
-
spaceTopAndBottom = spaceTopAndBottom / numberOfSpaces;
|
|
639
|
-
const newFlexLines = [];
|
|
640
|
-
const dummySpaceFlexLine = new FlexLine();
|
|
641
|
-
dummySpaceFlexLine._crossSize = spaceTopAndBottom;
|
|
642
|
-
this._flexLines.forEach((flexLine) => {
|
|
643
676
|
newFlexLines.push(dummySpaceFlexLine);
|
|
644
|
-
newFlexLines.push(flexLine);
|
|
645
|
-
newFlexLines.push(dummySpaceFlexLine);
|
|
646
|
-
});
|
|
647
|
-
this._flexLines = newFlexLines;
|
|
648
|
-
})();
|
|
649
|
-
break;
|
|
650
|
-
case AlignContent.SPACE_BETWEEN:
|
|
651
|
-
(() => {
|
|
652
|
-
let spaceBetweenFlexLine = size - totalCrossSize;
|
|
653
|
-
const numberOfSpaces = this._flexLines.length - 1;
|
|
654
|
-
spaceBetweenFlexLine = spaceBetweenFlexLine / numberOfSpaces;
|
|
655
|
-
let accumulatedError = 0;
|
|
656
|
-
const newFlexLines = [];
|
|
657
|
-
for (let i = 0, flexLineSize = this._flexLines.length; i < flexLineSize; i++) {
|
|
658
|
-
const flexLine = this._flexLines[i];
|
|
659
|
-
newFlexLines.push(flexLine);
|
|
660
|
-
if (i !== this._flexLines.length - 1) {
|
|
661
|
-
const dummySpaceFlexLine = new FlexLine();
|
|
662
|
-
if (i === this._flexLines.length - 2) {
|
|
663
|
-
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine + accumulatedError);
|
|
664
|
-
accumulatedError = 0;
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
dummySpaceFlexLine._crossSize = Math.round(spaceBetweenFlexLine);
|
|
668
|
-
}
|
|
669
|
-
accumulatedError += spaceBetweenFlexLine - dummySpaceFlexLine._crossSize;
|
|
670
|
-
if (accumulatedError > 1) {
|
|
671
|
-
dummySpaceFlexLine._crossSize += 1;
|
|
672
|
-
accumulatedError -= 1;
|
|
673
|
-
}
|
|
674
|
-
else if (accumulatedError < -1) {
|
|
675
|
-
dummySpaceFlexLine._crossSize -= 1;
|
|
676
|
-
accumulatedError += 1;
|
|
677
|
-
}
|
|
678
|
-
newFlexLines.push(dummySpaceFlexLine);
|
|
679
|
-
}
|
|
680
677
|
}
|
|
681
|
-
|
|
682
|
-
|
|
678
|
+
}
|
|
679
|
+
this._flexLines = newFlexLines;
|
|
683
680
|
break;
|
|
681
|
+
}
|
|
684
682
|
case AlignContent.CENTER: {
|
|
685
683
|
let spaceAboveAndBottom = size - totalCrossSize;
|
|
686
684
|
spaceAboveAndBottom = spaceAboveAndBottom / 2;
|
|
@@ -714,7 +712,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
714
712
|
_stretchViews(flexDirection, alignItems) {
|
|
715
713
|
if (alignItems === AlignItems.STRETCH) {
|
|
716
714
|
let viewIndex = 0;
|
|
717
|
-
this._flexLines
|
|
715
|
+
for (const flexLine of this._flexLines) {
|
|
718
716
|
for (let i = 0; i < flexLine.itemCount; i++, viewIndex++) {
|
|
719
717
|
const view = this._getReorderedChildAt(viewIndex);
|
|
720
718
|
const alignSelf = FlexboxLayout.getAlignSelf(view);
|
|
@@ -734,11 +732,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
734
732
|
throw new Error('Invalid flex direction: ' + flexDirection);
|
|
735
733
|
}
|
|
736
734
|
}
|
|
737
|
-
}
|
|
735
|
+
}
|
|
738
736
|
}
|
|
739
737
|
else {
|
|
740
|
-
this._flexLines
|
|
741
|
-
flexLine._indicesAlignSelfStretch
|
|
738
|
+
for (const flexLine of this._flexLines) {
|
|
739
|
+
for (const index of flexLine._indicesAlignSelfStretch) {
|
|
742
740
|
const view = this._getReorderedChildAt(index);
|
|
743
741
|
switch (flexDirection) {
|
|
744
742
|
case FlexDirection.ROW:
|
|
@@ -752,8 +750,8 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
752
750
|
default:
|
|
753
751
|
throw new Error('Invalid flex direction: ' + flexDirection);
|
|
754
752
|
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
757
755
|
}
|
|
758
756
|
}
|
|
759
757
|
_stretchViewVertically(view, crossSize) {
|
|
@@ -855,24 +853,40 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
855
853
|
if (mode === UNSPECIFIED) {
|
|
856
854
|
return false;
|
|
857
855
|
}
|
|
858
|
-
|
|
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
|
+
}
|
|
859
866
|
return maxSize < currentLength + childLength;
|
|
860
867
|
}
|
|
861
868
|
_getLargestMainSize() {
|
|
862
869
|
return this._flexLines.reduce((max, flexLine) => Math.max(max, flexLine.mainSize), Number.MIN_VALUE);
|
|
863
870
|
}
|
|
864
871
|
_getSumOfCrossSize() {
|
|
865
|
-
|
|
866
|
-
|
|
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;
|
|
867
884
|
}
|
|
868
885
|
_isMainAxisDirectionHorizontal(flexDirection) {
|
|
869
886
|
return flexDirection === FlexDirection.ROW || flexDirection === FlexDirection.ROW_REVERSE;
|
|
870
887
|
}
|
|
871
888
|
onLayout(left, top, right, bottom) {
|
|
872
|
-
|
|
873
|
-
// adjustment to iOS — otherwise we double-count the nav-bar / large-title
|
|
874
|
-
// inset and clobber the first children. See IOSHelper.hasIOSManagedInsetAncestor.
|
|
875
|
-
const insets = IOSHelper.hasIOSManagedInsetAncestor(this) ? { left: 0, top: 0, right: 0, bottom: 0 } : this.getSafeAreaInsets();
|
|
889
|
+
const insets = this.getSafeAreaInsets();
|
|
876
890
|
let isRtl = this.direction === CoreTypes.LayoutDirection.rtl;
|
|
877
891
|
switch (this.flexDirection) {
|
|
878
892
|
case FlexDirection.ROW:
|
|
@@ -911,8 +925,12 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
911
925
|
let childBottom = height - paddingBottom;
|
|
912
926
|
let childTop = paddingTop;
|
|
913
927
|
let childRight;
|
|
914
|
-
this._flexLines.
|
|
915
|
-
|
|
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
|
+
}
|
|
916
934
|
let spaceBetweenItem = 0.0;
|
|
917
935
|
switch (this.justifyContent) {
|
|
918
936
|
case JustifyContent.FLEX_START:
|
|
@@ -960,7 +978,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
960
978
|
const lp = child; // .style;
|
|
961
979
|
childLeft += lp.effectiveMarginLeft;
|
|
962
980
|
childRight -= lp.effectiveMarginRight;
|
|
963
|
-
|
|
981
|
+
if (this.effectiveColumnGap > 0 && this._hasPrecedingViews(currentViewIndex, j)) {
|
|
982
|
+
childLeft += this.effectiveColumnGap;
|
|
983
|
+
childRight -= this.effectiveColumnGap;
|
|
984
|
+
}
|
|
964
985
|
if (this.flexWrap === FlexWrap.WRAP_REVERSE) {
|
|
965
986
|
if (isRtl) {
|
|
966
987
|
this._layoutSingleChildHorizontal(child, flexLine, this.flexWrap, this.alignItems, Math.round(childRight) - child.getMeasuredWidth(), childBottom - child.getMeasuredHeight(), Math.round(childRight), childBottom);
|
|
@@ -988,7 +1009,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
988
1009
|
}
|
|
989
1010
|
childTop += flexLine._crossSize;
|
|
990
1011
|
childBottom -= flexLine._crossSize;
|
|
991
|
-
}
|
|
1012
|
+
}
|
|
992
1013
|
}
|
|
993
1014
|
_layoutSingleChildHorizontal(view, flexLine, flexWrap, alignItems, left, top, right, bottom) {
|
|
994
1015
|
const lp = view; // .style;
|
|
@@ -1051,8 +1072,12 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1051
1072
|
let childRight = width - paddingRight;
|
|
1052
1073
|
let childTop;
|
|
1053
1074
|
let childBottom;
|
|
1054
|
-
this._flexLines.
|
|
1055
|
-
|
|
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
|
+
}
|
|
1056
1081
|
let spaceBetweenItem = 0.0;
|
|
1057
1082
|
switch (this.justifyContent) {
|
|
1058
1083
|
case JustifyContent.FLEX_START:
|
|
@@ -1100,7 +1125,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1100
1125
|
const lp = child; // .style;
|
|
1101
1126
|
childTop += lp.effectiveMarginTop;
|
|
1102
1127
|
childBottom -= lp.effectiveMarginBottom;
|
|
1103
|
-
|
|
1128
|
+
if (this.effectiveRowGap > 0 && this._hasPrecedingViews(currentViewIndex, j)) {
|
|
1129
|
+
childTop += this.effectiveRowGap;
|
|
1130
|
+
childBottom -= this.effectiveRowGap;
|
|
1131
|
+
}
|
|
1104
1132
|
if (isRtl) {
|
|
1105
1133
|
if (fromBottomToTop) {
|
|
1106
1134
|
this._layoutSingleChildVertical(child, flexLine, true, this.alignItems, childRight - child.getMeasuredWidth(), Math.round(childBottom) - child.getMeasuredHeight(), childRight, Math.round(childBottom));
|
|
@@ -1128,7 +1156,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1128
1156
|
}
|
|
1129
1157
|
childLeft += flexLine.crossSize;
|
|
1130
1158
|
childRight -= flexLine.crossSize;
|
|
1131
|
-
}
|
|
1159
|
+
}
|
|
1132
1160
|
}
|
|
1133
1161
|
_layoutSingleChildVertical(view, flexLine, isRtl, alignItems, left, top, right, bottom) {
|
|
1134
1162
|
const lp = view; // .style;
|
|
@@ -1170,7 +1198,26 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|
|
1170
1198
|
}
|
|
1171
1199
|
}
|
|
1172
1200
|
}
|
|
1173
|
-
|
|
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
|
+
}
|
|
1174
1221
|
// requestLayout on set flexDirection, set flexWrap, set justifyContent, set alignItems, set alignContent
|
|
1175
1222
|
// NOTE Consider moving to View if frequently used
|
|
1176
1223
|
static getChildMeasureSpec(spec, padding, childDimension) {
|