修改表盘浏览特效界面
authorxue <2144439972@qq.com>
Mon, 30 Jun 2025 07:17:32 +0000 (15:17 +0800)
committerxue <2144439972@qq.com>
Mon, 30 Jun 2025 07:17:32 +0000 (15:17 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/include/SetDialStyleModel.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/include/SetDialStylePresenter.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/include/SetDialStyleView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/src/SetDialStyleModel.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/src/SetDialStylePresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp

index c27e300..042c7c0 100644 (file)
@@ -1,9 +1,4 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2024. All rights reserved.
- * Description: SetDialStyleModel.h
- * Author:
- * Create: 2024-06-06
- */
+
 
 #ifndef SET_DIAL_STYLE_MODEL_H
 #define SET_DIAL_STYLE_MODEL_H
@@ -28,7 +23,9 @@ private:
     struct {
         const DialStyle style;
         const char value[MAX_LEN];
-    } values_[static_cast<int>(DialStyle::STYLE_NUM)] = {
+    }
+
+    values_[static_cast<int>(DialStyle::STYLE_NUM)] = {
         {DialStyle::COVERFLOW, "DialStyle::COVERFLOW"},
         {DialStyle::ROLLER, "DialStyle::ROLLER"},
     };
index fda918e..8ab1288 100644 (file)
@@ -1,9 +1,3 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2024. All rights reserved.
- * Description: SetDialStylePresenter.h
- * Author:
- * Create: 2024-06-06
- */
 
 #ifndef SET_DIAL_STYLE_PRESENTER_H
 #define SET_DIAL_STYLE_PRESENTER_H
 #include "components/ui_view.h"
 #include "Presenter.h"
 
-namespace OHOS {
-class SetDialStyleModel;
-class SetDialStyleView;
-class SetDialStylePresenter : public Presenter<SetDialStyleView, SetDialStyleModel>,
-                              public UIView::OnClickListener,
-                              public UIView::OnDragListener {
-public:
-    SetDialStylePresenter();
-    ~SetDialStylePresenter();
-    SetDialStylePresenter(const SetDialStylePresenter&) = delete;
-    SetDialStylePresenter& operator=(const SetDialStylePresenter&) = delete;
-    bool OnClick(UIView &view, const ClickEvent &event) override;
-    bool OnDrag(UIView& view, const DragEvent& event) override;
-    DialStyle GetCurrentStyle() const
+namespace OHOS
+{
+    class SetDialStyleModel;
+    class SetDialStyleView;
+    class SetDialStylePresenter : public Presenter<SetDialStyleView, SetDialStyleModel>,
+                                  public UIView::OnClickListener,
+                                  public RootView::OnKeyActListener,
+                                  public UIView::OnDragListener
     {
-        return curStyle_;
-    }
+    public:
+        SetDialStylePresenter();
+        ~SetDialStylePresenter();
+        SetDialStylePresenter(const SetDialStylePresenter &) = delete;
+        SetDialStylePresenter &operator=(const SetDialStylePresenter &) = delete;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+        DialStyle GetCurrentStyle() const
+        {
+            return curStyle_;
+        }
 
-private:
-    DialStyle curStyle_ = DialStyle::COVERFLOW;
-};
+    private:
+        DialStyle curStyle_ = DialStyle::COVERFLOW;
+    };
 
 } // OHOS
 #endif
\ No newline at end of file
index e7f148a..8f6852e 100644 (file)
@@ -1,9 +1,3 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2024. All rights reserved.
- * Description: SetDialStyleView.h
- * Author:
- * Create: 2024-06-06
- */
 
 #ifndef SET_DIAL_STYLE_VIEW_H
 #define SET_DIAL_STYLE_VIEW_H
 #include "components/ui_label.h"
 #include "components/ui_view_group.h"
 #include "components/ui_toggle_button.h"
+#include "components/ui_button.h"
 #include "SetDialView.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
 #include "View.h"
 
-namespace OHOS {
-class SetDialStylePresenter;
-class SetDialStyleView : public View<SetDialStylePresenter> {
-public:
-    SetDialStyleView();
-    ~SetDialStyleView() override;
-    SetDialStyleView(const SetDialStyleView &) = delete;
-    SetDialStyleView& operator=(const SetDialStyleView &) = delete;
+namespace OHOS
+{
+    class SetDialStylePresenter;
+    class SetDialStyleView : public View<SetDialStylePresenter>
+    {
+    public:
+        SetDialStyleView();
+        ~SetDialStyleView() override;
+        SetDialStyleView(const SetDialStyleView &) = delete;
+        SetDialStyleView &operator=(const SetDialStyleView &) = delete;
 
-    void OnStart() override;
-    void OnClick(UIView &view);
+        void OnStart() override;
+        void OnClick(UIView &view);
 
-private:
-    UILabel labelCover_;
-    UILabel labelRoller_;
-    UILabel labelEnableAod_;
-    UIToggleButton btnCover_;
-    UIToggleButton btnRoller_;
-    UIToggleButton btnEnableAod_;
-    struct {
-        UIToggleButton *btn;
-        DialStyle style;
-    } styleTable_[static_cast<int>(DialStyle::STYLE_NUM)] = {
-        {&btnCover_, DialStyle::COVERFLOW},
-        {&btnRoller_, DialStyle::ROLLER},
+    private:
+        UILabelExt labelTitle_;
+
+        UILabelExt labelCover_;
+        UILabelExt labelRoller_;
+
+        UIToggleButton btnCover_;
+        UIToggleButton btnRoller_;
+
+        UIImageView Cover_Image_;
+        UIImageView Roller_Image_;
+        struct
+        {
+            UIToggleButton *btn;
+            DialStyle style;
+        } styleTable_[static_cast<int>(DialStyle::STYLE_NUM)] = {
+            {&btnCover_, DialStyle::COVERFLOW},
+            {&btnRoller_, DialStyle::ROLLER},
+        };
     };
-};
 } // OHOS
 #endif
\ No newline at end of file
index 81d833a..cd62e20 100644 (file)
@@ -1,43 +1,42 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2024. All rights reserved.
- * Description: SetDialStyleModel.cpp
- * Author:
- * Create: 2024-06-06
- */
 
 #include "SetDialStyleModel.h"
 #include "kv_store.h"
 
-namespace OHOS {
-void SetDialStyleModel::SetStyle(DialStyle style)
+namespace OHOS
 {
-    int len = sizeof(values_) / sizeof(values_[0]);
-    for (int i = 0; i < len; ++i) {
-        if (values_[i].style == style) {
-            UtilsSetValue(key_, values_[i].value);
-            break;
+    void SetDialStyleModel::SetStyle(DialStyle style)
+    {
+        int len = sizeof(values_) / sizeof(values_[0]);
+        for (int i = 0; i < len; ++i)
+        {
+            if (values_[i].style == style)
+            {
+                UtilsSetValue(key_, values_[i].value);
+                break;
+            }
         }
     }
-}
 
-DialStyle SetDialStyleModel::GetStyle()
-{
-    int len = sizeof(values_) / sizeof(values_[0]);
-    char temp[MAX_LEN];
-    UtilsGetValue(key_, temp, MAX_LEN);
-    for (int i = 0; i < len; ++i) {
-        if (strcmp(temp, values_[i].value) == 0) {
-            return values_[i].style;
+    DialStyle SetDialStyleModel::GetStyle()
+    {
+        int len = sizeof(values_) / sizeof(values_[0]);
+        char temp[MAX_LEN];
+        UtilsGetValue(key_, temp, MAX_LEN);
+        for (int i = 0; i < len; ++i)
+        {
+            if (strcmp(temp, values_[i].value) == 0)
+            {
+                return values_[i].style;
+            }
         }
+        return DialStyle::ROLLER;
     }
-    return DialStyle::COVERFLOW;
-}
 
-SetDialStyleModel::SetDialStyleModel()
-{
-}
+    SetDialStyleModel::SetDialStyleModel()
+    {
+    }
 
-SetDialStyleModel::~SetDialStyleModel()
-{
-}
+    SetDialStyleModel::~SetDialStyleModel()
+    {
+    }
 } // OHOS
\ No newline at end of file
index 6980d5f..e1e0edb 100644 (file)
@@ -1,45 +1,55 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2024. All rights reserved.
- * Description: SetDialStylePresenter.cpp
- * Author:
- * Create: 2024-06-06
- */
 
 #include "SetDialStyleView.h"
 #include "SetDialStyleModel.h"
 #include "SetDialStylePresenter.h"
 #include "NativeRegisterManager.h"
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
 
-namespace OHOS {
-
-REGIST_SLICE(VIEW_SET_DIAL_STYLE, SetDialStyleView, SetDialStylePresenter);
-
-SetDialStylePresenter::SetDialStylePresenter()
+namespace OHOS
 {
-    Attach(&SetDialStyleModel::GetInstance());
-}
+    REGIST_SLICE(VIEW_SET_DIAL_STYLE, SetDialStyleView, SetDialStylePresenter);
+    SetDialStylePresenter::SetDialStylePresenter()
+    {
+        Attach(&SetDialStyleModel::GetInstance());
+    }
 
-SetDialStylePresenter::~SetDialStylePresenter()
-{
-}
+    SetDialStylePresenter::~SetDialStylePresenter()
+    {
+    }
 
-bool SetDialStylePresenter::OnClick(UIView &view, const ClickEvent &event)
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnClick");
-    view_->OnClick(view);
-    return true;
-}
+    bool SetDialStylePresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnClick");
+        view_->OnClick(view);
+        return true;
+    }
 
-bool SetDialStylePresenter::OnDrag(UIView& view, const DragEvent& event)
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnDrag");
-    UNUSED(view);
-    if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
-        (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice");
-        uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-        NativeAbility::GetInstance().ChangeSlice(preSlice);
+    bool SetDialStylePresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetDialStylePresenter::OnDrag");
+        UNUSED(view);
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
+            (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY()))))
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice");
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(preSlice);
+        }
+        return true;
+    }
+
+    bool SetDialStylePresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            // 回退
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
     }
-    return true;
-}
 } // OHOS
