设置视图修改,使得各个按钮之间有空隙
author罗正yun <1732036298@qq.com>
Sat, 23 Dec 2023 09:34:35 +0000 (17:34 +0800)
committer罗正yun <1732036298@qq.com>
Sat, 23 Dec 2023 09:34:35 +0000 (17:34 +0800)
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp

index ff45de5..80cd05e 100755 (executable)
@@ -1,61 +1,61 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingAdapter.h\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#ifndef SETTING_ADAPTER_H\r
-#define SETTING_ADAPTER_H\r
-\r
-#include <list>\r
-#include <string>\r
-#include "components/ui_list.h"\r
-#include "components/ui_label.h"\r
-#include "components/ui_view_group.h"\r
-#include "components/ui_image_view.h"\r
-#include "components/abstract_adapter.h"\r
-#include "wearable_log.h"\r
-#include "UiConfig.h"\r
-#include "SettingModel.h"\r
-#include "SettingItemView.h"\r
-\r
-namespace OHOS {\r
-class SettingAdapter : public AbstractAdapter {\r
-public:\r
-    explicit SettingAdapter();\r
-    virtual ~SettingAdapter();\r
-\r
-    /* *\r
-    * @brief Sets the UIView adapter data, which is a SettingItem linked list.\r
-    *\r
-    * @param data Indicates the SettingItem linked list data.\r
-    * @since 1.0\r
-    * @version 1.0\r
-    */\r
-    void SetData(std::list<SettingItem> &data);\r
-\r
-    /* *\r
-    * @brief Obtains the <b>data</b> size of the UILabel adapter.\r
-    *\r
-    * @return Returns the <b>data</b> size of the UILabel adapter.\r
-    * @since 1.0\r
-    * @version 1.0\r
-    */\r
-    virtual uint16_t GetCount(void) override;\r
-\r
-    virtual UIView *GetView(UIView *inView, int16_t index) override;\r
-\r
-    virtual void AddListItem(const SettingItem &item);\r
-\r
-    void SetItemClickListener(UIView::OnClickListener *itemclicklistener)\r
-    {\r
-        itemClickListener = itemclicklistener;\r
-    }\r
-private:\r
-    std::list<SettingItem> listData;\r
-    UIView::OnClickListener *itemClickListener{nullptr};\r
-};\r
-}\r
-\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingAdapter.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SETTING_ADAPTER_H
+#define SETTING_ADAPTER_H
+
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+#include "components/abstract_adapter.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "SettingModel.h"
+#include "SettingItemView.h"
+
+namespace OHOS {
+class SettingAdapter : public AbstractAdapter {
+public:
+    explicit SettingAdapter();
+    virtual ~SettingAdapter();
+
+    /* *
+    * @brief Sets the UIView adapter data, which is a SettingItem linked list.
+    *
+    * @param data Indicates the SettingItem linked list data.
+    * @since 1.0
+    * @version 1.0
+    */
+    void SetData(std::list<SettingItem> &data);
+
+    /* *
+    * @brief Obtains the <b>data</b> size of the UILabel adapter.
+    *
+    * @return Returns the <b>data</b> size of the UILabel adapter.
+    * @since 1.0
+    * @version 1.0
+    */
+    virtual uint16_t GetCount(void) override;
+
+    virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+    virtual void AddListItem(const SettingItem &item);
+
+    void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+    {
+        itemClickListener = itemclicklistener;
+    }
+private:
+    std::list<SettingItem> listData;
+    UIView::OnClickListener *itemClickListener{nullptr};
+};
+}
+
 #endif
\ No newline at end of file
index f0339e3..3010026 100755 (executable)
@@ -1,33 +1,33 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingItem.h\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#ifndef SETTING_ITEM_H\r
-#define SETTING_ITEM_H\r
-\r
-#include <cstdint>\r
-\r
-namespace OHOS {\r
-/*\r
- * setting id.\r
- */\r
-typedef enum : uint16_t {\r
-    // setting item index\r
-    SETTING_ITEM_ZERO = 0x0000,\r
-    SETTING_ITEM_ONE,\r
-    SETTING_ITEM_TWO,\r
-    SETTING_ITEM_THREE,\r
-    SETTING_ITEM_FIVE,\r
-} SettingIndex;\r
-\r
-typedef struct {\r
-    SettingIndex index;\r
-    const char *icon;\r
-    const char *label;\r
-    bool hasSecondMenu;\r
-} SettingItem;\r
-}\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingItem.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SETTING_ITEM_H
+#define SETTING_ITEM_H
+
+#include <cstdint>
+
+namespace OHOS {
+/*
+ * setting id.
+ */
+typedef enum : uint16_t {
+    // setting item index
+    SETTING_ITEM_ZERO = 0x0000,
+    SETTING_ITEM_ONE,
+    SETTING_ITEM_TWO,
+    SETTING_ITEM_THREE,
+    SETTING_ITEM_FIVE,
+} SettingIndex;
+
+typedef struct {
+    SettingIndex index;
+    const char *icon;
+    const char *label;
+    bool hasSecondMenu;
+} SettingItem;
+}
 #endif
