add switch bridge
This commit is contained in:
@@ -25,7 +25,7 @@ void DoricSwitchNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
view->setProperty("checked", prop.toBool());
|
||||
checkByCodeToggle = false;
|
||||
} else if (name == "onSwitch") {
|
||||
|
||||
onSwitchFuncId = prop.toString();
|
||||
} else if (name == "offTintColor") {
|
||||
view->setProperty(
|
||||
"offTintColor",
|
||||
@@ -41,3 +41,13 @@ void DoricSwitchNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
DoricViewNode::blend(view, name, prop);
|
||||
}
|
||||
}
|
||||
|
||||
void DoricSwitchNode::onSwitch(bool checked) {
|
||||
if (checkByCodeToggle)
|
||||
return;
|
||||
if (!onSwitchFuncId.isEmpty()) {
|
||||
QVariantList args;
|
||||
args.append(checked);
|
||||
callJSResponse(onSwitchFuncId, args);
|
||||
}
|
||||
}
|
||||
|
@@ -10,12 +10,16 @@ class DORIC_EXPORT DoricSwitchNode : public DoricViewNode {
|
||||
private:
|
||||
bool checkByCodeToggle = false;
|
||||
|
||||
QString onSwitchFuncId;
|
||||
|
||||
public:
|
||||
using DoricViewNode::DoricViewNode;
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
|
||||
void onSwitch(bool checked);
|
||||
};
|
||||
|
||||
#endif // DORICSWITCHNODE_H
|
||||
|
Reference in New Issue
Block a user