diff --git a/doric-Qt/example/app/demo/DoricDemoBridge.cpp b/doric-Qt/example/app/demo/DoricDemoBridge.cpp
index 87370209..128b6c64 100644
--- a/doric-Qt/example/app/demo/DoricDemoBridge.cpp
+++ b/doric-Qt/example/app/demo/DoricDemoBridge.cpp
@@ -58,6 +58,9 @@ void DoricDemoBridge::navigate(QVariant route) {
name = "StorageDemo.js";
break;
case 14:
+ name = "SwitchDemo.js";
+ break;
+ case 15:
name = "TextDemo.js";
break;
}
diff --git a/doric-Qt/example/app/main.qml b/doric-Qt/example/app/main.qml
index 8811add5..7904ad87 100644
--- a/doric-Qt/example/app/main.qml
+++ b/doric-Qt/example/app/main.qml
@@ -15,7 +15,7 @@ ApplicationWindow {
ListView {
width: parent.width
- model: 15
+ model: 16
delegate: Rectangle {
Column {
anchors.centerIn: parent
@@ -51,6 +51,8 @@ ApplicationWindow {
case 13:
return "StorageDemo.js"
case 14:
+ return "SwitchDemo.js"
+ case 15:
return "TextDemo.js"
}
}
diff --git a/doric-Qt/example/app/qml.qrc b/doric-Qt/example/app/qml.qrc
index e83c096e..4b6147c5 100644
--- a/doric-Qt/example/app/qml.qrc
+++ b/doric-Qt/example/app/qml.qrc
@@ -23,6 +23,7 @@
../../../doric-demo/bundle/src/ScrollerDemo.js
../../../doric-demo/bundle/src/Snake.js
../../../doric-demo/bundle/src/StorageDemo.js
+ ../../../doric-demo/bundle/src/SwitchDemo.js
../../../doric-demo/bundle/src/TextDemo.js
@@ -41,6 +42,7 @@
../doric/resources/image.qml
../doric/resources/slider.qml
../doric/resources/input.qml
+ ../doric/resources/switch.qml
../doric/resources/toast.qml
../doric/resources/alert.qml
diff --git a/doric-Qt/example/doric/DoricRegistry.cpp b/doric-Qt/example/doric/DoricRegistry.cpp
index 0bd0bf87..cadcccdd 100644
--- a/doric-Qt/example/doric/DoricRegistry.cpp
+++ b/doric-Qt/example/doric/DoricRegistry.cpp
@@ -13,6 +13,7 @@
#include "shader/DoricRootNode.h"
#include "shader/DoricScrollerNode.h"
#include "shader/DoricStackNode.h"
+#include "shader/DoricSwitchNode.h"
#include "shader/DoricTextNode.h"
#include "shader/DoricVLayoutNode.h"
#include "shader/slider/DoricSlideItemNode.h"
@@ -35,6 +36,7 @@ DoricRegistry::DoricRegistry() {
registerViewNode("Slider");
registerViewNode("SlideItem");
registerViewNode("Input");
+ registerViewNode("Switch");
}
bool DoricRegistry::acquirePluginInfo(QString name) {
diff --git a/doric-Qt/example/doric/doric.pro b/doric-Qt/example/doric/doric.pro
index 033f3a81..783f2ee4 100644
--- a/doric-Qt/example/doric/doric.pro
+++ b/doric-Qt/example/doric/doric.pro
@@ -50,6 +50,7 @@ SOURCES += \
shader/DoricScrollerNode.cpp \
shader/DoricStackNode.cpp \
shader/DoricSuperNode.cpp \
+ shader/DoricSwitchNode.cpp \
shader/DoricTextNode.cpp \
shader/DoricVLayoutNode.cpp \
shader/DoricViewNode.cpp \
@@ -130,6 +131,7 @@ HEADERS += \
shader/DoricScrollerNode.h \
shader/DoricStackNode.h \
shader/DoricSuperNode.h \
+ shader/DoricSwitchNode.h \
shader/DoricTextNode.h \
shader/DoricVLayoutNode.h \
shader/DoricViewNode.h \
diff --git a/doric-Qt/example/doric/resources/switch.qml b/doric-Qt/example/doric/resources/switch.qml
new file mode 100644
index 00000000..617705aa
--- /dev/null
+++ b/doric-Qt/example/doric/resources/switch.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.12
+import QtQuick.Controls 2.5
+
+Switch {
+
+}
diff --git a/doric-Qt/example/doric/shader/DoricSwitchNode.cpp b/doric-Qt/example/doric/shader/DoricSwitchNode.cpp
new file mode 100644
index 00000000..4d93bba5
--- /dev/null
+++ b/doric-Qt/example/doric/shader/DoricSwitchNode.cpp
@@ -0,0 +1,36 @@
+#include "DoricSwitchNode.h"
+
+#include "../utils/DoricUtils.h"
+
+QQuickItem *DoricSwitchNode::build() {
+ QQmlComponent component(getContext()->getQmlEngine());
+
+ const QUrl url(QStringLiteral("qrc:/doric/qml/switch.qml"));
+ component.loadUrl(url);
+
+ if (component.isError()) {
+ qCritical() << component.errorString();
+ }
+
+ QQuickItem *item = qobject_cast(component.create());
+ this->createLayouts(item);
+
+ item->setProperty("wrapper", QString::number((qint64)this));
+ return item;
+}
+
+void DoricSwitchNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
+ if (name == "state") {
+
+ } else if (name == "onSwitch") {
+
+ } else if (name == "offTintColor") {
+
+ } else if (name == "onTintColor") {
+
+ } else if (name == "thumbTintColor") {
+
+ } else {
+ DoricViewNode::blend(view, name, prop);
+ }
+}
diff --git a/doric-Qt/example/doric/shader/DoricSwitchNode.h b/doric-Qt/example/doric/shader/DoricSwitchNode.h
new file mode 100644
index 00000000..2ae296ea
--- /dev/null
+++ b/doric-Qt/example/doric/shader/DoricSwitchNode.h
@@ -0,0 +1,17 @@
+#ifndef DORICSWITCHNODE_H
+#define DORICSWITCHNODE_H
+
+#include "DoricExport.h"
+
+#include "DoricViewNode.h"
+
+class DORIC_EXPORT DoricSwitchNode : public DoricViewNode {
+public:
+ using DoricViewNode::DoricViewNode;
+
+ QQuickItem *build() override;
+
+ virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
+};
+
+#endif // DORICSWITCHNODE_H