Skip to content

Commit 91d539d

Browse files
author
Hristo Hristov
committed
Merge pull request NativeScript#668 from NativeScript/hhristov/layout-in-modal-pages
Fix iOS layout in modal pages.
2 parents 208c21f + 73cf106 commit 91d539d

File tree

11 files changed

+127
-8
lines changed

11 files changed

+127
-8
lines changed

CrossPlatformModules.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,31 @@
150150
<TypeScriptCompile Include="apps\animations\model.ts" />
151151
<TypeScriptCompile Include="apps\orientation-demo\main-page.ts" />
152152
<TypeScriptCompile Include="apps\tests\navigation-tests.ts" />
153+
<TypeScriptCompile Include="apps\tests\ui\page\page21.ts">
154+
<DependentUpon>page21.xml</DependentUpon>
155+
</TypeScriptCompile>
156+
<TypeScriptCompile Include="apps\tests\pages\page20.ts">
157+
<DependentUpon>page20.xml</DependentUpon>
158+
</TypeScriptCompile>
159+
<TypeScriptCompile Include="apps\tests\pages\page19.ts">
160+
<DependentUpon>page19.xml</DependentUpon>
161+
</TypeScriptCompile>
153162
<TypeScriptCompile Include="apps\tests\ui\animation\animation-tests.ts" />
154163
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.android.ts" />
155164
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.d.ts" />
156165
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests-native.ios.ts" />
157166
<TypeScriptCompile Include="apps\tests\ui\repeaterItems-bindingToGestures.ts" />
158167
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-base-page.ts" />
159168
<TypeScriptCompile Include="apps\tests\xml-declaration\inherited-page.ts" />
169+
<Content Include="apps\tests\ui\page\page21.xml">
170+
<SubType>Designer</SubType>
171+
</Content>
172+
<Content Include="apps\tests\pages\page20.xml">
173+
<SubType>Designer</SubType>
174+
</Content>
175+
<Content Include="apps\tests\pages\page19.xml">
176+
<SubType>Designer</SubType>
177+
</Content>
160178
<Content Include="apps\ui-tests-app\app.css" />
161179
<TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" />
162180
<TypeScriptCompile Include="apps\ui-tests-app\pages\htmlview.ts" />
@@ -1964,6 +1982,7 @@
19641982
</FlavorProperties>
19651983
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
19661984
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
1985+
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
19671986
</VisualStudio>
19681987
</ProjectExtensions>
19691988
</Project>

CrossPlatformModules.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22310.1
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30501.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossPlatformModules", "CrossPlatformModules.csproj", "{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}"
77
EndProject

apps/tests/TKUnit.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ export function assert(test: any, message?: string) {
156156
}
157157
};
158158

159+
export function assertTrue(test: boolean, message?: string) {
160+
if (test !== true) {
161+
throw new Error(message);
162+
}
163+
};
164+
159165
export function assertNotEqual(actual: any, expected: any, message?: string) {
160166

161167
var equals = false;

apps/tests/pages/page19.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import observable = require("data/observable");
2+
import trace = require("trace");
3+
trace.addCategories(trace.categories.Layout);
4+
trace.enable();
5+
6+
export function onLoaded(args: observable.EventData) {
7+
(<any>args.object).bindingContext = [0, 1];
8+
}

apps/tests/pages/page19.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Page loaded="onLoaded">
2+
<ListView items="{{ $value }}" verticalAlignment="top" />
3+
</Page>

apps/tests/pages/page20.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import observable = require("data/observable");
2+
import trace = require("trace");
3+
import {Button} from "ui/button";
4+
import {Page} from "ui/page";
5+
trace.addCategories(trace.categories.Layout);
6+
trace.enable();
7+
8+
export function onTap(args: observable.EventData) {
9+
var btn = <Button>args.object;
10+
(<Page>btn.page).showModal("tests/pages/page21", null, null);
11+
}

apps/tests/pages/page20.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Page id="page" loaded="onLoaded">
2+
<StackLayout>
3+
<Button tap="onTap" text="Show Modal Page"/>
4+
</StackLayout>
5+
</Page>

apps/tests/ui/page/page-tests-common.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,41 @@ export function test_page_backgroundColor_is_white() {
366366
var page = <PageModule.Page>views[0];
367367
TKUnit.assertEqual(page.style.backgroundColor.hex.toLowerCase(), "#ffffff", "page background-color");
368368
});
369-
}
369+
}
370+
371+
//export function test_ModalPage_Layout_is_Correct() {
372+
// var testPage: PageModule.Page;
373+
// var label: LabelModule.Label;
374+
// var pageFactory = function () {
375+
// testPage = new PageModule.Page();
376+
// label = new LabelModule.Label();
377+
// label.text = "Will Show modal page";
378+
// testPage.content = label;
379+
// return testPage;
380+
// };
381+
382+
// helper.navigate(pageFactory);
383+
// var basePath = "ui/page/";
384+
// testPage.showModal(basePath + "page21", testPage, () => { }, false);
385+
386+
// // TODO: Remove this once navigate and showModal returns Promise<Page>.
387+
// TKUnit.wait(0.350);
388+
// var childPage = (<any>testPage).childPage;
389+
// var closeCallback: Function = (<any>testPage).close;
390+
391+
// try {
392+
// var layout = <stackLayoutModule.StackLayout>childPage.content;
393+
// var repeater = layout.getChildAt(1);
394+
// TKUnit.assertTrue(repeater.isLayoutValid, "layout should be valid.");
395+
// var bounds = repeater._getCurrentLayoutBounds();
396+
// var height = bounds.bottom - bounds.top;
397+
// TKUnit.assertTrue(height > 0, "Layout should be >0.");
398+
399+
// closeCallback();
400+
// TKUnit.wait(0.150);
401+
// }
402+
// finally {
403+
// helper.goBack
404+
// helper.goBack();
405+
// }
406+
//}

apps/tests/ui/page/page21.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {ShownModallyData} from "ui/page";
2+
3+
export function onShownModally(args: ShownModallyData) {
4+
args.context.childPage = args.object;
5+
args.context.close = args.closeCallback;
6+
7+
setTimeout(() => {
8+
(<any>args.object).bindingContext = [0, 1];
9+
}, 200);
10+
}

apps/tests/ui/page/page21.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Page shownModally="onShownModally">
2+
<StackLayout>
3+
<Label text="In Modal Page" />
4+
<Repeater items="{{ $value }}" verticalAlignment="top" />
5+
</StackLayout>
6+
</Page>

0 commit comments

Comments
 (0)