\ No newline at end of file
index 690b44a..98cbb77 100755 (executable)
@@ -1,37 +1,37 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingItemView.h\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#ifndef SETTING_ITEM_VIEW_H\r
-#define SETTING_ITEM_VIEW_H\r
-\r
-#include "components/ui_label.h"\r
-#include "components/ui_view_group.h"\r
-#include "components/ui_image_view.h"\r
-\r
-#include "UiConfig.h"\r
-#include "SettingModel.h"\r
-\r
-namespace OHOS {\r
-class SettingItemView : public UIViewGroup {\r
-public:\r
-    explicit SettingItemView();\r
-    virtual ~SettingItemView();\r
-    virtual void SetItemInfo(const SettingItem itemInfo);\r
-    virtual void SetUpChild();\r
-    SettingIndex GetSettingIndex();\r
-\r
-private:\r
-    SettingItemView(const SettingItemView &);\r
-    UIImageView sBackgroundImage;\r
-    UIImageView sIcon;\r
-    UILabel sLabel;\r
-    UIImageView sNextImage;\r
-    SettingItem sItemInfo = { SETTING_ITEM_ZERO, nullptr, nullptr, false };\r
-};\r
-}\r
-\r
-#endif\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingItemView.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SETTING_ITEM_VIEW_H
+#define SETTING_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/ui_image_view.h"
+
+#include "UiConfig.h"
+#include "SettingModel.h"
+
+namespace OHOS {
+class SettingItemView : public UIViewGroup {
+public:
+    explicit SettingItemView();
+    virtual ~SettingItemView();
+    virtual void SetItemInfo(const SettingItem itemInfo);
+    virtual void SetUpChild();
+    SettingIndex GetSettingIndex();
+
+private:
+    SettingItemView(const SettingItemView &);
+    UIImageView sBackgroundImage;
+    UIImageView sIcon;
+    UILabel sLabel;
+    UIImageView sNextImage;
+    SettingItem sItemInfo = { SETTING_ITEM_ZERO, nullptr, nullptr, false };
+};
+}
+
+#endif
index d3a36ba..ddabdf6 100755 (executable)
@@ -1,40 +1,40 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingModel.h\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#ifndef SETTING_MODEL_H\r
-#define SETTING_MODEL_H\r
-\r
-#include <cstdint>\r
-#include <map>\r
-#include "AppViewIDs.h"\r
-#include "UiConfig.h"\r
-#include "SettingItem.h"\r
-#include "SettingPresenter.h"\r
-\r
-namespace OHOS {\r
-    class SettingModel {\r
-    public:\r
-        static SettingModel &GetInstance(void);\r
-        void InitSettingItem();\r
-        const SettingItem *GetSettinglistItems() const;\r
-        uint8_t GetSettingListNum() const;\r
-        const std::map<SettingIndex, AppViewId> &GetSettingIdToViewId() const;\r
-        bool GetBlueToothConnectStatus(void);\r
-        void UpdateBlueToothConnectStatus(bool status);\r
-    private:\r
-        SettingModel();\r
-        SettingModel(const SettingModel &);\r
-        SettingModel &operator=(const SettingModel &);\r
-        virtual ~SettingModel();\r
-        static const uint16_t SETTING_ITEM_LEN = 5;\r
-        SettingItem settings[SETTING_ITEM_LEN] = { SETTING_ITEM_ZERO, nullptr, nullptr, false };\r
-        std::map<SettingIndex, AppViewId> settingIdToViewId;\r
-        bool btConnectStatus{false};\r
-    };\r
-}\r
-\r
-#endif\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingModel.h
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#ifndef SETTING_MODEL_H
+#define SETTING_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "SettingItem.h"
+#include "SettingPresenter.h"
+
+namespace OHOS {
+    class SettingModel {
+    public:
+        static SettingModel &GetInstance(void);
+        void InitSettingItem();
+        const SettingItem *GetSettinglistItems() const;
+        uint8_t GetSettingListNum() const;
+        const std::map<SettingIndex, AppViewId> &GetSettingIdToViewId() const;
+        bool GetBlueToothConnectStatus(void);
+        void UpdateBlueToothConnectStatus(bool status);
+    private:
+        SettingModel();
+        SettingModel(const SettingModel &);
+        SettingModel &operator=(const SettingModel &);
+        virtual ~SettingModel();
+        static const uint16_t SETTING_ITEM_LEN = 5;
+        SettingItem settings[SETTING_ITEM_LEN] = { SETTING_ITEM_ZERO, nullptr, nullptr, false };
+        std::map<SettingIndex, AppViewId> settingIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
index 96f9815..a753446 100755 (executable)
@@ -9,27 +9,28 @@
 #define SETTING_PRESENTER_H\r
 \r
 #include "Presenter.h"\r
-#include "components/ui_view.h"\r
+#include "SettingView.h"\r
+namespace OHOS\r
+{\r
+    class SettingView;\r
+    class SettingPresenter : public Presenter<SettingView>,\r
+                             public UIView::OnClickListener,\r
+                             public UIView::OnDragListener\r
+    {\r
+    public:\r
+        SettingPresenter();\r
+        virtual ~SettingPresenter();\r
+        void OnStart() override;\r
+        void OnPause() override;\r
+        void OnResume() override;\r
+        void OnStop() override;\r
+        static SettingPresenter *GetInstance();\r
 \r
-namespace OHOS {\r
-class SettingView;\r
-class SettingModel;\r
-class SettingPresenter : public Presenter<SettingView>,\r
-                         public UIView::OnClickListener,\r
-                         public UIView::OnDragListener {\r
-public:\r
-    SettingPresenter();\r
-    virtual ~SettingPresenter();\r
+    private:\r
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+        bool OnClick(UIView &view, const ClickEvent &event) override;\r
+        bool OnDrag(UIView &view, const DragEvent &event) override;\r
+    };\r
+} // namespace OHOS\r
 \r
-    virtual void OnStart() override;\r
-    virtual void OnResume() override;\r
-    virtual void OnStop() override;\r
-\r
-    bool OnClick(UIView &view, const ClickEvent &event) override;\r
-    virtual bool OnDrag(UIView& view, const DragEvent& event) override;\r
-private:\r
-    SettingModel *settingModel;\r
-};\r
-}\r
-\r
-#endif // SETTING_PRESENTER_H
\ No newline at end of file
+#endif
\ No newline at end of file
index 2e3badd..9d261cb 100755 (executable)
@@ -8,35 +8,49 @@
 #ifndef SETTING_VIEW_H\r
 #define SETTING_VIEW_H\r
 \r
+#include "BaseView.h"\r
 #include "View.h"\r
-#include "components/root_view.h"\r
 #include "components/ui_view_group.h"\r
 #include "components/ui_scroll_view.h"\r
 #include "components/ui_label.h"\r
-#include "components/ui_list.h"\r
-#include "window/window.h"\r
-#include "BaseView.h"\r
-#include "SettingAdapter.h"\r
-#include "ChangeSliceListener.h"\r
-namespace OHOS {\r
-class SettingPresenter;\r
-class SettingView : public View<SettingPresenter> {\r
-public:\r
-    SettingView();\r
-    virtual ~SettingView();\r
-\r
-    virtual void OnStart() override;\r
-    virtual void OnSetUpView() override;\r
-    virtual void OnTearDownView() override;\r
-    virtual void OnStop() override;\r
-    void AddSettingItemToList(const SettingItem &item);\r
-\r
-private:\r
-    SettingAdapter *listAdapter{nullptr};\r
-    UIScrollView *scrollView{nullptr};\r
-    UIList *contentList{nullptr};\r
-    UILabel *title{nullptr};\r
-    UIView::OnDragListener *dragListener{nullptr};\r
-};\r
+#include "components/ui_button.h"\r
+#include "components/ui_image_view.h"\r
+\r
+namespace OHOS\r
+{\r
+    class SettingPresenter;\r
+    class SettingView : public View<SettingPresenter>\r
+    {\r
+\r
+    public:\r
+        SettingView();\r
+        virtual ~SettingView();\r
+        static SettingView *GetInstance(void);\r
+\r
+        void OnStart() override;\r
+        void OnSetUpView() override;\r
+        void OnTearDownView() override;\r
+        void OnStop() override;\r
+\r
+    private:\r
+        void CreateSettingButton(UIScrollView *scrollview, UIButton *button, int x, int y, int w, int h, const char *viewid, const char *imagepath, UIView::OnClickListener *buttonclick);\r
+        void CreateSettingLabel(UIScrollView *scrollview, UILabel *label, int x, int y, int w, int h, int text_font, int line_height, const char *text);\r
+        void CreateSettingImageView(UIScrollView *scrollview, UIImageView *imageview, int x, int y, int w, int h, const char *imagepath, int border_radius);\r
+        void SetClickListen(UIView::OnClickListener *clicklisten);\r
+\r
+    private:\r
+        void InitSettingView(void);\r
+        void DeInitView(void);\r
+        void PreLoad(void);\r
+\r
+    private:\r
+        UIScrollView *scrollView = nullptr;\r
+        UILabel *titleLabel{nullptr};                  // 标题:设置\r
+        UIButton *button[5]{nullptr};                  // 5个按钮\r
+        UILabel *label[5]{nullptr};                    // 5个标签\r
+        UIImageView *image[10]{nullptr};               // 10张图片\r
+        UIView::OnClickListener *clicklisten{nullptr}; // 点击监听\r
+        bool viewInitStatus{false};\r
+    };\r
 }\r
-#endif // SETTING_VIEW_H
\ No newline at end of file
+#endif
\ No newline at end of file
index fd28e63..3ffb62c 100755 (executable)
@@ -1,68 +1,68 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingAdapter.cpp\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#include "SettingAdapter.h"\r
-\r
-namespace OHOS {\r
-SettingAdapter::SettingAdapter() {}\r
-\r
-SettingAdapter::~SettingAdapter()\r
-{\r
-    listData.clear();\r
-}\r
-\r
-uint16_t SettingAdapter::GetCount(void)\r
-{\r
-    return listData.size();\r
-}\r
-\r
-void SettingAdapter::SetData(std::list<SettingItem> &data)\r
-{\r
-    if (!listData.empty()) {\r
-        listData.clear();\r
-    }\r
-    std::list<SettingItem>::iterator it;\r
-    for (it = data.begin(); it != data.end(); it++) {\r
-        listData.push_back(*it);\r
-    }\r
-}\r
-\r
-UIView *SettingAdapter::GetView(UIView *inView, int16_t index)\r
-{\r
-    if (listData.empty()) {\r
-        return nullptr;\r
-    }\r
-    if (index < 0) {\r
-        return nullptr;\r
-    }\r
-    size_t uindex = index;\r
-    if (uindex >= listData.size()) {\r
-        return nullptr;\r
-    }\r
-\r
-    std::list<SettingItem>::iterator it = listData.begin();\r
-    for (int i = 0; i < index; i++) {\r
-        it++;\r
-    }\r
-    SettingItem itemData = *it;\r
-    SettingItemView *item = nullptr;\r
-    if (inView == nullptr) {\r
-        item = new SettingItemView();\r
-    } else {\r
-        item = static_cast<SettingItemView *>(inView);\r
-    }\r
-\r
-    item->SetItemInfo(itemData);\r
-    item->SetOnClickListener(itemClickListener);\r
-    return item;\r
-}\r
-\r
-void SettingAdapter::AddListItem(const SettingItem &item)\r
-{\r
-    listData.push_back(item);\r
-}\r
-} // namespace OHOS\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingAdapter.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SettingAdapter.h"
+
+namespace OHOS {
+SettingAdapter::SettingAdapter() {}
+
+SettingAdapter::~SettingAdapter()
+{
+    listData.clear();
+}
+
+uint16_t SettingAdapter::GetCount(void)
+{
+    return listData.size();
+}
+
+void SettingAdapter::SetData(std::list<SettingItem> &data)
+{
+    if (!listData.empty()) {
+        listData.clear();
+    }
+    std::list<SettingItem>::iterator it;
+    for (it = data.begin(); it != data.end(); it++) {
+        listData.push_back(*it);
+    }
+}
+
+UIView *SettingAdapter::GetView(UIView *inView, int16_t index)
+{
+    if (listData.empty()) {
+        return nullptr;
+    }
+    if (index < 0) {
+        return nullptr;
+    }
+    size_t uindex = index;
+    if (uindex >= listData.size()) {
+        return nullptr;
+    }
+
+    std::list<SettingItem>::iterator it = listData.begin();
+    for (int i = 0; i < index; i++) {
+        it++;
+    }
+    SettingItem itemData = *it;
+    SettingItemView *item = nullptr;
+    if (inView == nullptr) {
+        item = new SettingItemView();
+    } else {
+        item = static_cast<SettingItemView *>(inView);
+    }
+
+    item->SetItemInfo(itemData);
+    item->SetOnClickListener(itemClickListener);
+    return item;
+}
+
+void SettingAdapter::AddListItem(const SettingItem &item)
+{
+    listData.push_back(item);
+}
+} // namespace OHOS
index b0ed32b..e2b6a1d 100755 (executable)
@@ -1,80 +1,80 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingItemView.cpp\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#include "wearable_log.h"\r
-#include "SettingItemView.h"\r
-\r
-namespace OHOS {\r
-    static constexpr int16 SETTING_ICON_X = 19;\r
-    static constexpr int16_t SETTING_SICON_Y = 19;\r
-    static constexpr int16 NUM_22 = 22;\r
-    static constexpr int16_t SETTING_ITEM_BUTTON_HEIGHT = 100;\r
-    static constexpr int16_t SETTING_ITEM_LABEL_WIDTH = 150;\r
-    static constexpr int16_t SETTING_ITEM_LABEL_HEIGHT = 35;\r
-    static constexpr int16 SETTING_ITEM_FONT_SIZE = 30;\r
-    static constexpr int16_t SETTINGS_RESIZE_SIZE = 100;\r
-   \r
-    static constexpr int16 NUMS_2 = 2;\r
-    static constexpr int16 NUMS_50 = 50;\r
-\r
-    SettingItemView::SettingItemView()\r
-    {\r
-        SetPosition(0, 0, HORIZONTAL_RESOLUTION, SETTING_ITEM_BUTTON_HEIGHT);\r
-        SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-        SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);\r
-        SetTouchable(true);\r
-        SetUpChild();\r
-        Add(&sBackgroundImage);\r
-        Add(&sIcon);\r
-        Add(&sLabel);\r
-        Add(&sNextImage);\r
-    }\r
-\r
-    SettingItemView::~SettingItemView()\r
-    {\r
-        Remove(&sBackgroundImage);\r
-        Remove(&sIcon);\r
-        Remove(&sLabel);\r
-        Remove(&sNextImage);\r
-    }\r
-\r
-    void SettingItemView::SetItemInfo(const SettingItem itemInfo)\r
-    {\r
-        sItemInfo = itemInfo;\r
-        sIcon.SetSrc(itemInfo.icon);\r
-        sLabel.SetText(itemInfo.label);\r
-        sNextImage.SetVisible(itemInfo.hasSecondMenu);\r
-    }\r
-\r
-    void SettingItemView::SetUpChild()\r
-    {\r
-        sBackgroundImage.SetPosition(0,0);\r
-        sBackgroundImage.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        sIcon.SetPosition(SETTING_ICON_X, SETTING_SICON_Y);\r
-        sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);\r
-\r
-        sLabel.SetPosition(115,33);\r
-        sLabel.Resize(SETTING_ITEM_LABEL_WIDTH, SETTING_ITEM_LABEL_HEIGHT);\r
-        sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTING_ITEM_FONT_SIZE);\r
-        sLabel.SetStyle(STYLE_LINE_HEIGHT,35);\r
-        sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
-        sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);\r
-        sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full);\r
-        sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-        sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
-\r
-        sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE);\r
-        sNextImage.Resize(14,26);\r
-        sNextImage.SetPosition(326, (SETTING_ITEM_HEIGHT - sNextImage.GetHeight()) / NUMS_2);\r
-        sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);\r
-    }\r
-\r
-    SettingIndex SettingItemView::GetSettingIndex()\r
-    {\r
-        return sItemInfo.index;\r
-    }\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingItemView.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "wearable_log.h"
+#include "SettingItemView.h"
+
+namespace OHOS {
+    static constexpr int16 SETTING_ICON_X = 19;
+    static constexpr int16_t SETTING_SICON_Y = 19;
+    static constexpr int16 NUM_22 = 22;
+    static constexpr int16_t SETTING_ITEM_BUTTON_HEIGHT = 100;
+    static constexpr int16_t SETTING_ITEM_LABEL_WIDTH = 150;
+    static constexpr int16_t SETTING_ITEM_LABEL_HEIGHT = 35;
+    static constexpr int16 SETTING_ITEM_FONT_SIZE = 30;
+    static constexpr int16_t SETTINGS_RESIZE_SIZE = 100;
+   
+    static constexpr int16 NUMS_2 = 2;
+    static constexpr int16 NUMS_50 = 50;
+
+    SettingItemView::SettingItemView()
+    {
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, SETTING_ITEM_BUTTON_HEIGHT);
+        SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);
+        SetTouchable(true);
+        SetUpChild();
+        Add(&sBackgroundImage);
+        Add(&sIcon);
+        Add(&sLabel);
+        Add(&sNextImage);
+    }
+
+    SettingItemView::~SettingItemView()
+    {
+        Remove(&sBackgroundImage);
+        Remove(&sIcon);
+        Remove(&sLabel);
+        Remove(&sNextImage);
+    }
+
+    void SettingItemView::SetItemInfo(const SettingItem itemInfo)
+    {
+        sItemInfo = itemInfo;
+        sIcon.SetSrc(itemInfo.icon);
+        sLabel.SetText(itemInfo.label);
+        sNextImage.SetVisible(itemInfo.hasSecondMenu);
+    }
+
+    void SettingItemView::SetUpChild()
+    {
+        sBackgroundImage.SetPosition(0,0);
+        sBackgroundImage.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+        sIcon.SetPosition(SETTING_ICON_X, SETTING_SICON_Y);
+        sIcon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+        sLabel.SetPosition(115,33);
+        sLabel.Resize(SETTING_ITEM_LABEL_WIDTH, SETTING_ITEM_LABEL_HEIGHT);
+        sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTING_ITEM_FONT_SIZE);
+        sLabel.SetStyle(STYLE_LINE_HEIGHT,35);
+        sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+        sLabel.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);
+        sLabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full);
+        sLabel.SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        sLabel.SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+
+        sNextImage.SetSrc(PNG_SETTING_NEXT_IMAGE);
+        sNextImage.Resize(14,26);
+        sNextImage.SetPosition(326, (SETTING_ITEM_HEIGHT - sNextImage.GetHeight()) / NUMS_2);
+        sNextImage.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+    }
+
+    SettingIndex SettingItemView::GetSettingIndex()
+    {
+        return sItemInfo.index;
+    }
 }
