Skip to content

Commit af03408

Browse files
Hristo HristovHristo Hristov
authored andcommitted
iOS Frame, Page and TabView measure/layout methods removed. We now rely on the framework positioning. This will result in a change that width, height, minWidth, minHeight, margins not respected on these controls
iOS layout positioning now respects native properties like automaticallyAdjustsScrollViewInsets, edgesForExtendedLayout, extendedLayoutIncludesOpaqueBars, navigationBar.translucent, tabBar.translucent Removed frame-tests.ios.ts - those tests are now invalid Added new layout tests inside page-tests.ios.ts Commented few asserts in scroll-view-tests View now expose ios namespace with layoutView method and UILayoutViewController used by page, tab-view and application module ViewBase now expose viewController property that should be set from all widgets that are using viewcontrollers internally (like Page, Frame, TabView) ViewBase now sets ios property to either the view returned from createNativeView or to nativeViewProptected fragment.transitions now use animation/transition start to add fragments to waitingQueue. Before we did it manually in navigate/goBack. This way we can reuse the fragment.transition when calling showDialog. Also when animation/transition ends we check the animation/transition to see if this fragment should be set as current. Frame expose new loadViewFromEntry method (to load a view from URI) Frame navigation happens once frame is loaded Frame now supports Page as a child in XML Fixed GridLayout row, rowSpan, column, columnSpan properties type Fixed bug in GridLayout where add/remove of columns/rows won't update the internal state of the grid (backport from android when GridLayout is recycled) ListView will no longer invalidate layout when cell is removed Fixed bug in ScrollView ios where effectiveMinWidth/Height was multiplied to density (it is already on device pixels so no need to multiply) TabView android now calls loaded only on the selected child (not all) Core refactoring
1 parent 7bc0daf commit af03408

38 files changed

+930
-919
lines changed

apps/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"appRoot": "${workspaceRoot}",
1010
"sourceMaps": true,
1111
"watch": true,
12+
"stopOnEntry": true,
1213
"tnsArgs": [
1314
"--sync-all-files"
1415
]

apps/app/cuteness.io/app.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
import * as application from "tns-core-modules/application";
2-
import * as fps from "tns-core-modules/fps-meter";
3-
fps.addCallback(function (fps, minFps) {
4-
console.info("fps=" + fps + " minFps=" + minFps);
5-
});
6-
fps.start();
72

83
// Start the application
9-
application.start({ moduleName: "cuteness.io/main-page" });
4+
application.start({ moduleName: "cuteness.io/main-page" });

apps/app/cuteness.io/main-page.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export function pageLoaded(args: ObservableEventData) {
1212
var page = <Page>args.object;
1313

1414
page.bindingContext = appViewModel;
15-
16-
// Enable platform specific feature (in this case Android page caching)
17-
if (topmostFrame().android) {
18-
topmostFrame().android.cachePagesOnNavigate = true;
19-
}
2015
}
2116

2217
export function listViewItemTap(args: ListViewItemEventData) {

tests/app/TKUnit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export function assertEqual<T extends { equals?(arg: T): boolean } | any>(actual
211211
}
212212
}
213213
else if (actual !== expected) {
214-
throw new Error(`${message} Actual: <${actual}>(${typeof (actual)}). Expected: <${expected}>(${typeof (expected)})`);
214+
throw new Error(`${message} Actual: <${actual}>(${typeof (actual)}). Expected: <${expected}>(${typeof (expected)})` );
215215
}
216216
}
217217

@@ -350,7 +350,7 @@ export function wait(seconds: number): void {
350350
waitUntilReady(() => false, seconds, false);
351351
}
352352

