mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
18
apps/ui/app/text-field/focus-blur-events-page.ts
Normal file
18
apps/ui/app/text-field/focus-blur-events-page.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { TextField, TextView } from '@nativescript/core';
|
||||
|
||||
export function onLoaded(args) {
|
||||
const page = args.object;
|
||||
const textField = <TextField>page.getViewById('textField');
|
||||
const textView = <TextView>page.getViewById('textView');
|
||||
|
||||
attachToEvent(textField, 'blur');
|
||||
attachToEvent(textField, 'focus');
|
||||
attachToEvent(textView, 'blur');
|
||||
attachToEvent(textView, 'focus');
|
||||
}
|
||||
|
||||
function attachToEvent(control, event) {
|
||||
control.on(event, () => {
|
||||
control.text = event + ' is thrown';
|
||||
});
|
||||
}
|
||||
9
apps/ui/app/text-field/focus-blur-events-page.xml
Normal file
9
apps/ui/app/text-field/focus-blur-events-page.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="onLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="focus blur events"/>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
<TextField id="textField" hint="text field"/>
|
||||
<TextView id="textView" hint="text view"/>
|
||||
</StackLayout>
|
||||
</Page>
|
||||
18
apps/ui/app/text-field/main-page.ts
Normal file
18
apps/ui/app/text-field/main-page.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { EventData, WrapLayout, Page } from '@nativescript/core';
|
||||
import { SubMainPageViewModel } from '../sub-main-page-view-model';
|
||||
|
||||
export function pageLoaded(args: EventData) {
|
||||
const page = <Page>args.object;
|
||||
const wrapLayout = <WrapLayout>page.getViewById('wrapLayoutWithExamples');
|
||||
page.bindingContext = new SubMainPageViewModel(wrapLayout, loadExamples());
|
||||
}
|
||||
|
||||
export function loadExamples() {
|
||||
const examples = new Map<string, string>();
|
||||
examples.set('secured-text-field', 'text-field/secured-text-field-4135-page');
|
||||
examples.set('max-length', 'text-field/max-length-page');
|
||||
examples.set('text-field-border', 'text-field/text-field-border-page');
|
||||
examples.set('focus-blur-events', 'text-field/focus-blur-events-page');
|
||||
|
||||
return examples;
|
||||
}
|
||||
6
apps/ui/app/text-field/main-page.xml
Normal file
6
apps/ui/app/text-field/main-page.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Page loaded="pageLoaded">
|
||||
<ScrollView orientation="vertical" row="1">
|
||||
<WrapLayout id="wrapLayoutWithExamples"/>
|
||||
</ScrollView>
|
||||
</Page>
|
||||
29
apps/ui/app/text-field/max-length-page.ts
Normal file
29
apps/ui/app/text-field/max-length-page.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Page, TextField } from '@nativescript/core';
|
||||
|
||||
export function setText(args) {
|
||||
let page = args;
|
||||
|
||||
if (page.constructor.name !== 'Page') {
|
||||
page = args.object.page;
|
||||
setTextFieldText(page, 'inXml', 'in xml');
|
||||
}
|
||||
|
||||
setTextFieldText(page, 'maxLenghtFromCodeBehindWithText', 'from code behind');
|
||||
setTextFieldText(page, 'useInput', '');
|
||||
setTextFieldText(page, 'maxLenghtFromCodeBehind', '');
|
||||
}
|
||||
|
||||
export function pageLoaded(args) {
|
||||
const page = args.object;
|
||||
setText(page);
|
||||
}
|
||||
|
||||
function setTextFieldText(page: Page, name: string, text: string) {
|
||||
const textField = <TextField>page.getViewById(name);
|
||||
|
||||
if (name === 'maxLenghtFromCodeBehind' || name === 'maxLenghtFromCodeBehindWithText') {
|
||||
textField.maxLength = 3;
|
||||
}
|
||||
|
||||
textField.text = text;
|
||||
}
|
||||
13
apps/ui/app/text-field/max-length-page.xml
Normal file
13
apps/ui/app/text-field/max-length-page.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="maxLength" />
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
<TextField autocorrect="false" id="maxLenghtFromCodeBehindWithText" hint="max lenght and text from code behind" maxLength="3" />
|
||||
<TextField autocorrect="false" id="maxLenghtFromCodeBehind" hint="set only max length from code behind" />
|
||||
<TextField autocorrect="false" id="inXml" text="in xml" hint="in xml" maxLength="3" />
|
||||
<TextField autocorrect="false" id="useInput" hint="user input" maxLength="3" />
|
||||
<TextField autocorrect="false" id="useInput" hint="secured" maxLength="3" secure="true" />
|
||||
<Button tap="setText" text="Revert to initial state" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
11
apps/ui/app/text-field/secured-text-field-4135-page.ts
Normal file
11
apps/ui/app/text-field/secured-text-field-4135-page.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as observable from '@nativescript/core/data/observable';
|
||||
|
||||
export function pageLoaded(args) {
|
||||
var page = args.object;
|
||||
var textFieldSecured = page.getViewById('textFieldSecured');
|
||||
textFieldSecured.secure = true;
|
||||
|
||||
var obj = new observable.Observable();
|
||||
obj.set('textProperty', 'text');
|
||||
page.bindingContext = obj;
|
||||
}
|
||||
11
apps/ui/app/text-field/secured-text-field-4135-page.xml
Normal file
11
apps/ui/app/text-field/secured-text-field-4135-page.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded">
|
||||
<StackLayout>
|
||||
<Label text="hint" />
|
||||
<TextField secure="true" text="test" hint="hint"></TextField>
|
||||
<TextField secure="true" text="text"></TextField>
|
||||
<TextField secure="true" hint="hint" maxLength="3" ></TextField>
|
||||
<Label text="bindings" />
|
||||
<TextField id="textField" automationText="textField" text="{{ textProperty }}" />
|
||||
<TextField id="textFieldSecured" automationText="textFieldSecured" text="{{ textProperty }}" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
101
apps/ui/app/text-field/text-field-border-page.css
Normal file
101
apps/ui/app/text-field/text-field-border-page.css
Normal file
@@ -0,0 +1,101 @@
|
||||
TextField {
|
||||
font-size: 6;
|
||||
width: 80;
|
||||
height: 80;
|
||||
}
|
||||
|
||||
#s0 {
|
||||
border-width: 5;
|
||||
}
|
||||
|
||||
#s1 {
|
||||
border-width: 5;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
#s2 {
|
||||
border-width: 5;
|
||||
border-color: red red red green;
|
||||
}
|
||||
|
||||
#s3 {
|
||||
border-width: 5;
|
||||
border-color: red;
|
||||
border-radius: 5;
|
||||
}
|
||||
|
||||
#s4 {
|
||||
border-width: 5;
|
||||
border-color: red;
|
||||
border-radius: 50;
|
||||
}
|
||||
|
||||
#s5 {
|
||||
border-width: 5 10 15 20;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
#s6 {
|
||||
border-width: 5;
|
||||
border-color: red green blue yellow;
|
||||
}
|
||||
|
||||
#s7 {
|
||||
border-width: 5 10 15 20;
|
||||
border-color: red green blue yellow;
|
||||
}
|
||||
|
||||
#s8 {
|
||||
border-width: 5 10;
|
||||
border-color: red green;
|
||||
}
|
||||
|
||||
#s9 {
|
||||
border-width: 15 10 5;
|
||||
border-color: red green blue;
|
||||
}
|
||||
|
||||
#s10 {
|
||||
border-width: 5 0;
|
||||
border-color: black;
|
||||
}
|
||||
|
||||
#s11 {
|
||||
background-color: magenta;
|
||||
}
|
||||
|
||||
#s12 {
|
||||
border-width: 5 10 15 20;
|
||||
border-color: red green blue yellow;
|
||||
border-radius: 5 10 15 20;
|
||||
}
|
||||
|
||||
#s13 {
|
||||
border-width: 5 10 15 20;
|
||||
border-color: red green blue yellow;
|
||||
border-radius: 5;
|
||||
}
|
||||
|
||||
#s14 {
|
||||
border-width: 5 10 15 20;
|
||||
border-color: red green blue yellow;
|
||||
background-color: magenta;
|
||||
}
|
||||
|
||||
#s15 {
|
||||
border-width: 5 10 15 20;
|
||||
border-color: red green blue yellow;
|
||||
background-image: url('~/resources/images/test2.png');
|
||||
}
|
||||
|
||||
#s16 {
|
||||
border-width: 5;
|
||||
border-color: red;
|
||||
padding: 5;
|
||||
}
|
||||
|
||||
#s17 {
|
||||
border-width: 5 6 7 8;
|
||||
border-color: red green blue yellow;
|
||||
padding: 5 6 7 8;
|
||||
}
|
||||
22
apps/ui/app/text-field/text-field-border-page.xml
Normal file
22
apps/ui/app/text-field/text-field-border-page.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<Page>
|
||||
<GridLayout rows="*,*,*,*,*,*" columns="*,*,*">
|
||||
<TextField id="s0" row="0" col="0" autocorrect="false" textWrap="true" text="border-width: 5;"/>
|
||||
<TextField id="s1" row="0" col="1" autocorrect="false" textWrap="true" text="border-width: 5; border-color: red;"/>
|
||||
<TextField id="s2" row="0" col="2" autocorrect="false" textWrap="true" text="border-width: 5; border-color: red red red green;"/>
|
||||
<TextField id="s3" row="1" col="0" autocorrect="false" textWrap="true" text="border-width: 5; border-color: red; border-radius: 5;"/>
|
||||
<TextField id="s4" row="1" col="1" autocorrect="false" textWrap="true" text="border-width: 5; border-color: red; border-radius: 50;"/>
|
||||
<TextField id="s5" row="1" col="2" autocorrect="false" textWrap="true" text="border-width: 5 10 15 20; border-color: red;"/>
|
||||
<TextField id="s6" row="2" col="0" autocorrect="false" textWrap="true" text="border-width: 5; border-color: red green blue yellow;"/>
|
||||
<TextField id="s7" row="2" col="1" autocorrect="false" textWrap="true" text="border-width: 5 10 15 20; border-color: red green blue yellow;"/>
|
||||
<TextField id="s8" row="2" col="2" autocorrect="false" textWrap="true" text="border-width: 5 10; border-color: red green;"/>
|
||||
<TextField id="s9" row="3" col="0" autocorrect="false" textWrap="true" text="border-width: 15 10 5; border-color: red green blue;"/>
|
||||
<TextField id="s10" row="3" col="1" autocorrect="false" textWrap="true" text="border-width: 5 0; border-color: black;"/>
|
||||
<TextField id="s11" row="3" col="2" autocorrect="false" textWrap="true" text="background-color: magenta;"/>
|
||||
<TextField id="s12" row="4" col="0" autocorrect="false" textWrap="true" text="border-width: 5 10 15 20; border-color: red green blue yellow; border-radius: 5 10 15 20;"/>
|
||||
<TextField id="s13" row="4" col="1" autocorrect="false" textWrap="true" text="border-width: 5 10 15 20; border-color: red green blue yellow; border-radius: 5;"/>
|
||||
<TextField id="s14" row="4" col="2" autocorrect="false" textWrap="true" text="border-width: 5 10 15 20; border-color: red green blue yellow; background-color: magenta;"/>
|
||||
<TextField id="s15" row="5" col="0" autocorrect="false" textWrap="true" text="border-width: 5 10 15 20; border-color: red green blue yellow; background-image: url('~/resources/images/test2.png');"/>
|
||||
<TextField id="s16" row="5" col="1" autocorrect="false" textWrap="true" text="border-width: 5; border-color: red; padding: 5;"/>
|
||||
<TextField id="s17" row="5" col="2" autocorrect="false" textWrap="true" text="border-width: 5 6 7 8; border-color: red green blue yellow; padding: 5 6 7 8;"/>
|
||||
</GridLayout>
|
||||
</Page>
|
||||
Reference in New Issue
Block a user