Skip to content

Commit c26f1c9

Browse files
author
Vasil Chimev
authored
Add line-height test page (NativeScript#4638)
* Add lineHeight property to text-base.d.ts * Add line-height test page
1 parent 0f14101 commit c26f1c9

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { EventData, TextBase } from "tns-core-modules/ui/text-base";
2+
3+
const values = [3, 7, 13];
4+
5+
export function buttonTap(args: EventData) {
6+
let page = (<TextBase>args.object).page;
7+
let lbl = <TextBase>page.getViewById("label");
8+
let btn = <TextBase>page.getViewById("button");
9+
let tv = <TextBase>page.getViewById("textView");
10+
let ft = <TextBase>page.getViewById("formattedText");
11+
12+
let index = values.indexOf(lbl.lineHeight);
13+
let newIndex = (index + 1) % values.length;
14+
let newValue = values[newIndex];
15+
16+
lbl.lineHeight = newValue;
17+
btn.lineHeight = newValue;
18+
tv.lineHeight = newValue;
19+
ft.lineHeight = newValue;
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Page>
2+
<StackLayout>
3+
<Button automationText="Change" text="Change" tap="buttonTap" />
4+
<Label automationText="label" id="label" textWrap="true" style="text-decoration: underline; text-transform: capitalize; letter-spacing: 0.1; line-height: 7;"
5+
text="The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog." />
6+
<Button automationText="button" id="button" ios:textWrap="true" style="text-decoration: underline; text-transform: capitalize; letter-spacing: 0.1; line-height: 7;"
7+
text="The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog." />
8+
<TextView automationText="textView" id="textView" style="text-decoration: underline; text-transform: capitalize; letter-spacing: 0.1; line-height: 7;"
9+
text="The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog." />
10+
<Label automationText="formattedText" id="formattedText" textWrap="true" style="text-decoration: underline; text-transform: capitalize; letter-spacing: 0.1; line-height: 7;">
11+
<Label.formattedText>
12+
<FormattedString>
13+
<FormattedString.spans>
14+
<Span text="The quick brown fox jumps over the lazy dog." style="font-weight: bold; color: green;" />
15+
<Span text="The quick brown fox jumps over the lazy dog." style="font-style: italic; color: blue;" />
16+
</FormattedString.spans>
17+
</FormattedString>
18+
</Label.formattedText>
19+
</Label>
20+
</StackLayout>
21+
</Page>

apps/app/ui-tests-app/css/main-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function loadExamples() {
1414
examples.set("formatted", "css/decoration-transform-formattedtext");
1515
examples.set("radius", "css/radius");
1616
examples.set("spacing", "css/letter-spacing");
17+
examples.set("line-height", "css/line-height");
1718
examples.set("decoration", "css/text-decoration");
1819
examples.set("transform", "css/text-transform");
1920
examples.set("whitespace", "css/white-space");
@@ -39,6 +40,5 @@ export function loadExamples() {
3940
examples.set("styled-formatted-text", "css/styled-formatted-text");
4041
examples.set("non-uniform-radius", "css/non-uniform-radius");
4142
examples.set("missing-background-image", "css/missing-background-image");
42-
4343
return examples;
4444
}

tns-core-modules/ui/text-base/text-base.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export class TextBase extends View implements AddChildFromBuilder {
2929
*/
3030
letterSpacing: number;
3131

32+
/**
33+
* Gets or sets lineHeight style property.
34+
*/
35+
lineHeight: number;
36+
3237
/**
3338
* Gets or sets text-alignment style property.
3439
*/

0 commit comments

Comments
 (0)