1 | import * as layoutCommon from './layout-helper-common';
|
2 | export var layout;
|
3 | (function (layout) {
|
4 |
|
5 |
|
6 | layout.MODE_SHIFT = 30;
|
7 | layout.MODE_MASK = 0x3 << layout.MODE_SHIFT;
|
8 | layout.UNSPECIFIED = 0 << layout.MODE_SHIFT;
|
9 | layout.EXACTLY = 1 << layout.MODE_SHIFT;
|
10 | layout.AT_MOST = 2 << layout.MODE_SHIFT;
|
11 | layout.MEASURED_HEIGHT_STATE_SHIFT = 0x00000010;
|
12 | layout.MEASURED_STATE_TOO_SMALL = 0x01000000;
|
13 | layout.MEASURED_STATE_MASK = 0xff000000;
|
14 | layout.MEASURED_SIZE_MASK = 0x00ffffff;
|
15 | function getMode(mode) {
|
16 | return layoutCommon.getMode(mode);
|
17 | }
|
18 | layout.getMode = getMode;
|
19 | function getMeasureSpecMode(spec) {
|
20 | return layoutCommon.getMeasureSpecMode(spec);
|
21 | }
|
22 | layout.getMeasureSpecMode = getMeasureSpecMode;
|
23 | function getMeasureSpecSize(spec) {
|
24 | return layoutCommon.getMeasureSpecSize(spec);
|
25 | }
|
26 | layout.getMeasureSpecSize = getMeasureSpecSize;
|
27 | function makeMeasureSpec(size, mode) {
|
28 | return (Math.round(Math.max(0, size)) & ~layoutCommon.MODE_MASK) | (mode & layoutCommon.MODE_MASK);
|
29 | }
|
30 | layout.makeMeasureSpec = makeMeasureSpec;
|
31 | function getDisplayDensity() {
|
32 | return UIScreen.mainScreen.scale;
|
33 | }
|
34 | layout.getDisplayDensity = getDisplayDensity;
|
35 | function toDevicePixels(value) {
|
36 | return value * UIScreen.mainScreen.scale;
|
37 | }
|
38 | layout.toDevicePixels = toDevicePixels;
|
39 | function toDeviceIndependentPixels(value) {
|
40 | return value / UIScreen.mainScreen.scale;
|
41 | }
|
42 | layout.toDeviceIndependentPixels = toDeviceIndependentPixels;
|
43 | function round(value) {
|
44 | return layoutCommon.round(value);
|
45 | }
|
46 | layout.round = round;
|
47 | function measureNativeView(nativeView /* UIView */, width, widthMode, height, heightMode) {
|
48 | const view = nativeView;
|
49 | const nativeSize = view.sizeThatFits({
|
50 | width: widthMode === 0 ? Number.POSITIVE_INFINITY : toDeviceIndependentPixels(width),
|
51 | height: heightMode === 0 ? Number.POSITIVE_INFINITY : toDeviceIndependentPixels(height),
|
52 | });
|
53 | nativeSize.width = round(toDevicePixels(nativeSize.width));
|
54 | nativeSize.height = round(toDevicePixels(nativeSize.height));
|
55 | return nativeSize;
|
56 | }
|
57 | layout.measureNativeView = measureNativeView;
|
58 | function measureSpecToString(measureSpec) {
|
59 | return layoutCommon.measureSpecToString(measureSpec);
|
60 | }
|
61 | layout.measureSpecToString = measureSpecToString;
|
62 | })(layout || (layout = {}));
|
63 |
|
\ | No newline at end of file |