mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00

TKUnit default message change to empty string isSet method is now instance method of Property classes fix detaching from parent bindingContext - were using oldParent.parent instead of parent editable-text-base.android - onTextChanged implementation commented. Does nothing. frame - onCreateView wrapped in try/catch and shows label with exception message if any text-base.android - should support reset of nativeView. TransformationMethod won’t be set if TextField is secure Change some types to their string couterparts TextField.android won’t support multilines anymore in order to work as iOS In android when page is removed from native backstack we won’t call tearDownUI again a second time
58 lines
2.6 KiB
TypeScript
58 lines
2.6 KiB
TypeScript
import { TextFieldBase, secureProperty, whiteSpaceProperty, WhiteSpace } from "./text-field-common";
|
|
|
|
export * from "./text-field-common";
|
|
|
|
export class TextField extends TextFieldBase {
|
|
public _configureEditText() {
|
|
let nativeView = this.android;
|
|
nativeView.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
|
nativeView.setLines(1);
|
|
nativeView.setMaxLines(1);
|
|
nativeView.setHorizontallyScrolling(true);
|
|
}
|
|
|
|
public _onReturnPress() {
|
|
this.notify({ eventName: TextField.returnPressEvent, object: this })
|
|
}
|
|
|
|
get [secureProperty.native](): boolean {
|
|
return false;
|
|
}
|
|
set [secureProperty.native](value: boolean) {
|
|
const nativeView = this.nativeView;
|
|
const currentInputType = nativeView.getInputType();
|
|
const currentClass = currentInputType & android.text.InputType.TYPE_MASK_CLASS;
|
|
const currentFlags = currentInputType & android.text.InputType.TYPE_MASK_FLAGS;
|
|
let newInputType = currentInputType;
|
|
|
|
// Password variations are supported only for Text and Number classes.
|
|
if (value) {
|
|
if (currentClass === android.text.InputType.TYPE_CLASS_TEXT) {
|
|
newInputType = currentClass | currentFlags | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
|
}
|
|
else if (currentClass === android.text.InputType.TYPE_CLASS_NUMBER) {
|
|
newInputType = currentClass | currentFlags | android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD;
|
|
}
|
|
|
|
// Lower all autocapitalization bits, because password bits don't like them and we will receive "Unsupported input type: 16513" error for example.
|
|
newInputType = newInputType & ~28672; //28672 (0x0070000) 13,14,15 bits (111 0000 0000 0000)
|
|
}
|
|
else {
|
|
if (currentClass === android.text.InputType.TYPE_CLASS_TEXT) {
|
|
newInputType = currentClass | currentFlags | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL;
|
|
}
|
|
else if (currentClass === android.text.InputType.TYPE_CLASS_NUMBER) {
|
|
newInputType = currentClass | currentFlags | android.text.InputType.TYPE_NUMBER_VARIATION_NORMAL;
|
|
}
|
|
}
|
|
|
|
nativeView.setInputType(newInputType);
|
|
}
|
|
|
|
get [whiteSpaceProperty.native](): WhiteSpace {
|
|
return "nowrap";
|
|
}
|
|
set [whiteSpaceProperty.native](value: WhiteSpace) {
|
|
// Don't change it otherwise TextField will go to multiline mode.
|
|
}
|
|
} |