\ No newline at end of file
index 5bc4d36..01c2e71 100755 (executable)
@@ -1,71 +1,71 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingModel.cpp\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#include "SettingModel.h"\r
-#include "PullUpDownView.h"\r
-\r
-namespace OHOS {\r
-    SettingModel::SettingModel() {}\r
-\r
-    SettingModel::~SettingModel() {}\r
-\r
-    SettingModel &SettingModel::GetInstance()\r
-    {\r
-        static SettingModel instance;\r
-        return instance;\r
-    }\r
-\r
-    void SettingModel::InitSettingItem()\r
-    {\r
-        // settings[0] = {SETTING_ITEM_ZERO, PNG_BLUETOOTH_STITLE, "蓝牙耳机", true};\r
-        // settings[1] = {SETTING_ITEM_ONE, PNG_CONNECT_PHONE_IMAGE, "连接手机", true};\r
-        // settings[2] = {SETTING_ITEM_TWO, PNG_SETTTING_REBOOT_IMAGE, "重启", true};\r
-        // settings[3] = {SETTING_ITEM_THREE, PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true};\r
-        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE));\r
-        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE));\r
-        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_REBOOT));\r
-        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_REBOOT));\r
-        settings[0] = {SETTING_ITEM_ZERO, PNG_DISPLAY_BRIGHTNESS, "屏幕与亮度", true};\r
-        settings[1] = {SETTING_ITEM_ONE, PNG_BLUETOOTH, "蓝牙", true};\r
-        settings[2] = {SETTING_ITEM_TWO, PNG_SOUND_VIBRATION, "声音与震动", true};\r
-        settings[3] = {SETTING_ITEM_THREE, PNG_SECONDARY_FUNCTION, "辅助功能", true};\r
-        settings[4] = {SETTING_ITEM_FIVE, PNG_SYSTEM, "系统", true};\r
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS));\r
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_CONNECT_BLUETOOTH));\r
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_SOUND_VIBRATION));\r
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_SECONDARY_FUNCTION));\r
-        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_FIVE, VIEW_SYSTEM));\r
-    }\r
-\r
-    const SettingItem *SettingModel::GetSettinglistItems() const\r
-    {\r
-        return settings;\r
-    }\r
-\r
-    uint8_t SettingModel::GetSettingListNum() const\r
-    {\r
-        return SETTING_ITEM_LEN;\r
-    }\r
-\r
-    const std::map<SettingIndex, AppViewId> &SettingModel::GetSettingIdToViewId() const\r
-    {\r
-        return settingIdToViewId;\r
-    }\r
-\r
-    bool SettingModel::GetBlueToothConnectStatus(void)\r
-    {\r
-        return btConnectStatus;\r
-    }\r
-\r
-    void SettingModel::UpdateBlueToothConnectStatus(bool status)\r
-    {\r
-        btConnectStatus = status;\r
-        if (PullUpDownView::GetInstance() != NULL) {\r
-            PullUpDownView::GetInstance()->UpdateBlueToothStatus(status);\r
-        }\r
-    }\r
-}\r
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: SettingModel.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "SettingModel.h"
+#include "PullUpDownView.h"
+
+namespace OHOS {
+    SettingModel::SettingModel() {}
+
+    SettingModel::~SettingModel() {}
+
+    SettingModel &SettingModel::GetInstance()
+    {
+        static SettingModel instance;
+        return instance;
+    }
+
+    void SettingModel::InitSettingItem()
+    {
+        // settings[0] = {SETTING_ITEM_ZERO, PNG_BLUETOOTH_STITLE, "蓝牙耳机", true};
+        // settings[1] = {SETTING_ITEM_ONE, PNG_CONNECT_PHONE_IMAGE, "连接手机", true};
+        // settings[2] = {SETTING_ITEM_TWO, PNG_SETTTING_REBOOT_IMAGE, "重启", true};
+        // settings[3] = {SETTING_ITEM_THREE, PNG_SETTTING_SHUTDOWN_IMAGE, "关机", true};
+        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE));
+        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE));
+        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_REBOOT));
+        // settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_REBOOT));
+        settings[0] = {SETTING_ITEM_ZERO, PNG_DISPLAY_BRIGHTNESS, "屏幕与亮度", true};
+        settings[1] = {SETTING_ITEM_ONE, PNG_BLUETOOTH, "蓝牙", true};
+        settings[2] = {SETTING_ITEM_TWO, PNG_SOUND_VIBRATION, "声音与震动", true};
+        settings[3] = {SETTING_ITEM_THREE, PNG_SECONDARY_FUNCTION, "辅助功能", true};
+        settings[4] = {SETTING_ITEM_FIVE, PNG_SYSTEM, "系统", true};
+        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS));
+        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_ONE, VIEW_CONNECT_BLUETOOTH));
+        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_TWO, VIEW_SOUND_VIBRATION));
+        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_THREE, VIEW_SECONDARY_FUNCTION));
+        settingIdToViewId.insert(std::pair<SettingIndex, AppViewId>(SETTING_ITEM_FIVE, VIEW_SYSTEM));
+    }
+
+    const SettingItem *SettingModel::GetSettinglistItems() const
+    {
+        return settings;
+    }
+
+    uint8_t SettingModel::GetSettingListNum() const
+    {
+        return SETTING_ITEM_LEN;
+    }
+
+    const std::map<SettingIndex, AppViewId> &SettingModel::GetSettingIdToViewId() const
+    {
+        return settingIdToViewId;
+    }
+
+    bool SettingModel::GetBlueToothConnectStatus(void)
+    {
+        return btConnectStatus;
+    }
+
+    void SettingModel::UpdateBlueToothConnectStatus(bool status)
+    {
+        btConnectStatus = status;
+        if (PullUpDownView::GetInstance() != NULL) {
+            PullUpDownView::GetInstance()->UpdateBlueToothStatus(status);
+        }
+    }
+}
index 7c8f395..4f15960 100755 (executable)
@@ -1,52 +1,61 @@
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingPresenter.cpp\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#include "SettingView.h"\r
-#include "SettingModel.h"\r
+#include "AppViewIDs.h"\r
+#include "NativeAbility.h"\r
 #include "SettingPresenter.h"\r
