From: 罗正yun <1732036298@qq.com> Date: Sat, 23 Dec 2023 09:34:35 +0000 (+0800) Subject: 设置视图修改,使得各个按钮之间有空隙 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a78d5437ef1da5a7c3db363aaba208ac9b1a8e33;p=mirrors%2FFD230.git 设置视图修改,使得各个按钮之间有空隙 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h index ff45de5ab..80cd05eb6 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingAdapter.h @@ -1,61 +1,61 @@ -/* - * 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 -#include -#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 &data); - - /* * - * @brief Obtains the data size of the UILabel adapter. - * - * @return Returns the data 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 listData; - UIView::OnClickListener *itemClickListener{nullptr}; -}; -} - +/* + * 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 +#include +#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 &data); + + /* * + * @brief Obtains the data size of the UILabel adapter. + * + * @return Returns the data 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 listData; + UIView::OnClickListener *itemClickListener{nullptr}; +}; +} + #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h index f0339e3ba..3010026ea 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItem.h @@ -1,33 +1,33 @@ -/* - * 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 - -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; -} +/* + * 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 + +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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h index 690b44ad9..98cbb7715 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingItemView.h @@ -1,37 +1,37 @@ -/* - * 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 +/* + * 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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h index d3a36ba5f..ddabdf632 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingModel.h @@ -1,40 +1,40 @@ -/* - * 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 -#include -#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 &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 settingIdToViewId; - bool btConnectStatus{false}; - }; -} - -#endif +/* + * 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 +#include +#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 &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 settingIdToViewId; + bool btConnectStatus{false}; + }; +} + +#endif diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h index 96f98156e..a75344607 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingPresenter.h @@ -9,27 +9,28 @@ #define SETTING_PRESENTER_H #include "Presenter.h" -#include "components/ui_view.h" +#include "SettingView.h" +namespace OHOS +{ + class SettingView; + class SettingPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + SettingPresenter(); + virtual ~SettingPresenter(); + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static SettingPresenter *GetInstance(); -namespace OHOS { -class SettingView; -class SettingModel; -class SettingPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener { -public: - SettingPresenter(); - virtual ~SettingPresenter(); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS - virtual void OnStart() override; - virtual void OnResume() override; - virtual void OnStop() override; - - bool OnClick(UIView &view, const ClickEvent &event) override; - virtual bool OnDrag(UIView& view, const DragEvent& event) override; -private: - SettingModel *settingModel; -}; -} - -#endif // SETTING_PRESENTER_H \ No newline at end of file +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h index 2e3baddc2..9d261cb11 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/include/SettingView.h @@ -8,35 +8,49 @@ #ifndef SETTING_VIEW_H #define SETTING_VIEW_H +#include "BaseView.h" #include "View.h" -#include "components/root_view.h" #include "components/ui_view_group.h" #include "components/ui_scroll_view.h" #include "components/ui_label.h" -#include "components/ui_list.h" -#include "window/window.h" -#include "BaseView.h" -#include "SettingAdapter.h" -#include "ChangeSliceListener.h" -namespace OHOS { -class SettingPresenter; -class SettingView : public View { -public: - SettingView(); - virtual ~SettingView(); - - virtual void OnStart() override; - virtual void OnSetUpView() override; - virtual void OnTearDownView() override; - virtual void OnStop() override; - void AddSettingItemToList(const SettingItem &item); - -private: - SettingAdapter *listAdapter{nullptr}; - UIScrollView *scrollView{nullptr}; - UIList *contentList{nullptr}; - UILabel *title{nullptr}; - UIView::OnDragListener *dragListener{nullptr}; -}; +#include "components/ui_button.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class SettingPresenter; + class SettingView : public View + { + + public: + SettingView(); + virtual ~SettingView(); + static SettingView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void CreateSettingButton(UIScrollView *scrollview, UIButton *button, int x, int y, int w, int h, const char *viewid, const char *imagepath, UIView::OnClickListener *buttonclick); + void CreateSettingLabel(UIScrollView *scrollview, UILabel *label, int x, int y, int w, int h, int text_font, int line_height, const char *text); + void CreateSettingImageView(UIScrollView *scrollview, UIImageView *imageview, int x, int y, int w, int h, const char *imagepath, int border_radius); + void SetClickListen(UIView::OnClickListener *clicklisten); + + private: + void InitSettingView(void); + void DeInitView(void); + void PreLoad(void); + + private: + UIScrollView *scrollView = nullptr; + UILabel *titleLabel{nullptr}; // 标题:设置 + UIButton *button[5]{nullptr}; // 5个按钮 + UILabel *label[5]{nullptr}; // 5个标签 + UIImageView *image[10]{nullptr}; // 10张图片 + UIView::OnClickListener *clicklisten{nullptr}; // 点击监听 + bool viewInitStatus{false}; + }; } -#endif // SETTING_VIEW_H \ No newline at end of file +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp index fd28e63c5..3ffb62c85 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingAdapter.cpp @@ -1,68 +1,68 @@ -/* - * 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 &data) -{ - if (!listData.empty()) { - listData.clear(); - } - std::list::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::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(inView); - } - - item->SetItemInfo(itemData); - item->SetOnClickListener(itemClickListener); - return item; -} - -void SettingAdapter::AddListItem(const SettingItem &item) -{ - listData.push_back(item); -} -} // namespace OHOS +/* + * 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 &data) +{ + if (!listData.empty()) { + listData.clear(); + } + std::list::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::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(inView); + } + + item->SetItemInfo(itemData); + item->SetOnClickListener(itemClickListener); + return item; +} + +void SettingAdapter::AddListItem(const SettingItem &item) +{ + listData.push_back(item); +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp index b0ed32b68..e2b6a1dbb 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingItemView.cpp @@ -1,80 +1,80 @@ -/* - * 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; - } +/* + * 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 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp index 5bc4d3692..01c2e7131 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingModel.cpp @@ -1,71 +1,71 @@ -/* - * 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(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE)); - // settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE)); - // settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_REBOOT)); - // settingIdToViewId.insert(std::pair(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(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_BLUETOOTH)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_SOUND_VIBRATION)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_SECONDARY_FUNCTION)); - settingIdToViewId.insert(std::pair(SETTING_ITEM_FIVE, VIEW_SYSTEM)); - } - - const SettingItem *SettingModel::GetSettinglistItems() const - { - return settings; - } - - uint8_t SettingModel::GetSettingListNum() const - { - return SETTING_ITEM_LEN; - } - - const std::map &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); - } - } -} +/* + * 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(SETTING_ITEM_ZERO, VIEW_BLUETOOTH_EARPHONE)); + // settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_PHONE)); + // settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_REBOOT)); + // settingIdToViewId.insert(std::pair(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(SETTING_ITEM_ZERO, VIEW_DISPLAY_BRIGHTNESS)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_ONE, VIEW_CONNECT_BLUETOOTH)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_TWO, VIEW_SOUND_VIBRATION)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_THREE, VIEW_SECONDARY_FUNCTION)); + settingIdToViewId.insert(std::pair(SETTING_ITEM_FIVE, VIEW_SYSTEM)); + } + + const SettingItem *SettingModel::GetSettinglistItems() const + { + return settings; + } + + uint8_t SettingModel::GetSettingListNum() const + { + return SETTING_ITEM_LEN; + } + + const std::map &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); + } + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp index 7c8f3952f..4f159605b 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingPresenter.cpp @@ -1,52 +1,61 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingPresenter.cpp - * Author: - * Create: 2021-11-23 - */ - -#include "SettingView.h" -#include "SettingModel.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" #include "SettingPresenter.h" -#include "RebootModel.h" -namespace OHOS { + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SettingPresenter *g_pSettingPresenter = nullptr; + SettingPresenter::SettingPresenter() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::SettingPresenter()"); - settingModel = &SettingModel::GetInstance(); + + g_pSettingPresenter = this; } - SettingPresenter::~SettingPresenter() {} + SettingPresenter::~SettingPresenter() + { + + g_pSettingPresenter = nullptr; + } + + SettingPresenter *SettingPresenter::GetInstance() + { + + return g_pSettingPresenter; + } void SettingPresenter::OnStart() { + Presenter::OnStart(); - settingModel->InitSettingItem(); + } + + void SettingPresenter::OnPause(void) + { + + Presenter::OnPause(); } void SettingPresenter::OnResume(void) { - if (view_ == nullptr) { - return; - } - const SettingItem *itemInfo = settingModel->GetSettinglistItems(); - for (uint8_t i = 0; i < settingModel->GetSettingListNum(); i++) { - view_->AddSettingItemToList(itemInfo[i]); - } + + Presenter::OnResume(); } void SettingPresenter::OnStop(void) { - return; + + Presenter::OnStop(); } - bool SettingPresenter::OnDrag(UIView& view, const DragEvent& event) + bool SettingPresenter::OnDrag(UIView &view, const DragEvent &event) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::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(VIEW_APPLIST)"); + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); } return false; @@ -55,21 +64,27 @@ namespace OHOS { bool SettingPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); - SettingItemView *settingItemView = static_cast(&view); - SettingIndex index = settingItemView->GetSettingIndex(); - if (index >= SettingModel::GetInstance().GetSettingListNum()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnClick is no index"); - return false; - } else { - if (index == SETTING_ITEM_TWO) { - RebootModel::GetInstance()->SetSelectViewId(REBOOTDEVICE); - RebootModel::GetInstance()->SetExitsView(true); - } else if (index == SETTING_ITEM_THREE) { - RebootModel::GetInstance()->SetSelectViewId(SHUTDOWNDEVICE); - RebootModel::GetInstance()->SetExitsView(true); - } - NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index)); - return true; + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "Displayandbrightness") == 0) // 显示与亮度 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_DISPLAY_BRIGHTNESS); + } + else if (strcmp(view.GetViewId(), "bluetooth") == 0) // 蓝牙 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_CONNECT_BLUETOOTH); + } + else if (strcmp(view.GetViewId(), "Soundandvibration") == 0) // 声音与震动 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SOUND_VIBRATION); } + else if (strcmp(view.GetViewId(), "quickaccess") == 0) // 快速访问 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_QUICK_ACCESS); + } + else if (strcmp(view.GetViewId(), "system") == 0) // 系统 + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM); + } + return false; } -} +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp index 322647180..ce1087717 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/settings/src/SettingView.cpp @@ -1,156 +1,251 @@ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingView.cpp - * Author: - * Create: 2021-11-23 - */ - -#include - #include "SettingView.h" -#include "SettingItem.h" #include "SettingPresenter.h" +#include "UiConfig.h" -namespace OHOS { -static constexpr uint8_t SETTINGS_ITEM_FONT_SIZE = 30; -static constexpr int16_t SETTINGS_RESIZE_SIZE_WIDTH = 100; -static constexpr int16_t SETTINGS_RESIZE_SIZE_HEIGHT = 60; -static constexpr int16_t SETTING_TITLE_POSITION_X = 203; -static constexpr int16_t SETTING_LIST_POSITION_X = 43; -static constexpr int16_t SETTING_LIST_POSITION_Y = 120; -static constexpr int16_t SETTING_SCROLLBLANKSIZE = 50; -static constexpr int16 MAX_SCR_DIS = 1000; -static constexpr int16 LIST_POS = 20; -static constexpr int16 SNUM_2 = 2; - -SettingView::SettingView() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::SettingView"); -} + // 按钮上图片路径 + const char *BUTTON_IMAGE_PATH = "/user/res/SETTING_BACKGROUND.bin"; + // 每个按钮视图id + const char *SETTING_BUTTON_VIEW_ID[5] = { + "Displayandbrightness", // 显示与亮度 + "bluetooth", // 蓝牙 + "Soundandvibration", // 声音与震动 + "quickaccess", // 快速访问 + "system", // 系统 + }; + // 5个icon图片 + const char *ICON_IMAGE_PATH[5] = { + "/user/res/DISPLAY_BRIGHTNESS.bin", + "/user/res/SETTING_BLUETOOTH.bin", + "/user/res/SOUND_VIBRATION.bin", + "/user/res/QUICK_ACCESS.bin", + "/user/res/SYSTEM.bin", + }; + const char *TEXT_LABEL[5] = { + "屏幕与亮度", + "蓝牙", + "声音与震动", + "辅助功能", + "系统", + }; + + constexpr int BUTTON_X = 43; + constexpr int BUTTON_Y = 120; + constexpr int BUTTON_W = 380; + constexpr int BUTTON_H = 100; -SettingView::~SettingView() +} +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::~SettingView"); - scrollView->RemoveAll(); - delete title; - title = nullptr; - delete listAdapter; - listAdapter = nullptr; + static SettingView *g_pSettingView{nullptr}; - delete contentList; - contentList = nullptr; + SettingView::SettingView() + { - delete scrollView; - scrollView = nullptr; + g_pSettingView = this; + } - delete dragListener; - dragListener = nullptr; -} + SettingView::~SettingView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pSettingView = nullptr; + } -void SettingView::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart"); - View::OnStart(); + SettingView *SettingView::GetInstance() + { - BaseView::RootView(Color::Black().full); + return g_pSettingView; + } - listAdapter = new SettingAdapter(); - if (listAdapter == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::listAdapter is nullptr"); - return; + /// @brief 创建按钮 + /// @param scrollview + /// @param button + /// @param x x + /// @param y y + /// @param w width + /// @param h height + /// @param viewid 按钮id + /// @param imagepath 按钮上图片路径 + /// @param buttonclick 按钮点击监听 + void SettingView::CreateSettingButton(UIScrollView *scrollview, UIButton *button, int x, int y, int w, int h, const char *viewid, const char *imagepath, UIView::OnClickListener *buttonclick) + { + if (button == nullptr) + { + button = new UIButton(); + } + button->SetPosition(x, y, w, h); + button->SetViewId(viewid); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button->SetImageSrc(imagepath, nullptr); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetOnClickListener(buttonclick); + scrollview->Add(button); + button->SetVisible(true); } - listAdapter->SetItemClickListener(presenter_); - title = new UILabel(); - if (title == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::title is nullptr"); - return; + /// @brief 创建标签 + /// @param scrollview + /// @param label + /// @param x + /// @param y + /// @param w + /// @param h + /// @param text_font 字体大小 + /// @param line_height 字体行高 + /// @param text 字体文本 + void SettingView::CreateSettingLabel(UIScrollView *scrollview, UILabel *label, int x, int y, int w, int h, int text_font, int line_height, const char *text) + { + if (label == nullptr) + { + label = new UILabel(); + } + label->SetPosition(x, y, w, h); + label->SetStyle(STYLE_TEXT_FONT, text_font); + label->SetStyle(STYLE_LINE_HEIGHT, line_height); + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, text_font); + scrollview->Add(label); + label->SetVisible(true); } - title->SetPosition(SETTING_TITLE_POSITION_X, 52); - title->SetText("设置"); - title->Resize(SETTINGS_RESIZE_SIZE_WIDTH, SETTINGS_RESIZE_SIZE_HEIGHT); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, SETTINGS_ITEM_FONT_SIZE); - title->SetStyle(STYLE_LINE_HEIGHT, 35); - title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - title->SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - - contentList = new UIList(); - if (contentList == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr"); - return; + + /// @brief 创建图片 + /// @param scrollview + /// @param imageview + /// @param x + /// @param y + /// @param w + /// @param h + /// @param imagepath + /// @param border_radius 边框圆角 + void SettingView::CreateSettingImageView(UIScrollView *scrollview, UIImageView *imageview, int x, int y, int w, int h, const char *imagepath, int border_radius) + { + if (imageview == nullptr) + { + imageview = new UIImageView(); + } + imageview->SetPosition(x, y, w, h); + imageview->SetStyle(STYLE_BORDER_RADIUS, border_radius); + imageview->SetSrc(imagepath); + scrollview->Add(imageview); + imageview->SetVisible(true); } - contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y); - contentList->Resize(380, 700); - contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); - contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position - contentList->SetDraggable(true); - contentList->SetThrowDrag(false); - contentList->EnableAutoAlign(true); - contentList->SetMaxScrollDistance(MAX_SCR_DIS); - - scrollView = new UIScrollView(); - if (scrollView == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::scrollView is nullptr"); - return; + + /// @brief 设置点击监听 + /// @param clicklisten + void SettingView::SetClickListen(UIView::OnClickListener *clicklisten) + { + clicklisten = static_cast(SettingPresenter::GetInstance()); } - scrollView->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - scrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - scrollView->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); - scrollView->SetThrowDrag(true); - - dragListener = new SettingPresenter(); - if (dragListener == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnStart::new dragListener is nullptr"); - return; + + void SettingView::InitSettingView(void) + { + // 创建标题 + CreateSettingLabel(scrollView, titleLabel, 203, 52, 60, 35, 30, 35, "设置"); + // SetClickListen(clicklisten); + clicklisten = static_cast(SettingPresenter::GetInstance()); + for (int i = 0; i < 5; i++) + { + // 创建5个按钮 + CreateSettingButton(scrollView, button[i], BUTTON_X, BUTTON_Y + 120 * i, BUTTON_W, BUTTON_H, SETTING_BUTTON_VIEW_ID[i], BUTTON_IMAGE_PATH, clicklisten); + // 创建5个icon图片 + CreateSettingImageView(scrollView, image[i], 62, 139 + 120 * i, 62, 62, ICON_IMAGE_PATH[i], 100); + // 创建5个标签 + CreateSettingLabel(scrollView, label[i], 158, 153 + 120 * i, 150, 35, 30, 35, TEXT_LABEL[i]); + // 创建5个next图标 + CreateSettingImageView(scrollView, image[i + 5], 369, 157 + 120 * i, 14, 26, "/user/res/SETTING_NEXT.bin", 100); + } } - scrollView->SetOnDragListener(dragListener); -} -void SettingView::OnSetUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnSetUpView"); - View::OnSetUpView(); - if (scrollView == nullptr || contentList == nullptr || listAdapter == nullptr || title == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView:: OnSetUpView has nullptr"); - return; + void SettingView::DeInitView() + { + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + delete scrollView; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + for (int i = 0; i < 5; i++) + { + delete button[i]; + button[i] = nullptr; + + delete label[i]; + label[i] = nullptr; + + delete image[i]; + image[i] = nullptr; + + delete image[i + 5]; + image[i + 5] = nullptr; + } + if (clicklisten != nullptr) + { + delete clicklisten; + clicklisten = nullptr; + } + } + void SettingView::PreLoad(void) + { + if (!viewInitStatus) + { + InitSettingView(); + viewInitStatus = true; + } + } + void SettingView::OnStart() + { + + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + return; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView->SetScrollBlankSize(35); + scrollView->SetReboundSize(50); + scrollView->SetDirection(1); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + UIView::OnDragListener *draglistener = static_cast(SettingPresenter::GetInstance()); + scrollView->SetOnDragListener(draglistener); + PreLoad(); + RootView::GetInstance()->Add(scrollView); } - scrollView->Add(title); - scrollView->Add(contentList); - RootView::GetInstance()->Add(scrollView); - contentList->SetAdapter(listAdapter); - Draw(); - return; -} + void SettingView::OnSetUpView() + { -void SettingView::OnTearDownView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnTearDownView"); - View::OnTearDownView(); - return; -} + View::OnSetUpView(); + Draw(); + } -void SettingView::OnStop() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStop"); - View::OnStop(); - if (container_ != nullptr) { - container_->RemoveAll(); - delete container_; - container_ = nullptr; + void SettingView::OnTearDownView() + { + + View::OnTearDownView(); + return; } - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->RemoveAll(); - return; -} -void SettingView::AddSettingItemToList(const SettingItem &item) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::AddSettingItemToList"); - listAdapter->AddListItem(item); -} -} + void SettingView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file