From e848262caea15ec6efa53f9e2adacfb3f12cbc35 Mon Sep 17 00:00:00 2001 From: cheng Date: Thu, 22 Aug 2024 19:43:03 +0800 Subject: [PATCH] schedule file --- .../wearable/fd230app/CMakeLists.txt | 13 +- .../nativelauncher/include/NativeLauncher.h | 2 +- .../nativelauncher/src/NativeLauncher.cpp | 26 +- .../nativeui/applist/src/ApplistModel.cpp | 2 +- .../schedule/include/ScheduleListAdapter.h | 31 ++ .../schedule/include/ScheduleListItem.h | 63 +++ .../nativeui/schedule/include/ScheduleModel.h | 50 ++ .../schedule/include/SchedulePresenter.h | 42 ++ .../nativeui/schedule/include/ScheduleView.h | 85 ++++ .../schedule/src/ScheduleListAdapter.cpp | 81 ++++ .../schedule/src/ScheduleListItem.cpp | 142 ++++++ .../nativeui/schedule/src/ScheduleModel.cpp | 167 +++++++ .../schedule/src/SchedulePresenter.cpp | 132 ++++++ .../nativeui/schedule/src/ScheduleView.cpp | 448 ++++++++++++++++++ .../fs/user/res/Schedule/IMAGE_ITEM_ARROW.bin | 3 + 15 files changed, 1266 insertions(+), 21 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListAdapter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListItem.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleModel.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/include/SchedulePresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListAdapter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListItem.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleModel.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/src/SchedulePresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleView.cpp create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Schedule/IMAGE_ITEM_ARROW.bin diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 63e6c485f..46837da2e 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -132,7 +132,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits - # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/include ) set(SOURCES @@ -751,11 +751,12 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/goalhint.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/goalControlView.cpp - # #schedule - # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleView.cpp - # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/SchedulePresenter.cpp - # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleModel.cpp - # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListAdapter.cpp + #schedule + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/SchedulePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListAdapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListItem.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/calculator/src/CalculatorView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/calculator/src/CalculatorPresenter.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 9722f44d1..a3fd40998 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -120,7 +120,7 @@ namespace OHOS void InitDialingMethodSlice(void); /* -------------------------------------------------------------------------- */ void InitCalculatorSlice(void); - // void InitScheduleSlice(void); + void InitScheduleSlice(void); void InittestSlice(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 4ec1ca927..f46d76568 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -264,7 +264,7 @@ #include "traing/training_card/include/TraingCardPresenter.h" #include "traing/training_card/include/TraingCardView.h" /* -------------------------------------------------------------------------- */ -// #include "schedule/include/SchedulePresenter.h" +#include "schedule/include/SchedulePresenter.h" #ifdef SUPPORT_ALIPAY_SEC #include "AlipayMainView.h" @@ -414,7 +414,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ /*智能助手*/ {VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice}, - // {VIEW_SCHEDULE, &NativeLauncher::InitScheduleSlice}, + {VIEW_SCHEDULE, &NativeLauncher::InitScheduleSlice}, #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice}, @@ -1517,16 +1517,16 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_SET_DIAL_STYLE, setDialStyleView); } - // void NativeLauncher::InitScheduleSlice(void) - // { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitScheduleSlice"); - // SliceProxy * t_View = new AbilitySliceProxy; - // if (nullptr == t_View) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "View is nullptr"); - // return; - // } - // NativeAbility::GetInstance().AddSliceProxy(VIEW_SCHEDULE, t_View); - // } + void NativeLauncher::InitScheduleSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitScheduleSlice"); + SliceProxy * t_View = new AbilitySliceProxy; + if (nullptr == t_View) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "View is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SCHEDULE, t_View); + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index b84bc5eb1..9702822a7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -88,7 +88,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ // {VIEW_MUSIC_PLAYER, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_DEFAULT_IMG, "音乐播放器", STR_MUSIC, nullptr}, {VIEW_OFFLINEVOICE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_DEFAULT_IMG, "语音助手", STR_VOICE_ASSISTANT, nullptr}, - // {VIEW_SCHEDULE, PNG_APPLIST_SCHEDULE_IMAGE, PNG_APPLIST_SCHEDULE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "schedule", STR_SCHEDULE, nullptr}, + {VIEW_SCHEDULE, PNG_APPLIST_SCHEDULE_IMAGE, PNG_APPLIST_SCHEDULE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "schedule", STR_SCHEDULE, nullptr}, {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "设置", STR_SETTINGS, nullptr}, #if 0 /*屏蔽Slice*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListAdapter.h b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListAdapter.h new file mode 100644 index 000000000..e98c1ff8c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListAdapter.h @@ -0,0 +1,31 @@ + +#ifndef __SCHEDULELISTADAPTER_H__ +#define __SCHEDULELISTADAPTER_H__ + +#include "View.h" +#include "components/abstract_adapter.h" +#include "schedule/include/ScheduleModel.h" +#include "schedule/include/ScheduleListItem.h" + + +namespace OHOS +{ + class ScheduleListAdapter : public AbstractAdapter + { + public: + ScheduleListAdapter(); + ~ScheduleListAdapter() override; + ScheduleListAdapter * GetInstance(); + + UIView * GetView(UIView * inView, int16_t index) override; + uint16_t GetCount() override; + void AddListItem(const ScheduleListItemInfo &item); + + void SetItemClickListener(UIView::OnClickListener *itemClickListener); + + private: + List nodeList_; + UIView::OnClickListener * itemClickListener_; + }; +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListItem.h b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListItem.h new file mode 100644 index 000000000..09f5bef05 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleListItem.h @@ -0,0 +1,63 @@ + +#ifndef __SCHEDULELISTITEM_H__ +#define __SCHEDULELISTITEM_H__ + +#include "View.h" +#include "ohos_types.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + + +namespace OHOS +{ + typedef struct + { + std::string DateStr; + std::string TopicStr; + std::string TimeStr; + std::string DataStr; + uint8_t index; + bool is_date_item; + uint8_t child_num; // if(true == is_date_item) + uint8_t child_index; // if(false == is_date_item) + } ScheduleListItemInfo; + + + class ScheduleListItem : public UIViewGroup + { + public: + ScheduleListItem(); + ~ScheduleListItem() override; + void SetItemInfo(const ScheduleListItemInfo &itemInfo); + void ResetItemStyle(const ScheduleListItemInfo &itemInfo); + + + private: + ScheduleListItem(const ScheduleListItem &); + ScheduleListItem &operator = (const ScheduleListItem &); + + UIViewGroup InfoGroup_; + UILabelExt LabelExtDate_; + UILabelExt LabelExtTopic_; + UILabelExt LabelExtTime_; + UIImageView Image_; + // ScheduleListItemInfo itemInfo_ = { nullptr, nullptr, nullptr, nullptr, 0 }; + + #define ITEM_WIDTH (380) + #define ITEM_HEIGHT (100) + #define ITEM_GAP (20) + + #define ODD_ITEM_BACKGROUND_COLOR (0Xff001833) + #define ODD_ITEM_TOPIC_COLOR (0Xff0176ff) + #define ODD_ITEM_TIME_COLOR (0Xff8bc0ff) + + #define EVEN_ITEM_BACKGROUND_COLOR (0Xff331f00) + #define EVEN_ITEM_TOPIC_COLOR (0Xffff7b01) + #define EVEN_ITEM_TIME_COLOR (0Xffffc28b) + + #define IMAGE_ITEM_ARROW "/user/res/Schedule/IMAGE_ITEM_ARROW.bin" + // #define IMAGE_ITEM_ARROW "/user/res/settings/SETTINGS_DISPLAY_MODE.bin" + }; +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleModel.h b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleModel.h new file mode 100644 index 000000000..44e53e79d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleModel.h @@ -0,0 +1,50 @@ + +#ifndef __SCHEDULEMODEL_H__ +#define __SCHEDULEMODEL_H__ + +#include "ohos_types.h" +#include "schedule/include/ScheduleListItem.h" + + +namespace OHOS +{ + typedef struct + { + std::string date; // 7/8 + std::string topic; // xxxx + std::string time; //10:30-14:00 + std::string content; // yyyyyyy + }ScheduleRevData; + + #define SCHEDULE_DATA_COUNT_MAX (20) + + + class ScheduleModel + { + public: + static ScheduleModel &GetInstance(void); + uint8_t ScheduleDataInfoSet(void); + bool ScheduleDataIsEmpty(void); + ScheduleListItemInfo * ScheduleDataInfoGet(void); + + std::string ScheduleInfoDateStrGet(uint8_t index); + std::string ScheduleInfoTopicStrGet(uint8_t index); + std::string ScheduleInfoTimeStrGet(uint8_t index); + std::string ScheduleInfoDataStrGet(uint8_t index); + + void ScheduleSetByApp(ScheduleRevData * data, uint8_t index, bool is_finish); + + void ScheduleDataToInfo(void); + + private: + ScheduleModel(); + ~ScheduleModel(); + ScheduleModel(const ScheduleModel &) = delete; + ScheduleModel &operator=(const ScheduleModel &) = delete; + + ScheduleRevData ScheduleRevData_[SCHEDULE_DATA_COUNT_MAX] = {nullptr, nullptr, nullptr, nullptr}; + ScheduleListItemInfo ScheduleDataInfo_[SCHEDULE_DATA_COUNT_MAX*2] = {nullptr, nullptr, nullptr, nullptr, 0, false, 0, 0}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/include/SchedulePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/SchedulePresenter.h new file mode 100644 index 000000000..64dce3826 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/SchedulePresenter.h @@ -0,0 +1,42 @@ + +#ifndef __SCHEDULEPRESENTER_H__ +#define __SCHEDULEPRESENTER_H__ + +#include "Presenter.h" +#include "View.h" + +#include "schedule/include/ScheduleView.h" +#include "schedule/include/ScheduleModel.h" + + +namespace OHOS +{ + class ScheduleView; + class ScheduleModel; + class SchedulePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public RootView::OnKeyActListener + { + public: + SchedulePresenter(); + virtual ~SchedulePresenter(); + static SchedulePresenter * GetInstance(); + + void OnStart() override; + void OnResume() override; + void OnPause() override; + void OnStop() override; + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; + + ScheduleModel * ScheduleModel_; + bool X_DRAG_FLAG{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleView.h b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleView.h new file mode 100644 index 000000000..d6faf5c69 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/include/ScheduleView.h @@ -0,0 +1,85 @@ + +#ifndef __SCHEDULEVIEW_H__ +#define __SCHEDULEVIEW_H__ + +#include "View.h" +#include "ohos_types.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_list.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" +#include "common/screen.h" +#include "ui_resource_string.h" + +#include "schedule/include/SchedulePresenter.h" +#include "schedule/include/ScheduleListAdapter.h" +#include "schedule/include/ScheduleListItem.h" + + +namespace OHOS +{ + typedef enum + { + ENUM_SCHEDULE_NO_DATA_SCREEN, + ENUM_SCHEDULE_LIST_SCREEN, + ENUM_SCHEDULE_CONTENT_SCREEN, + ENUM_SCHEDULE_DELETE_SCREEN, + + ENUM_SCHEDULE_MAX_SCREEN + }ENUM_SCHEDULE_SCREEN; + + class SchedulePresenter; + class ScheduleView : public View + { + public: + ScheduleView(); + ~ScheduleView(); + static ScheduleView * GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void AddItemToList(const ScheduleListItemInfo &item); + void DisplayContentScreen(uint8_t index); + + private: + UIViewGroup * InitNoDataScreen(); + UIViewGroup * InitDataScreen(); + UILabelExt * InitLabel(int16_t x, int16_t y, int16_t width, int16_t height, + uint16_t line_height, uint8_t font_size, uint16_t text_id, uint32_t text_color); + void DisplayMainScreen(void); + + UIScrollView * InitContentScreen(); + + UIViewGroup * NoDataGroup_{nullptr}; + UILabelExt * LabelExt0_{nullptr}; + UIImageView * ImageView_{nullptr}; + UILabelExt * LabelExt1_{nullptr}; + UILabelExt * LabelExt2_{nullptr}; + + UIViewGroup * DataGroup_{nullptr}; + UIList * ScheduleList_{nullptr}; + ScheduleListAdapter * ScheduleListAdapter_{nullptr}; + + UIScrollView * ContentGroup_{nullptr}; + UILabelExt * ContentLabelExt0_{nullptr}; + UILabelExt * ContentLabelExt1_{nullptr}; + UILabelExt * ContentLabelExt2_{nullptr}; + UILabelExt * ContentLabelExt3_{nullptr}; + UIButton * ContentButton0_{nullptr}; + UIButton * ContentButton1_{nullptr}; + + UIViewGroup * GroupArray_[ENUM_SCHEDULE_MAX_SCREEN]{nullptr}; + + #define LIST_LEFT (43) + #define LIST_TOP (50) + #define LIST_WIDTH (Screen::GetInstance().GetWidth() - LIST_LEFT * 2) + #define LIST_HEIGHT (Screen::GetInstance().GetHeight() - LIST_TOP * 2) + + #define NO_DATA_IMAGE "/user/res/Schedule/schedule_no_data.bin" + }; +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListAdapter.cpp new file mode 100644 index 000000000..d1312f219 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListAdapter.cpp @@ -0,0 +1,81 @@ + + +#include "schedule/include/ScheduleListAdapter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static ScheduleListAdapter * p_ScheduleListAdapterInstance = nullptr; + + ScheduleListAdapter::ScheduleListAdapter() + { + p_ScheduleListAdapterInstance = this; + } + + ScheduleListAdapter::~ScheduleListAdapter() + { + p_ScheduleListAdapterInstance = nullptr; + nodeList_.Clear(); + } + + ScheduleListAdapter * ScheduleListAdapter::GetInstance() + { + return p_ScheduleListAdapterInstance; + } + + UIView * ScheduleListAdapter::GetView(UIView * inView, int16_t index) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:GetView,%d", __LINE__, index); + if(nodeList_.IsEmpty() || nodeList_.Size() <= index || 0 > index) + { + return nullptr; + } + + ScheduleListItem * item = nullptr; + ListNode * node = nodeList_.Begin(); + for (uint16_t i = 0; i < index; i++) + { + node = node->next_; + } + + if (nullptr == inView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:GetView", __LINE__); + item = new ScheduleListItem(); + if (nullptr == item) + return nullptr; + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:GetView", __LINE__); + item = static_cast(inView); + } + + if (item != nullptr) + { + item->SetViewIndex(index); + item->ResetItemStyle(node->data_); + item->SetItemInfo(node->data_); + item->SetOnClickListener(itemClickListener_); + } + + return item; + } + + uint16_t ScheduleListAdapter::GetCount() + { + return nodeList_.Size(); + } + + void ScheduleListAdapter::AddListItem(const ScheduleListItemInfo &item) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:AddListItem", __LINE__); + nodeList_.PushBack(item); + } + + void ScheduleListAdapter::SetItemClickListener(UIView::OnClickListener *itemClickListener) + { + itemClickListener_ = itemClickListener; + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListItem.cpp b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListItem.cpp new file mode 100644 index 000000000..b53ed61a9 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleListItem.cpp @@ -0,0 +1,142 @@ + +#include "ScheduleListItem.h" +#include "wearable_log.h" + +namespace OHOS +{ + ScheduleListItem::ScheduleListItem() + { + SetPosition(0, 0, ITEM_WIDTH, ITEM_HEIGHT + ITEM_GAP); + SetStyle(STYLE_BACKGROUND_COLOR, OHOS::Color::Black().full); + SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + // SetStyle(STYLE_BORDER_RADIUS, 20); + // SetTouchable(true); + + InfoGroup_.SetPosition(0, ITEM_GAP>>1, ITEM_WIDTH, ITEM_HEIGHT); + InfoGroup_.SetStyle(STYLE_BACKGROUND_COLOR, OHOS::Color::Black().full); + InfoGroup_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + InfoGroup_.SetStyle(STYLE_BORDER_RADIUS, 20); + InfoGroup_.SetTouchable(true); + + LabelExtDate_.SetPosition((ITEM_WIDTH - 300)>>1, (ITEM_HEIGHT - 55)>>1, 300, 55); + LabelExtDate_.SetStyle(STYLE_TEXT_FONT, 30); + LabelExtDate_.SetStyle(STYLE_LINE_HEIGHT, 35); + // LabelExtDate_.SetTextId(text_id); + LabelExtDate_.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + LabelExtDate_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LabelExtDate_.SetRollSpeed(70); + LabelExtDate_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + LabelExtDate_.SetStyle(STYLE_TEXT_COLOR, 0xffff5a36); + + LabelExtTopic_.SetPosition(47, 22, 250, 35); + LabelExtTopic_.SetStyle(STYLE_TEXT_FONT, 30); + LabelExtTopic_.SetStyle(STYLE_LINE_HEIGHT, 35); + // LabelExtTopic_.SetTextId(text_id); + LabelExtTopic_.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + LabelExtTopic_.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP); + LabelExtTopic_.SetRollSpeed(70); + LabelExtTopic_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // LabelExtTopic_.SetStyle(STYLE_TEXT_COLOR, 0xffff5a36); + + LabelExtTime_.SetPosition(47, 57, 105, 24); + LabelExtTime_.SetStyle(STYLE_TEXT_FONT, 20); + LabelExtTime_.SetStyle(STYLE_LINE_HEIGHT, 24); + // LabelExtTime_.SetTextId(text_id); + LabelExtTime_.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + LabelExtTime_.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP); + LabelExtTime_.SetRollSpeed(70); + LabelExtTime_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + // LabelExtTime_.SetStyle(STYLE_TEXT_COLOR, 0xffff5a36); + + Image_.SetPosition(326, 37, 14, 26); + Image_.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE); + Image_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + Image_.SetResizeMode(UIImageView::CENTER); + Image_.SetAutoEnable(false); + Image_.SetSrc(IMAGE_ITEM_ARROW); + + InfoGroup_.Add(&LabelExtDate_); + InfoGroup_.Add(&LabelExtTopic_); + InfoGroup_.Add(&LabelExtTime_); + InfoGroup_.Add(&Image_); + Add(&InfoGroup_); + } + + ScheduleListItem::~ScheduleListItem() + { + RemoveAll(); + } + + void ScheduleListItem::SetItemInfo(const ScheduleListItemInfo &itemInfo) + { + if(true == itemInfo.is_date_item) + { + LabelExtDate_.SetText(itemInfo.DateStr.c_str()); + } + else + { + if(0 == (itemInfo.child_index % 2)) + { + LabelExtTopic_.SetText(itemInfo.TopicStr.c_str()); + LabelExtTime_.SetText(itemInfo.TimeStr.c_str()); + } + else + { + LabelExtTopic_.SetText(itemInfo.TopicStr.c_str()); + LabelExtTime_.SetText(itemInfo.TimeStr.c_str()); + } + } + } + + void ScheduleListItem::ResetItemStyle(const ScheduleListItemInfo &itemInfo) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:ResetItemStyle,%d,%d,%d", + __LINE__, itemInfo.is_date_item, itemInfo.child_num, itemInfo.child_index); + + if(true == itemInfo.is_date_item) + { + SetHeight(ITEM_HEIGHT); + + InfoGroup_.SetStyle(STYLE_BACKGROUND_COLOR, OHOS::Color::Black().full); + InfoGroup_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + InfoGroup_.SetTouchable(false); + + LabelExtDate_.SetVisible(true); + LabelExtTopic_.SetVisible(false); + LabelExtTime_.SetVisible(false); + Image_.SetVisible(false); + } + else + { + if(0 == (itemInfo.child_index % 2)) + { + InfoGroup_.SetStyle(STYLE_BACKGROUND_COLOR, ODD_ITEM_BACKGROUND_COLOR); + InfoGroup_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + InfoGroup_.SetTouchable(true); + + LabelExtDate_.SetVisible(false); + LabelExtTopic_.SetVisible(true); + LabelExtTime_.SetVisible(true); + Image_.SetVisible(true); + + LabelExtTopic_.SetStyle(STYLE_TEXT_COLOR, ODD_ITEM_TOPIC_COLOR); + LabelExtTime_.SetStyle(STYLE_TEXT_COLOR, ODD_ITEM_TIME_COLOR); + } + else + { + InfoGroup_.SetStyle(STYLE_BACKGROUND_COLOR, EVEN_ITEM_BACKGROUND_COLOR); + InfoGroup_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + InfoGroup_.SetTouchable(true); + + LabelExtDate_.SetVisible(false); + LabelExtTopic_.SetVisible(true); + LabelExtTime_.SetVisible(true); + Image_.SetVisible(true); + + LabelExtTopic_.SetStyle(STYLE_TEXT_COLOR, EVEN_ITEM_TOPIC_COLOR); + LabelExtTime_.SetStyle(STYLE_TEXT_COLOR, EVEN_ITEM_TIME_COLOR); + } + } + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleModel.cpp new file mode 100644 index 000000000..1d5d7c061 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleModel.cpp @@ -0,0 +1,167 @@ + +#include "schedule/include/ScheduleModel.h" +#include "wearable_log.h" + +namespace OHOS +{ + ScheduleModel::ScheduleModel() + { + + } + + ScheduleModel::~ScheduleModel() + { + + } + + ScheduleModel &ScheduleModel::GetInstance() + { + static ScheduleModel instance; + return instance; + } + + static ScheduleListItemInfo t_data[10] = { + {"10-10", "date00", "a", "a", 0, true, 4, 0}, + {"10-10", "date000", "05:05", "jkguqpfhklal", 0, false, 0, 0}, + {"10-10", "date000", "06:06", "dalguqpfhklal", 0, false, 0, 1}, + {"10-10", "date002", "07:07", "atzdflal", 0, false, 0, 2}, + {"10-10", "date003", "08:08", "gjqpljkal", 0, false, 0, 3}, + + {"10-18", "date01", "b", "b", 0, true, 2, 0}, + {"10-18", "date011", "09:09", "qpfal", 0, false, 0, 0}, + {"10-18", "date011", "10:10", "tttccccccckgl", 0, false, 0, 1}, + + {"11-30", "date02", "c", "c", 0, true, 1, 0}, + {"11-30", "date020", "11:11", "qyq4100000fg21al", 0, false, 0, 0} + }; + + uint8_t ScheduleModel::ScheduleDataInfoSet(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleModel::ScheduleDataInfoSet 00"); + uint8_t count = 0; + + for(uint8_t i = 0; i < 10; i++) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:ScheduleModel::ScheduleDataInfoSet", __LINE__); + ScheduleDataInfo_[i].DateStr.assign(t_data[i].DateStr); + ScheduleDataInfo_[i].TopicStr.assign(t_data[i].TopicStr); + ScheduleDataInfo_[i].TimeStr.assign(t_data[i].TimeStr); + ScheduleDataInfo_[i].DataStr.assign(t_data[i].DataStr); + + ScheduleDataInfo_[i].index = t_data[i].index; + ScheduleDataInfo_[i].is_date_item = t_data[i].is_date_item; + ScheduleDataInfo_[i].child_num = t_data[i].child_num; + ScheduleDataInfo_[i].child_index = t_data[i].child_index; + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleModel::ScheduleDataInfoSet 10"); + + return count; + } + + bool ScheduleModel::ScheduleDataIsEmpty(void) + { + if(ScheduleDataInfo_[0].DateStr.length()) + return false; + + return true; + } + + ScheduleListItemInfo * ScheduleModel::ScheduleDataInfoGet(void) + { + return ScheduleDataInfo_; + } + + std::string ScheduleModel::ScheduleInfoDateStrGet(uint8_t index) + { + return ScheduleDataInfo_[index].DateStr.c_str(); + } + + std::string ScheduleModel::ScheduleInfoTopicStrGet(uint8_t index) + { + return ScheduleDataInfo_[index].TopicStr.c_str(); + } + + std::string ScheduleModel::ScheduleInfoTimeStrGet(uint8_t index) + { + return ScheduleDataInfo_[index].TimeStr.c_str(); + } + + std::string ScheduleModel::ScheduleInfoDataStrGet(uint8_t index) + { + return ScheduleDataInfo_[index].DataStr.c_str(); + } + + void ScheduleModel::ScheduleSetByApp(ScheduleRevData * data, uint8_t index, bool is_finish) + { + ScheduleRevData_[index].date.assign(data->date); + ScheduleRevData_[index].topic.assign(data->topic); + ScheduleRevData_[index].time.assign(data->time); + ScheduleRevData_[index].content.assign(data->content); + + if(true == is_finish) + { + ScheduleDataToInfo(); + } + } + + void ScheduleModel::ScheduleDataToInfo(void) + { + uint8_t i = 0; + uint8_t j = 0; + uint8_t count = 0; + + memset(ScheduleDataInfo_, 0x0, sizeof(ScheduleListItemInfo) * SCHEDULE_DATA_COUNT_MAX*2); + + count = 0; + + for(i = 0, j = 0; i < count, j < SCHEDULE_DATA_COUNT_MAX * 2; i++) + { + if(0 == i) + { + ScheduleDataInfo_[j].DateStr.assign(ScheduleRevData_[i].date); + ScheduleDataInfo_[j].index = j; + ScheduleDataInfo_[j].is_date_item = true; + + j++; + ScheduleDataInfo_[j].DateStr.assign(ScheduleRevData_[i].date); + ScheduleDataInfo_[j].TopicStr.assign(ScheduleRevData_[i].topic); + ScheduleDataInfo_[j].TimeStr.assign(ScheduleRevData_[i].time); + ScheduleDataInfo_[j].DataStr.assign(ScheduleRevData_[i].content); + ScheduleDataInfo_[j].index = j; + ScheduleDataInfo_[j].is_date_item = false; + ScheduleDataInfo_[j].child_index = 0; + } + else + { + if(0 == ScheduleRevData_[i].date.compare(ScheduleRevData_[i - 1].date)) + { + j++; + ScheduleDataInfo_[j].DateStr.assign(ScheduleRevData_[i].date); + ScheduleDataInfo_[j].TopicStr.assign(ScheduleRevData_[i].topic); + ScheduleDataInfo_[j].TimeStr.assign(ScheduleRevData_[i].time); + ScheduleDataInfo_[j].DataStr.assign(ScheduleRevData_[i].content); + ScheduleDataInfo_[j].index = j; + ScheduleDataInfo_[j].is_date_item = false; + ScheduleDataInfo_[j].child_index = ScheduleDataInfo_[i - 1].child_index + 1; + } + else + { + ScheduleDataInfo_[j].DateStr.assign(ScheduleRevData_[i].date); + ScheduleDataInfo_[j].index = j; + ScheduleDataInfo_[j].is_date_item = true; + + j++; + ScheduleDataInfo_[j].DateStr.assign(ScheduleRevData_[i].date); + ScheduleDataInfo_[j].TopicStr.assign(ScheduleRevData_[i].topic); + ScheduleDataInfo_[j].TimeStr.assign(ScheduleRevData_[i].time); + ScheduleDataInfo_[j].DataStr.assign(ScheduleRevData_[i].content); + ScheduleDataInfo_[j].index = j; + ScheduleDataInfo_[j].is_date_item = false; + ScheduleDataInfo_[j].child_index = 0; + } + } + } + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/src/SchedulePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/SchedulePresenter.cpp new file mode 100644 index 000000000..c831d33ce --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/SchedulePresenter.cpp @@ -0,0 +1,132 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 15:11:17 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-08 09:45:02 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/SchedulePresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "common/key_code.h" +#include +#include "UiConfig.h" +#include "schedule/include/SchedulePresenter.h" + + +namespace OHOS +{ + // 当前Presenter属性实例化的内存指针 + static SchedulePresenter * p_SchedulePresenterInstance = nullptr; + + SchedulePresenter::SchedulePresenter() + { + ScheduleModel_ = &ScheduleModel::GetInstance(); + p_SchedulePresenterInstance = this; + } + + SchedulePresenter::~SchedulePresenter() + { + p_SchedulePresenterInstance = nullptr; + } + + SchedulePresenter *SchedulePresenter::GetInstance() + { + return p_SchedulePresenterInstance; + } + + // 启动时执行的逻辑 + void SchedulePresenter::OnStart() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnStart"); + Presenter::OnStart(); + + ScheduleModel_->ScheduleDataInfoSet(); + } + + // 页面已经展示后的调用逻辑 + void SchedulePresenter::OnResume(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnResume"); + Presenter::OnResume(); + if (nullptr == view_) + { + return; + } + + ScheduleListItemInfo * ItemInfo = ScheduleModel_->ScheduleDataInfoGet(); + for (uint8_t i = 0; i < 10; i++) + { + view_->AddItemToList(ItemInfo[i]); + } + } + + // 页面准备切换到后台前执行的逻辑 + void SchedulePresenter::OnPause(void) + { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnPause"); + Presenter::OnPause(); + } + + // 页面完全置于后台时的逻辑。 + void SchedulePresenter::OnStop(void) + { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnStop"); + Presenter::OnStop(); + } + + bool SchedulePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnClick"); + + if (nullptr == &view) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:OnClick", __LINE__); + return false; + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:OnClick", __LINE__); + ScheduleListItem * item = static_cast(&view); + view_->DisplayContentScreen(item->GetViewIndex()); + } + return true; + } + + bool SchedulePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SchedulePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool SchedulePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SchedulePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + SchedulePresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool SchedulePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SchedulePresenter::OnKeyAct"); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleView.cpp new file mode 100644 index 000000000..aa22e2c50 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/schedule/src/ScheduleView.cpp @@ -0,0 +1,448 @@ + +#include "schedule/include/ScheduleView.h" +#include "wearable_log.h" + +namespace OHOS +{ + static ScheduleView * p_ScheduleViewInstance = nullptr; + + ScheduleView::ScheduleView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::ScheduleView"); + p_ScheduleViewInstance = this; + } + + ScheduleView::~ScheduleView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::~ScheduleView"); + p_ScheduleViewInstance = nullptr; + } + + ScheduleView * ScheduleView::GetInstance() + { + return p_ScheduleViewInstance; + } + + void ScheduleView::OnStart() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::OnStart"); + View::OnStart(); + + SetContainerView(new UIViewGroup()); + if (nullptr == GetContainer()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__); + return; + } + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + container_->SetOnDragListener(presenter_); + container_->Add(InitNoDataScreen()); + container_->Add(InitDataScreen()); + + RootView::GetInstance()->SetOnKeyActListener(presenter_); + } + + void ScheduleView::OnSetUpView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::OnSetUpView"); + View::OnSetUpView(); + + DisplayMainScreen(); + // GroupArray_ + Draw(); + } + + void ScheduleView::OnTearDownView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::OnTearDownView"); + View::OnTearDownView(); + } + + void ScheduleView::OnStop() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScheduleView::OnStop"); + View::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + + if (nullptr != container_) + { + container_->RemoveAll(); + if (nullptr != NoDataGroup_) + { + NoDataGroup_->RemoveAll(); + if (nullptr != LabelExt0_) + { + delete LabelExt0_; + LabelExt0_ = nullptr; + } + if (nullptr != ImageView_) + { + delete ImageView_; + ImageView_ = nullptr; + } + if (nullptr != LabelExt1_) + { + delete LabelExt1_; + LabelExt1_ = nullptr; + } + if (nullptr != LabelExt2_) + { + delete LabelExt2_; + LabelExt2_ = nullptr; + } + + delete NoDataGroup_; + NoDataGroup_ = nullptr; + } + if (nullptr != DataGroup_) + { + DataGroup_->RemoveAll(); + if (nullptr != ScheduleListAdapter_) + { + delete ScheduleListAdapter_; + ScheduleListAdapter_ = nullptr; + } + if (nullptr != ScheduleList_) + { + delete ScheduleList_; + ScheduleList_ = nullptr; + } + + delete DataGroup_; + DataGroup_ = nullptr; + } + delete container_; + container_ = nullptr; + } + } + + void ScheduleView::AddItemToList(const ScheduleListItemInfo &item) + { + ScheduleListAdapter_->AddListItem(item); + } + + void ScheduleView::DisplayMainScreen(void) + { + if(true == ScheduleModel::GetInstance().ScheduleDataIsEmpty()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:DisplayMainScreen", __LINE__); + NoDataGroup_->SetVisible(true); + DataGroup_->SetVisible(false); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:DisplayMainScreen", __LINE__); + NoDataGroup_->SetVisible(false); + DataGroup_->SetVisible(true); + ScheduleList_->RefreshList(); + } + } + + void ScheduleView::DisplayContentScreen(uint8_t index) + { + NoDataGroup_->SetVisible(false); + DataGroup_->SetVisible(false); + + UIScrollView * temp_group = InitContentScreen(); + if(nullptr == temp_group) + return; + + container_->Add(temp_group); + + ContentLabelExt0_->SetText(ScheduleModel::GetInstance().ScheduleInfoDateStrGet(index).c_str()); + + int16_t temp_y = 0; + temp_y = ContentLabelExt0_->GetY() + ContentLabelExt0_->GetHeight() + 50; + ContentLabelExt1_->SetY(temp_y); + ContentLabelExt1_->SetText(ScheduleModel::GetInstance().ScheduleInfoTopicStrGet(index).c_str()); + + temp_y = ContentLabelExt1_->GetY() + ContentLabelExt1_->GetHeight() + 20; + ContentLabelExt2_->SetY(temp_y); + ContentLabelExt2_->SetText(ScheduleModel::GetInstance().ScheduleInfoTimeStrGet(index).c_str()); + + temp_y = ContentLabelExt2_->GetY() + ContentLabelExt2_->GetHeight() + 20; + ContentLabelExt3_->SetY(temp_y); + ContentLabelExt3_->SetText(ScheduleModel::GetInstance().ScheduleInfoDataStrGet(index).c_str()); + + temp_y = ContentLabelExt3_->GetY() + ContentLabelExt3_->GetHeight() + 50; + ContentButton0_->SetY(temp_y); + + temp_y = ContentButton0_->GetY() + ContentButton0_->GetHeight() + 20; + ContentButton1_->SetY(temp_y); + } + + UIViewGroup * ScheduleView::InitNoDataScreen() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__); + if(nullptr == NoDataGroup_) + { + NoDataGroup_ = new UIViewGroup(); + if(nullptr == NoDataGroup_) + return nullptr; + } + NoDataGroup_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + NoDataGroup_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + NoDataGroup_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + NoDataGroup_->SetOnDragListener(presenter_); + NoDataGroup_->SetTouchable(true); + NoDataGroup_->SetDraggable(true); + + if(nullptr == LabelExt0_) + { + LabelExt0_ = InitLabel(83, 50, 300, 35, 35, 30, STR_SCHEDULE_TITLE, Color::White().full); + if(nullptr == LabelExt0_) + { + return nullptr; + } + } + + if(nullptr == ImageView_) + { + ImageView_ = new UIImageView(); + if(nullptr == ImageView_) + { + return nullptr; + } + + ImageView_->SetPosition(175, 150, 116, 120); + // ImageView_->SetAutoEnable(true); + // ImageView_->SetViewId(viewId); + ImageView_->SetSrc(NO_DATA_IMAGE); + } + + if(nullptr == LabelExt1_) + { + LabelExt1_ = InitLabel(53, 330, 360, 35, 35, 30, STR_SCHEDULE_NO_DATA, 0xff999999); + if(nullptr == LabelExt1_) + { + return nullptr; + } + } + + if(nullptr == LabelExt2_) + { + LabelExt2_ = InitLabel(53, 370, 360, 35, 35, 30, STR_SCHEDULE_NO_DATA_PROMPT, 0xff999999); + if(nullptr == LabelExt2_) + { + return nullptr; + } + } + + NoDataGroup_->Add(LabelExt0_); + NoDataGroup_->Add(ImageView_); + NoDataGroup_->Add(LabelExt1_); + NoDataGroup_->Add(LabelExt2_); + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__); + return NoDataGroup_; + } + + UIViewGroup * ScheduleView::InitDataScreen() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__); + if(nullptr == DataGroup_) + { + DataGroup_ = new UIViewGroup(); + if(nullptr == DataGroup_) + return nullptr; + } + DataGroup_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + DataGroup_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + DataGroup_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + DataGroup_->SetOnDragListener(presenter_); + DataGroup_->SetTouchable(true); + DataGroup_->SetDraggable(true); + + if(nullptr == ScheduleListAdapter_) + { + ScheduleListAdapter_ = new ScheduleListAdapter(); + if(nullptr == ScheduleListAdapter_) + return nullptr; + + ScheduleListAdapter_->SetItemClickListener(presenter_); + } + + if(nullptr == ScheduleList_) + { + ScheduleList_ = new UIList(); + if(nullptr == ScheduleList_) + { + return nullptr; + } + } + ScheduleList_->SetPosition(LIST_LEFT, LIST_TOP, LIST_WIDTH, LIST_HEIGHT); + // ScheduleList_->SetScrollBlankSize(30); + // ScheduleList_->SetSelectPosition(VERTICAL_RESOLUTION / 2); + ScheduleList_->SetDraggable(true); + ScheduleList_->SetThrowDrag(true); + // ScheduleList_->EnableAutoAlign(true); + ScheduleList_->SetAdapter(ScheduleListAdapter_); + // ScheduleList_->SetScrollStateListener(presenter_); + ScheduleList_->SetMaxScrollDistance(1000); // 1000: max scroll distance + ScheduleList_->SetSwipeACCLevel(800); // 800: compensation distance + ScheduleList_->SetDragACCLevel(5); // 5: drag acceleration + ScheduleList_->SetYScrollBarVisible(false); + + ScheduleList_->SetRotateFactor(2); // 增加表冠控制 + ScheduleList_->RequestFocus(); + + DataGroup_->Add(ScheduleList_); + + return DataGroup_; + } + + UIScrollView * ScheduleView::InitContentScreen() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__); + if(nullptr == ContentGroup_) + { + ContentGroup_ = new UIScrollView(); + if(nullptr == ContentGroup_) + return nullptr; + } + // ContentGroup_->SetViewIndex(ENUM_SCHEDULE_CONTENT_SCREEN); + ContentGroup_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + ContentGroup_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + ContentGroup_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + ContentGroup_->SetOnDragListener(presenter_); + ContentGroup_->SetTouchable(true); + ContentGroup_->SetDraggable(true); + + ContentGroup_->SetScrollBlankSize(40); + ContentGroup_->SetReboundSize(40); + ContentGroup_->SetDirection(1); + ContentGroup_->SetMaxScrollDistance(1000); + ContentGroup_->SetThrowDrag(true); + ContentGroup_->RequestFocus(); + ContentGroup_->SetRotateFactor(2); + + if(nullptr == ContentLabelExt0_) + { + ContentLabelExt0_ = new UILabelExt(); + if(nullptr == ContentLabelExt0_) + return nullptr; + + ContentLabelExt0_->SetPosition(83, 50, 300, 35); + ContentLabelExt0_->SetStyle(STYLE_TEXT_FONT, 30); + ContentLabelExt0_->SetStyle(STYLE_LINE_HEIGHT, 35); + // ContentLabelExt0_->SetTextId(text_id); + ContentLabelExt0_->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + ContentLabelExt0_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + ContentLabelExt0_->SetRollSpeed(70); + ContentLabelExt0_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ContentLabelExt0_->SetStyle(STYLE_TEXT_COLOR, 0xffff5a36); + } + + if(nullptr == ContentLabelExt1_) + { + ContentLabelExt1_ = new UILabelExt(); + if(nullptr == ContentLabelExt1_) + return nullptr; + + ContentLabelExt1_->SetPosition(53, 0, 360, 35); + ContentLabelExt1_->SetStyle(STYLE_TEXT_FONT, 30); + ContentLabelExt1_->SetStyle(STYLE_LINE_HEIGHT, 35); + // ContentLabelExt1_->SetTextId(text_id); + ContentLabelExt1_->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + ContentLabelExt1_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP); + ContentLabelExt1_->SetRollSpeed(70); + ContentLabelExt1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ContentLabelExt1_->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + } + + if(nullptr == ContentLabelExt2_) + { + ContentLabelExt2_ = new UILabelExt(); + if(nullptr == ContentLabelExt2_) + return nullptr; + + ContentLabelExt2_->SetPosition(53, 0, 360, 35); + ContentLabelExt2_->SetStyle(STYLE_TEXT_FONT, 30); + ContentLabelExt2_->SetStyle(STYLE_LINE_HEIGHT, 35); + // ContentLabelExt2_->SetTextId(text_id); + ContentLabelExt2_->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + ContentLabelExt2_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP); + ContentLabelExt2_->SetRollSpeed(70); + ContentLabelExt2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ContentLabelExt2_->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + } + + if(nullptr == ContentLabelExt3_) + { + ContentLabelExt3_ = new UILabelExt(); + if(nullptr == ContentLabelExt3_) + return nullptr; + + int16_t y = ContentLabelExt2_->GetHeight(); + ContentLabelExt3_->SetPosition(53, 0, 360, 35); + ContentLabelExt3_->SetStyle(STYLE_TEXT_FONT, 30); + ContentLabelExt3_->SetStyle(STYLE_LINE_HEIGHT, 35); + // ContentLabelExt3_->SetTextId(text_id); + ContentLabelExt3_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + ContentLabelExt3_->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP); + ContentLabelExt3_->SetRollSpeed(70); + ContentLabelExt3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ContentLabelExt3_->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + } + + if(nullptr == ContentButton0_) + { + ContentButton0_ = new UIButton(); + if(nullptr == ContentButton0_) + return nullptr; + + ContentButton0_->SetPosition(93, 0, 280, 90); + // ContentButton0_->SetViewId(); + ContentButton0_->SetStyle(STYLE_BACKGROUND_COLOR, 0xfffd5213); + ContentButton0_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + ContentButton0_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffd5213, UIButton::PRESSED); + } + + if(nullptr == ContentButton1_) + { + ContentButton1_ = new UIButton(); + if(nullptr == ContentButton1_) + return nullptr; + + ContentButton1_->SetPosition(93, 0, 280, 90); + // ContentButton1_->SetViewId(); + ContentButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + ContentButton1_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + ContentButton1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + } + + ContentGroup_->Add(ContentLabelExt0_); + ContentGroup_->Add(ContentLabelExt1_); + ContentGroup_->Add(ContentLabelExt2_); + ContentGroup_->Add(ContentLabelExt3_); + ContentGroup_->Add(ContentButton0_); + ContentGroup_->Add(ContentButton1_); + + return ContentGroup_; + } + + UILabelExt * ScheduleView::InitLabel(int16_t x, int16_t y, int16_t width, int16_t height, + uint16_t line_height, uint8_t font_size, uint16_t text_id, uint32_t text_color) + { + UILabelExt * LabelExt = new UILabelExt(); + if(nullptr == LabelExt) + { + return nullptr; + } + + LabelExt->SetPosition(x, y, width, height); + LabelExt->SetStyle(STYLE_TEXT_FONT, font_size); + LabelExt->SetStyle(STYLE_LINE_HEIGHT, line_height); + LabelExt->SetTextId(text_id); + LabelExt->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + LabelExt->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LabelExt->SetRollSpeed(70); + LabelExt->SetFont(DEFAULT_VECTOR_FONT_FILENAME, font_size); + LabelExt->SetStyle(STYLE_TEXT_COLOR, text_color); + + return LabelExt; + } + +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Schedule/IMAGE_ITEM_ARROW.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Schedule/IMAGE_ITEM_ARROW.bin new file mode 100644 index 000000000..4822819b2 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Schedule/IMAGE_ITEM_ARROW.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cba8ef0eaffc79e3918a64cac8e3e607f0f3522b827f2e02e855dd03017dd846 +size 360 -- 2.17.1