diff --git a/doric-android/doric/src/main/java/pub/doric/shader/InputNode.java b/doric-android/doric/src/main/java/pub/doric/shader/InputNode.java index 680df674..41c75409 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/InputNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/InputNode.java @@ -190,6 +190,37 @@ public class InputNode extends ViewNode implements TextWatcher, View.O } break; + case "editable": + if (prop.isBoolean()) { + view.setEnabled(prop.asBoolean().value()); + } + break; + case "returnKeyType": + if (prop.isNumber()) { + int returnKeyType = prop.asNumber().toInt(); + switch (returnKeyType) { + case 1: + view.setImeOptions(EditorInfo.IME_ACTION_DONE); + break; + case 2: + view.setImeOptions(EditorInfo.IME_ACTION_SEARCH); + break; + case 3: + view.setImeOptions(EditorInfo.IME_ACTION_NEXT); + break; + case 4: + view.setImeOptions(EditorInfo.IME_ACTION_GO); + break; + case 5: + view.setImeOptions(EditorInfo.IME_ACTION_SEND); + break; + case 0: + default: + view.setImeOptions(EditorInfo.IME_ACTION_UNSPECIFIED); + break; + } + } + break; default: super.blend(view, name, prop); break; diff --git a/doric-demo/src/ListInSliderDemo.ts b/doric-demo/src/ListInSliderDemo.ts new file mode 100644 index 00000000..f6833c54 --- /dev/null +++ b/doric-demo/src/ListInSliderDemo.ts @@ -0,0 +1,40 @@ +import { Color, Group, layoutConfig, list, listItem, modal, Panel, slider, stack, text } from "doric"; + +@Entry +class ListInSlider extends Panel { + build(root: Group) { + slider({ + layoutConfig: layoutConfig().most(), + itemCount: 2, + renderPage: (idx) => { + if (idx === 0) { + return listItem( + list({ + itemCount: 100, + layoutConfig: layoutConfig().most(), + renderItem: (idx) => { + return listItem( + text({ + text: `Item ${idx}`, + onClick: () => { + modal(context).alert(`Clicked ${idx}`) + } + })) + } + }), + { + layoutConfig: layoutConfig().most(), + }) + } + return listItem( + stack([], { + layoutConfig: layoutConfig().most(), + backgroundColor: idx === 0 ? Color.BLUE : Color.GREEN, + }), + { + layoutConfig: layoutConfig().most(), + }) + } + }).in(root) + } +} \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m index 691ce60e..ceb9e335 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m @@ -157,7 +157,31 @@ - (void)blendView:(DoricInputView *)view forPropName:(NSString *)name propValue: } } } else if ([name isEqualToString:@"password"]) { - self.view.secureTextEntry = [(NSNumber *) prop boolValue]; + view.secureTextEntry = [(NSNumber *) prop boolValue]; + } else if ([name isEqualToString:@"editable"]) { + view.editable = [(NSNumber *) prop boolValue]; + } else if ([name isEqualToString:@"returnKeyType"]) { + switch ([(NSNumber *) prop integerValue]) { + case 1: + view.returnKeyType = UIReturnKeyDone; + break; + case 2: + view.returnKeyType = UIReturnKeySearch; + break; + case 3: + view.returnKeyType = UIReturnKeyNext; + break; + case 4: + view.returnKeyType = UIReturnKeyGo; + break; + case 5: + view.returnKeyType = UIReturnKeySend; + break; + case 0: + default: + view.returnKeyType = UIReturnKeyDefault; + break; + } } else { [super blendView:view forPropName:name propValue:prop]; } diff --git a/doric-js/src/widget/input.ts b/doric-js/src/widget/input.ts index 90d65ed0..98ae0f0f 100644 --- a/doric-js/src/widget/input.ts +++ b/doric-js/src/widget/input.ts @@ -19,6 +19,15 @@ import { Gravity } from "../util/gravity"; import { BridgeContext } from "../runtime/global"; import { layoutConfig } from "../util/index.util"; +export enum ReturnKeyType { + Default = 0, + Done = 1, + Search = 2, + Next = 3, + Go = 4, + Send = 5, +} + export class Input extends View { @InconsistProperty @@ -57,6 +66,12 @@ export class Input extends View { @Property password?: boolean + @Property + editable?: boolean + + @Property + returnKeyType?: ReturnKeyType + getText(context: BridgeContext) { return this.nativeChannel(context, 'getText')() as Promise }