add inputtype
This commit is contained in:
parent
6b1040b8a2
commit
8e8999dd7a
@ -44,9 +44,9 @@ import pub.doric.extension.bridge.DoricPromise;
|
|||||||
*/
|
*/
|
||||||
@DoricPlugin(name = "Input")
|
@DoricPlugin(name = "Input")
|
||||||
public class InputNode extends ViewNode<EditText> implements TextWatcher, View.OnFocusChangeListener {
|
public class InputNode extends ViewNode<EditText> implements TextWatcher, View.OnFocusChangeListener {
|
||||||
|
private final InputMethodManager mInputMethodManager;
|
||||||
private String onTextChangeId;
|
private String onTextChangeId;
|
||||||
private String onFocusChangeId;
|
private String onFocusChangeId;
|
||||||
private final InputMethodManager mInputMethodManager;
|
|
||||||
|
|
||||||
public InputNode(DoricContext doricContext) {
|
public InputNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
@ -121,6 +121,24 @@ public class InputNode extends ViewNode<EditText> implements TextWatcher, View.O
|
|||||||
onFocusChangeId = null;
|
onFocusChangeId = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "inputType":
|
||||||
|
if (prop.isNumber()) {
|
||||||
|
switch (prop.asNumber().toInt()) {
|
||||||
|
case 1:
|
||||||
|
mView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
mView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
mView.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
super.blend(view, name, prop);
|
super.blend(view, name, prop);
|
||||||
break;
|
break;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Panel, Group, scroller, vlayout, layoutConfig, LayoutSpec, Input, Gravity, log, input, text, Color, Text } from "doric";
|
import { Panel, Group, scroller, vlayout, layoutConfig, LayoutSpec, Input, Gravity, log, input, text, Color, Text, InputType } from "doric";
|
||||||
import { title } from "./utils";
|
import { title } from "./utils";
|
||||||
@Entry
|
@Entry
|
||||||
class TextDemo extends Panel {
|
class TextDemo extends Panel {
|
||||||
@ -7,6 +7,35 @@ class TextDemo extends Panel {
|
|||||||
vlayout(
|
vlayout(
|
||||||
[
|
[
|
||||||
title("Text Demo"),
|
title("Text Demo"),
|
||||||
|
input({
|
||||||
|
width : 100,
|
||||||
|
height:100,
|
||||||
|
inputType: InputType.Number,
|
||||||
|
hintText: "number"
|
||||||
|
}),
|
||||||
|
|
||||||
|
// input({
|
||||||
|
// width : 100,
|
||||||
|
// height:100,
|
||||||
|
// inputType: InputType.NumberSigned,
|
||||||
|
// hintText: "NumberSigned"
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// input({
|
||||||
|
// width : 100,
|
||||||
|
// height:100,
|
||||||
|
// inputType: InputType.Alphabet,
|
||||||
|
// hintText: "Alphabet"
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// input({
|
||||||
|
// width : 100,
|
||||||
|
// height:100,
|
||||||
|
// inputType: InputType.Phone,
|
||||||
|
// hintText: "Phone"
|
||||||
|
|
||||||
|
// }),
|
||||||
|
|
||||||
text({
|
text({
|
||||||
text: "This is normal text",
|
text: "This is normal text",
|
||||||
}),
|
}),
|
||||||
|
@ -132,7 +132,31 @@ - (void)blendView:(DoricInputView *)view forPropName:(NSString *)name propValue:
|
|||||||
|
|
||||||
} else if ([name isEqualToString:@"maxLength"]) {
|
} else if ([name isEqualToString:@"maxLength"]) {
|
||||||
self.maxLength = prop;
|
self.maxLength = prop;
|
||||||
} else {
|
}
|
||||||
|
else if([name isEqualToString:@"inputType"]){
|
||||||
|
switch ([prop integerValue]) {
|
||||||
|
case 1: {
|
||||||
|
// [self.view setKeyboardType: UIKeyboardTypeNumberPad ];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
[self.view setKeyboardType: UIKeyboardTypeDecimalPad];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
[self.view setKeyboardType: UIKeyboardTypeAlphabet];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
[self.view setKeyboardType: UIKeyboardTypePhonePad];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
[super blendView:view forPropName:name propValue:prop];
|
[super blendView:view forPropName:name propValue:prop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
doric-js/index.d.ts
vendored
8
doric-js/index.d.ts
vendored
@ -705,6 +705,7 @@ declare module 'doric/lib/src/widget/input' {
|
|||||||
textColor?: Color;
|
textColor?: Color;
|
||||||
textSize?: number;
|
textSize?: number;
|
||||||
hintText?: string;
|
hintText?: string;
|
||||||
|
inputType?: InputType;
|
||||||
hintTextColor?: Color;
|
hintTextColor?: Color;
|
||||||
multiline?: boolean;
|
multiline?: boolean;
|
||||||
textAlignment?: Gravity;
|
textAlignment?: Gravity;
|
||||||
@ -716,6 +717,13 @@ declare module 'doric/lib/src/widget/input' {
|
|||||||
requestFocus(context: BridgeContext): Promise<any>;
|
requestFocus(context: BridgeContext): Promise<any>;
|
||||||
releaseFocus(context: BridgeContext): Promise<any>;
|
releaseFocus(context: BridgeContext): Promise<any>;
|
||||||
}
|
}
|
||||||
|
export enum InputType {
|
||||||
|
Default = 0,
|
||||||
|
Number = 1,
|
||||||
|
NumberSigned = 2,
|
||||||
|
Alphabet = 3,
|
||||||
|
Phone = 4
|
||||||
|
}
|
||||||
export function input(config: Partial<Input>): Input;
|
export function input(config: Partial<Input>): Input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user