增加经期开始与结束的列表
authorCaisking <Casiking@zhihuishixun.com>
Fri, 24 Oct 2025 12:03:57 +0000 (20:03 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Fri, 24 Oct 2025 12:03:57 +0000 (20:03 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthDateAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthMainPage.h [new file with mode: 0644]
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthSettingPage.h [new file with mode: 0644]
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthSettingPage_new.h [new file with mode: 0644]
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthView.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthDateAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthMainPage.cpp [moved from code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthView.cpp with 93% similarity]
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthPresenter.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthSettingPage.cpp [new file with mode: 0644]

diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthDateAdapter.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthDateAdapter.h
new file mode 100644 (file)
index 0000000..ec0e092
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved.
+ * Description: WomenHealthDateAdapter - 女性健康日期列表适配器
+ * Create: 2025-01-24
+ */
+
+#ifndef WOMEN_HEALTH_DATE_ADAPTER_H
+#define WOMEN_HEALTH_DATE_ADAPTER_H
+
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/ui_label.h"
+#include "components/ui_view_group.h"
+#include "components/abstract_adapter.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+
+namespace OHOS {
+
+// 日期列表项数据结构
+struct WomenHealthDateItem {
+    char dateText[64];       // 日期文本(如"10月23日(今天)")
+    int year;
+    int month;
+    int day;
+    bool isToday;            // 是否是今天
+    const char* index;       // 索引标识(用于点击识别)
+};
+
+// 日期列表项视图
+class WomenHealthDateItemView : public UIViewGroup {
+public:
+    WomenHealthDateItemView();
+    ~WomenHealthDateItemView() override;
+    
+    void SetItemInfo(const WomenHealthDateItem& itemInfo);
+    const char* GetViewId();
+    
+private:
+    void SetUpChild();
+    
+    UILabel dateLabel_;
+    WomenHealthDateItem itemInfo_;
+};
+
+// 日期列表适配器
+class WomenHealthDateAdapter : public AbstractAdapter {
+public:
+    explicit WomenHealthDateAdapter();
+    ~WomenHealthDateAdapter() override;
+    
+    void SetData(std::list<WomenHealthDateItem>& data);
+    uint16_t GetCount() override;
+    UIView* GetView(UIView* inView, int16_t index) override;
+    void AddListItem(const WomenHealthDateItem& item);
+    void ClearListItem();
+    
+    void SetItemClickListener(UIView::OnClickListener* itemclicklistener)
+    {
+        itemClickListener_ = itemclicklistener;
+    }
+    
+    std::list<WomenHealthDateItem> listData_;  // 公开访问(供OnClick使用)
+    
+private:
+    UIView::OnClickListener* itemClickListener_{nullptr};
+};
+
+}
+
+#endif  // WOMEN_HEALTH_DATE_ADAPTER_H
+
diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthMainPage.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthMainPage.h
new file mode 100644 (file)
index 0000000..629d1c1
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved.
+ * Description: WomenHealthMainPage - 女性健康主页面
+ * Create: 2025-01-24
+ */
+
+#ifndef WOMEN_HEALTH_MAIN_PAGE_H
+#define WOMEN_HEALTH_MAIN_PAGE_H
+
+#include "components/ui_view_group.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_label_button.h"
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_image_view.h"
+#include "SlicePage.h"
+#include "UiConfig.h"
+#include "womenhealth/include/WomenHealthView.h"
+#include "womenhealth/include/WomenHealthPresenter.h"
+
+namespace OHOS {
+
+// 日期状态枚举
+enum DayStatus {
+    DAY_STATUS_NORMAL = 0,      // 普通日期
+    DAY_STATUS_TODAY,           // 今天(灰色)
+    DAY_STATUS_MENSTRUAL,       // 月经期(红色)
+    DAY_STATUS_OVULATION,       // 排卵期(蓝色)
+    DAY_STATUS_PREDICT          // 预测经期(浅红色)
+};
+
+class WomenHealthPresenter;
+
+// 女性健康主页面 - 显示日历
+class WomenHealthMainPage : public SlicePage<WomenHealthPresenter> {
+public:
+    WomenHealthMainPage();
+    ~WomenHealthMainPage() override;
+    
+    void OnStart(void* data) override;
+    
+    static WomenHealthMainPage* GetInstance();
+    bool updata_label(int8_t type);
+    bool IsShowingCurrentMonth();
+    void BackToToday();
+
+private:
+    bool Label_init();
+    
+    // 拆分后的初始化函数
+    void InitDayMarkers();
+    void InitTitleLabel();
+    void InitMonthLabel(int year, int month, int day, int weekday);
+    void InitArrowButtons();
+    void InitEditButton();
+    void InitWeekLabels();
+    void InitDayLabels();
+    void UpdateDayDisplay(int year, int month, int maxDays, int weekday);
+    
+    // 辅助函数
+    int CalculateMonthDays(int year, int month);
+    int CalculateWeekday(int year, int month, int day);
+    void UpdateArrowButtonsVisibility();
+    void UpdateEditButtonText();
+    
+    // 判断某一天的状态
+    DayStatus GetDayStatus(uint32_t year, uint32_t month, uint32_t day);
+    void DrawDayMarker(int dayIndex, int x, int y, DayStatus status);
+    
+    UIViewGroup* group{nullptr};
+    
+    // 顶部UI组件
+    UILabel* title_label{nullptr};
+    UILabel* mon_label{nullptr};
+    UILabelButton* left_arrow{nullptr};
+    UILabelButton* right_arrow{nullptr};
+    
+    // 星期和日期标签
+    UILabel* week_label[7]{nullptr};
+    UILabel* day_label[31]{nullptr};
+    
+    // 底部按钮
+    UILabelButton* edit_button{nullptr};
+    
+    // 颜色标记圆圈
+    UIImageView* dayMarker[31]{nullptr};
+    
+    uint32_t show_y{0};
+    uint32_t show_m{0};
+    uint32_t show_d{0};
+    
+    uint32_t today_y{0};
+    uint32_t today_m{0};
+    uint32_t today_d{0};
+};
+
+}
+
+#endif  // WOMEN_HEALTH_MAIN_PAGE_H
+
diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthSettingPage.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthSettingPage.h
new file mode 100644 (file)
index 0000000..2dc4508
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved.
+ * Description: WomenHealthSettingPage - 女性健康经期设置页面
+ * Create: 2025-01-24
+ */
+
+#ifndef WOMEN_HEALTH_SETTING_PAGE_H
+#define WOMEN_HEALTH_SETTING_PAGE_H
+
+#include "components/ui_label.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "SlicePage.h"
+#include "UiConfig.h"
+#include "womenhealth/include/WomenHealthView.h"
+#include "womenhealth/include/WomenHealthDateAdapter.h"
+
+namespace OHOS {
+
+class WomenHealthPresenter;
+
+// 女性健康设置页面 - 用于选择经期开始/结束日期
+class WomenHealthSettingPage : public SlicePage<WomenHealthPresenter>,
+                                public UIView::OnDragListener,
+                                public UIView::OnClickListener {
+public:
+    WomenHealthSettingPage();
+    ~WomenHealthSettingPage() override;
+    
+    void OnStart(void* data) override;
+    bool OnDrag(UIView& view, const DragEvent& event) override;
+    bool OnClick(UIView& view, const ClickEvent& event) override;
+    
+private:
+    void InitView();                    // 初始化视图
+    void InitTitleLabel();              // 初始化标题
+    void InitDateList();                // 初始化日期列表
+    void GenerateStartDateList(int days);    // 生成开始日期列表(最近N天)
+    void GenerateEndDateList(int startYear, int startMonth, int startDay, int maxDays); // 生成结束日期列表
+    void SwitchToEndDateMode(int startYear, int startMonth, int startDay); // 切换到结束日期选择模式
+    
+    UIViewGroup* group_{nullptr};                  // 主容器
+    UILabel* titleLabel_{nullptr};                 // 标题标签
+    UIList* dateList_{nullptr};                    // 日期列表
+    WomenHealthDateAdapter* adapter_{nullptr};     // 列表适配器
+    
+    bool isStartDate_{true};            // true=选择开始日期, false=选择结束日期
+    int startYear_{0};                  // 开始日期-年(用于生成结束日期列表)
+    int startMonth_{0};                 // 开始日期-月
+    int startDay_{0};                   // 开始日期-日
+    
+    char indexBuffer_[32][16];          // 存储index字符串
+};
+
+}
+
+#endif  // WOMEN_HEALTH_SETTING_PAGE_H
+
diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthSettingPage_new.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/include/WomenHealthSettingPage_new.h
new file mode 100644 (file)
index 0000000..2dc4508
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved.
+ * Description: WomenHealthSettingPage - 女性健康经期设置页面
+ * Create: 2025-01-24
+ */
+
+#ifndef WOMEN_HEALTH_SETTING_PAGE_H
+#define WOMEN_HEALTH_SETTING_PAGE_H
+
+#include "components/ui_label.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "SlicePage.h"
+#include "UiConfig.h"
+#include "womenhealth/include/WomenHealthView.h"
+#include "womenhealth/include/WomenHealthDateAdapter.h"
+
+namespace OHOS {
+
+class WomenHealthPresenter;
+
+// 女性健康设置页面 - 用于选择经期开始/结束日期
+class WomenHealthSettingPage : public SlicePage<WomenHealthPresenter>,
+                                public UIView::OnDragListener,
+                                public UIView::OnClickListener {
+public:
+    WomenHealthSettingPage();
+    ~WomenHealthSettingPage() override;
+    
+    void OnStart(void* data) override;
+    bool OnDrag(UIView& view, const DragEvent& event) override;
+    bool OnClick(UIView& view, const ClickEvent& event) override;
+    
+private:
+    void InitView();                    // 初始化视图
+    void InitTitleLabel();              // 初始化标题
+    void InitDateList();                // 初始化日期列表
+    void GenerateStartDateList(int days);    // 生成开始日期列表(最近N天)
+    void GenerateEndDateList(int startYear, int startMonth, int startDay, int maxDays); // 生成结束日期列表
+    void SwitchToEndDateMode(int startYear, int startMonth, int startDay); // 切换到结束日期选择模式
+    
+    UIViewGroup* group_{nullptr};                  // 主容器
+    UILabel* titleLabel_{nullptr};                 // 标题标签
+    UIList* dateList_{nullptr};                    // 日期列表
+    WomenHealthDateAdapter* adapter_{nullptr};     // 列表适配器
+    
+    bool isStartDate_{true};            // true=选择开始日期, false=选择结束日期
+    int startYear_{0};                  // 开始日期-年(用于生成结束日期列表)
+    int startMonth_{0};                 // 开始日期-月
+    int startDay_{0};                   // 开始日期-日
+    
+    char indexBuffer_[32][16];          // 存储index字符串
+};
+
+}
+
+#endif  // WOMEN_HEALTH_SETTING_PAGE_H
+
index 4b2a4a7..4d1002a 100644 (file)
@@ -1,6 +1,6 @@
- /*
+/*
  * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: CalculatorView.h
+ * Description: WomenHealthView.h - 女性健康View(空壳,用于关联Presenter)
  * Author:
  * Create: 2021-10-12
  */
@@ -9,98 +9,26 @@
 #define WomenHealth_VIEW_H
 
 #include "View.h"
+#include "womenhealth/include/WomenHealthPresenter.h"
 
-#include "components/ui_view_group.h"
-#include "components/ui_image_animator.h"
-#include "components/ui_scroll_view.h"
-#include "components/ui_label.h"
-#include "components/ui_label_ext.h"
-#include "components/ui_label_button.h"
-#include "components/ui_list.h"
-#include "components/abstract_adapter.h"
-#include "components/ui_image_view.h"
+namespace OHOS {
 
- #include "womenhealth/include/WomenHealthPresenter.h"
- 
- namespace OHOS {
-
-// 日期状态枚举
-enum DayStatus {
-    DAY_STATUS_NORMAL = 0,      // 普通日期
-    DAY_STATUS_TODAY,           // 今天(灰色)
-    DAY_STATUS_MENSTRUAL,       // 月经期(红色)
-    DAY_STATUS_OVULATION,       // 排卵期(蓝色)
-    DAY_STATUS_PREDICT          // 预测经期(浅红色)
+// 页面枚举 - 用于SlicePage切换
+enum WOMEN_HEALTH_PAGES {
+    WOMEN_HEALTH_MAIN_PAGE = 1,      // 主页面(日历视图)- 0 is invalid
+    WOMEN_HEALTH_SETTING_PAGE = 2,   // 设置页面(日期选择列表)
 };
 
+// 女性健康View - 空壳类,用于关联Presenter
+// 实际界面由WomenHealthMainPage和WomenHealthSettingPage实现
 class WomenHealthView : public View<WomenHealthPresenter>
 {
 public:
-    WomenHealthView();
-    ~WomenHealthView();
-
-    void OnStart() override;
-    static WomenHealthView *GetInstance();
-    bool updata_label(int8_t type);
-    
-    // 公共方法:判断当前是否显示今天所在月份
-    bool IsShowingCurrentMonth();
-
-    void BackToToday();                                            // 回到今天所在月份
-
-private:
-    bool Label_init();
-    
-    // 拆分后的初始化函数(降低耦合度)
-    void InitDayMarkers();                                         // 初始化颜色标记圆圈
-    void InitTitleLabel();                                         // 初始化顶部标题"生理周期"
-    void InitMonthLabel(int year, int month, int day, int weekday); // 初始化日期标签(X月X日 星期X)
-    void InitArrowButtons();                                       // 初始化左右箭头按钮
-    void InitEditButton();                                         // 初始化底部"编辑"按钮
-    void InitWeekLabels();                                         // 初始化星期标签
-    void InitDayLabels();                                          // 初始化日期标签UI对象
-    void UpdateDayDisplay(int year, int month, int maxDays, int weekday);  // 更新日期显示
-    
-    // 辅助函数
-    int CalculateMonthDays(int year, int month);                   // 计算某月有多少天
-    int CalculateWeekday(int year, int month, int day);            // 使用蔡勒公式计算星期几
-    void UpdateArrowButtonsVisibility();                           // 更新左右箭头按钮的显示状态
-    void UpdateEditButtonText();                                   // 更新底部按钮文本(编辑/回今天)
-
-    
-    // 判断某一天的状态(月经期、排卵期、预测经期等)
-    DayStatus GetDayStatus(uint32_t year, uint32_t month, uint32_t day);
-    
-    // 为指定日期绘制颜色标记圆圈
-    void DrawDayMarker(int dayIndex, int x, int y, DayStatus status);
-    
-    UIViewGroup *group{nullptr};
-    UIView:: OnDragListener* dragListener{nullptr};
-    
-    // 顶部UI组件
-    UILabel *title_label{nullptr};        // 标题"生理周期"
-    UILabel *mon_label{nullptr};          // 日期标签"X月X日 星期X"
-    UILabelButton *left_arrow{nullptr};   // 左箭头按钮
-    UILabelButton *right_arrow{nullptr};  // 右箭头按钮
-    
-    // 星期和日期标签
-    UILabel *week_label[7]{nullptr};
-    UILabel *day_label[31]{nullptr};
-    
-    // 底部按钮
-    UILabelButton *edit_button{nullptr};  // 编辑按钮
-    
-    // 不同状态的标记圆圈(最多显示31天)
-    UIImageView *dayMarker[31]{nullptr};  // 颜色标记圆圈数组
-    
-    uint32_t show_y=0;   // 当前显示的年
-    uint32_t show_m=0;   // 当前显示的月
-    uint32_t show_d=0;   // 当前显示的日
-    
-    uint32_t today_y=0;  // 今天的年
-    uint32_t today_m=0;  // 今天的月
-    uint32_t today_d=0;  // 今天的日
+    WomenHealthView() {}
+    ~WomenHealthView() override {}
+    void OnStart() override {}
 };
+
 }
 
-#endif
\ No newline at end of file
+#endif  // WomenHealth_VIEW_H
diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthDateAdapter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthDateAdapter.cpp
new file mode 100644 (file)
index 0000000..a9d0a1c
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved.
+ * Description: WomenHealthDateAdapter - 女性健康日期列表适配器实现
+ * Create: 2025-01-24
+ */
+
+#include "womenhealth/include/WomenHealthDateAdapter.h"
+#include "wearable_log.h"
+
+namespace OHOS {
+
+static constexpr int16_t DATE_ITEM_WIDTH = 394;
+static constexpr int16_t DATE_ITEM_HEIGHT = 70;
+static constexpr int16_t DATE_LABEL_FONT_SIZE = 30;
+
+//========== WomenHealthDateItemView 实现 ==========
+
+WomenHealthDateItemView::WomenHealthDateItemView()
+{
+    SetPosition(0, 0, DATE_ITEM_WIDTH, DATE_ITEM_HEIGHT);
+    SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    SetTouchable(true);
+    SetUpChild();
+    Add(&dateLabel_);
+}
+
+WomenHealthDateItemView::~WomenHealthDateItemView()
+{
+    Remove(&dateLabel_);
+}
+
+void WomenHealthDateItemView::SetUpChild()
+{
+    dateLabel_.SetPosition(0, 0, DATE_ITEM_WIDTH, DATE_ITEM_HEIGHT);
+    dateLabel_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);  // 文本居中显示
+    dateLabel_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, DATE_LABEL_FONT_SIZE);
+    dateLabel_.SetStyle(STYLE_TEXT_COLOR, Color::White().full);
+    dateLabel_.SetStyle(STYLE_TEXT_OPA, OPA_OPAQUE);
+    dateLabel_.SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+}
+
+void WomenHealthDateItemView::SetItemInfo(const WomenHealthDateItem& itemInfo)
+{
+    itemInfo_ = itemInfo;
+    dateLabel_.SetText(itemInfo.dateText);
+}
+
+const char* WomenHealthDateItemView::GetViewId()
+{
+    return itemInfo_.index;
+}
+
+//========== WomenHealthDateAdapter 实现 ==========
+
+WomenHealthDateAdapter::WomenHealthDateAdapter()
+{
+}
+
+WomenHealthDateAdapter::~WomenHealthDateAdapter()
+{
+    listData_.clear();
+}
+
+uint16_t WomenHealthDateAdapter::GetCount()
+{
+    return listData_.size();
+}
+
+void WomenHealthDateAdapter::SetData(std::list<WomenHealthDateItem>& data)
+{
+    if (!listData_.empty()) {
+        listData_.clear();
+    }
+    std::list<WomenHealthDateItem>::iterator it;
+    for (it = data.begin(); it != data.end(); it++) {
+        listData_.push_back(*it);
+    }
+}
+
+UIView* WomenHealthDateAdapter::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<WomenHealthDateItem>::iterator it = listData_.begin();
+    for (int i = 0; i < index; i++) {
+        it++;
+    }
+    WomenHealthDateItem itemData = *it;
+    
+    WomenHealthDateItemView* item = nullptr;
+    if (inView == nullptr) {
+        item = new WomenHealthDateItemView();
+    } else {
+        item = static_cast<WomenHealthDateItemView*>(inView);
+    }
+    
+    item->SetItemInfo(itemData);
+    item->SetOnClickListener(itemClickListener_);
+    return item;
+}
+
+void WomenHealthDateAdapter::AddListItem(const WomenHealthDateItem& item)
+{
+    listData_.push_back(item);
+}
+
+void WomenHealthDateAdapter::ClearListItem()
+{
+    listData_.clear();
+}
+
+}  // namespace OHOS
+
@@ -5,27 +5,32 @@
  * Create: 2021-10-12
  */
 
- #include "womenhealth/include/WomenHealthView.h"
+ #include "womenhealth/include/WomenHealthMainPage.h"
  #include "womenhealth/include/WomenHealthModel.h"
  #include "uicomponents/UIComponents.h"
+ #include "SlicePageFactory.h"
  
  #include "wearable_log.h"
  #include "UiConfig.h"
  #include "NativeAbility.h"
  #include "ConfigModel.h"
  #include "languagecode/LanguageInit.h"
+
 namespace OHOS
 {
-    // 全局静态指针,用于获取当前View实例
-    static WomenHealthView *g_pMainView_WomenHealthView = nullptr;
+    // 注册主页面
+    REGIST_SLICE_PAGE(VIEW_WOMEN_HEALTH, WOMEN_HEALTH_PAGES::WOMEN_HEALTH_MAIN_PAGE, WomenHealthMainPage, true);
+
+    // 全局静态指针,用于获取当前MainPage实例
+    static WomenHealthMainPage *g_pMainPage_WomenHealthMainPage = nullptr;
 
     /**
-     * @brief 构造函数 - 创建女性健康界面对象
+     * @brief 构造函数 - 创建女性健康主页面对象
      * 作用:初始化全局实例指针,让其他地方可以通过GetInstance()获取这个对象
      */
-    WomenHealthView::WomenHealthView()
+    WomenHealthMainPage::WomenHealthMainPage()
     {
-        g_pMainView_WomenHealthView = this; // 保存当前对象指针到全局变量
+        g_pMainPage_WomenHealthMainPage = this; // 保存当前对象指针到全局变量
     }
 
     /**
@@ -33,9 +38,9 @@ namespace OHOS
      * 作用:清理所有分配的内存,防止内存泄漏
      * 包括:主容器、月份标签、星期标签、日期标签、今日标记、动画等
      */
-    WomenHealthView::~WomenHealthView()
+    WomenHealthMainPage::~WomenHealthMainPage()
     {
-        g_pMainView_WomenHealthView = nullptr;
+        g_pMainPage_WomenHealthMainPage = nullptr;
         if (group) // 如果主容器存在
         {
             group->RemoveAll(); // 移除所有子控件
@@ -115,7 +120,7 @@ namespace OHOS
             group = nullptr;
         }
 
-        g_pMainView_WomenHealthView = nullptr;
+        g_pMainPage_WomenHealthMainPage = nullptr;
     }
 
     /**
@@ -123,9 +128,9 @@ namespace OHOS
      * @return 返回当前女性健康界面的指针
      * 作用:其他地方可以通过这个函数获取界面对象,进行界面更新等操作
      */
-    WomenHealthView *WomenHealthView::GetInstance()
+    WomenHealthMainPage *WomenHealthMainPage::GetInstance()
     {
-        return g_pMainView_WomenHealthView;
+        return g_pMainPage_WomenHealthMainPage;
     }
     
     /**
@@ -134,7 +139,7 @@ namespace OHOS
      * 
      * 作用:供Presenter调用,判断应该执行"编辑"还是"回今天"功能
      */
-    bool WomenHealthView::IsShowingCurrentMonth()
+    bool WomenHealthMainPage::IsShowingCurrentMonth()
     {
         return (show_y == today_y && show_m == today_m);
     }
@@ -150,7 +155,7 @@ namespace OHOS
      * @param month 月份(1-12)
      * @return 该月的天数
      */
-    int WomenHealthView::CalculateMonthDays(int year, int month)
+    int WomenHealthMainPage::CalculateMonthDays(int year, int month)
     {
         // 判断是否闰年
         bool isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
@@ -174,7 +179,7 @@ namespace OHOS
      * 
      * 使用系统的 mktime 和 localtime 函数来计算星期,避免手动实现蔡勒公式可能的错误
      */
-    int WomenHealthView::CalculateWeekday(int year, int month, int day)
+    int WomenHealthMainPage::CalculateWeekday(int year, int month, int day)
     {
         struct tm timeStruct = {0};
         timeStruct.tm_year = year - 1900;  // tm_year是从1900年开始
@@ -208,7 +213,7 @@ namespace OHOS
      * 作用:创建用于标记月经期、排卵期等状态的圆圈
      * 注意:必须先添加到容器,这样才会显示在日期标签下方
      */
-    void WomenHealthView::InitDayMarkers()
+    void WomenHealthMainPage::InitDayMarkers()
     {
         for (int i = 0; i < 31; i++) {
             if (dayMarker[i] == nullptr) {
@@ -227,7 +232,7 @@ namespace OHOS
     /**
      * @brief 初始化顶部标题"生理周期"
      */
-    void WomenHealthView::InitTitleLabel()
+    void WomenHealthMainPage::InitTitleLabel()
     {
         if (title_label == nullptr) {
             title_label = new UILabel();
@@ -253,7 +258,7 @@ namespace OHOS
      * @param day 日期(当前日期)
      * @param weekday 星期几
      */
-    void WomenHealthView::InitMonthLabel(int year, int month, int day, int weekday)
+    void WomenHealthMainPage::InitMonthLabel(int year, int month, int day, int weekday)
     {
         if (mon_label == nullptr) {
             mon_label = new UILabel();
@@ -283,7 +288,7 @@ namespace OHOS
     /**
      * @brief 初始化左右箭头按钮
      */
-    void WomenHealthView::InitArrowButtons()
+    void WomenHealthMainPage::InitArrowButtons()
     {
         // 左箭头按钮
         if (left_arrow == nullptr) {
@@ -335,7 +340,7 @@ namespace OHOS
     /**
      * @brief 初始化底部"编辑"按钮
      */
-    void WomenHealthView::InitEditButton()
+    void WomenHealthMainPage::InitEditButton()
     {
         if (edit_button == nullptr) {
             edit_button = new UILabelButton();
@@ -366,7 +371,7 @@ namespace OHOS
      * 作用:显示日历的星期头部
      * 注意:根据设计图要求,暂时不显示星期行
      */
-    void WomenHealthView::InitWeekLabels()
+    void WomenHealthMainPage::InitWeekLabels()
     {
         for (int i = 0; i < 7; i++) {
             if (week_label[i] == nullptr) {
@@ -403,7 +408,7 @@ namespace OHOS
      * 作用:预先创建所有可能用到的日期标签对象
      * 注意:因为去掉了星期行,日期起始Y坐标调整为120(原来是140)
      */
-    void WomenHealthView::InitDayLabels()
+    void WomenHealthMainPage::InitDayLabels()
     {
         for (int i = 0; i < 31; i++) {
             if (day_label[i] == nullptr) {
@@ -434,7 +439,7 @@ namespace OHOS
      * - 如果当前显示的是今天所在月份 → 显示"编辑"
      * - 如果当前显示的不是今天所在月份 → 显示"回今天"
      */
-    void WomenHealthView::UpdateEditButtonText()
+    void WomenHealthMainPage::UpdateEditButtonText()
     {
         if (edit_button == nullptr) {
             return;
@@ -453,7 +458,7 @@ namespace OHOS
      * 
      * 作用:点击"回今天"按钮时调用,将界面切换回今天所在的月份
      */
-    void WomenHealthView::BackToToday()
+    void WomenHealthMainPage::BackToToday()
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "回到今天所在月份: %d年%d月", today_y, today_m);
         
@@ -500,7 +505,7 @@ namespace OHOS
      * 1. 如果当前月 = 经期开始月,隐藏左箭头(不能查看更早的月份)
      * 2. 如果当前月 = 预测的最后一个月,隐藏右箭头(不能查看更晚的月份)
      */
-    void WomenHealthView::UpdateArrowButtonsVisibility()
+    void WomenHealthMainPage::UpdateArrowButtonsVisibility()
     {
         WomenHealthModel* model = WomenHealthModel::GetInstance();
         
@@ -545,7 +550,7 @@ namespace OHOS
      * @param maxDays 该月最大天数
      * @param weekday 1号是星期几
      */
-    void WomenHealthView::UpdateDayDisplay(int year, int month, int maxDays, int weekday)
+    void WomenHealthMainPage::UpdateDayDisplay(int year, int month, int maxDays, int weekday)
     {
         // 显示当月的所有日期
         for (int i = 0; i < maxDays; i++) {
@@ -594,7 +599,7 @@ namespace OHOS
      * 5. 预测月经期(粉色)
      * 6. 普通日期(白色)
      */
-    DayStatus WomenHealthView::GetDayStatus(uint32_t year, uint32_t month, uint32_t day)
+    DayStatus WomenHealthMainPage::GetDayStatus(uint32_t year, uint32_t month, uint32_t day)
     {
         // 获取当前系统时间
         time_t now;
@@ -651,7 +656,7 @@ namespace OHOS
      * - 今天:灰色 (0xFF808080)
      * - 普通日:不显示圆圈
      */
-    void WomenHealthView::DrawDayMarker(int dayIndex, int x, int y, DayStatus status)
+    void WomenHealthMainPage::DrawDayMarker(int dayIndex, int x, int y, DayStatus status)
     {
         // 如果是普通日期,隐藏标记
         if (status == DAY_STATUS_NORMAL) {
@@ -715,7 +720,7 @@ namespace OHOS
      * 7. 更新箭头按钮显示状态
      * 8. 刷新界面
      */
-    bool WomenHealthView::updata_label(int8_t type)
+    bool WomenHealthMainPage::updata_label(int8_t type)
     {
         // 第一步:隐藏所有日期标签和颜色标记
         for (int i = 0; i < 31; i++) {
@@ -820,7 +825,7 @@ namespace OHOS
      * 3. 依次调用各个初始化函数
      * 4. 更新日期显示
      */
-    bool WomenHealthView::Label_init()
+    bool WomenHealthMainPage::Label_init()
     {
         // 第一步:获取当前系统时间
         time_t currtime;
@@ -864,9 +869,9 @@ namespace OHOS
  
     /**
      * @brief 界面启动函数 - 进入女性健康界面时调用
-     * 
+     *
      * 作用:创建主容器并初始化所有UI组件
-     * 
+     *
      * 工作流程:
      * 1. 创建主容器(UIViewGroup)
      * 2. 设置容器大小为全屏
@@ -874,13 +879,13 @@ namespace OHOS
      * 4. 设置拖动监听器(由Presenter处理)
      * 5. 调用Label_init()初始化所有标签
      */
-    void WomenHealthView::OnStart()
+    void WomenHealthMainPage::OnStart(void* data)
     {
         // 创建主容器
         group = new UIViewGroup();
         if (group == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WomenHealthView::创建主容器失败");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WomenHealthMainPage::创建主容器失败");
             return;
         }
         
@@ -891,8 +896,8 @@ namespace OHOS
         group->SetDraggable(true);     // 允许拖动
         group->SetOnDragListener(presenter_);  // 设置拖动监听器,由Presenter处理滑动事件
         
-        // 将容器添加到根容器
-        AddViewToRootContainer(group);
+        // 将容器添加到页面容器(SlicePage方法)
+        AddViewToPageContainer(group);
 
         //测试一下效果 设置今天为月经开始日期
         TimeObj startDate = {2025, 10, 23};
@@ -901,7 +906,7 @@ namespace OHOS
         // 初始化所有标签和UI组件
         if (!Label_init())
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WomenHealthView::初始化标签失败");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WomenHealthMainPage::初始化标签失败");
             return;
         }
     }
index 4ffa656..44d425b 100644 (file)
@@ -6,6 +6,7 @@
  */
 
  #include "womenhealth/include/WomenHealthView.h"
+ #include "womenhealth/include/WomenHealthMainPage.h"
  #include "womenhealth/include/WomenHealthModel.h"
  #include "gfx_utils/mem_check.h"
  #include "common/key_code.h"
@@ -16,6 +17,7 @@
  namespace OHOS
  {
 
+    // 注册女性健康到菜单(View是空壳,实际界面由MainPage和SettingPage实现)
     REGIST_MENU_PRO(VIEW_WOMEN_HEALTH, WomenHealthView, WomenHealthPresenter,
         PNG_APPLIST_WOMANHEALTH_IMAGE_BIG, PNG_APPLIST_WOMANHEALTH_IMAGE, PNG_APPLIST_WOMANHEALTH_IMAGE, "女性健康", STR_WOMANHEALTH);
 
        if(strcmp(view.GetViewId(), NEXT_MONTH) == 0)
        {
            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "点击右箭头:切换到下个月");
-           WomenHealthView::GetInstance()->updata_label(2);
+           WomenHealthMainPage::GetInstance()->updata_label(2);
        }
        else if(strcmp(view.GetViewId(), PREV_MONTH) == 0)
        {
            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "点击左箭头:切换到上个月");
-           WomenHealthView::GetInstance()->updata_label(1);
+           WomenHealthMainPage::GetInstance()->updata_label(1);
        }
        else if(strcmp(view.GetViewId(), EDIT) == 0)
        {
            // 判断当前是否显示今天所在月份
-           if (WomenHealthView::GetInstance()->IsShowingCurrentMonth())
+           if (WomenHealthMainPage::GetInstance()->IsShowingCurrentMonth())
            {
-               // 当前显示今天所在月份 -> 执行"编辑"功能
-               WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "点击编辑按钮:跳转到编辑页面");
-               // TODO: 跳转到编辑页面,让用户设置经期开始日期
-               // NativeAbility::GetInstance().Navigate(VIEW_WOMEN_HEALTH_EDIT);
+               // 当前显示今天所在月份 -> 执行"编辑"功能,跳转到日期设置页面
+               WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "点击编辑按钮:跳转到经期设置页面");
+               NativeAbility::GetInstance().SwitchPageInSlice(
+                   WOMEN_HEALTH_PAGES::WOMEN_HEALTH_SETTING_PAGE,
+                   nullptr,
+                   TransitionType::TRANSITION_INVALID,
+                   true);
            }
            else
            {
                // 当前显示其他月份 -> 执行"回今天"功能
                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "点击回今天按钮:返回今天所在月份");
                //需要先判断界面是否存在
-               if(WomenHealthView::GetInstance() != nullptr)
+               if(WomenHealthMainPage::GetInstance() != nullptr)
                {
-                   WomenHealthView::GetInstance()->BackToToday();
+                   WomenHealthMainPage::GetInstance()->BackToToday();
                }
            }
        }
         //  if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)
         //  {
         //      // if(event.GetPreLastPoint().y-event.GetStartPoint().y>100)
-        //      WomenHealthView::GetInstance()->updata_label(2);
+        //      WomenHealthMainPage::GetInstance()->updata_label(2);
         //  }
         //  if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM)
         //  {
         //      // if(event.GetPreLastPoint().y-event.GetStartPoint().y>100)
-        //      WomenHealthView::GetInstance()->updata_label(1);
+        //      WomenHealthMainPage::GetInstance()->updata_label(1);
         //  }
          return true;
      }
diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthSettingPage.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/womenhealth/src/WomenHealthSettingPage.cpp
new file mode 100644 (file)
index 0000000..0661727
--- /dev/null
@@ -0,0 +1,470 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2025-2025. All rights reserved.
+ * Description: WomenHealthSettingPage - 女性健康经期设置页面实现
+ * Create: 2025-01-24
+ */
+
+#include "womenhealth/include/WomenHealthSettingPage.h"
+#include "womenhealth/include/WomenHealthMainPage.h"  // 添加主页面头文件,用于刷新日历
+#include "womenhealth/include/WomenHealthModel.h"
+#include "womenhealth/include/WomenHealthPresenter.h"
+#include "womenhealth/include/WomenHealthView.h"
+#include "NativeAbility.h"
+#include "SlicePageFactory.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include <time.h>
+#include <stdio.h>
+
+namespace OHOS {
+
+// 注册子页面 - 日期设置页面
+REGIST_SLICE_PAGE(VIEW_WOMEN_HEALTH, WOMEN_HEALTH_PAGES::WOMEN_HEALTH_SETTING_PAGE, WomenHealthSettingPage, false);
+
+static constexpr uint16_t TITLE_POS_X = 100;
+static constexpr uint16_t TITLE_POS_Y = 30;
+static constexpr uint16_t TITLE_WIDTH = 254;
+static constexpr uint16_t TITLE_HEIGHT = 50;
+static constexpr uint16_t TITLE_FONT_SIZE = 36;
+
+static constexpr uint16_t LIST_POS_X = 30;
+static constexpr uint16_t LIST_POS_Y = 100;
+static constexpr uint16_t LIST_WIDTH = 394;
+static constexpr uint16_t LIST_HEIGHT = 354;
+
+WomenHealthSettingPage::WomenHealthSettingPage()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WomenHealthSettingPage::WomenHealthSettingPage");
+}
+
+WomenHealthSettingPage::~WomenHealthSettingPage()
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WomenHealthSettingPage::~WomenHealthSettingPage");
+    
+    if (group_ != nullptr) {
+        group_->RemoveAll();
+        delete group_;
+        group_ = nullptr;
+    }
+    
+    if (titleLabel_ != nullptr) {
+        delete titleLabel_;
+        titleLabel_ = nullptr;
+    }
+    
+    if (dateList_ != nullptr) {
+        delete dateList_;
+        dateList_ = nullptr;
+    }
+    
+    if (adapter_ != nullptr) {
+        delete adapter_;
+        adapter_ = nullptr;
+    }
+}
+
+void WomenHealthSettingPage::OnStart(void* data)
+{
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WomenHealthSettingPage::OnStart");
+    InitView();
+}
+
+void WomenHealthSettingPage::InitView()
+{
+    // 创建主容器
+    group_ = new UIViewGroup();
+    if (group_ == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "创建主容器失败");
+        return;
+    }
+    group_->SetPosition(0, 0);
+    group_->Resize(466, 466);
+    group_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+    group_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
+    group_->SetOnDragListener(this);
+    group_->SetDraggable(true);
+    
+    // 初始化标题
+    InitTitleLabel();
+    
+    // 初始化日期列表
+    InitDateList();
+    
+    // 添加到页面容器
+    AddViewToPageContainer(group_);
+}
+
+void WomenHealthSettingPage::InitTitleLabel()
+{
+    titleLabel_ = new UILabel();
+    if (titleLabel_ == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "创建标题失败");
+        return;
+    }
+    
+    titleLabel_->SetPosition(TITLE_POS_X, TITLE_POS_Y, TITLE_WIDTH, TITLE_HEIGHT);
+    titleLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+    titleLabel_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TITLE_FONT_SIZE);
+    titleLabel_->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
+    titleLabel_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    titleLabel_->SetText("经期开始");
+    
+    group_->Add(titleLabel_);
+}
+
+void WomenHealthSettingPage::InitDateList()
+{
+    // 创建列表
+    dateList_ = new UIList(UIList::VERTICAL);
+    if (dateList_ == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "创建列表失败");
+        return;
+    }
+    
+    dateList_->SetPosition(LIST_POS_X, LIST_POS_Y, LIST_WIDTH, LIST_HEIGHT);
+    dateList_->SetThrowDrag(true);
+    dateList_->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    
+    // 创建适配器
+    adapter_ = new WomenHealthDateAdapter();
+    if (adapter_ == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "创建适配器失败");
+        return;
+    }
+    
+    // 设置点击监听器
+    adapter_->SetItemClickListener(this);
+    
+    // 生成开始日期列表(最近20天)
+    GenerateStartDateList(20);
+    
+    // 设置适配器并刷新列表
+    dateList_->SetAdapter(adapter_);
+    dateList_->RefreshList();
+    
+    // 添加到容器
+    group_->Add(dateList_);
+    
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "日期列表初始化完成,共%d项", adapter_->GetCount());
+}
+
+void WomenHealthSettingPage::GenerateStartDateList(int days)
+{
+    if (adapter_ == nullptr) {
+        return;
+    }
+    
+    adapter_->ClearListItem();
+    
+    // 获取当前时间
+    time_t now = time(nullptr);
+    struct tm* currentTm = localtime(&now);
+    
+    // 生成日期列表(从20天前到今天,正序排列)
+    for (int i = days - 1; i >= 0; i--) {  // 倒序遍历,实现正序显示
+        time_t targetTime = now - (i * 24 * 3600); // 往前推i天
+        struct tm* targetTm = localtime(&targetTime);
+        
+        WomenHealthDateItem item;
+        item.year = targetTm->tm_year + 1900;
+        item.month = targetTm->tm_mon + 1;
+        item.day = targetTm->tm_mday;
+        item.isToday = (i == 0);
+        
+        // 格式化日期文本:月/日 格式
+        if (item.isToday) {
+            snprintf(item.dateText, sizeof(item.dateText), "%d/%d(今天)", 
+                     item.month, item.day);
+        } else {
+            snprintf(item.dateText, sizeof(item.dateText), "%d/%d", 
+                     item.month, item.day);
+        }
+        
+        // 设置索引(用于点击识别)
+        int index = days - 1 - i;  // 计算正确的索引
+        snprintf(indexBuffer_[index], sizeof(indexBuffer_[index]), "%d", index);
+        item.index = indexBuffer_[index];
+        
+        adapter_->AddListItem(item);
+    }
+    
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "生成了%d个开始日期项(从20天前到今天)", days);
+}
+
+void WomenHealthSettingPage::GenerateEndDateList(int startYear, int startMonth, int startDay, int maxDays)
+{
+    if (adapter_ == nullptr) {
+        return;
+    }
+    
+    adapter_->ClearListItem();
+    
+    // 构造开始日期
+    struct tm startTm = {0};
+    startTm.tm_year = startYear - 1900;
+    startTm.tm_mon = startMonth - 1;
+    startTm.tm_mday = startDay;
+    time_t startTime = mktime(&startTm);
+    
+    // 获取当前时间
+    time_t now = time(nullptr);
+    
+    // 计算从开始日期到今天的天数
+    int daysDiff = (now - startTime) / (24 * 3600);
+    int actualDays = (daysDiff < maxDays) ? daysDiff : maxDays;  // 取较小值
+    
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "生成结束日期列表: 从%d-%02d-%02d开始到今天,共%d天", 
+                  startYear, startMonth, startDay, actualDays);
+    
+    // 生成从开始日期+1天到今天的列表
+    for (int i = 1; i <= actualDays; i++) {
+        time_t targetTime = startTime + (i * 24 * 3600); // 往后推i天
+        struct tm* targetTm = localtime(&targetTime);
+        
+        WomenHealthDateItem item;
+        item.year = targetTm->tm_year + 1900;
+        item.month = targetTm->tm_mon + 1;
+        item.day = targetTm->tm_mday;
+        item.isToday = false;
+        
+        // 格式化日期文本:月/日 格式
+        snprintf(item.dateText, sizeof(item.dateText), "%d/%d", 
+                 item.month, item.day);
+        
+        // 设置索引
+        snprintf(indexBuffer_[i-1], sizeof(indexBuffer_[i-1]), "%d", i);
+        item.index = indexBuffer_[i-1];
+        
+        adapter_->AddListItem(item);
+    }
+    
+    // 添加最后一项"还不知道"
+    WomenHealthDateItem unknownItem;
+    unknownItem.year = 0;
+    unknownItem.month = 0;
+    unknownItem.day = 0;
+    unknownItem.isToday = false;
+    snprintf(unknownItem.dateText, sizeof(unknownItem.dateText), "还不知道");
+    snprintf(indexBuffer_[actualDays], sizeof(indexBuffer_[actualDays]), "unknown");
+    unknownItem.index = indexBuffer_[actualDays];
+    adapter_->AddListItem(unknownItem);
+    
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "生成了%d个结束日期项(含'还不知道')", actualDays + 1);
+}
+
+void WomenHealthSettingPage::SwitchToEndDateMode(int startYear, int startMonth, int startDay)
+{
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "切换到结束日期选择模式,开始日期: %d-%02d-%02d", 
+                  startYear, startMonth, startDay);
+    
+    // 保存开始日期
+    startYear_ = startYear;
+    startMonth_ = startMonth;
+    startDay_ = startDay;
+    
+    // 切换模式
+    isStartDate_ = false;
+    
+    // 更新标题
+    if (titleLabel_ != nullptr) {
+        titleLabel_->SetText("经期结束");
+    }
+    
+    // 生成结束日期列表(最多20天)
+    GenerateEndDateList(startYear, startMonth, startDay, 20);
+    
+    // 刷新列表显示
+    if (dateList_ != nullptr) {
+        dateList_->RefreshList();
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "结束日期列表已刷新");
+    }
+}
+
+bool WomenHealthSettingPage::OnClick(UIView& view, const ClickEvent& event)
+{
+    UNUSED(event);
+    
+    // 获取点击的列表项
+    WomenHealthDateItemView* itemView = static_cast<WomenHealthDateItemView*>(&view);
+    if (itemView == nullptr) {
+        return false;
+    }
+    
+    const char* viewId = itemView->GetViewId();
+    int index = atoi(viewId);
+    
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "点击了列表项,index=%d", index);
+    
+    // 获取适配器中的数据
+    std::list<WomenHealthDateItem>& listData = adapter_->listData_;
+    if (listData.empty()) {
+        return false;
+    }
+    
+    // 根据index找到对应的item
+    std::list<WomenHealthDateItem>::iterator it = listData.begin();
+    int currentIndex = 0;
+    
+    if (isStartDate_) {
+        // 开始日期列表
+        for (it = listData.begin(); it != listData.end(); it++, currentIndex++) {
+            if (currentIndex == index) {
+                break;
+            }
+        }
+    } else {
+        // 结束日期列表
+        for (it = listData.begin(); it != listData.end(); it++, currentIndex++) {
+            if (currentIndex == index - 1) {
+                break;
+            }
+        }
+    }
+    
+    if (it == listData.end()) {
+        return false;
+    }
+    
+    WomenHealthDateItem& selectedItem = *it;
+    WomenHealthModel* model = WomenHealthModel::GetInstance();
+    
+    if (isStartDate_) {
+        // ========== 选择开始日期 ==========
+        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "用户选择经期开始日期: %d-%02d-%02d %s", 
+                      selectedItem.year, selectedItem.month, selectedItem.day,
+                      selectedItem.isToday ? "(今天)" : "");
+        
+        // 如果选择的是今天,直接设置开始日期并返回主页面
+        if (selectedItem.isToday) {
+            TimeObj startDate = {selectedItem.year, selectedItem.month, selectedItem.day};
+            model->SetMenstrualStartDate(startDate);
+            
+            // 今天开始,设置结束日期也为今天(假设经期还在进行中)
+            TimeObj endDate = {selectedItem.year, selectedItem.month, selectedItem.day};
+            model->SetMenstrualEndDate(endDate);
+            
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "选择今天作为开始日期,直接返回主页面");
+            
+            // 刷新主页面日历显示
+            if (WomenHealthMainPage::GetInstance() != nullptr) {
+                WomenHealthMainPage::GetInstance()->updata_label(0);  // 刷新当前月份显示
+            }
+            
+            NativeAbility::GetInstance().SwitchPageInSlice(
+                WOMEN_HEALTH_PAGES::WOMEN_HEALTH_MAIN_PAGE, 
+                nullptr,
+                TransitionType::TRANSITION_INVALID, 
+                true);
+        } else {
+            // 选择的不是今天,需要继续选择结束日期
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "选择非今天,切换到结束日期选择模式");
+            SwitchToEndDateMode(selectedItem.year, selectedItem.month, selectedItem.day);
+        }
+    } else {
+        // ========== 选择结束日期 ==========
+        
+        // 检查是否选择了"还不知道"
+        if (selectedItem.year == 0) {
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "用户选择'还不知道',设置开始日期,结束日期为今天");
+            
+            // 设置开始日期
+            TimeObj startDate = {startYear_, startMonth_, startDay_};
+            model->SetMenstrualStartDate(startDate);
+            
+            // 设置结束日期为今天(经期还在继续)
+            time_t now = time(nullptr);
+            struct tm* currentTm = localtime(&now);
+            TimeObj endDate = {currentTm->tm_year + 1900, currentTm->tm_mon + 1, currentTm->tm_mday};
+            model->SetMenstrualEndDate(endDate);
+            
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "经期设置: 开始%d-%02d-%02d,结束%d-%02d-%02d(今天)", 
+                          startYear_, startMonth_, startDay_,
+                          endDate.year, endDate.month, endDate.day);
+            
+            // 刷新主页面日历显示
+            if (WomenHealthMainPage::GetInstance() != nullptr) {
+                WomenHealthMainPage::GetInstance()->updata_label(0);  // 刷新当前月份显示
+            }
+            
+            // 返回主页面
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "经期设置完成,返回主页面");
+            NativeAbility::GetInstance().SwitchPageInSlice(
+                WOMEN_HEALTH_PAGES::WOMEN_HEALTH_MAIN_PAGE, 
+                nullptr,
+                TransitionType::TRANSITION_INVALID, 
+                true);
+        } else {
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "用户选择经期结束日期: %d-%02d-%02d", 
+                          selectedItem.year, selectedItem.month, selectedItem.day);
+            
+            // 计算经期天数
+            struct tm startTm = {0};
+            startTm.tm_year = startYear_ - 1900;
+            startTm.tm_mon = startMonth_ - 1;
+            startTm.tm_mday = startDay_;
+            time_t startTime = mktime(&startTm);
+            
+            struct tm endTm = {0};
+            endTm.tm_year = selectedItem.year - 1900;
+            endTm.tm_mon = selectedItem.month - 1;
+            endTm.tm_mday = selectedItem.day;
+            time_t endTime = mktime(&endTm);
+            
+            int days = (endTime - startTime) / (24 * 3600) + 1; // +1包括结束日当天
+            
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "经期天数: %d天 (从%d-%02d-%02d到%d-%02d-%02d)", 
+                          days,
+                          startYear_, startMonth_, startDay_,
+                          selectedItem.year, selectedItem.month, selectedItem.day);
+            
+            // 设置经期开始日期
+            TimeObj startDate = {startYear_, startMonth_, startDay_};
+            model->SetMenstrualStartDate(startDate);
+            
+            // 设置经期结束日期
+            TimeObj endDate = {selectedItem.year, selectedItem.month, selectedItem.day};
+            model->SetMenstrualEndDate(endDate);
+            
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "经期设置: 开始%d-%02d-%02d,结束%d-%02d-%02d,共%d天", 
+                          startYear_, startMonth_, startDay_,
+                          selectedItem.year, selectedItem.month, selectedItem.day, days);
+            
+            // 刷新主页面日历显示
+            if (WomenHealthMainPage::GetInstance() != nullptr) {
+                WomenHealthMainPage::GetInstance()->updata_label(0);  // 刷新当前月份显示
+            }
+            
+            // 返回主页面
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "经期设置完成,返回主页面");
+            NativeAbility::GetInstance().SwitchPageInSlice(
+                WOMEN_HEALTH_PAGES::WOMEN_HEALTH_MAIN_PAGE, 
+                nullptr,
+                TransitionType::TRANSITION_INVALID, 
+                true);
+        }
+    }
+    
+    return true;
+}
+
+bool WomenHealthSettingPage::OnDrag(UIView& view, const DragEvent& event)
+{
+    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, "右滑返回主页面");
+        NativeAbility::GetInstance().SwitchPageInSlice(
+            WOMEN_HEALTH_PAGES::WOMEN_HEALTH_MAIN_PAGE, 
+            nullptr,
+            TransitionType::TRANSITION_INVALID, 
+            true);
+    }
+    
+    return true;
+}
+
+}
+