FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(iOS): Safe Area Support (#6230) · NativeScript/NativeScript@982acdc · GitHub

Commit 982acdc

Browse files
authored
feat(iOS): Safe Area Support (#6230)
1 parent 46705ee commit 982acdc

39 files changed

Lines changed: 3243 additions & 917 deletions

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ e2e/**/test-results.xml
3636
# Webpack configuration files
3737
webpack.config.js
3838
tsconfig.esm.json
39+
tsconfig.tns.json
3940

4041
# Generated files
4142
*.map
@@ -65,4 +66,4 @@ TestRunResult.txt
6566

6667
tns-core-modules.base.d.ts
6768
tns-core-modules.d.ts
68-
tns-core-modules.es6.d.ts
69+
tns-core-modules.es6.d.ts

‎apps/app/ui-tests-app/button/background.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Page>
22
<GridLayout rows="240, *">
3-
<GridLayout width="290" id="test-element" automationText="test-element" />
3+
<GridLayout automationText="test-element" id="test-element" width="290" iosOverflowSafeArea="false"></GridLayout>
44
<WrapLayout row="1">
55
<Button width="40" height="40" text="r" tap="resetTap"/>
66

‎apps/app/ui-tests-app/button/issue-4287.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2-
<GridLayout columns="auto * auto" rows="auto *" borderWidth="1" borderColor="black">
2+
<GridLayout columns="auto * auto" rows="auto *" borderWidth="1" borderColor="black" iosOverflowSafeArea="false">
33

44
<StackLayout borderWidth="1" borderColor="black" verticalAlignment="top" width="150">
55
<Label text="textWrap: false" horizontalAlignment="center"/>

‎apps/app/ui-tests-app/css/clip-path.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Page>
2-
<GridLayout columns="*,*" rows="*,*,*,*" automationText="clipPath">
2+
<GridLayout automationText="clipPath" columns="*,*" rows="*,*,*,*" iosOverflowSafeArea="false">
33
<StackLayout col="0" colSpan="2" row="0" width="100" height="100" style.backgroundColor="magenta">
44
<Button text="no clip-path" width="100" height="100" style="background-image: url('~/ui-tests-app/resources/images/inset-test.png'); background-size: 100% 100%; background-repeat: no-repeat;"/>
55
</StackLayout>

‎apps/app/ui-tests-app/css/margins-paddings-with-percentage.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { EventData } from "tns-core-modules/data/observable";
44
import * as button from "tns-core-modules/ui/button";
55

66
const cssPercentage = `
7-
Page { margin: 5% 10% 15% 8%; background-color: orange; font-size: 8; }
7+
Page { background-color: orange; font-size: 8; }
88
GridLayout { margin: 3%; background-color: lightgreen; font-size: 8; }
99
StackLayout { border-color: red; border-width: 1; }
1010
StackLayout * { border-color: blue; border-width: 1; }
@@ -16,7 +16,7 @@ const cssPercentage = `
1616
Button { color: black }`;
1717

1818
const cssWithouPercentage = `
19-
Page { margin:15 10 15 30; background-color: orange; font-size: 8; }
19+
Page { background-color: orange; font-size: 8; }
2020
GridLayout { margin:3; background-color: lightgreen; font-size: 8; }
2121
StackLayout { border-color: red; border-width: 1; }
2222
StackLayout * { border-color: blue; border-width: 1; }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:cC="ui-tests-app/issues/component" id="main-page">
2-
<StackLayout style.borderWidth="1" style.borderColor="black">
2+
<StackLayout style.borderColor="black" style.borderWidth="1" iosOverflowSafeArea="false">
33
<Label class="ui-tests-app-issue-1639-red" text="main-page red from app.css" textWrap="true" />
44
<Label class="local-red" text="main-page red from issue-1639.css" textWrap="true" />
5-
<cC:customView/>
5+
<cC:customView/>
66
</StackLayout>
77
</Page>

‎apps/app/ui-tests-app/issues/issue-3007.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Label id="Label" backgroundColor="red" class="elementStyle" text="sample label" textWrap="true"/>
77
<TextField id="TextField" backgroundColor="green" class="elementStyle" hint="" text="Sample textfield" />
88
<TextView id="TextView" class="elementStyle" text="Sample text view" backgroundColor="yellow" editable="true" />
9-
<AbsoluteLayout id="AbsoluteLayout" class="container"/>
9+
<AbsoluteLayout id="AbsoluteLayout" class="container" iosOverflowSafeArea="false"></AbsoluteLayout>
1010
</StackLayout>
1111
</ScrollView>
1212
</Page>

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"typescript": "^2.6.1"
4747
},
4848
"scripts": {
49-
"setup": "npm run dev-link-tns-platform-declarations && npm run dev-link-tns-core-modules && npm run dev-link-tests && npm run dev-link-apps",
49+
"setup": "npm run dev-link-tns-platform-declarations && npm run dev-link-tns-core-modules && npm run dev-link-tests && npm run dev-link-apps && npm run dev-link-e2e-modal",
5050
"tsc": "node --max_old_space_size=4096 ./node_modules/typescript/bin/tsc",
5151
"ci": "tsc && npm run tslint && npm run ci-apps && npm run ci-e2e && npm run ci-tests",
5252
"ci-apps": "cd apps && npm i ../tns-core-modules ../tns-platform-declarations --save",

‎tests/app/testRunner.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as platform from "tns-core-modules/platform";
1111
import "./ui-test";
1212
import * as fs from "tns-core-modules/file-system";
1313
import { unsetValue } from "tns-core-modules/ui/core/properties";
14-
import { ad } from "tns-core-modules/utils/utils";
14+
import { ad, ios } from "tns-core-modules/utils/utils";
1515

1616
Frame.defaultAnimatedNavigation = false;
1717

@@ -135,6 +135,16 @@ allTests["STACKLAYOUT"] = stackLayoutTests;
135135
import * as flexBoxLayoutTests from "./ui/layouts/flexbox-layout-tests";
136136
allTests["FLEXBOXLAYOUT"] = flexBoxLayoutTests;
137137

138+
import * as safeAreaLayoutTests from "./ui/layouts/safe-area-tests";
139+
import * as safeAreaListViewtTests from "./ui/list-view/list-view-safe-area-tests";
140+
import * as scrollViewSafeAreaTests from "./ui/scroll-view/scroll-view-safe-area-tests";
141+
142+
if (platform.isIOS && ios.MajorVersion > 10) {
143+
allTests["SAFEAREALAYOUT"] = safeAreaLayoutTests;
144+
allTests["SAFEAREA-LISTVIEW"] = safeAreaListViewtTests;
145+
allTests["SAFEAREA-SCROLL-VIEW"] = scrollViewSafeAreaTests;
146+
}
147+
138148
import * as stylePropertiesTests from "./ui/styling/style-properties-tests";
139149
allTests["STYLE-PROPERTIES"] = stylePropertiesTests;
140150

‎tests/app/ui/helper.ts‎

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as frame from "tns-core-modules/ui/frame";
22
import { ViewBase, View, unsetValue, isIOS } from "tns-core-modules/ui/core/view";
33
import { Page } from "tns-core-modules/ui/page";
4+
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
45
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
56
import { Button } from "tns-core-modules/ui/button";
67
import * as TKUnit from "../TKUnit";
@@ -78,13 +79,55 @@ export function do_PageTest_WithStackLayout_AndButton(test: (views: [Page, Stack
7879
newPage.content = null;
7980
}
8081

81-
//export function buildUIAndRunTest(controlToTest, testFunction, pageCss?, testDelay?) {
82-
export function buildUIAndRunTest<T extends View>(controlToTest: T, testFunction: (views: [T, Page]) => void, pageCss?) {
82+
export interface PageOptions {
83+
pageCss?: any,
84+
actionBar?: boolean,
85+
actionBarFlat?: boolean,
86+
actionBarHidden?: boolean,
87+
tabBar?: boolean
88+
}
89+
90+
//export function buildUIAndRunTest(controlToTest, testFunction, options) {
91+
export function buildUIAndRunTest<T extends View>(controlToTest: T, testFunction: (views: [T, Page]) => void, options?: PageOptions) {
8392
clearPage();
8493
let newPage = getCurrentPage();
8594

86-
newPage.css = pageCss;
87-
newPage.content = controlToTest;
95+
let testSubject = controlToTest as View;
96+
97+
if (options) {
98+
if (options.pageCss) {
99+
newPage.css = options.pageCss;
100+
}
101+
102+
newPage.actionBarHidden = true;
103+
newPage.actionBar.flat = false;
104+
105+
if (options.actionBar) {
106+
newPage.actionBarHidden = false;
107+
newPage.actionBar.title = "Test ActionBar";
108+
}
109+
110+
if (options.actionBarFlat) {
111+
newPage.actionBarHidden = false;
112+
newPage.actionBar.title = "Test ActionBar Flat";
113+
newPage.actionBar.flat = true;
114+
}
115+
116+
if (options.actionBarHidden) {
117+
newPage.actionBarHidden = true;
118+
}
119+
120+
if (options.tabBar) {
121+
const tabView = new TabView();
122+
const tabEntry = new TabViewItem();
123+
tabEntry.title = "Test";
124+
tabEntry.view = controlToTest;
125+
tabView.items = [tabEntry];
126+
testSubject = tabView;
127+
}
128+
}
129+
130+
newPage.content = testSubject;
88131

89132
testFunction([controlToTest, newPage]);
90133
newPage.content = null;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL