Files
NativeScript/apps/app/ui-tests-app/css/border-playground.ts
Hristo Deshev 629eb6e683 Use relative imports in tns-core-modules.
Use tns-core-modules/* imports in outside code (apps, tests, etc)
2017-03-13 14:37:59 +02:00

40 lines
1.7 KiB
TypeScript

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 { TextView } from "tns-core-modules/ui/text-view";
import { ScrollView } from "tns-core-modules/ui/scroll-view";
let red = new Color("red");
let green = new Color("green");
export function onToggle(args: EventData){
let button = <Button>args.object;
let target = button.page.getViewById<View>("target");
let debugConsole = button.page.getViewById<TextView>("debugConsole");
let scrollView = button.page.getViewById<ScrollView>("scrollView");
if (button.text === "Color"){
target[button.id] = target[button.id] ? undefined : red;
debugConsole.text += `> border-color: ${target.borderColor}\n`;
}
else if (button.text === "Width"){
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;
debugConsole.text += `> border-radius: ${target.borderRadius}\n`;
}
else if (button.text === "BGColor"){
target.backgroundColor = target.backgroundColor ? undefined : green;
debugConsole.text += `> background-color: ${target.backgroundColor}\n`;
}
else if (button.text === "BGImage"){
target.backgroundImage = target.backgroundImage ? undefined : `~/ui-tests-app/pages/test2.png`;
debugConsole.text += `> background-image: ${target.backgroundImage}\n`;
}
scrollView.scrollToVerticalOffset(scrollView.scrollableHeight, true);
}