mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: update tslint rules (#7391)
This commit is contained in:
@@ -24,7 +24,7 @@ export class ActionItemPostitionView extends observable.Observable {
|
||||
set text(value: string) {
|
||||
if (this._text !== value) {
|
||||
this._text = value;
|
||||
this.notifyPropertyChange("text", value)
|
||||
this.notifyPropertyChange("text", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { EventData } from "tns-core-modules/data/observable";
|
||||
import { TabView } from "tns-core-modules/ui/tab-view";
|
||||
|
||||
export function onLoaded(args: EventData) {
|
||||
console.log("TEST", args.object)
|
||||
console.log("TEST", args.object);
|
||||
const tabView = <TabView>args.object;
|
||||
tabView.ios.tabBar.translucent = false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as frame from "tns-core-modules/ui/frame";
|
||||
import * as frame from "tns-core-modules/ui/frame";
|
||||
import { EventData } from "tns-core-modules/ui/frame";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
import { ActionBar } from "tns-core-modules/ui/action-bar";
|
||||
@@ -11,7 +11,7 @@ export function navigate() {
|
||||
|
||||
export function onChangeRenderingMode(args: EventData) {
|
||||
const button = <Button>args.object;
|
||||
const actionBar = <ActionBar>button.page.actionBar
|
||||
const actionBar = <ActionBar>button.page.actionBar;
|
||||
actionBar.iosIconRenderingMode = <"automatic" | "alwaysOriginal" | "alwaysTemplate">iconModes[(iconModes.indexOf(actionBar.iosIconRenderingMode) + 1) % iconModes.length];
|
||||
button.text = "" + actionBar.iosIconRenderingMode;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as frame from "tns-core-modules/ui/frame";
|
||||
import * as frame from "tns-core-modules/ui/frame";
|
||||
import { EventData } from "tns-core-modules/ui/frame";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
import { ActionBar } from "tns-core-modules/ui/action-bar";
|
||||
@@ -11,7 +11,7 @@ export function navigate() {
|
||||
|
||||
export function onChangeRenderingMode(args: EventData) {
|
||||
const button = <Button>args.object;
|
||||
const actionBar = <ActionBar>button.page.actionBar
|
||||
const actionBar = <ActionBar>button.page.actionBar;
|
||||
actionBar.iosIconRenderingMode = <"automatic" | "alwaysOriginal" | "alwaysTemplate">iconModes[(iconModes.indexOf(actionBar.iosIconRenderingMode) + 1) % iconModes.length];
|
||||
button.text = "" + actionBar.iosIconRenderingMode;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ShownModallyData } from "tns-core-modules/ui/page";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
import { Label } from "tns-core-modules/ui/label"
|
||||
import { Page } from "tns-core-modules/ui/page"
|
||||
import { Label } from "tns-core-modules/ui/label";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
|
||||
let closeCallback: Function;
|
||||
|
||||
@@ -18,8 +18,8 @@ export function change(args) {
|
||||
|
||||
var page: Page = <Page>button.parent;
|
||||
|
||||
console.log("---------------------page-------------------------")
|
||||
console.log(page)
|
||||
console.log("---------------------page-------------------------");
|
||||
console.log(page);
|
||||
var label: Label = <Label>page.getViewById("label1");
|
||||
label.text = "fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { topmost } from "tns-core-modules/ui/frame";
|
||||
|
||||
export function btnClick(args: EventData) {
|
||||
(<Page>args.object).page.showModal("action-bar/modal-page", {
|
||||
context: "",
|
||||
context: "",
|
||||
closeCallback: (arg: string) => console.log("Callback args: " + arg),
|
||||
fullscreen: true
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import { topmost } from "tns-core-modules/ui/frame";
|
||||
|
||||
export function btnClick(args: EventData) {
|
||||
(<Page>args.object).page.showModal("action-bar/modal-page-hidden-action-bar-page", {
|
||||
context: "",
|
||||
context: "",
|
||||
closeCallback: (arg: string) => console.log("Callback args: " + arg),
|
||||
fullscreen: true
|
||||
});
|
||||
|
||||
@@ -16,5 +16,6 @@ export function loadExamples() {
|
||||
examples.set("height-basic", "animation/height-basic-page");
|
||||
examples.set("layout-stack-height", "animation/layout-stack-height-page");
|
||||
examples.set("effect-summary-details", "animation/effect-summary-details-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as buttonModule from "tns-core-modules/ui/button";
|
||||
import * as buttonModule from "tns-core-modules/ui/button";
|
||||
import * as pageModule from "tns-core-modules/ui/page";
|
||||
import * as textFieldModule from "tns-core-modules/ui/text-field";
|
||||
import * as stackLayoutModule from "tns-core-modules/ui/layouts/stack-layout";
|
||||
@@ -20,13 +20,13 @@ export function createPage() {
|
||||
targetTwoWay.id = "textFieldTwoWay";
|
||||
buttonOneWay.id = "buttonOneWay";
|
||||
buttonTwoWay.id = "buttonTwoWay";
|
||||
buttonSetText.id = "buttonSetText";
|
||||
buttonSetText.id = "buttonSetText";
|
||||
|
||||
targetOneWay.automationText = "textFieldOneWay";
|
||||
targetTwoWay.automationText = "textFieldTwoWay";
|
||||
buttonSetText.automationText = "buttonSetText";
|
||||
//buttonOneWay.automationText = "buttonOneWay";
|
||||
//buttonTwoWay.automationText = "buttonTwoWay";
|
||||
//buttonOneWay.automationText = "buttonOneWay";
|
||||
//buttonTwoWay.automationText = "buttonTwoWay";
|
||||
|
||||
buttonSetText.text = "SetText";
|
||||
buttonSetText.on(buttonModule.Button.tapEvent, function () {
|
||||
@@ -76,5 +76,6 @@ export function createPage() {
|
||||
stack.addChild(buttonTwoWay);
|
||||
|
||||
page.content = stack;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export function pageLoaded(args: EventData) {
|
||||
}
|
||||
|
||||
export function loadExamples() {
|
||||
const examples = new Map<string, string>();
|
||||
const examples = new Map<string, string>();
|
||||
examples.set("bottom-navigation", "bottom-navigation/bottom-navigation-page");
|
||||
examples.set("issue-5470", "bottom-navigation/issue-5470-page");
|
||||
examples.set("background-color", "bottom-navigation/background-color-page");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { View } from "tns-core-modules/ui/core/view";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
import { Color } from "tns-core-modules/color";
|
||||
import { Color } from "tns-core-modules/color";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { ScrollView } from "tns-core-modules/ui/scroll-view";
|
||||
|
||||
@@ -19,19 +19,19 @@ export function onToggle(args: EventData) {
|
||||
debugConsole.text += `> border-color: ${target.borderColor}\n`;
|
||||
}
|
||||
else if (button.text === "Width") {
|
||||
target[button.id] = target[button.id] ? 0 : 10;
|
||||
target[button.id] = target[button.id] ? 0 : 10;
|
||||
debugConsole.text += `> border-width: ${target.borderWidth}\n`;
|
||||
}
|
||||
else if (button.text === "Radius") {
|
||||
target[button.id] = target[button.id] ? 0 : 10;
|
||||
target[button.id] = target[button.id] ? 0 : 10;
|
||||
debugConsole.text += `> border-radius: ${target.borderRadius}\n`;
|
||||
}
|
||||
else if (button.text === "BGColor") {
|
||||
target.backgroundColor = target.backgroundColor ? undefined : green;
|
||||
target.backgroundColor = target.backgroundColor ? undefined : green;
|
||||
debugConsole.text += `> background-color: ${target.backgroundColor}\n`;
|
||||
}
|
||||
else if (button.text === "BGImage") {
|
||||
target.backgroundImage = target.backgroundImage ? undefined : `~/resources/images/test2.png`;
|
||||
target.backgroundImage = target.backgroundImage ? undefined : `~/resources/images/test2.png`;
|
||||
debugConsole.text += `> background-image: ${target.backgroundImage}\n`;
|
||||
}
|
||||
else if (button.text === "BGGradient") {
|
||||
|
||||
@@ -19,5 +19,6 @@ export function loadExamples() {
|
||||
examples.set("issue-4287", "button/issue-4287-page");
|
||||
examples.set("issue-4385", "button/issue-4385-page");
|
||||
examples.set("highlight-4740", "button/highlight-4740/highlight-4740-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const tests = [
|
||||
{ name: "to right yellow-blue-pink", backgroundImage: "linear-gradient(to right, yellow, green, pink)"},
|
||||
{ name: "-45deg green-blue-pink", backgroundImage: "linear-gradient(-45deg, green, blue, pink)"},
|
||||
{ name: "45deg green-blue-pink", backgroundImage: "linear-gradient(45deg, green, blue, pink)"},
|
||||
]
|
||||
];
|
||||
|
||||
export function onLoaded(args) {
|
||||
applyNextStyle(args);
|
||||
|
||||
@@ -27,7 +27,7 @@ const tests = [
|
||||
{ name: "[shuffle] position percents, image, no-repeat, orange hex color", background: "100% 100% url(\"~/resources/images/icon.png\") no-repeat #F9791F" },
|
||||
{ name: "[shuffle] position percents, image, repeat-x, green color", background: "100% 100% url(\"~/resources/images/icon.png\") repeat-x green" },
|
||||
{ name: "[shuffle] image, repeat-x, position, blue color,", background: "url(\"~/resources/images/icon.png\") repeat-x 150 150 blue" },
|
||||
]
|
||||
];
|
||||
|
||||
export function onLoaded(args) {
|
||||
applyNextStyle(args);
|
||||
|
||||
@@ -6,7 +6,7 @@ const states = [
|
||||
{ class: "elevation-10", text: "elevetion 10" },
|
||||
{ class: "elevation-10 pressed-z-10", text: "elevetion 10 pressed-z 10" },
|
||||
{ class: "elevation-0", text: "elevetion 0" },
|
||||
]
|
||||
];
|
||||
let currentState = 0;
|
||||
|
||||
export function buttonTap(args: EventData) {
|
||||
|
||||
@@ -45,5 +45,6 @@ export function loadExamples() {
|
||||
examples.set("background-shorthand", "css/background-shorthand-page");
|
||||
examples.set("background-image-linear-gradient", "css/background-image-linear-gradient-page");
|
||||
examples.set("background-image", "css/background-image-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -4,27 +4,27 @@ import { EventData } from "tns-core-modules/data/observable";
|
||||
import * as button from "tns-core-modules/ui/button";
|
||||
|
||||
const cssPercentage = `
|
||||
Page { background-color: orange; font-size: 8; }
|
||||
GridLayout { margin: 3%; background-color: lightgreen; font-size: 8; }
|
||||
StackLayout { border-color: red; border-width: 1; }
|
||||
StackLayout * { border-color: blue; border-width: 1; }
|
||||
GridLayout { border-color: green; border-width: 1; }
|
||||
.test1 { padding: 10%; }
|
||||
.test2 { padding: 10%; background-color: lightblue; }
|
||||
.test3 { margin: 1% 2% 3% 4%; }
|
||||
WrapLayout { orientation: vertical; width: 75%; height: 45% }
|
||||
Page { background-color: orange; font-size: 8; }
|
||||
GridLayout { margin: 3%; background-color: lightgreen; font-size: 8; }
|
||||
StackLayout { border-color: red; border-width: 1; }
|
||||
StackLayout * { border-color: blue; border-width: 1; }
|
||||
GridLayout { border-color: green; border-width: 1; }
|
||||
.test1 { padding: 10%; }
|
||||
.test2 { padding: 10%; background-color: lightblue; }
|
||||
.test3 { margin: 1% 2% 3% 4%; }
|
||||
WrapLayout { orientation: vertical; width: 75%; height: 45% }
|
||||
Button { color: black }`;
|
||||
|
||||
const cssWithouPercentage = `
|
||||
Page { background-color: orange; font-size: 8; }
|
||||
GridLayout { margin:3; background-color: lightgreen; font-size: 8; }
|
||||
StackLayout { border-color: red; border-width: 1; }
|
||||
StackLayout * { border-color: blue; border-width: 1; }
|
||||
GridLayout { border-color: green; border-width: 1; }
|
||||
.test1 { padding: 10; }
|
||||
.test2 { padding: 10; background-color: lightblue; }
|
||||
.test3 { margin: 10 20 30 40; }
|
||||
WrapLayout { orientation: vertical; width: 100; height: 120; }
|
||||
Page { background-color: orange; font-size: 8; }
|
||||
GridLayout { margin:3; background-color: lightgreen; font-size: 8; }
|
||||
StackLayout { border-color: red; border-width: 1; }
|
||||
StackLayout * { border-color: blue; border-width: 1; }
|
||||
GridLayout { border-color: green; border-width: 1; }
|
||||
.test1 { padding: 10; }
|
||||
.test2 { padding: 10; background-color: lightblue; }
|
||||
.test3 { margin: 10 20 30 40; }
|
||||
WrapLayout { orientation: vertical; width: 100; height: 120; }
|
||||
Button { color: black }`;
|
||||
|
||||
var isSCCWithPercentage = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as pageModule from "tns-core-modules/ui/page";
|
||||
import * as pageModule from "tns-core-modules/ui/page";
|
||||
import * as labelModule from "tns-core-modules/ui/label";
|
||||
import * as stackLayoutModule from "tns-core-modules/ui/layouts/stack-layout";
|
||||
import * as textViewModule from "tns-core-modules/ui/text-view";
|
||||
@@ -20,6 +20,7 @@ export function createPage() {
|
||||
});
|
||||
|
||||
page.content = stackLayout;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as labelModule from "tns-core-modules/ui/label";
|
||||
import * as labelModule from "tns-core-modules/ui/label";
|
||||
import * as gestures from "tns-core-modules/ui/gestures";
|
||||
import * as button from "tns-core-modules/ui/button";
|
||||
import * as pages from "tns-core-modules/ui/page";
|
||||
@@ -110,6 +110,7 @@ export function createPage() {
|
||||
|
||||
var page = new pages.Page();
|
||||
page.content = stack;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ export function pageLoaded(args: observable.EventData) {
|
||||
}
|
||||
|
||||
export function tapAction(args: gestures.GestureEventData) {
|
||||
console.log("tapAction")
|
||||
console.log("tapAction");
|
||||
}
|
||||
|
||||
export function doubleTapAction(args: gestures.GestureEventData) {
|
||||
console.log("doubleTapAction")
|
||||
console.log("doubleTapAction");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as pages from "tns-core-modules/ui/page";
|
||||
import * as pages from "tns-core-modules/ui/page";
|
||||
import * as button from "tns-core-modules/ui/button";
|
||||
import * as stackModule from "tns-core-modules/ui/layouts/stack-layout";
|
||||
|
||||
@@ -16,5 +16,6 @@ export function createPage() {
|
||||
|
||||
var page = new pages.Page();
|
||||
page.content = stack;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import * as gestures from "tns-core-modules/ui/gestures";
|
||||
|
||||
export function onTouch(args: gestures.TouchGestureEventData) {
|
||||
@@ -11,14 +11,14 @@ export function onTouch(args: gestures.TouchGestureEventData) {
|
||||
let pointers = args.getActivePointers();
|
||||
for (let index = 0; index < pointers.length; index++) {
|
||||
p = pointers[index];
|
||||
msg += " p" + index + "[" + Math.round(p.getX()) + ", " + Math.round(p.getY()) + "]"
|
||||
msg += " p" + index + "[" + Math.round(p.getX()) + ", " + Math.round(p.getY()) + "]";
|
||||
}
|
||||
|
||||
msg += " ALL: ";
|
||||
pointers = args.getAllPointers();
|
||||
for (let index = 0; index < pointers.length; index++) {
|
||||
p = pointers[index];
|
||||
msg += " p" + index + "[" + Math.round(p.getX()) + ", " + Math.round(p.getY()) + "]"
|
||||
msg += " p" + index + "[" + Math.round(p.getX()) + ", " + Math.round(p.getY()) + "]";
|
||||
}
|
||||
|
||||
console.log(msg);
|
||||
|
||||
@@ -10,7 +10,7 @@ function applyCss() {
|
||||
// console.log(boxCss);
|
||||
args.object.page.addCss(boxCss);
|
||||
// console.log(args.object.page.css);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function applyStyles(args) {
|
||||
|
||||
@@ -18,5 +18,6 @@ export function loadExamples() {
|
||||
examples.set("flex-perf", "flexbox/flexbox-perf-comparison-page");
|
||||
examples.set("flexbox-4143", "flexbox/flexbox-4143-page");
|
||||
examples.set("flexbox-4834", "flexbox/flexbox-4834-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ function set(what: string) {
|
||||
return function(args) {
|
||||
let containerCss = " #container { " + args.object.tag + " }" ;
|
||||
args.object.page.addCss(containerCss);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const flexDirection = set("flexDirection");
|
||||
|
||||
@@ -50,12 +50,12 @@ if (isIOS) {
|
||||
const nsFontFamilies = UIFont.familyNames;
|
||||
for (let i = 0; i < nsFontFamilies.count; i++) {
|
||||
const family = nsFontFamilies.objectAtIndex(i);
|
||||
fontFamilies.push(family)
|
||||
fontFamilies.push(family);
|
||||
|
||||
const nsFonts = UIFont.fontNamesForFamilyName(family);
|
||||
for (let j = 0; j < nsFonts.count; j++) {
|
||||
const font = nsFonts.objectAtIndex(j);
|
||||
fontNames.push(font)
|
||||
fontNames.push(font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ function prepareTitle(text: string, fontSize: number) {
|
||||
title.borderWidth = 1;
|
||||
title.borderColor = white;
|
||||
title.textAlignment = "center";
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -161,6 +162,7 @@ function prepareLabel(fontFamily: string, fontStyle: string, fontWeight: string)
|
||||
if (fontFamily === "FontAwesome") {
|
||||
label.text += "\uF17B\uF10B";
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export function resetStyles(args) {
|
||||
v.style.borderTopRightRadius = unsetValue;
|
||||
v.style.borderBottomRightRadius = unsetValue;
|
||||
v.style.borderBottomLeftRadius = unsetValue;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export function resetStyles(args) {
|
||||
v.style.fontWeight = unsetValue;
|
||||
v.style.color = unsetValue;
|
||||
v.style.textAlignment = unsetValue;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export function resetStyles(args) {
|
||||
v.style.fontWeight = unsetValue;
|
||||
v.style.color = unsetValue;
|
||||
v.style.textAlignment = unsetValue;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export function resetStyles(args) {
|
||||
v.style.fontWeight = unsetValue;
|
||||
v.style.color = unsetValue;
|
||||
v.style.textAlignment = unsetValue;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ const sources = [
|
||||
{ w: 18, h: 32, src: "i18x32" }
|
||||
].map(({w, h, src}) => ({w, h, src: `res://${src}` }));
|
||||
const stretchModes: Stretch[] = ["none", "aspectFill", "aspectFit", "fill"];
|
||||
const widths = [ +8, 0, -8 ]
|
||||
const heights = [ +8, 0, -8 ]
|
||||
const widths = [ +8, 0, -8 ];
|
||||
const heights = [ +8, 0, -8 ];
|
||||
|
||||
export function navigatingTo(args) {
|
||||
const variants: { src: string, stretch: Stretch, width: number, height: number }[] = [];
|
||||
|
||||
@@ -6,7 +6,7 @@ import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
|
||||
export function toggle(args: EventData) {
|
||||
const page = <Page>((<any>args.object).page);
|
||||
|
||||
const getElementById = id => page.getViewById(id)
|
||||
const getElementById = id => page.getViewById(id);
|
||||
|
||||
const toggleBtn = <Button>getElementById("toggleUserInteraction");
|
||||
const isEnabled = toggleBtn.text === "disable" ? true : false;
|
||||
|
||||
@@ -31,7 +31,7 @@ export function loadExamples() {
|
||||
examples.set("ng-repo-1599", "issues/issue-ng-repo-1599-page");
|
||||
examples.set("ng-repo-1626", "issues/issue-ng-repo-1626-page");
|
||||
examples.set("6439", "issues/issue-6439-page");
|
||||
examples.set("open-file-6895", "issues/open-file-6895-page")
|
||||
examples.set("open-file-6895", "issues/open-file-6895-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ const setLabelTextAndLog = (args, text: string) => {
|
||||
const label = <Label>page.getViewById("resultLabel");
|
||||
label.set("text", text);
|
||||
console.log("on button tap");
|
||||
}
|
||||
};
|
||||
|
||||
export function onTap(args: EventData) {
|
||||
setLabelTextAndLog(args, "onButtonTapResult");
|
||||
|
||||
@@ -28,7 +28,7 @@ export class ListPickerView extends Observable {
|
||||
set showListPicker(value: string) {
|
||||
if (this._showListPicker !== value) {
|
||||
this._showListPicker = value;
|
||||
this.notifyPropertyChange("showListPicker", value)
|
||||
this.notifyPropertyChange("showListPicker", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ export class ListPickerJsonArrayModel extends Observable {
|
||||
}
|
||||
|
||||
export function navigatingTo(args: EventData) {
|
||||
let page = <Page>args.object;
|
||||
let page = <Page>args.object;
|
||||
page.bindingContext = new ListPickerJsonArrayModel();
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ export function loadExamples() {
|
||||
examples.set("issue_2895", "list-picker/issue_2895-page");
|
||||
examples.set("list-picker", "list-picker/list-picker-page");
|
||||
examples.set("list-picker-json-array", "list-picker/list-picker-json-array-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export function pageLoaded(args) {
|
||||
|
||||
page.bindingContext = {
|
||||
"items": viewModel.items
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.onItemTap = function (args) {
|
||||
@@ -18,4 +18,4 @@ exports.onItemTap = function (args) {
|
||||
|
||||
currentItem.age = currentItem.age + 1;
|
||||
listArray.setItem(index, currentItem);
|
||||
}
|
||||
};
|
||||
@@ -13,7 +13,7 @@ export function loaded(args) {
|
||||
}
|
||||
|
||||
export function toggle(args) {
|
||||
console.log("toggle : ")
|
||||
console.log("toggle : ");
|
||||
let context = args.object.bindingContext;
|
||||
console.dir(context);
|
||||
context.set("selected", !context.selected);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout";
|
||||
import { Color } from "tns-core-modules/color";
|
||||
|
||||
export function selectItemTemplate(item: Item, index: number, items: ObservableArray<Item>): string {
|
||||
return item.id % 10 === 0 ? "red" : item.id % 2 === 0 ? "green" : "yellow";
|
||||
return item.id % 10 === 0 ? "red" : item.id % 2 === 0 ? "green" : "yellow";
|
||||
}
|
||||
|
||||
export function pageLoaded(args: EventData) {
|
||||
@@ -18,17 +18,18 @@ export function pageLoaded(args: EventData) {
|
||||
|
||||
let lv4 = page.getViewById<ListView>("lv4");
|
||||
lv4.itemTemplateSelector = (item: Item, index: number, items: ObservableArray<Item>) => {
|
||||
return index % 10 === 0 ? "red" : index % 2 === 0 ? "green" : "yellow";
|
||||
return index % 10 === 0 ? "red" : index % 2 === 0 ? "green" : "yellow";
|
||||
};
|
||||
|
||||
let createLabel = (backgroundColor: Color) => {
|
||||
let label = new Label();
|
||||
let createLabel = (backgroundColor: Color) => {
|
||||
let label = new Label();
|
||||
label.bind({
|
||||
sourceProperty: null,
|
||||
targetProperty: "text",
|
||||
expression: "$value"
|
||||
});
|
||||
label.style.backgroundColor = backgroundColor;
|
||||
|
||||
return label;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Item extends Observable {
|
||||
set name(value: string) {
|
||||
if (this._name !== value) {
|
||||
this._name = value;
|
||||
this.notifyPropertyChange("name", value)
|
||||
this.notifyPropertyChange("name", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class Item extends Observable {
|
||||
set id(value: number) {
|
||||
if (this._id !== value) {
|
||||
this._id = value;
|
||||
this.notifyPropertyChange("id", value)
|
||||
this.notifyPropertyChange("id", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class Item extends Observable {
|
||||
set age(value: number) {
|
||||
if (this._age !== value) {
|
||||
this._age = value;
|
||||
this.notifyPropertyChange("age", value)
|
||||
this.notifyPropertyChange("age", value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ export class ViewModel extends Observable {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
this._items.push(new Item(`Item`, i, 0));
|
||||
}
|
||||
|
||||
return this._items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class MainPageViewModel extends TestPageMainViewModel {
|
||||
|
||||
set filteredListOfExamples(array: ObservableArray<TestExample>) {
|
||||
if (this._filteredListOfExamples !== array) {
|
||||
this._filteredListOfExamples = array
|
||||
this._filteredListOfExamples = array;
|
||||
this.notifyPropertyChange("filteredListOfExamples", array);
|
||||
this.toggleExamplePanels(array);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ export class MainPageViewModel extends TestPageMainViewModel {
|
||||
const testExample = new TestExample(key, value);
|
||||
this.filteredListOfExamples.push(testExample);
|
||||
MainPageViewModel.ALL_EXAMPLES.push(testExample);
|
||||
MainPageViewModel._examplesDictionary.set(value, testExample)
|
||||
MainPageViewModel._examplesDictionary.set(value, testExample);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { MainPageViewModel } from "./main-page-view-model";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
|
||||
import { isAndroid } from "tns-core-modules/platform"
|
||||
import { isAndroid } from "tns-core-modules/platform";
|
||||
|
||||
export function pageLoaded(args: EventData) {
|
||||
const page = <Page>args.object;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Page, ShownModallyData } from "tns-core-modules/ui/page";
|
||||
import { Page, ShownModallyData } from "tns-core-modules/ui/page";
|
||||
import { EventData, fromObject } from "tns-core-modules/data/observable";
|
||||
|
||||
export function onShowingModally(args: ShownModallyData) {
|
||||
@@ -13,7 +13,7 @@ export function onShowingModally(args: ShownModallyData) {
|
||||
console.log("login-page.onLoginButtonTap");
|
||||
args.closeCallback(this.username, this.password);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function onShownModally(args: ShownModallyData) {
|
||||
|
||||
@@ -7,7 +7,7 @@ function createCloseCallback(label: Label, context?: string): (username: string,
|
||||
result = context ? context + "/" + result : result;
|
||||
console.log(result);
|
||||
label.text = result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function openModal(page: Page, label: Label, context: string) {
|
||||
|
||||
@@ -12,5 +12,6 @@ export function pageLoaded(args: EventData) {
|
||||
export function loadExamples() {
|
||||
const examples = new Map<string, string>();
|
||||
examples.set("statusBar", "page/status-bar-css-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -64,4 +64,4 @@ function reset(page: Page) {
|
||||
page.actionBarHidden = false;
|
||||
page.backgroundSpanUnderStatusBar = false;
|
||||
page.actionBar.backgroundColor = unsetValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ export function pageLoaded(args: EventData) {
|
||||
}
|
||||
|
||||
export function loadExamples() {
|
||||
const examples = new Map<string, string>();
|
||||
const examples = new Map<string, string>();
|
||||
examples.set("properties", "perf/properties/main-page");
|
||||
examples.set("memory-leaks", "perf/memory-leaks/main-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ function getStack(stack: StackLayout): StackLayout {
|
||||
let p = new StackLayout();
|
||||
stack.removeChildren();
|
||||
stack.addChild(p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export function addRemove(counts: Array<number>, parent: LayoutBase): string {
|
||||
counts.forEach((count) => {
|
||||
if (count > 10000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ export function setBackgroundColor(counts: Array<number>, parent?: LayoutBase):
|
||||
counts.forEach((count) => {
|
||||
if (parent && count > 10000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,7 +72,8 @@ export function setBorderWidths(counts: Array<number>, parent?: LayoutBase): str
|
||||
counts.forEach((count) => {
|
||||
if (count > 10000 && parent) {
|
||||
result += setResultTime(noValue);
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const lbl = setup(parent);
|
||||
@@ -111,6 +114,7 @@ export function setColorWithParents(counts: Array<number>, parent: LayoutBase):
|
||||
counts.forEach((count) => {
|
||||
if (count > 10000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,6 +153,7 @@ export function setFontSizeWithParents(counts: Array<number>, parent: LayoutBase
|
||||
counts.forEach((count) => {
|
||||
if (count > 1000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,13 +191,14 @@ export function setFontWeightWithParents(counts: Array<number>, parent: LayoutBa
|
||||
counts.forEach((count) => {
|
||||
if (count > 1000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setupParents(parent);
|
||||
const time = executeTest(() => {
|
||||
for (let i = 0; i < count; i++) {
|
||||
style.fontWeight = i % 2 === 0 ? "bold" : "normal"
|
||||
style.fontWeight = i % 2 === 0 ? "bold" : "normal";
|
||||
}
|
||||
});
|
||||
result += setResultTime(time);
|
||||
@@ -221,6 +227,7 @@ export function setBindingContextWithParents(counts: Array<number>, parent: Layo
|
||||
counts.forEach((count) => {
|
||||
if (count > 10000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
setupParents(parent);
|
||||
@@ -240,6 +247,7 @@ export function setBindingContextWithParentsBound(counts: Array<number>, parent:
|
||||
counts.forEach((count) => {
|
||||
if (count > 1000) {
|
||||
result += setResultTime(noValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,7 +266,7 @@ export function setBindingContextWithParentsBound(counts: Array<number>, parent:
|
||||
function setupParents(parent: LayoutBase, bindToContext: boolean = false): void {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let stack = new StackLayout();
|
||||
parent.addChild(stack)
|
||||
parent.addChild(stack);
|
||||
for (let j = 0; j < 3; j++) {
|
||||
let innerStack = new StackLayout();
|
||||
stack.addChild(innerStack);
|
||||
@@ -305,6 +313,7 @@ function executeTest(func: Function): string {
|
||||
|
||||
const avg = total / average;
|
||||
const res = `${avg.toFixed(2)}`;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,5 +13,6 @@ export function loadExamples() {
|
||||
const examples = new Map<string, string>();
|
||||
examples.set("activity-indicator", "progress-bar/activity-indicator-page");
|
||||
examples.set("progress-bar", "progress-bar/progress-page");
|
||||
return examples;
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@ export function loadExamples() {
|
||||
examples.set("safe-area-images", "scroll-view/safe-area-images-page");
|
||||
examples.set("safe-area-images-overflow", "scroll-view/safe-area-images-overflow-page");
|
||||
examples.set("layout-outside-scroll", "scroll-view/layout-outside-scroll-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Issue5039ViewModel } from "./issue-5039-view-model"
|
||||
import { Issue5039ViewModel } from "./issue-5039-view-model";
|
||||
import { SearchBar } from "tns-core-modules/ui/search-bar";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
|
||||
export function navigatingTo(args) {
|
||||
const page = <Page>args.object;
|
||||
const searchBar = <SearchBar>page.getViewById("searchBar")
|
||||
const searchBar = <SearchBar>page.getViewById("searchBar");
|
||||
page.bindingContext = new Issue5039ViewModel(searchBar);
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Observable } from "tns-core-modules/data/observable"
|
||||
import { ObservableArray } from "tns-core-modules/data/observable-array"
|
||||
import { Observable } from "tns-core-modules/data/observable";
|
||||
import { ObservableArray } from "tns-core-modules/data/observable-array";
|
||||
import { SearchBar } from "tns-core-modules/ui/search-bar";
|
||||
|
||||
export class Issue5039ViewModel extends Observable {
|
||||
|
||||
private _items = ["apple", "apple cider", "apple pie", "orange", "orange juice", "strawberry", "blueberry"]
|
||||
public items = new ObservableArray()
|
||||
private _items = ["apple", "apple cider", "apple pie", "orange", "orange juice", "strawberry", "blueberry"];
|
||||
public items = new ObservableArray();
|
||||
|
||||
constructor(private _searchBar: SearchBar) {
|
||||
super()
|
||||
this.items.push(this._items)
|
||||
super();
|
||||
this.items.push(this._items);
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
@@ -21,7 +21,7 @@ export class Issue5039ViewModel extends Observable {
|
||||
}
|
||||
|
||||
filter(value: string = "") {
|
||||
this.items.splice(0, this.items.length) // remove all items
|
||||
this.items.push(this._items.filter(i => -1 !== i.indexOf(value)))
|
||||
this.items.splice(0, this.items.length); // remove all items
|
||||
this.items.push(this._items.filter(i => -1 !== i.indexOf(value)));
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,6 @@ export function loadExamples() {
|
||||
examples.set("tab-view-android-swipe", "tab-view/tab-view-android-swipe-page");
|
||||
examples.set("tab-view-icon-title-placement", "tab-view/icon-title-placement-page");
|
||||
examples.set("tab-text-color", "tab-view/tab-text-color-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ const CSS = `
|
||||
#tab2 { text-transform: lowercase; }
|
||||
#tab3 { text-transform: uppercase; }
|
||||
#tab4 { text-transform: capitalize; }
|
||||
`
|
||||
`;
|
||||
|
||||
export function applyTap(args) {
|
||||
var page = <Page>args.object.page;
|
||||
|
||||
@@ -10,7 +10,7 @@ export function pageLoaded(args: EventData) {
|
||||
}
|
||||
|
||||
export function loadExamples() {
|
||||
const examples = new Map<string, string>();
|
||||
const examples = new Map<string, string>();
|
||||
examples.set("bottom-navigation", "tabs/default");
|
||||
examples.set("issue-5470", "bottom-navigation/issue-5470");
|
||||
examples.set("background-color", "bottom-navigation/background-color");
|
||||
|
||||
@@ -72,7 +72,7 @@ export class TestPageMainViewModel extends Observable {
|
||||
|
||||
btn.text = key;
|
||||
btn.automationText = key;
|
||||
this.buttonsPanel.addChild(btn)
|
||||
this.buttonsPanel.addChild(btn);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export class TestPageMainViewModel extends Observable {
|
||||
let arrayOfKeys = new Array<string>();
|
||||
map.forEach((value, key, map) => {
|
||||
arrayOfKeys.push(key);
|
||||
})
|
||||
});
|
||||
|
||||
arrayOfKeys.sort((a, b) => {
|
||||
if (a < b) {
|
||||
@@ -89,13 +89,14 @@ export class TestPageMainViewModel extends Observable {
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return a.localeCompare(b);
|
||||
})
|
||||
});
|
||||
|
||||
let sortedExamples = new Map<string, string>();
|
||||
arrayOfKeys.forEach((k) => {
|
||||
sortedExamples.set(k, this._examples.get(k));
|
||||
})
|
||||
});
|
||||
|
||||
this._examples.clear();
|
||||
this._examples = sortedExamples;
|
||||
|
||||
@@ -3,30 +3,31 @@ import { unsetValue } from "tns-core-modules/ui/core/view";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { TextField } from "tns-core-modules/ui/text-field";
|
||||
|
||||
function exectuteOnAll(page: Page, callback: (txt: TextView | TextField) => void) {
|
||||
function exectuteOnAll(page: Page, callback: (txt: TextView | TextField) => void) {
|
||||
page.getViewById("container").eachChild((child) => {
|
||||
if (child instanceof TextView || child instanceof TextField) {
|
||||
callback(child);
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function setText(args) {
|
||||
exectuteOnAll(args.object.page, (txt) => {
|
||||
txt.text = "set text";
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function resetStyles(args) {
|
||||
exectuteOnAll(args.object.page, (txt) => {
|
||||
txt.style.color = unsetValue;
|
||||
txt.style.placeholderColor = unsetValue;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function resetText(args) {
|
||||
exectuteOnAll(args.object.page, (txt) => {
|
||||
txt.text = "";
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@ export function loadExamples() {
|
||||
examples.set("text-view-hint-color", "text-view/text-view-hint-color-page");
|
||||
examples.set("hint-text-color", "text-view/hint-text-color-page");
|
||||
examples.set("scrolling-and-sizing", "text-view/scrolling-and-sizing-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ export function loadExamples() {
|
||||
examples.set("webview", "web-view/web-view-page");
|
||||
examples.set("webtest", "web-view/web-view-test-page");
|
||||
examples.set("query", "web-view/query-params-page");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ const htmlString = `<html>
|
||||
</html>`;
|
||||
|
||||
export function loadRelative() {
|
||||
setSrc(relUrl)
|
||||
setSrc(relUrl);
|
||||
}
|
||||
export function loadAbsolute() {
|
||||
setSrc(absoluteUrl)
|
||||
setSrc(absoluteUrl);
|
||||
}
|
||||
export function loadFile() {
|
||||
setSrc(fileUrl)
|
||||
setSrc(fileUrl);
|
||||
}
|
||||
export function loadString() {
|
||||
setSrc(htmlString)
|
||||
setSrc(htmlString);
|
||||
}
|
||||
|
||||
function setSrc(src) {
|
||||
|
||||
@@ -11,23 +11,23 @@ export class ImageHelper {
|
||||
|
||||
public async compareScreen(imageName: string, timeOutSeconds?: number, tolerance?: number, toleranceType?: ImageOptions) {
|
||||
imageName = this.increaseImageName(imageName);
|
||||
const result = await this._driver.compareScreen(imageName, timeOutSeconds, tolerance, toleranceType)
|
||||
const result = await this._driver.compareScreen(imageName, timeOutSeconds, tolerance, toleranceType);
|
||||
this._imagesResults.set(imageName, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async compareElement(imageName: string, element: UIElement, tolerance: number, timeOutSeconds: number, toleranceType: ImageOptions = ImageOptions.pixel) {
|
||||
imageName = this.increaseImageName(imageName);
|
||||
const result = await this._driver.compareElement(element, imageName, tolerance, timeOutSeconds, toleranceType)
|
||||
imageName = this.increaseImageName(imageName);
|
||||
const result = await this._driver.compareElement(element, imageName, tolerance, timeOutSeconds, toleranceType);
|
||||
this._imagesResults.set(imageName, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async compareRectangle(imageName: string, element: IRectangle, tolerance: number, timeOutSeconds: number, toleranceType: ImageOptions = ImageOptions.pixel) {
|
||||
imageName = this.increaseImageName(imageName);
|
||||
const result = await this._driver.compareRectangle(element, imageName, timeOutSeconds, tolerance, toleranceType)
|
||||
imageName = this.increaseImageName(imageName);
|
||||
const result = await this._driver.compareRectangle(element, imageName, timeOutSeconds, tolerance, toleranceType);
|
||||
this._imagesResults.set(imageName, result);
|
||||
|
||||
return result;
|
||||
@@ -44,7 +44,7 @@ export class ImageHelper {
|
||||
});
|
||||
|
||||
this.reset();
|
||||
assert.isTrue(!shouldFailTest, `Image comparisson failers`)
|
||||
assert.isTrue(!shouldFailTest, `Image comparisson failers`);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
@@ -48,5 +48,5 @@ export class ButtonBackgroundPage extends PageObjectBaseModel {
|
||||
await this.tapBtn(button);
|
||||
await this.imageHelper.compareElement(imageName, presenter, 18, 5, ImageOptions.pixel);
|
||||
this.imageHelper.assertImages();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ describe("button-background-suite", () => {
|
||||
it("background_11", async function () {
|
||||
const presenter = await backgroundPage.testElement();
|
||||
await backgroundPage.imageHelper.compareElement("background_11_clean", presenter, 0.1, 2);
|
||||
backgroundPage.imageHelper.assertImages()
|
||||
backgroundPage.imageHelper.assertImages();
|
||||
});
|
||||
|
||||
it("background_12", async function () {
|
||||
|
||||
Reference in New Issue
Block a user