353-
export function waitUntilReady(isReady: () => boolean, timeoutSec: number = 300, shouldThrow: boolean = true) {
353+
export function waitUntilReady(isReady: () => boolean, timeoutSec: number = 3, shouldThrow: boolean = true) {
354354
if (!isReady) {
355355
return;
356356
}

tests/app/app/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ application.on(application.lowMemoryEvent, function (args: application.Applicati
8686

8787
application.on(application.uncaughtErrorEvent, function (args: application.UnhandledErrorEventData) {
8888
console.log("NativeScriptError: " + args.error);
89-
console.log((<any>args.error).nativeException);
90-
console.log((<any>args.error).stackTrace);
89+
console.log((<any>args.error).nativeException || (<any>args.error).nativeError);
90+
console.log((<any>args.error).stackTrace || (<any>args.error).stack);
9191
});
9292

9393
// Android activity events

tests/app/testRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ function showReportPage(finalMessage: string) {
346346
page.className = unsetValue;
347347
page.bindingContext = unsetValue;
348348
page.style.color = unsetValue;
349-
page.style.backgroundColor = unsetValue;
349+
page.backgroundColor = "white";
350350
page.content = stack;
351351
messageContainer.focus();
352352
page.style.fontSize = 11;

tests/app/ui/frame/frame-tests.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ export function test_percent_margin_set_to_page_support() {
6161
TKUnit.assertTrue(PercentLength.equals(currentPage.marginTop, 0));
6262
TKUnit.assertTrue(PercentLength.equals(currentPage.marginRight, 0));
6363
TKUnit.assertTrue(PercentLength.equals(currentPage.marginBottom, 0));
64-
}
64+
}
Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +0,0 @@
1-
import * as frameModule from "tns-core-modules/ui/frame";
2-
import * as TKUnit from "../../TKUnit";
3-
import * as uiUtils from "tns-core-modules/ui/utils";
4-
import { PercentLength, unsetValue } from "tns-core-modules/ui/core/view";
5-
6-
export function test_percent_width_and_height_set_to_page_support() {
7-
let topFrame = frameModule.topmost();
8-
let currentPage = topFrame.currentPage;
9-
10-
(<any>currentPage).width = "50%";
11-
(<any>currentPage).height = "50%";
12-
13-
TKUnit.waitUntilReady(() => {
14-
return currentPage.isLayoutValid;
15-
}, 1);
16-
17-
let topFrameWidth = topFrame.getMeasuredWidth();
18-
let topFrameHeight = topFrame.getMeasuredHeight();
19-
20-
let currentPageWidth = currentPage.getMeasuredWidth();
21-
let currentPageHeight = currentPage.getMeasuredHeight();
22-
23-
TKUnit.assertEqual(currentPageWidth, Math.round(topFrameWidth / 2), "Current page measuredWidth incorrect");
24-
TKUnit.assertEqual(currentPageHeight, Math.round(topFrameHeight / 2), "Current page measuredHeight incorrect");
25-
26-
//reset values.
27-
currentPage.height = unsetValue;
28-
currentPage.width = unsetValue;
29-
30-
TKUnit.assertTrue(PercentLength.equals(currentPage.width, "auto"));
31-
TKUnit.assertTrue(PercentLength.equals(currentPage.height, "auto"));
32-
}
33-
34-
export function test_percent_margin_set_to_page_support() {
35-
percent_margin_set_to_page_support(false);
36-
}
37-
38-
export function test_percent_margin_set_to_page_support_with_backgroundSpanUnderStatusBar() {
39-
percent_margin_set_to_page_support(true);
40-
}
41-
42-
function percent_margin_set_to_page_support(backgroundSpanUnderStatusBar: boolean) {
43-
const topFrame = frameModule.topmost();
44-
const currentPage = topFrame.currentPage;
45-
46-
const topFrameWidth = topFrame.getMeasuredWidth();
47-
const topFrameHeight = topFrame.getMeasuredHeight();
48-
const statusBar = backgroundSpanUnderStatusBar ? 0 : uiUtils.ios.getStatusBarHeight();
49-
50-
currentPage.margin = "10%";
51-
currentPage.backgroundSpanUnderStatusBar = backgroundSpanUnderStatusBar;
52-
53-
TKUnit.waitUntilReady(() => {
54-
return currentPage.isLayoutValid;
55-
}, 1);
56-
57-
const currentPageWidth = currentPage.getMeasuredWidth();
58-
const currentPageHeight = currentPage.getMeasuredHeight();
59-
const marginWidth = Math.round(topFrameWidth * 0.1);
60-
const marginHeight = Math.round((topFrameHeight - statusBar) * 0.1);
61-
62-
// expected page size
63-
TKUnit.assertEqual(currentPageWidth, topFrameWidth - 2 * marginWidth, "Page measure width");
64-
TKUnit.assertEqual(currentPageHeight, topFrameHeight - 2 * marginHeight - statusBar, "Page measure height");
65-
66-
// expected page bounds
67-
const bounds = currentPage._getCurrentLayoutBounds();
68-
TKUnit.assertEqual(bounds.left, Math.round(marginWidth), "Current page LEFT position incorrect");
69-
TKUnit.assertEqual(bounds.top, Math.round(marginHeight + statusBar), "Current page TOP position incorrect");
70-
TKUnit.assertEqual(bounds.right, Math.round(marginWidth + currentPageWidth), "Current page RIGHT position incorrect");
71-
TKUnit.assertEqual(bounds.bottom, Math.round(marginHeight + statusBar + currentPageHeight), "Current page BOTTOM position incorrect");
72-
73-
//reset values.
74-
currentPage.margin = "0";
75-
TKUnit.waitUntilReady(() => {
76-
return currentPage.isLayoutValid;
77-
}, 1);
78-
79-
TKUnit.assertTrue(PercentLength.equals(currentPage.marginLeft, 0));
80-
TKUnit.assertTrue(PercentLength.equals(currentPage.marginTop, 0));
81-
TKUnit.assertTrue(PercentLength.equals(currentPage.marginRight, 0));
82-
TKUnit.assertTrue(PercentLength.equals(currentPage.marginBottom, 0));
83-
}

0 commit comments

Comments
 (0)