-#include "RebootModel.h"\r
-namespace OHOS {\r
+\r
+namespace OHOS\r
+{\r
+\r
+    // 当前Presenter属性实例化的内存指针\r
+    static SettingPresenter *g_pSettingPresenter = nullptr;\r
+\r
     SettingPresenter::SettingPresenter()\r
     {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::SettingPresenter()");\r
-        settingModel = &SettingModel::GetInstance();\r
+\r
+        g_pSettingPresenter = this;\r
     }\r
 \r
-    SettingPresenter::~SettingPresenter() {}\r
+    SettingPresenter::~SettingPresenter()\r
+    {\r
+\r
+        g_pSettingPresenter = nullptr;\r
+    }\r
+\r
+    SettingPresenter *SettingPresenter::GetInstance()\r
+    {\r
+\r
+        return g_pSettingPresenter;\r
+    }\r
 \r
     void SettingPresenter::OnStart()\r
     {\r
+\r
         Presenter<SettingView>::OnStart();\r
-        settingModel->InitSettingItem();\r
+    }\r
+\r
+    void SettingPresenter::OnPause(void)\r
+    {\r
+\r
+        Presenter<SettingView>::OnPause();\r
     }\r
 \r
     void SettingPresenter::OnResume(void)\r
     {\r
-        if (view_ == nullptr) {\r
-            return;\r
-        }\r
-        const SettingItem *itemInfo = settingModel->GetSettinglistItems();\r
-        for (uint8_t i = 0; i < settingModel->GetSettingListNum(); i++) {\r
-            view_->AddSettingItemToList(itemInfo[i]);\r
-        }\r
+\r
+        Presenter<SettingView>::OnResume();\r
     }\r
 \r
     void SettingPresenter::OnStop(void)\r
     {\r
-        return;\r
+\r
+        Presenter<SettingView>::OnStop();\r
     }\r
 \r
-    bool SettingPresenter::OnDrag(UIView& view, const DragEvent& event)\r
+    bool SettingPresenter::OnDrag(UIView &view, const DragEvent &event)\r
     {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag");\r
         UNUSED(view);\r
         if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&\r
-            (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {\r
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice(VIEW_APPLIST)");\r
+            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
+        {\r
             NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);\r
         }\r
         return false;\r
@@ -55,21 +64,27 @@ namespace OHOS {
     bool SettingPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
         UNUSED(event);\r
-        SettingItemView *settingItemView = static_cast<SettingItemView *>(&view);\r
-        SettingIndex index = settingItemView->GetSettingIndex();\r
-        if (index >= SettingModel::GetInstance().GetSettingListNum()) {\r
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnClick is no index");\r
-            return false;\r
-        } else {\r
-            if (index == SETTING_ITEM_TWO) {\r
-                RebootModel::GetInstance()->SetSelectViewId(REBOOTDEVICE);\r
-                RebootModel::GetInstance()->SetExitsView(true);\r
-            } else if (index == SETTING_ITEM_THREE) {\r
-                RebootModel::GetInstance()->SetSelectViewId(SHUTDOWNDEVICE);\r
-                RebootModel::GetInstance()->SetExitsView(true);\r
-            }\r
-            NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index));\r
-            return true;\r
+        // 根据控件id查找是哪个控件触发了点击回调\r
+        if (strcmp(view.GetViewId(), "Displayandbrightness") == 0) // 显示与亮度\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_DISPLAY_BRIGHTNESS);\r
+        }\r
+        else if (strcmp(view.GetViewId(), "bluetooth") == 0) // 蓝牙\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_CONNECT_BLUETOOTH);\r
+        }\r
+        else if (strcmp(view.GetViewId(), "Soundandvibration") == 0) // 声音与震动\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_SOUND_VIBRATION);\r
         }\r
+        else if (strcmp(view.GetViewId(), "quickaccess") == 0) // 快速访问\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_QUICK_ACCESS);\r
+        }\r
+        else if (strcmp(view.GetViewId(), "system") == 0) // 系统\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM);\r
+        }\r
+        return false;\r
     }\r
