秒表视图添加退出动画
authorluozheng <1732036298@qq.com>
Fri, 7 Jun 2024 09:49:46 +0000 (17:49 +0800)
committerluozheng <1732036298@qq.com>
Fri, 7 Jun 2024 09:49:46 +0000 (17:49 +0800)
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h
code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp
code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h
code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp

index 0de9bc1..95175ac 100644 (file)
@@ -12,6 +12,7 @@
 #include "traing/include/TraingModel.h"
 #include "components/ui_hexagons_list.h"
 #include "TransitionType.h"
+#include "AppViewIDs.h"
 
 namespace OHOS {
     ApplistPresenter::ApplistPresenter()
@@ -84,7 +85,8 @@ namespace OHOS {
         AppViewId viewId = itemView->GetViewId();
         if (FloatMore(hexagonsView->GetGlobalScale(), 2.0f)) { // 2.0 threshold for beginning transition
             hexagonsView->StopRotateAnimator();
-            NativeAbility::GetInstance().ChangeSlice(viewId, TransitionType::TRANSITION_HEXAGONS);
+            //NativeAbility::GetInstance().ChangeSlice(viewId, TransitionType::TRANSITION_HEXAGONS);
+            NativeAbility::GetInstance().EnterSlice(viewId, TransitionType::TRANSITION_HEXAGONS);
             hexagonsView->ClearFocus();
         }
         return true;
@@ -117,7 +119,7 @@ namespace OHOS {
             hexagonsView->Scale(1.0f, itemView->GetViewIndex()); // switch focus to click view
             type = TransitionType::TRANSITION_HEXAGONS;
         }
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d", viewId);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d type = %d", viewId,type);
         if (viewId < VIEW_MAX_INTER_APP) {
             //NativeAbility::GetInstance().ChangeSlice(viewId, type);
             NativeAbility::GetInstance().EnterSlice(viewId, type);
index 2ef2793..500f1a0 100644 (file)
@@ -1,8 +1,9 @@
 /*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SetDesktopModel.h
- * Author:
- * Create: 2021-11-23
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-07 09:21:47
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-07 15:03:40
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h
  */
 
 #ifndef SET_DESKTOP_MODEL_H
@@ -15,8 +16,8 @@
 #include "SetDesktopPresenter.h"
 
 typedef enum {
-    APPLIST_STYLE,
-    HEXAGONS_STYLE,
+    APPLIST_STYLE,  //列表显示
+    HEXAGONS_STYLE, //蜂窝显示
 } DesktopStyle;
 
 namespace OHOS {
index 43c523e..c84a750 100644 (file)
@@ -1,8 +1,9 @@
 /*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: SettingModel.cpp
- * Author:
- * Create: 2021-11-23
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-07 09:21:47
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-07 11:17:14
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp
  */
 
 #include "SetDesktopModel.h"
@@ -21,6 +22,7 @@ namespace OHOS {
         return instance;
     }
 
+    //获取applist的显示样式
     DesktopStyle SetDesktopModel::GetDesktopStyle(void)
     {
         DesktopStyle style;
index 253b6a2..f866b60 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-04-04 15:13:51\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-04-07 17:22:21\r
+ * @LastEditTime: 2024-06-07 17:07:38\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h\r
  */\r
 #ifndef MAIN_STOPWATCH_PRESENTER_H\r
@@ -50,6 +50,7 @@ namespace OHOS
         // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
         bool OnClick(UIView &view, const ClickEvent &event) override;\r
         bool OnDrag(UIView &view, const DragEvent &event) override;\r
+        bool OnDragEnd(UIView &view, const DragEvent &event) override;\r
         bool OnChange(UICheckBox::UICheckBoxState state) override;\r
         bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
     private:\r
@@ -63,6 +64,7 @@ namespace OHOS
         List<const char *> *m_listdata = nullptr;\r
         uint64_t lastRecordTime = 0; // 上次记录时间\r
         int RecordCycleNumber{0};    // 用来记录计时圈数\r
+        bool X_DRAG_FLAG{false};\r
     };\r
 } // namespace OHOS\r
 \r
index 8b4c1c6..1c58e32 100644 (file)
@@ -1,5 +1,6 @@
 #include "AppViewIDs.h"\r
 #include "NativeAbility.h"\r
+#include "UiConfig.h"\r
 #include "stopwatch/include/MainStopWatchPresenter.h"\r
 #include "stopwatch/include/StopWatchModel.h"\r
 #include "common/key_code.h"\r
@@ -100,11 +101,23 @@ namespace OHOS
 \r
     bool MainStopWatchPresenter::OnDrag(UIView &view, const DragEvent &event)\r
     {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainStopWatchPresenter::OnDrag");\r
         UNUSED(view);\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
-            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
+        if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动\r
         {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);\r
+            MainStopWatchPresenter::X_DRAG_FLAG = true;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    bool MainStopWatchPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainStopWatchPresenter::OnDragEnd");\r
+        UNUSED(view);\r
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && MainStopWatchPresenter::X_DRAG_FLAG)\r
+        {\r
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+            X_DRAG_FLAG = false;\r
         }\r
         return true;\r
     }\r
@@ -274,10 +287,9 @@ namespace OHOS
         // 如果是power键就返回上一级\r
         if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)\r
         {\r
-            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
-            NativeAbility::GetInstance().ChangeSlice(preSlice);\r
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
         }\r
-        return true;\r
+        return false;\r
     }\r
 \r
 }
\ No newline at end of file
index b2d8ba4..165ae02 100644 (file)
@@ -390,6 +390,7 @@ namespace OHOS
         scrollView[MAIN_STOPWATCH]->Add(ResetOrMarkbutton);\r
         group->Add(scrollView[MAIN_STOPWATCH]);\r
         RootView::GetInstance()->Add(group);\r
+        container_ = group;\r
         Draw();\r
     }\r
 \r