Skip to content

Commit 7c60735

Browse files
rigor789NathanWalker
authored andcommitted
chore: cleanup background handling
1 parent 21da315 commit 7c60735

File tree

21 files changed

+174
-51
lines changed

21 files changed

+174
-51
lines changed

apps/automated/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

apps/toolbox/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

apps/toolbox/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"url": "https://github.com/NativeScript/NativeScript.git"
88
},
99
"dependencies": {
10-
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core",
11-
"@nativescript/core": "file:../../packages/core"
10+
"@nativescript/core": "file:../../packages/core",
11+
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core"
1212
},
1313
"devDependencies": {
1414
"@nativescript/android": "7.0.1",
1515
"@nativescript/ios": "7.2.0",
1616
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
17-
"typescript": "file:../../node_modules/typescript"
17+
"typescript": "4.0.7"
1818
}
1919
}

apps/toolbox/src/main-page.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<Button text="box-shadow" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
1111
<Button text="root-layout" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
1212
<Button text="a11y" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
13+
<Button text="css-playground" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo"/>
1314
</StackLayout>
1415
</ScrollView>
1516
</StackLayout>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Observable, EventData, Page, Label } from '@nativescript/core';
2+
import { addTaggedAdditionalCSS, removeTaggedAdditionalCSS } from '@nativescript/core/ui/styling/style-scope';
3+
4+
let page: Page;
5+
let playLabel: Label;
6+
let CSSTag = 'css-playground';
7+
8+
export function navigatingTo(args: EventData) {
9+
page = <Page>args.object;
10+
page.bindingContext = new CssPlaygroundModel();
11+
playLabel = page.getViewById('play');
12+
}
13+
14+
export class CssPlaygroundModel extends Observable {
15+
currentCSS = [
16+
`width: 200;`,
17+
`font-size: 20;`,
18+
`background: #65adf1;`,
19+
`color: white;`,
20+
`box-shadow: 5 5;`,
21+
// `text-shadow: 2 2 red;`,
22+
`padding: 16;`,
23+
].join('\n');
24+
25+
onTextChange(args) {
26+
this.currentCSS = args.value;
27+
}
28+
29+
resetCSS() {
30+
console.log('reset css...');
31+
removeTaggedAdditionalCSS(CSSTag);
32+
33+
playLabel._onCssStateChange();
34+
}
35+
36+
applyCSS(args) {
37+
this.resetCSS();
38+
addTaggedAdditionalCSS(`#play { ${this.currentCSS}`, CSSTag);
39+
playLabel._onCssStateChange();
40+
}
41+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2+
<Page.actionBar>
3+
<ActionBar title="CSS Playground" class="action-bar">
4+
</ActionBar>
5+
</Page.actionBar>
6+
7+
<GridLayout rows="*, *">
8+
<ContentView>
9+
<Label id="play" text="I'm a test label." verticalAlignment="center"/>
10+
</ContentView>
11+
12+
<GridLayout row="1" rows="*, auto, auto" borderTopWidth="1">
13+
<TextView text="{{ currentCSS }}" textChange="{{ onTextChange }}"/>
14+
15+
<Button class="btn btn-primary" text="Apply" row="1" tap="{{ applyCSS }}"/>
16+
<Button class="btn btn-primary btn-orange" text="Reset" row="2" tap="{{ resetCSS }}"/>
17+
</GridLayout>
18+
</GridLayout>
19+
</Page>

apps/toolbox/src/pages/root-layout.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { EventData, Page, Observable, RootLayoutOptions, getRootLayout, StackLayout, View } from '@nativescript/core';
2-
import { Enums } from '@nativescript/core';
1+
import { EventData, Page, Observable, RootLayoutOptions, getRootLayout, StackLayout, View, CoreTypes } from '@nativescript/core';
32

43
export function navigatingTo(args: EventData) {
54
const page = <Page>args.object;

apps/ui/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

apps/ui/src/css/text-shadow-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ const possibleValues = [
1212
];
1313
let currentIndex = 0;
1414

15-
export function butonTap(args: EventData) {
15+
export function buttonTap(args: EventData) {
1616
let page = (<TextBase>args.object).page;
1717
let lbl = <TextBase>page.getViewById('Label');
1818
let btn = <TextBase>page.getViewById('Button');
1919
let textField = <TextBase>page.getViewById('TextField');
2020
let textView = <TextBase>page.getViewById('TextView');
2121

2222
let newIndex = currentIndex++ % possibleValues.length;
23-
let newValue = <any>possibleValues[newIndex];
23+
let newValue = possibleValues[newIndex];
2424

2525
lbl.textShadow = newValue;
2626
btn.textShadow = newValue;

apps/ui/src/css/text-shadow-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Page>
22
<StackLayout>
3-
<Button id="Change" automationText="Change" text="Change" tap="butonTap" />
3+
<Button id="Change" automationText="Change" text="Change" tap="buttonTap" />
44
<Label id="Label" automationText="Label" text="Label" />
55
<Button id="Button" automationText="Button" text="Button" />
66
<TextField id="TextField" automationText="TextField" text="TextField" />

0 commit comments

Comments
 (0)