-}\r
+}
\ No newline at end of file
index 3226471..ce10877 100755 (executable)
-/*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: SettingView.cpp\r
- * Author:\r
- * Create: 2021-11-23\r
- */\r
-\r
-#include <string>\r
-\r
 #include "SettingView.h"\r
-#include "SettingItem.h"\r
 #include "SettingPresenter.h"\r
+#include "UiConfig.h"\r
 \r
-namespace OHOS {\r
-static constexpr uint8_t SETTINGS_ITEM_FONT_SIZE = 30;\r
-static constexpr int16_t SETTINGS_RESIZE_SIZE_WIDTH = 100;\r
-static constexpr int16_t SETTINGS_RESIZE_SIZE_HEIGHT = 60;\r
-static constexpr int16_t SETTING_TITLE_POSITION_X = 203;\r
-static constexpr int16_t SETTING_LIST_POSITION_X = 43;\r
-static constexpr int16_t SETTING_LIST_POSITION_Y = 120;\r
-static constexpr int16_t SETTING_SCROLLBLANKSIZE = 50;\r
-static constexpr int16 MAX_SCR_DIS = 1000;\r
-static constexpr int16 LIST_POS = 20;\r
-static constexpr int16 SNUM_2 = 2;\r
-\r
-SettingView::SettingView()\r
+namespace OHOS\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::SettingView");\r
-}\r
+    // 按钮上图片路径\r
+    const char *BUTTON_IMAGE_PATH = "/user/res/SETTING_BACKGROUND.bin";\r
+    // 每个按钮视图id\r
+    const char *SETTING_BUTTON_VIEW_ID[5] = {\r
+        "Displayandbrightness", // 显示与亮度\r
+        "bluetooth",            // 蓝牙\r
+        "Soundandvibration",    // 声音与震动\r
+        "quickaccess",          // 快速访问\r
+        "system",               // 系统\r
+    };\r
+    // 5个icon图片\r
+    const char *ICON_IMAGE_PATH[5] = {\r
+        "/user/res/DISPLAY_BRIGHTNESS.bin",\r
+        "/user/res/SETTING_BLUETOOTH.bin",\r
+        "/user/res/SOUND_VIBRATION.bin",\r
+        "/user/res/QUICK_ACCESS.bin",\r
+        "/user/res/SYSTEM.bin",\r
+    };\r
+    const char *TEXT_LABEL[5] = {\r
+        "屏幕与亮度",\r
+        "蓝牙",\r
+        "声音与震动",\r
+        "辅助功能",\r
+        "系统",\r
+    };\r
+\r
+    constexpr int BUTTON_X = 43;\r
+    constexpr int BUTTON_Y = 120;\r
+    constexpr int BUTTON_W = 380;\r
+    constexpr int BUTTON_H = 100;\r
 \r
