diff --git a/apps/app/ui-tests-app/css/text-decoration.ts b/apps/app/ui-tests-app/css/text-decoration.ts index 3304b372e..737181045 100644 --- a/apps/app/ui-tests-app/css/text-decoration.ts +++ b/apps/app/ui-tests-app/css/text-decoration.ts @@ -1,60 +1,26 @@ -import view = require("ui/core/view"); -import label = require("ui/label"); -import button = require("ui/button"); -import textField = require("ui/text-field"); -import textView = require("ui/text-view"); +import { EventData, TextBase, TextDecoration } from "ui/text-base"; +import { Page } from "ui/page"; -export function changeTextButonTap(args) { - var btnChange = args.object; - var lbl = btnChange.parent.getViewById("Label"); - var btn = btnChange.parent.getViewById("Button"); - var textField = btnChange.parent.getViewById("TextField"); - var textView = btnChange.parent.getViewById("TextView"); +const possibleValues = [ + TextDecoration.NONE, + TextDecoration.UNDERLINE, + TextDecoration.LINE_THROUGH, + TextDecoration.UNDERLINE_LINE_THROUGH +]; + +export function butonTap(args: EventData) { + let page = (args.object).page; + let lbl = page.getViewById("Label"); + let btn = page.getViewById("Button"); + let textField = page.getViewById("TextField"); + let textView = page.getViewById("TextView"); - if(lbl.text === "Change text") { - lbl.text = btn.text = textField.text = textView.text = "Text changed"; - } else { - lbl.text = btn.text = textField.text = textView.text = "Change text"; - } -} - -export function butonTap(args) { - var btnChange = args.object; - var lbl = btnChange.parent.getViewById("Label"); - var btn = btnChange.parent.getViewById("Button"); - var textField = btnChange.parent.getViewById("TextField"); - var textView = btnChange.parent.getViewById("TextView"); - - if (lbl.style.textDecoration === "none") { - lbl.style.textDecoration = "underline"; - btn.style.textDecoration = "underline"; - textField.style.textDecoration = "underline"; - textView.style.textDecoration = "underline"; - } else if (lbl.style.textDecoration === "underline") { - lbl.style.textDecoration = "line-through"; - btn.style.textDecoration = "line-through"; - textField.style.textDecoration = "line-through"; - textView.style.textDecoration = "line-through"; - } else if (lbl.style.textDecoration === "line-through") { - lbl.style.textDecoration = "line-through underline"; - btn.style.textDecoration = "line-through underline"; - textField.style.textDecoration = "line-through underline"; - textView.style.textDecoration = "line-through underline"; - } else if (lbl.style.textDecoration === "line-through underline") { - lbl.style.textDecoration = "line-through underline none"; - btn.style.textDecoration = "line-through underline none"; - textField.style.textDecoration = "line-through underline none"; - textView.style.textDecoration = "line-through underline none"; - } else if (lbl.style.textDecoration === "line-through underline none") { - lbl.style.textDecoration = "none"; - btn.style.textDecoration = "none"; - textField.style.textDecoration = "none"; - textView.style.textDecoration = "none"; - - if(lbl.text === "Change text") { - lbl.text = btn.text = textField.text = textView.text = "Text changed"; - } else { - lbl.text = btn.text = textField.text = textView.text = "Change text"; - } - } + let currentIndex = possibleValues.indexOf(lbl.textDecoration); + let newIndex = (currentIndex + 1) % possibleValues.length; + let newValue = possibleValues[newIndex]; + + lbl.textDecoration = newValue; + btn.textDecoration = newValue; + textField.textDecoration = newValue; + textView.textDecoration = newValue; } diff --git a/apps/app/ui-tests-app/css/text-decoration.xml b/apps/app/ui-tests-app/css/text-decoration.xml index 9de343b28..a938cfc8a 100644 --- a/apps/app/ui-tests-app/css/text-decoration.xml +++ b/apps/app/ui-tests-app/css/text-decoration.xml @@ -1,36 +1,9 @@ - + -