Include new ui tests for fonts

This commit is contained in:
SvetoslavTsenov
2017-03-01 17:40:16 +02:00
parent c5bd4d1ff0
commit 886fbb260d
13 changed files with 147 additions and 72 deletions

View File

@ -42,6 +42,7 @@ export function pageLoaded(args: EventData) {
examples.set("listview_bg_separator_color", "css/listview_bg_separator_color");
examples.set("padding-and-border", "css/padding-and-border");
examples.set("border-playground", "css/border-playground");
examples.set("textview-hint-color", "css/textview-hint-color");
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel;

View File

@ -1,49 +1,42 @@
import * as view from "ui/core/view";
import * as label from "ui/label";
import * as button from "ui/button";
import * as textField from "ui/text-field";
import * as textView from "ui/text-view";
import { Label } from "ui/label";
import { Button } from "ui/button";
import { TextField } from "ui/text-field";
import { TextView } from "ui/text-view";
import { Page } from "ui/page";
export function changeTextButonTap(args) {
var btnChange = <button.Button>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label");
var btn = <button.Button>btnChange.parent.getViewById("Button");
var textField = <textField.TextField>btnChange.parent.getViewById("TextField");
var textView = <textView.TextView>btnChange.parent.getViewById("TextView");
export function onChangeText(args) {
const page = <Page>args.object.page;
const lblElelemtn = <Label>page.getViewById("Label");
const btnElement = <Button>page.getViewById("Button");
const textFieldElement = <TextField>page.getViewById("TextField");
const textViewElement = <TextView>page.getViewById("TextView");
if(lbl.text === "Change text") {
lbl.text = btn.text = textField.text = textView.text = "Text changed";
if (lblElelemtn.text === "Change text") {
lblElelemtn.text = btnElement.text = textFieldElement.text = textViewElement.text = "Text changed";
} else {
lbl.text = btn.text = textField.text = textView.text = "Change text";
lblElelemtn.text = btnElement.text = textFieldElement.text = textViewElement.text = "Change text";
}
}
export function butonTap(args) {
var btnChange = <view.View>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label");
var btn = <button.Button>btnChange.parent.getViewById("Button");
var textField = <textField.TextField>btnChange.parent.getViewById("TextField");
var textView = <textView.TextView>btnChange.parent.getViewById("TextView");
if (lbl.style.textTransform === "none") {
lbl.style.textTransform = "capitalize";
btn.style.textTransform = "capitalize";
textField.style.textTransform = "capitalize";
textView.style.textTransform = "capitalize";
} else if (lbl.style.textTransform === "capitalize") {
lbl.style.textTransform = "uppercase";
btn.style.textTransform = "uppercase";
textField.style.textTransform = "uppercase";
textView.style.textTransform = "uppercase";
} else if (lbl.style.textTransform === "uppercase") {
lbl.style.textTransform = "lowercase";
btn.style.textTransform = "lowercase";
textField.style.textTransform = "lowercase";
textView.style.textTransform = "lowercase";
} else if (lbl.style.textTransform === "lowercase") {
lbl.style.textTransform = "none";
btn.style.textTransform = "none";
textField.style.textTransform = "none";
textView.style.textTransform = "none";
export function onChangeTextTransformation(args) {
const page = <Page>args.object.page;
const lblElelemtn = <Label>page.getViewById("Label");
const btnElement = <Button>page.getViewById("Button");
const textFieldElement = <TextField>page.getViewById("TextField");
const textViewElement = <TextView>page.getViewById("TextView");
let style = lblElelemtn.style.textTransform;
if (lblElelemtn.style.textTransform === "none") {
style = "capitalize";
} else if (lblElelemtn.style.textTransform === "capitalize") {
style = "uppercase";
} else if (lblElelemtn.style.textTransform === "uppercase") {
style = "lowercase";
} else if (lblElelemtn.style.textTransform === "lowercase") {
style = "none";
}
lblElelemtn.style.textTransform = style;
btnElement.style.textTransform = style;
textFieldElement.style.textTransform = style;
textViewElement.style.textTransform = style;
}

View File

@ -1,36 +1,14 @@
<Page >
<Page>
<Page.actionBar>
<ActionBar title="Text transform" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout>
<Button id="ChangeText" text="Change text" tap="changeTextButonTap" />
<Button id="Change" text="Change" tap="butonTap" />
<Button id="ChangeText" text="Change text" tap="onChangeText" />
<Button id="Change" text="Change" tap="onChangeTextTransformation" />
<Label id="Label" text="label Label" style.textTransform="none" />
<Button id="Button" text="button Button" style.textTransform="none" />
<TextField id="TextField" text="textField textField" style.textTransform="none" />
<TextView id="TextView" text="textView textView" style.textTransform="none" />
<!--
<Label text="label label" style="text-transform:none" />
<Label text="label label" style="text-transform:capitalize" />
<Label text="label label" style="text-transform:uppercase" />
<Label text="label label" style="text-transform:lowercase" />
<TextField text="textField textField" style="text-transform:none" />
<TextField text="textField textField" style="text-transform:capitalize" />
<TextField text="textField textField" style="text-transform:uppercase;" />
<TextField text="textField textField" style="text-transform:lowercase" />
<TextField text="textField textField" style="text-transform:uppercase; text-decoration:underline;" />
<TextView text="textView textView" style="text-transform:none" />
<TextView text="textView textView" style="text-transform:capitalize" />
<TextView text="textView textView" style="text-transform:uppercase" />
<TextView text="textView textView" style="text-transform:lowercase" />
<TextView text="textView textView" style="text-transform:uppercase; text-decoration:underline;" />
<Button text="button Button" style="text-transform:none" />
<Button text="button Button" style="text-transform:capitalize" />
<Button text="button Button" style="text-transform:uppercase" />
<Button text="button Button" style="text-transform:lowercase" />
<Button text="button Button" style="text-transform:uppercase; text-decoration:underline;" />
-->
</StackLayout>
</Page>

View File

@ -0,0 +1,14 @@
import { Page } from "ui/page";
import { TextView } from "ui/text-view";
import { Color } from "color";
export function changeTextAndColor(args) {
const page = <Page>args.object.page;
const tv1Hint = <TextView>page.getViewById("tv1Hint");
const tv2Hint = <TextView>page.getViewById("tv2Hint");
const tv3Hint = <TextView>page.getViewById("tv3Hint");
tv1Hint.text = "chnaged text + color";
tv1Hint.color = new Color("blue");
tv2Hint.text = "changed text only";
tv3Hint.color = new Color("green");
}

View File

@ -0,0 +1,14 @@
<Page>
<Page.actionBar>
<ActionBar title="TextView hint color"/>
</Page.actionBar>
<StackLayout>
<Label text="Should change text and color" />
<TextView id="tv1Hint" hint="hint1" text="" color="pink" fontSize="32" />
<Label text="Should change apply text" />
<TextView id="tv2Hint" hint="hint2" color="orange" fontSize="32" />
<Label text="Should change only color of hint" />
<TextView id="tv3Hint" hint="hint3" color="blue" fontSize="32" />
<Button id="btn" text="Change text and color" tap="changeTextAndColor"/>
</StackLayout>
</Page>

View File

@ -0,0 +1,5 @@
import { topmost } from "ui/frame";
export function onTap(args){
topmost().goBack();
}

View File

@ -0,0 +1,6 @@
<Page xmlns="http://www.nativescript.org/tns.xsd">
<StackLayout>
<Label text="Second page" textWrap="true" />
<Button text="Go Back" tap="onTap" />
</StackLayout>
</Page>

View File

@ -0,0 +1,11 @@
Button {
background-color: #48a23f;
text-align: center;
width: 32%;
height: 25%;
font-size: 18em;
}
.font-awesome {
font-family: "FontAwesome";
}

View File

@ -0,0 +1,5 @@
import { topmost } from "ui/frame";
export function onTap(){
topmost().navigate("ui-tests-app/font/issue-3654-2");
}

View File

@ -0,0 +1,47 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="FontAwesome" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout class="p-20">
<Label text="Tap the button" class="h1 text-center"/>
<Label text="&#xf0a1;" class="font-awesome" fontFamily="FontAwesome" fontSize="42em" />
<Button text="TAP" tap="onTap">
<FormattedString>
<Span text="&#xf0a1;" class="font-awesome" fontFamily="FontAwesome" fontSize="42em" foregroundColor="white" fontAttributes="Bold"></Span>
<Span text="font-awesome" fontAttributes="Bold"></Span>
</FormattedString>
</Button>
<Button text="TAP" tap="onTap" class="">
<FormattedString>
<Span text="&#xf1ec;" fontFamily="FontAwesome" fontSize="42em" foregroundColor="white" fontAttributes="Bold"></Span>
<Span text="some text" fontAttributes="Bold"></Span>
</FormattedString>
</Button>
<Button text="TAP" tap="onTap" class="">
<FormattedString>
<Span text="&#xf017;" fontFamily="FontAwesome" fontSize="42em" foregroundColor="white" fontAttributes="Bold"></Span>
<Span text="some text" fontAttributes="Bold"></Span>
</FormattedString>
</Button>
<Button text="TAP" tap="onTap" class="">
<FormattedString>
<Span text="&#xf1b9;" fontFamily="FontAwesome" fontSize="42em" foregroundColor="white" fontAttributes="Bold"></Span>
<Span text="some text" fontAttributes="Bold"></Span>
</FormattedString>
</Button>
<Button text="TAP" tap="onTap" class="">
<FormattedString>
<Span text="&#xf075;" fontFamily="FontAwesome" fontSize="42em" foregroundColor="white" fontAttributes="Bold"></Span>
<Span text="some text" fontAttributes="Bold"></Span>
</FormattedString>
</Button>
<Button text="TAP" tap="onTap" class="">
<FormattedString>
<Span text="&#xf05a;" fontFamily="FontAwesome" fontSize="42em" foregroundColor="white" fontAttributes="Bold"></Span>
<Span text="some text" fontAttributes="Bold"></Span>
</FormattedString>
</Button>
<Label text="{{ message }}" class="h2 text-center" textWrap="true"/>
</StackLayout>
</Page>

View File

@ -18,6 +18,7 @@ export function pageLoaded(args: EventData) {
examples.set("nordic", "nordic/nordic");
examples.set("customfonts", "font/custom-fonts");
examples.set("all-fonts", "font/all-fonts");
examples.set("awesome-3654", "font/issue-3654");
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel;

Binary file not shown.