-SettingView::~SettingView()\r
+}\r
+namespace OHOS\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::~SettingView");\r
-    scrollView->RemoveAll();\r
-    delete title;\r
-    title = nullptr;\r
 \r
-    delete listAdapter;\r
-    listAdapter = nullptr;\r
+    static SettingView *g_pSettingView{nullptr};\r
 \r
-    delete contentList;\r
-    contentList = nullptr;\r
+    SettingView::SettingView()\r
+    {\r
 \r
-    delete scrollView;\r
-    scrollView = nullptr;\r
+        g_pSettingView = this;\r
+    }\r
 \r
-    delete dragListener;\r
-    dragListener = nullptr;\r
-}\r
+    SettingView::~SettingView()\r
+    {\r
+        if (viewInitStatus == true)\r
+        {\r
+            DeInitView();\r
+        }\r
+        g_pSettingView = nullptr;\r
+    }\r
 \r
-void SettingView::OnStart()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart");\r
-    View<SettingPresenter>::OnStart();\r
+    SettingView *SettingView::GetInstance()\r
+    {\r
 \r
-    BaseView::RootView(Color::Black().full);\r
+        return g_pSettingView;\r
+    }\r
 \r
-    listAdapter = new SettingAdapter();\r
-    if (listAdapter == nullptr) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::listAdapter is nullptr");\r
-        return;\r
+    /// @brief 创建按钮\r
+    /// @param scrollview\r
+    /// @param button\r
+    /// @param x x\r
+    /// @param y y\r
+    /// @param w width\r
+    /// @param h height\r
+    /// @param viewid 按钮id\r
+    /// @param imagepath 按钮上图片路径\r
+    /// @param buttonclick 按钮点击监听\r
+    void SettingView::CreateSettingButton(UIScrollView *scrollview, UIButton *button, int x, int y, int w, int h, const char *viewid, const char *imagepath, UIView::OnClickListener *buttonclick)\r
+    {\r
+        if (button == nullptr)\r
+        {\r
+            button = new UIButton();\r
+        }\r
+        button->SetPosition(x, y, w, h);\r
+        button->SetViewId(viewid);\r
+        button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        button->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        button->SetImageSrc(imagepath, nullptr);\r
+        button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED);\r
+        button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
+        button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+        button->SetOnClickListener(buttonclick);\r
+        scrollview->Add(button);\r
+        button->SetVisible(true);\r
     }\r
