系统视图左滑退出和其子视图分开
author罗正yun <1732036298@qq.com>
Thu, 25 Jan 2024 09:41:38 +0000 (17:41 +0800)
committer罗正yun <1732036298@qq.com>
Thu, 25 Jan 2024 09:41:38 +0000 (17:41 +0800)
code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp

index 7d23daf..d48e279 100644 (file)
@@ -7,8 +7,8 @@
 namespace OHOS\r
 {\r
 \r
-    static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文 \r
-    static const char *ENGLISH_CHECKBOX = "EnglishCheckBox";                      // English \r
+    static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文\r
+    static const char *ENGLISH_CHECKBOX = "EnglishCheckBox";                      // English\r
     class RadiobuttonOnChangeListener : public UICheckBox::OnChangeListener\r
     {\r
     public:\r
@@ -25,6 +25,16 @@ namespace OHOS
         UIRadioButton *m_uiView{nullptr};\r
     };\r
 \r
+    class SystemViewOnDragListener : public UIView::OnDragListener\r
+    {\r
+    public:\r
+        SystemViewOnDragListener() {}\r
+\r
+        ~SystemViewOnDragListener() {}\r
+\r
+        bool OnDrag(UIView &view, const DragEvent &event) override;\r
+    };\r
+\r
     class SystemView;\r
     class SystemPresenter : public Presenter<SystemView>,\r
                             public UIView::OnClickListener,\r
index 617357c..a7d67a6 100644 (file)
@@ -94,6 +94,16 @@ namespace OHOS
         return false;\r
     }\r
 \r
+    bool SystemViewOnDragListener::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&\r
+            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
+        }\r
+        return true;\r
+    }\r
+\r
     /// @brief 简体中文单选按钮被选中\r
     /// @param  void\r
     /// @return true 表示选中 ,false 表示未选中\r
index 52d180a..4760d3d 100644 (file)
@@ -64,7 +64,7 @@ namespace OHOS
         SystemScrollView[0]->SetScrollBlankSize(35);\r
         SystemScrollView[0]->SetReboundSize(50);\r
         SystemScrollView[0]->SetDirection(1);\r
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SystemPresenter::GetInstance());\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new SystemViewOnDragListener());\r
         if (draglistener == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!");\r