1- import { QPushButton , QIcon , NodeWidget } from "@nodegui/nodegui" ;
1+ import { NodeWidget } from "@nodegui/nodegui" ;
22import { Fiber } from "react-reconciler" ;
3- import { ViewProps , setProps as setViewProps } from "../View" ;
43import { registerComponent , ComponentConfig } from "../config" ;
5- interface ButtonProps extends ViewProps {
6- text ?: string ;
7- flat ?: boolean ;
8- icon ?: QIcon ;
9- }
10-
11- const setProps = (
12- widget : QPushButton ,
13- newProps : ButtonProps ,
14- oldProps : ButtonProps
15- ) => {
16- const setter : ButtonProps = {
17- set text ( buttonText : string ) {
18- widget . setText ( buttonText ) ;
19- } ,
20- set flat ( isFlat : boolean ) {
21- widget . setFlat ( isFlat ) ;
22- } ,
23- set icon ( icon : QIcon ) {
24- widget . setIcon ( icon ) ;
25- }
26- } ;
27- Object . assign ( setter , newProps ) ;
28- setViewProps ( widget , newProps , oldProps ) ;
29- } ;
4+ import { setProps , ButtonProps , RNButton } from "./RNButton" ;
305
316class ButtonConfig extends ComponentConfig {
32- id = "button" ;
7+ tagName = RNButton . tagName ;
338 shouldSetTextContent ( nextProps : object ) : boolean {
349 return true ;
3510 }
@@ -39,7 +14,7 @@ class ButtonConfig extends ComponentConfig {
3914 context : any ,
4015 workInProgress : Fiber
4116 ) : NodeWidget {
42- const widget = new QPushButton ( ) ;
17+ const widget = new RNButton ( ) ;
4318 setProps ( widget , newProps , { } ) ;
4419 return widget ;
4520 }
@@ -50,7 +25,7 @@ class ButtonConfig extends ComponentConfig {
5025 newProps : object ,
5126 finishedWork : Fiber
5227 ) : void {
53- setProps ( instance as QPushButton , newProps , oldProps ) ;
28+ setProps ( instance as RNButton , newProps , oldProps ) ;
5429 }
5530}
5631
0 commit comments