-    listAdapter->SetItemClickListener(presenter_);\r
 \r
-    title = new UILabel();\r
-    if (title == nullptr) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::title is nullptr");\r
-        return;\r
+    /// @brief 创建标签\r
+    /// @param scrollview\r
+    /// @param label\r
+    /// @param x\r
+    /// @param y\r
+    /// @param w\r
+    /// @param h\r
+    /// @param text_font 字体大小\r
+    /// @param line_height 字体行高\r
+    /// @param text 字体文本\r
+    void SettingView::CreateSettingLabel(UIScrollView *scrollview, UILabel *label, int x, int y, int w, int h, int text_font, int line_height, const char *text)\r
+    {\r
+        if (label == nullptr)\r
+        {\r
+            label = new UILabel();\r
+        }\r
+        label->SetPosition(x, y, w, h);\r
+        label->SetStyle(STYLE_TEXT_FONT, text_font);\r
+        label->SetStyle(STYLE_LINE_HEIGHT, line_height);\r
+        label->SetText(text);\r
+        label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, text_font);\r
+        scrollview->Add(label);\r
+        label->SetVisible(true);\r
     }\r
-    title->SetPosition(SETTING_TITLE_POSITION_X, 52);\r
-    title->SetText("设置");\r
-    title->Resize(SETTINGS_RESIZE_SIZE_WIDTH, SETTINGS_RESIZE_SIZE_HEIGHT);\r
-    title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTINGS_ITEM_FONT_SIZE);\r
-    title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-    title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-    title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);\r
-    title->SetStyle(STYLE_TEXT_COLOR, Color::White().full);\r
-    title->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-    title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);\r
-\r
-    contentList = new UIList();\r
-    if (contentList == nullptr) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr");\r
-        return;\r
+\r
+    /// @brief 创建图片\r
+    /// @param scrollview\r
+    /// @param imageview\r
+    /// @param x\r
+    /// @param y\r
+    /// @param w\r
+    /// @param h\r
+    /// @param imagepath\r
+    /// @param border_radius 边框圆角\r
+    void SettingView::CreateSettingImageView(UIScrollView *scrollview, UIImageView *imageview, int x, int y, int w, int h, const char *imagepath, int border_radius)\r
+    {\r
+        if (imageview == nullptr)\r
+        {\r
+            imageview = new UIImageView();\r
+        }\r
+        imageview->SetPosition(x, y, w, h);\r
+        imageview->SetStyle(STYLE_BORDER_RADIUS, border_radius);\r
+        imageview->SetSrc(imagepath);\r
+        scrollview->Add(imageview);\r
+        imageview->SetVisible(true);\r
     }\r
