Skip to content

Commit 76e0426

Browse files
authored
adds attributes (#75)
1 parent d4f2ba8 commit 76e0426

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/components/View/RNView.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
CursorShape,
66
NodeWidget,
77
QIcon,
8-
FlexLayout
8+
FlexLayout,
9+
WidgetAttribute
910
} from "@nodegui/nodegui";
1011
import { RNWidget, RNProps } from "../config";
1112

@@ -106,6 +107,11 @@ export interface ViewProps extends RNProps {
106107
* Prop to set the ref. The ref will return the underlying nodegui widget.
107108
*/
108109
ref?: any;
110+
/**
111+
* Prop to set the Widget Attributes. example:
112+
* <View attributes={{Qt::WA_Disabled: true}} />
113+
*/
114+
attributes?: WidgetAttributesMap;
109115
}
110116

111117
/**
@@ -128,6 +134,7 @@ export const setViewProps = (
128134
console.warn("Both styleSheet and inlineStyle can't be used together");
129135
}
130136
widget.setInlineStyle(inlineStyle);
137+
console.log(inlineStyle);
131138
},
132139
set geometry(geometry: Geometry) {
133140
widget.setGeometry(
@@ -202,6 +209,11 @@ export const setViewProps = (
202209
widget.addEventListener(eventType, newEvtListener);
203210
}
204211
);
212+
},
213+
set attributes(attributesMap: WidgetAttributesMap) {
214+
Object.entries(attributesMap).forEach(([attribute, value]) => {
215+
widget.setAttribute(Number(attribute), value);
216+
});
205217
}
206218
};
207219
Object.assign(setter, newProps);
@@ -269,3 +281,7 @@ type Position = {
269281
interface ListenerMap {
270282
[key: string]: (payload?: any) => void;
271283
}
284+
285+
type WidgetAttributesMap = {
286+
[key: number]: boolean;
287+
};

0 commit comments

Comments
 (0)