mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Implemented placeholder-color for text-view IOS
This commit is contained in:
32
apps/app/ui-tests-app/css/hint-text-color.ts
Normal file
32
apps/app/ui-tests-app/css/hint-text-color.ts
Normal 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 = "";
|
||||
})
|
||||
}
|
24
apps/app/ui-tests-app/css/hint-text-color.xml
Normal file
24
apps/app/ui-tests-app/css/hint-text-color.xml
Normal 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>
|
@ -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;
|
||||
|
@ -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>
|
Reference in New Issue
Block a user