-    contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y);\r
-    contentList->Resize(380, 700);\r
-    contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE);\r
-    contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position\r
-    contentList->SetDraggable(true);\r
-    contentList->SetThrowDrag(false);\r
-    contentList->EnableAutoAlign(true);\r
-    contentList->SetMaxScrollDistance(MAX_SCR_DIS);\r
-\r
-    scrollView = new UIScrollView();\r
-    if (scrollView == nullptr) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::scrollView is nullptr");\r
-        return;\r
+\r
+    /// @brief 设置点击监听\r
+    /// @param clicklisten\r
+    void SettingView::SetClickListen(UIView::OnClickListener *clicklisten)\r
+    {\r
+        clicklisten = static_cast<UIView::OnClickListener *>(SettingPresenter::GetInstance());\r
     }\r
-    scrollView->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
-    scrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-    scrollView->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY);\r
-    scrollView->SetThrowDrag(true);\r
-\r
-    dragListener = new SettingPresenter();\r
-    if (dragListener == nullptr) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnStart::new dragListener is nullptr");\r
-        return;\r
+\r
+    void SettingView::InitSettingView(void)\r
+    {\r
+        // 创建标题\r
+        CreateSettingLabel(scrollView, titleLabel, 203, 52, 60, 35, 30, 35, "设置");\r
+        // SetClickListen(clicklisten);\r
+        clicklisten = static_cast<UIView::OnClickListener *>(SettingPresenter::GetInstance());\r
+        for (int i = 0; i < 5; i++)\r
+        {\r
+            // 创建5个按钮\r
+            CreateSettingButton(scrollView, button[i], BUTTON_X, BUTTON_Y + 120 * i, BUTTON_W, BUTTON_H, SETTING_BUTTON_VIEW_ID[i], BUTTON_IMAGE_PATH, clicklisten);\r
+            // 创建5个icon图片\r
+            CreateSettingImageView(scrollView, image[i], 62, 139 + 120 * i, 62, 62, ICON_IMAGE_PATH[i], 100);\r
+            // 创建5个标签\r
+            CreateSettingLabel(scrollView, label[i], 158, 153 + 120 * i, 150, 35, 30, 35, TEXT_LABEL[i]);\r
+            // 创建5个next图标\r
+            CreateSettingImageView(scrollView, image[i + 5], 369, 157 + 120 * i, 14, 26, "/user/res/SETTING_NEXT.bin", 100);\r
+        }\r
     }\r
-    scrollView->SetOnDragListener(dragListener);\r
-}\r
 \r
-void SettingView::OnSetUpView()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnSetUpView");\r
-    View<SettingPresenter>::OnSetUpView();\r
-    if (scrollView == nullptr || contentList == nullptr || listAdapter == nullptr || title == nullptr) {\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnSetUpView  has nullptr");\r
-        return;\r
+    void SettingView::DeInitView()\r
+    {\r
+        if (scrollView != nullptr)\r
+        {\r
+            scrollView->RemoveAll();\r
+            delete scrollView;\r
+        }\r
+        if (titleLabel != nullptr)\r
+        {\r
+            delete titleLabel;\r
+            titleLabel = nullptr;\r
+        }\r
+        for (int i = 0; i < 5; i++)\r
+        {\r
+            delete button[i];\r
+            button[i] = nullptr;\r
+\r
+            delete label[i];\r
+            label[i] = nullptr;\r
+\r
+            delete image[i];\r
+            image[i] = nullptr;\r
+\r
+            delete image[i + 5];\r
+            image[i + 5] = nullptr;\r
+        }\r
+        if (clicklisten != nullptr)\r
+        {\r
+            delete clicklisten;\r
+            clicklisten = nullptr;\r
+        }\r
+    }\r
+    void SettingView::PreLoad(void)\r
+    {\r
+        if (!viewInitStatus)\r
+        {\r
+            InitSettingView();\r
+            viewInitStatus = true;\r
+        }\r
+    }\r
+    void SettingView::OnStart()\r
+    {\r
+\r
+        scrollView = new UIScrollView();\r
+        if (scrollView == nullptr)\r
+        {\r
+            return;\r
+        }\r
+        scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+        scrollView->SetScrollBlankSize(35);\r
+        scrollView->SetReboundSize(50);\r
+        scrollView->SetDirection(1);\r
+        scrollView->SetTouchable(true);\r
+        scrollView->SetDraggable(true);\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SettingPresenter::GetInstance());\r
+        scrollView->SetOnDragListener(draglistener);\r
+        PreLoad();\r
+        RootView::GetInstance()->Add(scrollView);\r
     }\r
-    scrollView->Add(title);\r
-    scrollView->Add(contentList);\r
-    RootView::GetInstance()->Add(scrollView);\r
-    contentList->SetAdapter(listAdapter);\r
 \r
-    Draw();\r
-    return;\r
-}\r
+    void SettingView::OnSetUpView()\r
+    {\r
 \r
-void SettingView::OnTearDownView()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnTearDownView");\r
-    View<SettingPresenter>::OnTearDownView();\r
-    return;\r
-}\r
+        View<SettingPresenter>::OnSetUpView();\r
+        Draw();\r
+    }\r
 \r
-void SettingView::OnStop()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop");\r
-    View<SettingPresenter>::OnStop();\r
-    if (container_ != nullptr) {\r
-        container_->RemoveAll();\r
-        delete container_;\r
-        container_ = nullptr;\r
+    void SettingView::OnTearDownView()\r
+    {\r
+\r
+        View<SettingPresenter>::OnTearDownView();\r
+        return;\r
     }\r
-    RootView::GetInstance()->ClearOnKeyActListener();\r
-    RootView::GetInstance()->RemoveAll();\r
-    return;\r
-}\r
 \r
-void SettingView::AddSettingItemToList(const SettingItem &item)\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::AddSettingItemToList");\r
-    listAdapter->AddListItem(item);\r
-}\r
-}\r
+    void SettingView::OnStop()\r
+    {\r
+\r
+        View<SettingPresenter>::OnStop();\r
+        RootView::GetInstance()->RemoveAll();\r
+        return;\r
+    }\r
+}
\ No newline at end of file