Implemented placeholder-color for text-view IOS

This commit is contained in:
vakrilov
2017-03-10 17:00:03 +02:00
parent 629eb6e683
commit 84819f6c9a
6 changed files with 104 additions and 25 deletions

View File

@ -0,0 +1,32 @@
import { Page } from "tns-core-modules/ui/page";
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) {
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 = "";
})
}

View File

@ -0,0 +1,24 @@
<Page>
<Page.actionBar>
<ActionBar title="TextView hint color"/>
</Page.actionBar>
<StackLayout id="container">
<Label text="TextView:" />
<TextView hint="nothing" fontSize="18" />
<TextView hint="placeholder-color" style="placeholder-color: green;" fontSize="18" />
<TextView hint="color" style="color: blue;" fontSize="18" />
<TextView hint="both" style="color: blue; placeholder-color: green;" fontSize="18" />
<Label text="TextField:" />
<TextField hint="nothing" fontSize="18" />
<TextField hint="placeholder-color" style="placeholder-color: green;" fontSize="18" />
<TextField hint="color" style="color: blue;" fontSize="18" />
<TextField hint="both" style="color: blue; placeholder-color: green;" fontSize="18" />
<StackLayout orientation="horizontal">
<Button id="btnSetText" text="set text" tap="setText" width="80"/>
<Button id="btnResetStyles" text="reset style" tap="resetStyles" width="80"/>
<Button id="btnClearText" text="reset text" tap="resetText" width="80"/>
</StackLayout>
</StackLayout>
</Page>

View File

@ -43,6 +43,7 @@ export function pageLoaded(args: EventData) {
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");
examples.set("hint-text-color", "css/hint-text-color");
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel;

View File

@ -5,10 +5,13 @@
<StackLayout>
<Label text="Should change text and color" />
<TextView id="tv1Hint" hint="hint1 pink" text="" color="pink" fontSize="32" />
<Label text="Should change apply text" />
<TextView id="tv2Hint" hint="hint2 orange" color="orange" fontSize="32" />
<Label text="Should change only color of hint" />
<TextView id="tv3Hint" hint="hint3 blue" color="blue" fontSize="32" />
<Button id="btn" text="Change text and color" tap="changeTextAndColor"/>
</StackLayout>
</Page>