-
-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathindex.ts
47 lines (45 loc) · 1.6 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Fiber } from "react-reconciler";
import { AppContainer } from "../../reconciler";
import { ComponentConfig, registerComponent } from "../config";
import { RNInputDialog, InputDialogProps } from "./RNInputDialog";
class InputDialogConfig extends ComponentConfig {
tagName: string = RNInputDialog.tagName;
shouldSetTextContent(nextProps: InputDialogProps): boolean {
return false;
}
createInstance(newProps: InputDialogProps, rootInstance: AppContainer, context: any, workInProgress: Fiber): RNInputDialog {
const widget = new RNInputDialog();
widget.setProps(newProps, {});
return widget;
}
commitMount(instance: RNInputDialog, newProps: InputDialogProps, internalInstanceHandle: any): void {
if (newProps.visible !== false && newProps.open !== false) {
instance.show();
}
return;
}
commitUpdate(instance: RNInputDialog, updatePayload: any, oldProps: InputDialogProps, newProps: InputDialogProps, finishedWork: Fiber): void {
instance.setProps(newProps, oldProps);
}
}
/**
* Pop up InputDialog inheriting the functionality of nodegui's `QInputDialog`
* @example
* ```javascript
* function DialogExample(props){
* const [open, setOpen] = useState(false);
* const events = useEventHandler<QInputDialogSignals>({
* textValueChanged(value){
* //....do whatever
* }
* }, [....deps])
* return (
* <View>
* <InputDialog open={open} on={events}/>
* <Button text="open dialog" on={{clicked:()=>setOpen(true)}}/>
* </View>
* )
* }
* ```
*/
export const InputDialog = registerComponent<InputDialogProps>(new InputDialogConfig());