手电筒视图优化
authorluozheng <1732036298@qq.com>
Fri, 7 Jun 2024 10:06:59 +0000 (18:06 +0800)
committerluozheng <1732036298@qq.com>
Fri, 7 Jun 2024 10:06:59 +0000 (18:06 +0800)
code/sdk/application/wearable/fd230app/nativeui/flashlight/include/FlashlightPresenter.h
code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightView.cpp

index 440250d..2d5b46e 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-10 17:32:31
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-10 19:36:50
+ * @LastEditTime: 2024-06-07 17:52:25
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/flashligh/include/FlashlightPresenter.h
  */
 
@@ -38,6 +38,7 @@ namespace OHOS
         bool OnDrag(UIView &view, const DragEvent &event) override;
         bool OnDragEnd(UIView &view, const DragEvent &event) override;
         bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+        bool X_DRAG_FLAG{false};
     };
 }
 
index a6cb957..d96dc1a 100644 (file)
@@ -2,12 +2,13 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-10 17:32:38
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-07 10:37:20
+ * @LastEditTime: 2024-06-07 17:56:29
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/flashligh/src/FlashlightPresenter.cpp
  */
 
 #include "AppViewIDs.h"
 #include "NativeAbility.h"
+#include "UiConfig.h"
 #include "flashlight/include/FlashlightPresenter.h"
 #include "flashlight/include/FlashlightModel.h"
 #include "common/key_code.h"
@@ -56,23 +57,30 @@ namespace OHOS
 
     bool FlashlightPresenter::OnDrag(UIView &view, const DragEvent &event)
     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DnotDisturbPresenter::OnDrag");
         UNUSED(view);
-        UNUSED(event);
+        if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+        {
+            FlashlightPresenter::X_DRAG_FLAG = true;
+        }
         return true;
     }
 
     bool FlashlightPresenter::OnDragEnd(UIView &view, const DragEvent &event)
     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DnotDisturbPresenter::OnDragEnd");
         UNUSED(view);
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && FlashlightPresenter::X_DRAG_FLAG)
         {
-            NativeAbility::GetInstance().Back();
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+            X_DRAG_FLAG = false;
         }
         return true;
     }
 
     bool FlashlightPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DnotDisturbPresenter::OnClick");
         UNUSED(event);
         if (&view == FlashlightView::GetInstance()->GetGroupView())
         {
index 11eccc4..60bc2b7 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-10 17:32:08
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-10 21:22:43
+ * @LastEditTime: 2024-06-07 18:04:33
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/flashligh/src/FlashlightView.cpp
  */
 #include "flashlight/include/FlashlightView.h"
@@ -133,6 +133,7 @@ namespace OHOS
         group->Add(FlashlightVector);
         group->Add(LineImage);
         RootView::GetInstance()->Add(group);
+        container_ = group;
         Draw();
     }