From 51e448aa10f1b300bf2fbc3bc31fb6ad57c667ec Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Thu, 15 Dec 2016 13:20:25 +0200 Subject: [PATCH] Fixed: getViewById, TextDecoration --- apps/app/ui-tests-app/css/text-decoration.ts | 80 ++++++------------- apps/app/ui-tests-app/css/text-decoration.xml | 37 ++------- apps/app/ui-tests-app/css/text-transform.ts | 17 +--- tns-core-modules/tns-core-modules.base.d.ts | 1 + tns-core-modules/ui/core/view-base.ts | 58 +++++++++++++- tns-core-modules/ui/core/view-common.ts | 45 ----------- tns-core-modules/ui/core/view.d.ts | 23 ------ tns-core-modules/ui/definitions.d.ts | 26 ++++++ .../flexbox-layout/flexbox-layout-common.ts | 22 ++--- tns-core-modules/ui/styling/converters.ts | 7 +- tns-core-modules/ui/styling/style.d.ts | 3 +- tns-core-modules/ui/styling/style.ts | 6 +- .../ui/text-base/text-base-common.ts | 32 ++++---- .../ui/text-base/text-base.android.ts | 6 +- tns-core-modules/ui/text-base/text-base.d.ts | 14 +++- .../ui/text-base/text-base.ios.ts | 7 +- 16 files changed, 170 insertions(+), 214 deletions(-) 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 @@ - + -