--- /dev/null
+/***
+ * @Date: 2024-06-25 14:50:26
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditNap: 2024-07-01 15:10:12
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepNapView.h
+ */
+/***
+ * @Date: 2024-06-25 14:50:26
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditNap: 2024-06-25 17:29:03
+ * @FilePath:
+ * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepNapView.h
+ */
+/***
+ * @Date: 2024-06-25 14:50:26
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditNap: 2024-06-25 16:30:55
+ * @FilePath:
+ * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepNapView.h
+ */
+
+#ifndef Sleep_Nap_VIEW_H
+#define Sleep_Nap_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+
+#include "components/root_view.h"
+#include "components/ui_circle_progress.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+
+#include "AppGroupView.h"
+#include "wearable_log.h"
+#include <iostream>
+
+namespace OHOS {
+class SleepNapView : public AppGroupView {
+
+public:
+ SleepNapView();
+ virtual ~SleepNapView();
+ static SleepNapView *GetInstance(void);
+ bool InitPage(void);
+ virtual bool InitView(void *caller) override;
+ void ClearAll();
+ bool GetInitViewState(void);
+ void SleepDataRefresh();
+
+private:
+ UILabelExt *napsleeptitle{nullptr};
+ UILabelExt *napwaketitle{nullptr};
+ UILabelExt *naptitle{nullptr};
+ UILabelExt *napsleep{nullptr};
+ UILabelExt *napwake{nullptr};
+ UILabelExt *apptitle{nullptr}; // 详情
+
+ UIImageView *transverseline_1{nullptr}; // 横线1
+ UIImageView *transverseline_2{nullptr}; // 横线2
+ UIImageView *verticalline{nullptr}; // 竖线
+ bool viewInitStatus{false};
+};
+} // namespace OHOS
+
+#endif
\ No newline at end of file
--- /dev/null
+#include "sleep/include/SleepNapView.h"
+#include "ConfigModel.h"
+#include "common/image_cache_manager.h"
+#include "sleep/include/SleepModel.h"
+#include "string"
+#include "uicomponents/UIComponents.h"
+namespace OHOS {
+
+static SleepNapView *g_pSleepNapView{nullptr};
+static std::string restStr;
+static std::string sleepStr;
+static std::string wakeStr;
+static std::string napsleepStr;
+static std::string napwakeStr;
+SleepNapView::SleepNapView() {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepNapView::SleepNapView");
+ SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ SetViewIndex(0); // 视图索引
+
+ g_pSleepNapView = this;
+}
+
+SleepNapView::~SleepNapView() {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SleepNapView::~SleepNapView");
+ ClearAll();
+
+ g_pSleepNapView = nullptr;
+}
+
+void SleepNapView::SleepDataRefresh() {
+
+ int nap_hour = SleepModel::GetInstance().get_nap_hour();
+ int nap_min = SleepModel::GetInstance().get_nap_min();
+
+ //小睡数据
+ if (nap_hour != 0 || nap_min != 0) {
+ if (napsleep != nullptr && napwake != nullptr) {
+ napsleep->SetText((SleepModel::GetInstance().get_napsleep_str()).c_str());
+ napwake->SetText((SleepModel::GetInstance().get_napwake_str()).c_str());
+ }
+ }
+}
+
+void SleepNapView::ClearAll() {
+ RemoveAll();
+
+ if (transverseline_1 != nullptr) {
+ delete transverseline_1;
+ transverseline_1 = nullptr;
+ }
+ if (transverseline_2 != nullptr) {
+ delete transverseline_2;
+ transverseline_2 = nullptr;
+ }
+ if (verticalline != nullptr) {
+ delete verticalline;
+ verticalline = nullptr;
+ }
+
+ if (napsleeptitle != nullptr) {
+ delete napsleeptitle;
+ napsleeptitle = nullptr;
+ }
+ if (napwaketitle != nullptr) {
+ delete napwaketitle;
+ napwaketitle = nullptr;
+ }
+ if (napwake != nullptr) {
+ delete napwake;
+ napwake = nullptr;
+ }
+ if (napsleep != nullptr) {
+ delete napsleep;
+ napsleep = nullptr;
+ }
+ if (naptitle != nullptr) {
+ delete naptitle;
+ naptitle = nullptr;
+ }
+}
+
+SleepNapView *SleepNapView::GetInstance() { return g_pSleepNapView; }
+
+
+bool SleepNapView::InitPage(void) {
+ /* ---------------------------------- 线条初始化
+ * --------------------------------- */
+ CreateLine(transverseline_1, 0, 169, 466, 2, "transverseline_1");
+ CreateLine(transverseline_2, 0, 296, 466, 2, "transverseline_2");
+ CreateLine(verticalline, 232, 191, 2, 82, "verticalline");
+ /* -------------------------------- title初始化
+ * -------------------------------- */
+ InitLabel(naptitle, 83, 90, 300, 35, "resttitle", "小睡数据",
+ DEFAULT_VECTOR_FONT_FILENAME, 30);
+ InitLabelExt(napsleeptitle, 21, 203, 200, 35, "sleeptitle", STR_SLEEPTIME,
+ DEFAULT_VECTOR_FONT_FILENAME, 30);
+ InitLabelExt(napwaketitle, 213, 203, 300, 35, "waketitle", STR_WALKTIME,
+ DEFAULT_VECTOR_FONT_FILENAME, 30);
+ InitLabelExt(apptitle, 93, 300, 300, 200, "apptitle", STR_APPMORE,
+ DEFAULT_VECTOR_FONT_FILENAME, 26);
+ apptitle->SetTextColor(Color::Gray());
+ /* ------------------------------- 数据label初始化
+ * ------------------------------- */
+ napsleepStr = "--";
+ InitLabel(napsleep, 10, 238, 230, 47, "sleeplabel", napsleepStr.c_str(),
+ DEFAULT_VECTOR_FONT_FILENAME, 40);
+ napsleep->SetTextColor(Color::GetColorFromRGBA(0x53, 0x20, 0xE2, 0xff));
+ napwakeStr = "--";
+ InitLabel(napwake, 245, 238, 230, 47, "wakelabel", napwakeStr.c_str(),
+ DEFAULT_VECTOR_FONT_FILENAME, 40);
+ napwake->SetTextColor(Color::GetColorFromRGBA(0x53, 0x20, 0xE2, 0xff));
+ /* --------------------------------------------------------------------------
+ */
+ /* -------------------------------- 将组件添加到根视图
+ * ------------------------------- */
+ Add(transverseline_1);
+ Add(transverseline_2);
+ Add(verticalline);
+
+ Add(naptitle);
+ Add(napsleeptitle);
+ Add(napwaketitle);
+ Add(napsleep);
+ Add(napwake);
+ Add(apptitle);
+
+ return true;
+}
+
+bool SleepNapView::InitView(void *caller) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepNapView InitView %p", caller);
+ if (InitPage() == false) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepNapView::InitPage fail");
+ return false;
+ }
+ SetDraggable(true);
+ SetTouchable(true);
+ SleepDataRefresh();
+ return true;
+}
+
+// 获取视图初始化状态
+bool SleepNapView::GetInitViewState(void) { return viewInitStatus; }
+} // namespace OHOS
\ No newline at end of file