\ No newline at end of file
index 54c08a7..2ba3b29 100644 (file)
-/*
- * Copyright (c) CompanyNameMagicTag 2024. All rights reserved.
- * Description: SetDialStyleView.cpp
- * Author:
- * Create: 2024-06-06
- */
+
 
 #include "SetDialStyleView.h"
 #include "SetDialStyleModel.h"
 #include "SetDialStylePresenter.h"
+#include "UiConfig.h"
+#include "ui_resource_string.h"
 #include "MainModel.h"
-
-namespace OHOS {
-SetDialStyleView::SetDialStyleView()
-{
-}
-
-SetDialStyleView::~SetDialStyleView()
+namespace OHOS
 {
-}
+    SetDialStyleView::SetDialStyleView()
+    {
+    }
 
-void SetDialStyleView::OnStart()
-{
-    GetRootContainer()->SetDraggable(true);
-    GetRootContainer()->SetTouchable(true);
-    if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) { // support default slide back firstly
-        GetRootContainer()->SetOnDragListener(presenter_);
+    SetDialStyleView::~SetDialStyleView()
+    {
     }
-    const int16_t BTN_HEIGHT = 55;
-    const int16_t BTN_WIDTH = 113;
-    const int16_t LABEL_WIDTH = 110;
-    const int16_t LABEL_HEIGHT = 18;
-    const int16_t COVER_X = 20;
-    const int16_t ROLLER_X = 158;
-    const int16_t ENABLE_X = 296;
-    const int16_t Y1 = 176;
-    const int16_t Y2 = 250;
-
-    labelCover_.SetPosition(COVER_X, Y2, LABEL_WIDTH, LABEL_HEIGHT);
-    labelCover_.SetText("Coverflow");
-    AddViewToRootContainer(&labelCover_);
-
-    labelRoller_.SetPosition(ENABLE_X, Y2, LABEL_WIDTH, LABEL_HEIGHT);
-    labelRoller_.SetText("Roller");
-    AddViewToRootContainer(&labelRoller_);
-
-    btnCover_.SetPosition(COVER_X, Y1, BTN_WIDTH, BTN_HEIGHT);
-    AddViewToRootContainer(&btnCover_);
-    btnRoller_.SetPosition(ENABLE_X, Y1, BTN_WIDTH, BTN_HEIGHT);
-    AddViewToRootContainer(&btnRoller_);
-
-    const DialStyle style = SetDialStyleModel::GetInstance().GetStyle();
-    int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
-    for (int i = 0; i < len; ++i) {
-        if (style == styleTable_[i].style) {
-            styleTable_[i].btn->SetState(true);
-        } else {
-            styleTable_[i].btn->SetState(false);
+
+    void SetDialStyleView::OnStart()
+    {
+        GetRootContainer()->SetDraggable(true);
+        GetRootContainer()->SetTouchable(true);
+        if (PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr)
+        { // support default slide back firstly
+            GetRootContainer()->SetOnDragListener(presenter_);
         }
-    }
 
-    btnCover_.SetOnClickListener(presenter_);
-    btnRoller_.SetOnClickListener(presenter_);
-}
 
-void SetDialStyleView::OnClick(UIView &view)
-{
-    const UIToggleButton *ptr = dynamic_cast<UIToggleButton*>(&view);
-    if (ptr == nullptr) {
-        return;
-    }
-    int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
-    for (int i = 0; i < len; ++i) {
-        if (ptr == styleTable_[i].btn) {
-            styleTable_[i].btn->SetState(true);
-            SetDialStyleModel::GetInstance().SetStyle(styleTable_[i].style);
-        } else {
-            styleTable_[i].btn->SetState(false);
+            Cover_Image_.SetPosition(43, 120, 380, 100);
+            Cover_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            Cover_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            Cover_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
+            AddViewToRootContainer(&Cover_Image_);
+
+            
+
+            Roller_Image_.SetPosition(43, 240, 380, 100);
+            Roller_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            Roller_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            Roller_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
+            AddViewToRootContainer(&Roller_Image_);
+
+            labelTitle_.SetPosition(83, 50, 300, 60);
+            labelTitle_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            labelTitle_.SetTextId(STR_BROWSING_SPECIAL_EFFECTS);
+            // labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 居中
+            labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+            labelTitle_.SetRollSpeed(23);
+            labelTitle_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            AddViewToRootContainer(&labelTitle_);
+
+            labelCover_.SetPosition(90, 153, 200, 60);
+            labelCover_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            labelCover_.SetTextId(STR_OVERLAY_FLOW);
+            AddViewToRootContainer(&labelCover_);
+
+            labelRoller_.SetPosition(90, 273, 200, 60);
+            labelRoller_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            labelRoller_.SetTextId(STR_ROLLER);
+            AddViewToRootContainer(&labelRoller_);
+
+            btnCover_.SetPosition(298, 145, 100, 50);
+            btnCover_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+            AddViewToRootContainer(&btnCover_);
+            btnRoller_.SetPosition(298, 265, 100, 50);
+            btnRoller_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+            AddViewToRootContainer(&btnRoller_);
+
+            const DialStyle style = SetDialStyleModel::GetInstance().GetStyle();
+            int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
+            for (int i = 0; i < len; ++i)
+            {
+                if (style == styleTable_[i].style)
+                {
+                    styleTable_[i].btn->SetState(true);
+                }
+                else
+                {
+                    styleTable_[i].btn->SetState(false);
+                }
+            }
+
+            btnCover_.SetOnClickListener(presenter_);
+            btnRoller_.SetOnClickListener(presenter_);
         }
-    }
-}
-} // OHOS
\ No newline at end of file
+
+
+        void SetDialStyleView::OnClick(UIView & view)
+        {
+            const UIToggleButton *ptr = dynamic_cast<UIToggleButton *>(&view);
+            if (ptr == nullptr)
+            {
+                return;
+            }
+            int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
+            for (int i = 0; i < len; ++i)
+            {
+                if (ptr == styleTable_[i].btn)
+                {
+                    styleTable_[i].btn->SetState(true);
+                    SetDialStyleModel::GetInstance().SetStyle(styleTable_[i].style);
+                }
+                else
+                {
+                    styleTable_[i].btn->SetState(false);
+                }
+            }
+            // 切换到切换表盘Slice
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL);
+        }
+    } // OHOS
\ No newline at end of file