【训练】UI
authorCaisking <Casiking@zhihuishixun.com>
Fri, 25 Apr 2025 10:07:57 +0000 (18:07 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Fri, 25 Apr 2025 10:07:57 +0000 (18:07 +0800)
158 files changed:
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/TrainingType.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/Training_UiConfig.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingEnddataPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingEnddataView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingNomalPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingNomalView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingSetPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingSetView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetCaluliView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetMileView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetStepView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetTimeView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingEnddataView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingNomalView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingSetPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingSetView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetCaluliView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetMileView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetStepView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetTimeView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnotePresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnotePresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingDataAllView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingControlView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingDataView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingDetailView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/Training_CardPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/Training_CardView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingDataAllView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingControlView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingDataView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingDetailView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/Training_CardPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/Training_CardView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDancePresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDancePresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIcePresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIcePresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestAdapter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestItemView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestAdapter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestItemView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestView.cpp [new file with mode: 0644]

diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/TrainingType.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/TrainingType.h
new file mode 100644 (file)
index 0000000..daabd24
--- /dev/null
@@ -0,0 +1,186 @@
+/***
+ * @Date: 2024-04-23 17:54:29
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-23 17:55:36
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/TrainingType.h
+ */
+#ifndef TRAINING_TYPE_H
+#define TRAINING_TYPE_H
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+namespace OHOS
+{
+#define MAX_TAININGNUM 176
+
+    struct training_data
+    {
+        Exercisetype sporttype;    // 运动类
+        UIResourceTextId sportId;  // 运动项目
+        ExerciseClass sport_cywee; // 在cywee里面对应的类型
+    };
+
+    training_data tainging_indetail_data[MAX_TAININGNUM] =
+        {
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING},            // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_FREETRAINING, ExerciseClass::FREE_TRAINING},       // 自由训练
+            {Exercisetype::FITNESS, STR_EXERCISE_RESISTANCETRAINING, ExerciseClass::FREE_TRAINING}, // 肌力训练
+            {Exercisetype::FITNESS, STR_EXERCISE_SPINBIKE, ExerciseClass::FREE_TRAINING},           // 飞轮车/室内健身车
+            {Exercisetype::FITNESS, STR_EXERCISE_TREADMILL, ExerciseClass::FREE_TRAINING},          // 踏步机
+            {Exercisetype::FITNESS, STR_EXERCISE_STROLLMACHINE, ExerciseClass::FREE_TRAINING},      // 漫步机
+            {Exercisetype::FITNESS, STR_EXERCISE_HIIT, ExerciseClass::FREE_TRAINING},               // 高强度间歇训练
+            {Exercisetype::FITNESS, STR_EXERCISE_CROSSFIT, ExerciseClass::FREE_TRAINING},           // 健身
+            {Exercisetype::FITNESS, STR_EXERCISE_GROUPCALISTHENICS, ExerciseClass::FREE_TRAINING},  // 团体操
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGA, ExerciseClass::FREE_TRAINING},               // 瑜珈
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGACAT, ExerciseClass::FREE_TRAINING},            // 瑜珈猫式
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGACOW, ExerciseClass::FREE_TRAINING},            // 瑜珈牛式
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGACOBRA, ExerciseClass::FREE_TRAINING},          // 瑜珈眼镜蛇式
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGAHERO1, ExerciseClass::FREE_TRAINING},          // 瑜珈英雄式1
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGAHERO2, ExerciseClass::FREE_TRAINING},          // 瑜珈英雄式2
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGAHERO3, ExerciseClass::FREE_TRAINING},          // 瑜珈英雄式3
+            {Exercisetype::FITNESS, STR_EXERCISE_YOGAROLLING, ExerciseClass::FREE_TRAINING},        // 瑜珈滚轮
+
+            {Exercisetype::FITNESS, STR_EXERCISE_OUTDOORWALKING, ExerciseClass::FREE_TRAINING}, // 室外走路
+            {Exercisetype::FITNESS, STR_EXERCISE_OUTDOORRUNNING, ExerciseClass::OUTDOOR},       // 室外跑步
+            {Exercisetype::FITNESS, STR_EXERCISE_INDOORWALKING, ExerciseClass::FREE_TRAINING},  // 室内走路
+            {Exercisetype::FITNESS, STR_EXERCISE_INDOORRUNNING, ExerciseClass::INDOOR},         // 室内跑步
+            {Exercisetype::FITNESS, STR_EXERCISE_OUTDOORBIKING, ExerciseClass::FREE_TRAINING},  // 室外骑行
+
+            {Exercisetype::FITNESS, STR_EXERCISE_JUMPINGROPE, ExerciseClass::FREE_TRAINING},                 // 跳绳
+            {Exercisetype::FITNESS, STR_EXERCISE_PILATES, ExerciseClass::FREE_TRAINING},                     // 皮拉提斯
+            {Exercisetype::FITNESS, STR_EXERCISE_CROSS_FIT, ExerciseClass::FREE_TRAINING},                   // 混合健身
+            {Exercisetype::FITNESS, STR_EXERCISE_FUNCTIONALTRAINING, ExerciseClass::FREE_TRAINING},          // 功能性训练
+            {Exercisetype::FITNESS, STR_EXERCISE_PHYSICALTRAINING, ExerciseClass::FREE_TRAINING},            // 体能训练
+            {Exercisetype::FITNESS, STR_EXERCISE_TAEKWONDO, ExerciseClass::FREE_TRAINING},                   // 跆拳道/踢拳
+            {Exercisetype::FITNESS, STR_EXERCISE_BOXING, ExerciseClass::FREE_TRAINING},                      // 拳击
+            {Exercisetype::FITNESS, STR_EXERCISE_KICKBOXING, ExerciseClass::FREE_TRAINING},                  // 自由搏击
+            {Exercisetype::FITNESS, STR_EXERCISE_KARATE, ExerciseClass::FREE_TRAINING},                      // 空手道
+            {Exercisetype::FITNESS, STR_EXERCISE_FENCING, ExerciseClass::FREE_TRAINING},                     // 击剑
+            {Exercisetype::FITNESS, STR_EXERCISE_CORETRAINING, ExerciseClass::FREE_TRAINING},                // 核心训练
+            {Exercisetype::FITNESS, STR_EXERCISE_BODYCOMBAT, ExerciseClass::FREE_TRAINING},                  // 拳击有氧
+            {Exercisetype::FITNESS, STR_EXERCISE_KENDO, ExerciseClass::FREE_TRAINING},                       // 剑道
+            {Exercisetype::FITNESS, STR_EXERCISE_HORIZONTALBAR, ExerciseClass::FREE_TRAINING},               // 单杠
+            {Exercisetype::FITNESS, STR_EXERCISE_PARALLELBARS, ExerciseClass::FREE_TRAINING},                // 双杠
+            {Exercisetype::FITNESS, STR_EXERCISE_CIRCUIT, ExerciseClass::FREE_TRAINING},                     // 循环训练
+            {Exercisetype::FITNESS, STR_EXERCISE_AEROBICS, ExerciseClass::FREE_TRAINING},                    // 有氧运动
+            {Exercisetype::FITNESS, STR_EXERCISE_CALISTHENICE, ExerciseClass::FREE_TRAINING},                // 健美操
+            {Exercisetype::FITNESS, STR_EXERCISE_P90X, ExerciseClass::FREE_TRAINING},                        // P90X
+            {Exercisetype::FITNESS, STR_EXERCISE_KETTLEBELLTRAINING, ExerciseClass::FREE_TRAINING},          // 壶铃训练
+            {Exercisetype::FITNESS, STR_EXERCISE_MIXEDMARTIALARTS, ExerciseClass::FREE_TRAINING},            // 综合格斗
+            {Exercisetype::FITNESS, STR_EXERCISE_STAIRCLIMBINGMACHINE, ExerciseClass::FREE_TRAINING},        // 爬楼梯机
+            {Exercisetype::FITNESS, STR_EXERCISE_WEIGHTLIFTING, ExerciseClass::FREE_TRAINING},               // 举重
+            {Exercisetype::FITNESS, STR_EXERCISE_BARRE, ExerciseClass::FREE_TRAINING},                       // Barre
+            {Exercisetype::FITNESS, STR_EXERCISE_HANDCYCLING, ExerciseClass::FREE_TRAINING},                 // 手轮
+            {Exercisetype::FITNESS, STR_EXERCISE_TRACKFIELD, ExerciseClass::FREE_TRAINING},                  // 田径
+            {Exercisetype::FITNESS, STR_EXERCISE_WRESTLING, ExerciseClass::FREE_TRAINING},                   // 角力
+            {Exercisetype::FITNESS, STR_EXERCISE_MINDBODY, ExerciseClass::FREE_TRAINING},                    // 身心运动
+            {Exercisetype::FITNESS, STR_EXERCISE_FLEXIBILITY, ExerciseClass::FREE_TRAINING},                 // 柔软操
+            {Exercisetype::FITNESS, STR_EXERCISE_MIXEDCARDIO, ExerciseClass::FREE_TRAINING},                 // 混和有氧
+            {Exercisetype::FITNESS, STR_EXERCISE_TRADITIONALSTRENGTHTRAINING, ExerciseClass::FREE_TRAINING}, // 传统肌力训练
+            {Exercisetype::FITNESS, STR_EXERCISE_CROSSTRAINING, ExerciseClass::FREE_TRAINING},               // 交叉训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GYMNASTICS, ExerciseClass::FREE_TRAINING},                  // 体操
+            {Exercisetype::FITNESS, STR_EXERCISE_STEPTRAINING, ExerciseClass::FREE_TRAINING},                // 阶梯训练
+            {Exercisetype::FITNESS, STR_EXERCISE_ELLIPTICALTRAINER, ExerciseClass::FREE_TRAINING},           // 椭圆机
+            {Exercisetype::FITNESS, STR_EXERCISE_ROWINGMACHINE, ExerciseClass::FREE_TRAINING},               // 划船机
+
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+            {Exercisetype::FITNESS, STR_EXERCISE_GENERAL, ExerciseClass::FREE_TRAINING}, // 一般训练
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/Training_UiConfig.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/Training_UiConfig.h
new file mode 100644 (file)
index 0000000..0772360
--- /dev/null
@@ -0,0 +1,216 @@
+#ifndef TRAINING_UI_CONFIG_H
+#define TRAINING_UI_CONFIG_H
+
+#include <cstdint>
+#include "ohos_types.h"
+#include "graphic_config.h"
+#include "traing/Training_UiConfig.h"
+
+namespace OHOS
+{
+
+// Paths for different icons in the Training folder
+#define ICON36 "/user/res/Training/icon_36x36"
+#define ICON60 "/user/res/Training/icon_60x60"
+#define ICON80 "/user/res/Training/icon_80x80"
+#define ICON54 "user/res/Training/icon_54x79"
+#define MODULES "/user/res/Training/modules"
+#define TRAINING_GIF "/user/res/Training/training_GIF"
+    static constexpr int16_t MAX_SCROLL_DIS = 1000;
+    static constexpr int16 ROTATE_FACTOR_2 = 2;
+    // Icons in the icon_36x36 folder
+    static constexpr const char *BALL_IMAGE = ICON36 "/Ball.bin";
+    static constexpr const char *DANCE_IMAGE = ICON36 "/Dance.bin";
+    static constexpr const char *FITNESS_IMAGE = ICON36 "/Fitness.bin";
+    static constexpr const char *ICE_IMAGE = ICON36 "/Ice.bin";
+    static constexpr const char *JUMPROPE_IMAGE = ICON36 "/Jumprope.bin";
+    static constexpr const char *LIMIT_IMAGE = ICON36 "/Limit.bin";
+    static constexpr const char *MOUNTAINEERING_IMAGE = ICON36 "/Mountaineering.bin";
+    static constexpr const char *OTHER_IMAGE = ICON36 "/Other.bin";
+    static constexpr const char *PINGPONG_IMAGE = ICON36 "/Pingpong.bin";
+    static constexpr const char *REST_IMAGE = ICON36 "/Rest.bin";
+    static constexpr const char *SWIMMING_IMAGE = ICON36 "/Swimming.bin";
+    static constexpr const char *RIDING_IMAGE = ICON36 "/riding.bin";
+    static constexpr const char *RUNNING_IMAGE = ICON36 "/running.bin";
+    static constexpr const char *WALKING_IMAGE = ICON36 "/walking.bin";
+
+    // Icons in the icon_60x60 folder
+    static constexpr const char *RIDING_60_IMAGE_END = ICON60 "/riding.bin";
+    static constexpr const char *RUNNING_60_IMAGE_END = ICON60 "/running.bin";
+    static constexpr const char *WALKING_60_IMAGE_END = ICON60 "/walking.bin";
+    static constexpr const char *RIDING_60_IMAGE = ICON60 "/Riding_60.bin";
+    static constexpr const char *RUNNING_60_IMAGE = ICON60 "/Running_60.bin";
+    static constexpr const char *WALKING_60_IMAGE = ICON60 "/walking_60.bin";
+
+
+    static constexpr const char *FREE_60_IMAGE = ICON60 "/FreeTraining_60.bin";
+
+
+    // Icons in the icon_80x80 folder
+    static constexpr const char *JUMPROPE_80_IMAGE = ICON80 "/Jumprope_80.bin";
+    static constexpr const char *MOUNTAINEERING_80_IMAGE = ICON80 "/Mountaineering_80.bin";
+    static constexpr const char *PINGPONG_80_IMAGE = ICON80 "/Pingpong_80.bin";
+    static constexpr const char *RIDING_80_IMAGE = ICON80 "/Riding_80.bin";
+
+    // Icon in the icon_54x79 folder
+    static constexpr const char *BALL_54_IMAGE = ICON54 "/Ball_54.bin";
+    static constexpr const char *DANCE_54_IMAGE = ICON54 "/Dance_54.bin";
+    static constexpr const char *FITNESS_54_IMAGE = ICON54 "/Fitness_54.bin";
+    static constexpr const char *ICE_54_IMAGE = ICON54 "/Ice_54.bin";
+    static constexpr const char *LIMIT_54_IMAGE = ICON54 "/Limit_54.bin";
+    static constexpr const char *OTHER_54_IMAGE = ICON54 "/Other_54.bin";
+    static constexpr const char *REST_54_IMAGE = ICON54 "/Rest_54.bin";
+    static constexpr const char *SWIMMING_54_IMAGE = ICON54 "/Swimming_54.bin";
+    static constexpr const char *WALKING_54_IMAGE = ICON54 "/Walking_54.bin";
+
+    // Modules icons
+    static constexpr const char *ARROWS_IMAGE = MODULES "/Arrows.bin";
+    static constexpr const char *BACK_IMAGE = MODULES "/Back.bin";
+    static constexpr const char *BOUTTONGROUND_IMAGE = MODULES "/Bouttonground.bin";
+    static constexpr const char *BUTTONGROUND2_IMAGE = MODULES "/Buttonground2.bin";
+    static constexpr const char *BUBBLE_IMAGE = MODULES "/Bubble.bin";
+    static constexpr const char *BUTTONOK_IMAGE = MODULES "/Buttonok.bin";
+    static constexpr const char *COLOR_PROGRESS_IMAGE = MODULES "/Color_Progress.bin";
+    static constexpr const char *CALORIES_IMAGE = MODULES "/Calories.bin";
+    static constexpr const char *CALORIES_30_IMAGE = MODULES "/Calories_30.bin";
+    static constexpr const char *CONTROL_POINT_IMAGE = MODULES "/Control_point.bin";
+    static constexpr const char *DATA_POINT_IMAGE = MODULES "/Data_point.bin";
+    static constexpr const char *GO_1_IMAGE = MODULES "/Go.bin";
+    static constexpr const char *GO_2_IMAGE = MODULES "/Go_2.bin";
+    static constexpr const char *GPS_1_IMAGE = MODULES "/GPS_1.bin";
+    static constexpr const char *GPS_2_IMAGE = MODULES "/GPS_2.bin";
+    static constexpr const char *HEARTRATE_IMAGE = MODULES "/Heartrate.bin";
+    static constexpr const char *HEARTRATE_1_IMAGE = MODULES "/Heartrate_1.bin";
+    static constexpr const char *HEARTRATE_2_IMAGE = MODULES "/Heartrate_2.bin";
+    static constexpr const char *HEARTRATE_30_IMAGE = MODULES "/Heartrate_30.bin";
+    static constexpr const char *ICON_IMAGE = MODULES "/Icon.bin";
+    static constexpr const char *INCO_UP_IMAGE = MODULES "/Inco_up.bin";
+    static constexpr const char *INCO_UP_40_IMAGE = MODULES "/Inco_up_40.bin";
+    static constexpr const char *LINE_IMAGE = MODULES "/Line.bin";
+    static constexpr const char *LINE_1_IMAGE = MODULES "/Line_1.bin";
+    static constexpr const char *MILEAGE_IMAGE = MODULES "/Mileage.bin";
+    static constexpr const char *LINE_2_IMAGE = MODULES "/Line_2.bin";
+    static constexpr const char *MILEAGE_30_IMAGE = MODULES "/Mileage_30.bin";
+    static constexpr const char *MORE_IMAGE = MODULES "/More.bin";
+    static constexpr const char *MORE_ICON_IMAGE = MODULES "/More_icon.bin";
+    static constexpr const char *MOREVIEW_IMAGE = MODULES "/MoreView.bin";
+    static constexpr const char *NO_IMAGE = MODULES "/No.bin";
+    static constexpr const char *NOTE_IMAGE = MODULES "/Note.bin";
+    static constexpr const char *PATH_IMAGE = MODULES "/Path.bin";
+    static constexpr const char *PIONT_BLACK_IMAGE = MODULES "/Piont_black.bin";
+    static constexpr const char *PIONT_BUBBLE_IMAGE = MODULES "/Piont_bubble.bin";
+    static constexpr const char *POINT_BLUE_IMAGE = MODULES "/Point_blue.bin";
+    static constexpr const char *POINT_GREEN_IMAGE = MODULES "/Point_green.bin";
+    static constexpr const char *POINT_ORANGE_IMAGE = MODULES "/Point_orange.bin";
+    static constexpr const char *POINT_YELLOW_IMAGE = MODULES "/Point_yellow.bin";
+    static constexpr const char *PROGRESS_IMAGE = MODULES "/Progress.bin";
+    static constexpr const char *SPORT_CONTINUE_IMAGE = MODULES "/Sport_continue.bin";
+    static constexpr const char *SPORT_PAUSE_IMAGE = MODULES "/Sport_pause.bin";
+    static constexpr const char *SPORT_STOP_IMAGE = MODULES "/Sport_stop.bin";
+    static constexpr const char *SPORT_STRENGTH_IMAGE = MODULES "/Sport_strength.bin";
+    static constexpr const char *STEP_30_IMAGE = MODULES "/Step_30.bin";
+    static constexpr const char *SPORT_HEARTRATE_IMAGE = MODULES "/sport_heartrate.bin";
+    static constexpr const char *TIME_IMAGE = MODULES "/Time.bin";
+    // static constexpr const char *WALKING_54_IMAGE = MODULES "/Walking_54.bin";
+    static constexpr const char *WARNING_IMAGE = MODULES "/Warning.bin";
+    static constexpr const char *YES_IMAGE = MODULES "/Yes.bin";
+    static constexpr const char *RECOED_IMAGE = MODULES "/Norecord.bin";
+
+    // Training GIF
+    static constexpr const char *TRAINING_GIF_IMAGE_1 = TRAINING_GIF "/win/1.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_2 = TRAINING_GIF "/win/2.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_3 = TRAINING_GIF "/win/3.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_4 = TRAINING_GIF "/win/4.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_5 = TRAINING_GIF "/win/5.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_6 = TRAINING_GIF "/win/6.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_7 = TRAINING_GIF "/win/7.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_8 = TRAINING_GIF "/win/8.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_9 = TRAINING_GIF "/win/9.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_10 = TRAINING_GIF "/win/10.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_11 = TRAINING_GIF "/win/11.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_12 = TRAINING_GIF "/win/12.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_13 = TRAINING_GIF "/win/13.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_14 = TRAINING_GIF "/win/14.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_15 = TRAINING_GIF "/win/15.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_16 = TRAINING_GIF "/win/16.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_17 = TRAINING_GIF "/win/17.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_18 = TRAINING_GIF "/win/18.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_19 = TRAINING_GIF "/win/19.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_20 = TRAINING_GIF "/win/20.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_21 = TRAINING_GIF "/win/21.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_22 = TRAINING_GIF "/win/22.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_23 = TRAINING_GIF "/win/23.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_24 = TRAINING_GIF "/win/24.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_25 = TRAINING_GIF "/win/25.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_26 = TRAINING_GIF "/win/26.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_27 = TRAINING_GIF "/win/27.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_28 = TRAINING_GIF "/win/28.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_29 = TRAINING_GIF "/win/29.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_30 = TRAINING_GIF "/win/30.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_31 = TRAINING_GIF "/win/31.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_32 = TRAINING_GIF "/win/32.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_33 = TRAINING_GIF "/win/33.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_34 = TRAINING_GIF "/win/34.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_35 = TRAINING_GIF "/win/35.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_36 = TRAINING_GIF "/win/36.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_37 = TRAINING_GIF "/win/37.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_38 = TRAINING_GIF "/win/38.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_39 = TRAINING_GIF "/win/39.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_40 = TRAINING_GIF "/win/40.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_41 = TRAINING_GIF "/win/41.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_42 = TRAINING_GIF "/win/42.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_43 = TRAINING_GIF "/win/43.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_44 = TRAINING_GIF "/win/44.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_45 = TRAINING_GIF "/win/45.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_46 = TRAINING_GIF "/win/46.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_47 = TRAINING_GIF "/win/47.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_48 = TRAINING_GIF "/win/48.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_49 = TRAINING_GIF "/win/49.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_50 = TRAINING_GIF "/win/50.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_51 = TRAINING_GIF "/win/51.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_52 = TRAINING_GIF "/win/52.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_53 = TRAINING_GIF "/win/53.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_54 = TRAINING_GIF "/win/54.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_55 = TRAINING_GIF "/win/55.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_56 = TRAINING_GIF "/win/56.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_57 = TRAINING_GIF "/win/57.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_58 = TRAINING_GIF "/win/58.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_59 = TRAINING_GIF "/win/59.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_60 = TRAINING_GIF "/win/60.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_61 = TRAINING_GIF "/win/61.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_62 = TRAINING_GIF "/win/62.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_63 = TRAINING_GIF "/win/63.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_64 = TRAINING_GIF "/win/64.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_65 = TRAINING_GIF "/win/65.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_66 = TRAINING_GIF "/win/66.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_67 = TRAINING_GIF "/win/67.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_68 = TRAINING_GIF "/win/68.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_69 = TRAINING_GIF "/win/69.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_70 = TRAINING_GIF "/win/70.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_71 = TRAINING_GIF "/win/71.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_72 = TRAINING_GIF "/win/72.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_73 = TRAINING_GIF "/win/73.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_74 = TRAINING_GIF "/win/74.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_75 = TRAINING_GIF "/win/75.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_76 = TRAINING_GIF "/win/76.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_77 = TRAINING_GIF "/win/77.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_78 = TRAINING_GIF "/win/78.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_79 = TRAINING_GIF "/win/79.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_80 = TRAINING_GIF "/win/80.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_81 = TRAINING_GIF "/win/81.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_82 = TRAINING_GIF "/win/82.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_83 = TRAINING_GIF "/win/83.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_84 = TRAINING_GIF "/win/84.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_85 = TRAINING_GIF "/win/85.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_86 = TRAINING_GIF "/win/86.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_87 = TRAINING_GIF "/win/87.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_88 = TRAINING_GIF "/win/88.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_89 = TRAINING_GIF "/win/89.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_90 = TRAINING_GIF "/win/90.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_91 = TRAINING_GIF "/win/91.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_92 = TRAINING_GIF "/win/92.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_93 = TRAINING_GIF "/win/93.bin";
+    static constexpr const char *TRAINING_GIF_IMAGE_94 = TRAINING_GIF "/win/94.bin";
+
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingEnddataPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingEnddataPresenter.h
new file mode 100644 (file)
index 0000000..9f2c02f
--- /dev/null
@@ -0,0 +1,49 @@
+/***
+ * @Date: 2024-07-05 18:15:38
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-25 18:17:08
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-29 17:46:18
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataPresenter.h
+ */
+
+#ifndef _TraingEnddata_PRESENTER_H
+#define _TraingEnddata_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingEnddataView.h"
+
+namespace OHOS
+{
+    class TraingEnddataView;
+
+    class TraingEnddataPresenter : public Presenter<TraingEnddataView>,
+                                   public UIView::OnClickListener,
+                                   public RootView::OnKeyActListener,
+                                   public UIView::OnDragListener
+    {
+    public:
+        TraingEnddataPresenter();
+        virtual ~TraingEnddataPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+        void NavigateBack(); // 返回函数
+        static TraingEnddataPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+        // bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingEnddataView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingEnddataView.h
new file mode 100644 (file)
index 0000000..16fface
--- /dev/null
@@ -0,0 +1,119 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-25 10:32:38
+ * @FilePath:
+ * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-16 09:27:11
+ * @FilePath:
+ * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h
+ */
+#ifndef _TraingEnddata_VIEW_H
+#define _TraingEnddata_VIEW_H
+
+
+#include "View.h"
+#include "components/icon_adapter.h"
+#include "components/ui_button.h"
+#include "components/ui_card_page.h"
+#include "components/ui_chart.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_view_group.h"
+#include "ohos_types.h"
+#include "wearable_log.h"
+#include <ui_scroll_view.h>
+
+#include "TraingEnddataPresenter.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+namespace OHOS {
+#define BUTTONBACK "button1"
+
+class TraingEnddataPresenter;
+class TraingEnddataView : public View<TraingEnddataPresenter> {
+
+public:
+  TraingEnddataView();
+  virtual ~TraingEnddataView();
+  static TraingEnddataView *GetInstance(void);
+
+  void OnStart() override;
+
+  void InitView();
+  void DeInit();
+
+  void PreLoad(void);
+
+  void InitData(void);
+  void InitializeImageViews(void);
+  void InitializeLabels(void);
+  void SetLabelsTextColor(const std::vector<UILabel *> &labels,
+                          OHOS::ColorType color);
+  void AddLabelsToScrollView(const std::vector<UILabel *> &labels);
+  void InitializeExitControls(void);
+
+  void BonusdataView();
+  void ExitView();
+
+private:
+  UIView::OnDragListener *draglistener{nullptr};
+  TraingEnddataView(TraingEnddataView &&) = delete;
+  TraingEnddataView &operator=(TraingEnddataView &&) = delete;
+
+  UIScrollView *scrollView_ = nullptr;
+
+  UILabelExt *labelutime = nullptr;    // u训练时间
+  UILabelExt *labelutag = nullptr;     // u训练完成度
+  UILabelExt *labelumile = nullptr;    // u训练距离
+  UILabelExt *labeluheart = nullptr;   // u训练平均心率
+  UILabelExt *labelustrong = nullptr;  // u训练强度
+  UILabelExt *labelusteps = nullptr;   // u训练步数
+  UILabelExt *labeluavpace = nullptr;  // u训练平均配速
+  UILabelExt *labelufreq = nullptr;    // u训练步频
+  UILabelExt *labelustride = nullptr;  // u训练步幅
+  UILabelExt *labelucalorie = nullptr; // u训练卡路里
+
+  UILabelExt *labeltype = nullptr;     // 训练类型
+  UILabelExt *labelsport = nullptr;    // 训练项
+  UILabelExt *labelduration = nullptr; // 训练时间
+  UILabelExt *labeltag = nullptr;      // 训练目标完成度
+  UILabelExt *labeltime = nullptr;     // 训练时长
+  UILabelExt *labelmile = nullptr;     // 训练距离
+  UILabelExt *labelheart = nullptr;    // 训练平均心率
+  UILabelExt *labelstrong = nullptr;   // 训练强度
+  UILabelExt *labelsteps = nullptr;    // 训练步数
+  UILabelExt *labelavpace = nullptr;   // 训练平均配速
+  UILabelExt *labelfreq = nullptr;     // 训练步频
+  UILabelExt *labelstride = nullptr;   // 训练步幅
+  UILabelExt *labelcalories = nullptr; // 训练卡路里
+
+  UILabelExt *exitLabel = nullptr;        // APP提醒
+  UILabelButtonExt *exitButton = nullptr; // 返回按键
+
+  UIImageView *imageIcon = nullptr;
+  UIImageView *imageLine2 = nullptr;
+  UIImageView *imageLine3 = nullptr;
+  UIImageView *imageLine4 = nullptr;
+  UIImageView *imageLine5 = nullptr;
+  UIImageView *imageLine6 = nullptr;
+  UIImageView *imageLine7 = nullptr;
+  UIImageView *imageLine8 = nullptr;
+  UIImageView *imageLine9 = nullptr;
+  UIImageView *imageLine10 = nullptr;
+  UIImageView *imageLine11 = nullptr;
+  UIImageView *imageLine12 = nullptr;
+
+  bool viewiInitStatus{false};
+};
+} // namespace OHOS
+#endif // TraingEnddata_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingModel.h
new file mode 100644 (file)
index 0000000..6a969d7
--- /dev/null
@@ -0,0 +1,407 @@
+
+
+#ifndef Traing_MODEL_H
+#define Traing_MODEL_H
+
+// #include "View.h"
+#include "string.h"
+#include "wearable_log.h"
+
+// #include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
+#include "ui_resource_string.h"
+
+// #include "cywee_hal.h"
+// #include "cywee_service.h"
+
+#include <cmath>
+#include <iostream>
+#include <memory>
+#include <queue>
+#include <stdint.h>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#define TRAINING_PATH "user/userdata/sport/TrainingData/"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct Trainingdata_hard {
+  uint32_t num;
+};
+/*
+"src":0,
+"ty":0,
+"st":1657865201,
+"sp":1657867001,
+"tgt":0,
+"tg":5000,
+"pg":60,
+"du":1800,
+"ca":2355,//卡路里为该数值乘以0.1
+"di":3000,
+"hr":127,
+"stp":10000
+*/
+struct Trainingdata {
+  // 0:手表开启的训练1:APP开启的训练
+  uint32_t src;
+  // 0:健身类1:舞蹈类2:休闲运动3:球类4:水上项目5:冰上项目6:极限运动
+  // 7:其他
+  uint32_t bt;
+  // 训练类型0:健走1:跑步2:骑行
+  uint32_t ty;
+  // 开始时间戳
+  uint32_t st;
+  // 结束时间戳
+  uint32_t sp;
+  // 训练目标类型
+  uint32_t tgt;
+  // 训练目标
+  uint32_t tg;
+  // 目标完成度
+  uint32_t pg;
+  // 训练时长
+  uint32_t du;
+  // 卡路里
+  uint32_t ca;
+  // 距离
+  uint32_t di;
+  // 平均心率
+  uint32_t hr;
+  // 步数
+  uint32_t stp;
+  // 训练强度
+  uint32_t ti;
+  // 圈数
+  uint32_t cir;
+  // 最高海拔高度
+  uint32_t alt;
+  // 平均配速
+  uint32_t apc;
+  // 最快配速
+  uint32_t fpc;
+  // 最慢配速
+  uint32_t spc;
+  // 步幅
+  uint32_t std;
+  // 步频
+  uint32_t cdc;
+};
+Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset);
+
+int write_Trainingdata_data(Trainingdata data);
+
+#ifdef __cplusplus
+}
+#endif
+
+namespace OHOS {
+#define TIME_INTERVAL 10;
+#define CALORIES_INTERVAL 100;
+#define DISTANCE_INTERVAL 1;
+#define STEPS_INTERVAL 500;
+
+#define MAX_FILE_PATH_LENGTH 128
+#define TRAINING_DATA_DIRECTORY "user/userdata/sport/"
+#define TRAINING_RECORD_FILE "user/userdata/sport/Record.json"
+#define TRAINING_HEART_FILE "user/userdata/sport/HeartTabel/"
+#define TRAINING_PACE_FILE "user/userdata/sport/PaceTabel/"
+#define MAX_DATA_COUNT 10
+
+#define TIMER 1
+#define BLETEST 0
+#define HARD_OFF 1
+#define READTEST 0
+
+#define MAX_HEART_RATE 220
+#define AGE_THRESHOLD 59
+#define LOW_INTENSITY_THRESHOLD 59
+#define MEDIUM_INTENSITY_LOWER_THRESHOLD 60
+#define MEDIUM_INTENSITY_UPPER_THRESHOLD 69
+#define HIGH_INTENSITY_LOWER_THRESHOLD 70
+#define HIGH_INTENSITY_UPPER_THRESHOLD 79
+
+#define MAXSPORTID 176
+
+// 运动状态
+enum class ExerciseState {
+  End = 0,
+  Start,
+  Pause,
+  Continue,
+  General,
+};
+// 运动项目
+enum class ExerciseClass {
+  NORMAL = 0,
+  TREADMILL,
+  OUTDOOR,
+  INDOOR,
+  FITNESS_PEDOMETER,
+  FREE_TRAINING,
+};
+// 运动类型
+enum class Exercisetype {
+  // 0:健身类 1:舞蹈类 2:休闲运动 3:球类 4:水上项目 5:冰上项目 6:极限运动
+  // 7:其他
+  FITNESS = 0,
+  DANCE,
+  LEISURE,
+  BALL,
+  WATER,
+  ICE,
+  EXTREME,
+  OTHER
+};
+// 训练目标类型
+enum class ExerciseTag {
+  Distance,
+  Calories,
+  Duration,
+  Steps,
+  UNKNOW,
+};
+
+enum Exercise {
+  LOW_INTENSITY = 0,
+  MEDIUM_INTENSITY,
+  HIGH_INTENSITY,
+  VERY_HIGH_INTENSITY
+};
+
+enum ENTEYTYPE {
+  MAIN_ENTER = 0,
+  APPLIST_ENTER,
+};
+#pragma pack(push, 1)
+struct PaceEntry {
+  uint32_t timestamp; // 4 bytes
+  uint16_t pace;      // 2 bytes
+};
+//心率表结构体
+struct HeartRateEntry {
+  uint32_t timestamp; // 4 bytes
+  uint8_t heartRate;  // 1 byte
+};
+#pragma pack(pop)
+struct SportData {
+  uint32 starttime; // 开始时间时间戳
+  uint32 endtime;   // 结束时间时间戳
+  int duration;     // 训练时长
+  int goaldegree;   // 目标完成度
+  int calories;     // 训练卡路里
+  int steps;        // 训练步数
+  int distance;     // 训练距离
+  int intensity; // 训练强度 (0:较低强度 1:中等强度 2:高等强度 3:超高强度)
+  int heart;     // 运动心率
+  int avgheart;  // 训练平均心率
+  int tag;       // 训练目标
+  int pc;        // 训练配速
+  std::string start_date; // 训练开始日期
+  std::string start_time; // 训练开始时间
+  std::string end_time;   // 训练结束时间
+  Exercisetype sportType; // 训练类型(0:健身类 1:跳舞类 2:休闲运动 3:球类
+                          // 4:水上运动:5:冰上运动:6:极限运动:7:其他)
+  UIResourceTextId sportId; // 训练Id
+  ExerciseTag sportTagType; // 训练目标类型(0: 距离 1:时长 2:卡路里 3:步数)
+  int apc;                  // 平均配速
+  int fpc;                  // 最快配速
+  int spc;                  // 最慢配速
+  int cdc;                  // 步频
+  int std;                  // 步幅
+
+  void Initialize() {
+    starttime = 0;
+    endtime = 0;
+    duration = 0;
+    goaldegree = 0;
+    calories = 0;
+    steps = 0;
+    distance = 0;
+    intensity = 0;
+    heart = 0;
+    avgheart = 0;
+    tag = 0;
+    start_date = "";
+    start_time = "";
+    end_time = "";
+    sportType = Exercisetype::FITNESS;
+    sportId = UIResourceTextId::STR_EXTREME_SPORTS;
+    sportTagType = ExerciseTag::UNKNOW;
+    apc = 0;
+    fpc = 0;
+    spc = 0;
+    cdc = 0;
+    std = 0;
+  }
+
+  void Reset() {
+    Initialize(); // 调用初始化函数将数据重置为初始状态
+  }
+};
+
+class TraingModel {
+public:
+  TraingModel();
+  ~TraingModel();
+  static TraingModel *GetInstance(void);
+  void Init();
+
+  /*定时器 */
+  std::string DisplayMotionDuration();
+
+  // 训练存储相关配置
+  bool CheckDataJson();                 /*判断json文件是否存在*/
+  bool SaveDataToJson(SportData *data); /*保存训练记录到json文件*/
+  bool
+  LoadDataFormJson(std::vector<SportData> &sportDataVector); /*加载json文件*/
+  void RecordSportData();                                    /*保存数据*/
+
+  // 训练数据相关配置
+  #ifdef CYWEE_ACTIVITY_ENABLE
+  void AnalysisData(cywee_activity_result_t *cyweeInfo); /*解析传输过来的数据*/
+  void AnalysisExtraData(cywee_activity_result_extre_info_t *cyweeInfo); /*解析运动额外数据*/
+  #endif
+
+  void AnalysisHeartData(uint8_t hrs);              /*解析运动心率数据*/
+  SportData *GetSportdata();                        /*获取训练数据*/
+  void SetIntensity(int heart);                     /*设置训练强度*/
+  UIResourceTextId GetIntensity();                  /*获取训练强度STR*/
+  uint32_t GetSportTime();                          /*获取目前运动时长*/
+  bool SaveSportData();                             /*保存数据*/
+  void SendLiveData();                              /*发送实时数据*/
+  int CalculateAverageHeartRate(int newHeartRate);  /*平均心率计算*/
+  int CalculateFilteredHeartRate(int newHeartRate); /*显示心率计算*/
+  int Averageheartrate(int newHeartRate);           /*平均心率窗口数*/
+  void SetSportdata(SportData *data); /*设置训练数据[为训练记录准备]*/
+  int GetCal();                       /*获取运动卡路里*/
+  int GetDuration();                  //获取运动时长
+
+  // 训练状态相关配置
+  void SetEntryType(ENTEYTYPE type);          /*设置进入训练方式*/
+  ENTEYTYPE GetEntryType();                   /*获取训练进入方式*/
+  void SetSportOpenWay(bool way);             /*设置运动开始方式*/
+  void SetSportOpenState(bool state);         /*设置运动是否开始*/
+  bool GetSportOpenState();                   /*获取运动是否开始*/
+  bool GetMomentum();                         /*获取训练量是否达标*/
+  void SetSportState(ExerciseState state);    /*设置运动状态*/
+  ExerciseState GetSportState();              /*获取运动状态*/
+  void ResetSharedTrainingData();             /*重新初始化训练配置*/
+  void set_sport_config(UIResourceTextId id); // 运动识别进入运动
+
+  // 训练时间相关配置
+  std::string AnalysisTimestamp(uint64_t timestamp); /*解析时间戳*/
+  std::string GetTrainingTime();                     /*获取运动总时长*/
+  std::string GetStartTiemStr();                     /*获取开始时间Str*/
+  std::string GetEndTiemStr();                       /*获取结束时间Str*/
+  void SetTimestamp();     /*设置训练开始与结束*/
+  void SetStartDateTime(); /*设置开始时间*/
+  void SetEndTime();       /*设置结束时间*/
+  bool GetFormattedDate(std::string &dateOutput,
+                        const char *errorMsg); /*获取日期*/
+  bool GetFormattedTime(std::string &timeOutput,
+                        const char *errorMsg); /*获取时间*/
+  uint32_t get_current_time();
+
+  // 训练项相关配置
+  void IsSpecialSport(UIResourceTextId sportId_); /*判断是否为特殊训练*/
+  bool GetIsSpecial();                     /*获取是否为特殊训练*/
+  void SetSportEvent(UIResourceTextId id); /*设置运动项目*/
+  UIResourceTextId GetSportEvent();        /*获取运动项目*/
+  ExerciseClass GetSportId();              /*获取运动项目Id*/
+  int GetBleSportId(Exercisetype sporttype, UIResourceTextId id); /*获取协议Id*/
+  UIResourceTextId GetSportTypeId(Exercisetype type); /*获取训练类Id*/
+  void SetSportType(Exercisetype type);               /*设置运动类型*/
+  // std::string GetSportType(Exercisetype sporttype); /*获取训练类型type图片*/
+  // std::string GetSportIcon(Exercisetype sporttype); /*获取训练类型icon图片*/
+  std::string GetSportIcon(Exercisetype sporttype, UIResourceTextId id,
+                           uint8_t type);
+
+  // 训练目标相关配置
+  void SetSportTag(ExerciseTag tagtpye,
+                   int tag);     /*设置训练目标类型以及训练目标*/
+  int GetSportTag();             /*获取训练目标*/
+  ExerciseTag GetSportTagtype(); /*获取项目目标类型*/
+  int GetSportTagData();         /*获取对应的训练目标的值*/
+  int GetGoaldegree();           /*获取训练目标完成百分比*/
+  std::string GetTagStr();       /*获取训练目标Str*/
+  void CheckSportTag();
+  void CheckTimeTag();
+  uint32_t GetCurrentSportTag();
+  void updata_goal();
+  bool IsGetGoaldegree();
+
+  /*配速表以及心率表配置*/
+  bool AddHeartRateData(uint32_t timestamp, uint8_t heartRate);
+  bool AddPaceData(uint32_t timestamp, uint16_t pace);
+  bool SaveHeartTable();
+  bool SavePaceTable();
+  void ClearHeartTable();
+  void ClearPaceTable();
+  std::string GetHeartTablePath(uint32_t timestamp);
+  std::string GetPaceTablePath(uint32_t timestamp);
+  void StoreDataIfMinutePassed();
+  void SendLiveDataIfNecessary();
+
+  // 打印配置
+  void printTrainingData(const Trainingdata &data); /*打印数据*/
+  void printf_data(SportData *data);                /*打印函数*/
+  void PrintHeartRateTable();
+  void PrintPaceTable();
+
+  //配置用户信息
+  void SetUserSportdata();
+  void SetMaxHeart(int maxheart);
+
+private:
+  TraingModel(const TraingModel &) = delete;
+  TraingModel &operator=(const TraingModel &) = delete;
+
+  std::string motionDuration;                              // 显示训练时长
+  UIResourceTextId sportId_ = STR_EXERCISE_OUTDOORWALKING; // 训练项目
+  Exercisetype sportType_ = Exercisetype::FITNESS;         // 训练类型
+  ExerciseState sportState_ = ExerciseState::General;      // 训练状态
+  ExerciseTag sportTagType_ = ExerciseTag::UNKNOW;         // 训练目标类型
+
+  ENTEYTYPE entey_type = ENTEYTYPE::MAIN_ENTER; // 进入方式
+
+  bool isspecialsport_{false};
+  int sportTag_ = 0; // 训练目标
+  int freq = 0;      // 训练发送数据频率
+
+  bool Gettagstuats{false}; // 训练达标标志位
+  bool Startstate{false};   // 开始训练标志位
+  bool Endstate{false};     // 结束训练标志位
+  bool Openingway{false};   // 运动开启方式 [0 手表  1 app]
+  bool MomentumFlag{false}; // 训练量达标标志位
+  bool Openstate{false};    // 运动是否开始
+
+  std::vector<int> heartRateData;       // 存储所有心率数据
+  std::vector<int> recentHeartRates;    // 显示心率
+  std::unordered_map<int, int> delayed; // 延迟删除的心率值
+  std::priority_queue<int> maxHeap;     // 最大堆,存储最大心率值
+  std::priority_queue<int, std::vector<int>, std::greater<int>>
+      minHeap;              // 最小堆,存储最小心率值
+  int totalHeartRate;       // 总心率
+  int countHeartRate;       // 心率计数
+  const int windowSize = 5; // 移动平均窗口大小
+  uint32_t heartcount{0};
+
+  std::vector<HeartRateEntry> heartRateTable; // 心率表
+  std::vector<PaceEntry> paceTable;           // 配速表
+  const size_t MAX_ENTRIES = 100000;          // 规定最大进场条目数
+
+  int user_maxHeart{190}; // 用户最高心率
+  int user_Age{20};       // 用户年龄
+  int user_autoget{1};    // 自动获取设置
+  int user_freq{10};      // 训练频率
+  int user_Intensity{160};
+
+  uint32_t current_goal{0}; // 当前目标
+};
+} // namespace OHOS
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingNomalPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingNomalPresenter.h
new file mode 100644 (file)
index 0000000..cc6134c
--- /dev/null
@@ -0,0 +1,38 @@
+
+#ifndef _TraingNomal_PRESENTER_H
+#define _TraingNomal_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingNomalView.h"
+
+namespace OHOS
+{
+    class TraingNomalView;
+
+    class TraingNomalPresenter : public Presenter<TraingNomalView>,
+                                 public UIView::OnClickListener,
+                                 public RootView::OnKeyActListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingNomalPresenter();
+        virtual ~TraingNomalPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+        void NavigateBack();
+
+        static TraingNomalPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+        // bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingNomalView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingNomalView.h
new file mode 100644 (file)
index 0000000..85b11f3
--- /dev/null
@@ -0,0 +1,71 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-25 17:40:40
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-23 20:29:54
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h
+ */
+#ifndef _TraingNomal_VIEW_H
+#define _TraingNomal_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "TraingNomalPresenter.h"
+namespace OHOS
+{
+#define BUTTONGO "button1"
+#define BUTTONSET "button2"
+
+    class TraingNomalPresenter;
+    class TraingNomalView : public View<TraingNomalPresenter>
+    {
+
+    public:
+        TraingNomalView();
+        virtual ~TraingNomalView();
+        static TraingNomalView *GetInstance(void);
+
+        void OnStart() override;
+
+        void InitView();
+        void DeInit();
+
+        void InitList();
+        void PreLoad(void);
+        void UpdateTraingTag(); // 更新训练目标
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingNomalView(TraingNomalView &&) = delete;
+        TraingNomalView &operator=(TraingNomalView &&) = delete;
+
+        UILabelExt *sporttitle_ = nullptr;
+        UIButton *buttonGo_ = nullptr;
+        UILabelButtonExt *buttonSet_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingNomal_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingPresenter.h
new file mode 100644 (file)
index 0000000..db1adc5
--- /dev/null
@@ -0,0 +1,50 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-25 18:44:38
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-29 17:42:47
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingPresenter.h
+ */
+
+#ifndef _Traing_PRESENTER_H
+#define _Traing_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingView.h"
+
+namespace OHOS
+{
+    class TraingView;
+
+    class TraingPresenter : public Presenter<TraingView>,
+                            public UIView::OnClickListener,
+                            public UIView::OnDragListener,
+                            public RootView::OnKeyActListener
+    {
+    public:
+        TraingPresenter();
+        virtual ~TraingPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+        void NavigateBack();
+
+        static TraingPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingSetPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingSetPresenter.h
new file mode 100644 (file)
index 0000000..b963678
--- /dev/null
@@ -0,0 +1,62 @@
+/***
+ * @Date: 2024-07-24 09:45:49
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-25 17:28:43
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetPresenter.h
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 10:18:50
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetPresenter.h
+ */
+#ifndef _TraingSet_PRESENTER_H
+#define _TraingSet_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingSetView.h"
+
+namespace OHOS
+{
+    typedef enum
+    {
+        SET_VIEW = 0, // 主界面
+        SET_CALORIES,
+        SET_DURATION,
+        SET_STEPS,
+        SET_DISTANCE,
+        MAX_SETVIEW,
+    } SETGOLDVIEWID;
+
+    class TraingSetView;
+    class TraingSetPresenter : public Presenter<TraingSetView>,
+                               public UIView::OnClickListener,
+                               public RootView::OnKeyActListener,
+                               public UIView::OnDragListener
+    {
+    public:
+        TraingSetPresenter();
+        virtual ~TraingSetPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingSetPresenter *GetInstance();
+
+        const char *GetButtonIdFromCard(int cardID);
+        int GetTagFromCard(int cardID);
+        ExerciseTag GetExerciseTagFromCard(int cardID);
+        void NavigateBack();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingSetView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingSetView.h
new file mode 100644 (file)
index 0000000..3ab1f26
--- /dev/null
@@ -0,0 +1,116 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-17 16:29:01
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetView.h
+ */
+#ifndef _TraingSet_VIEW_H
+#define _TraingSet_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/include/TrainingSetCaluliView.h"
+#include "traing/include/TrainingSetTimeView.h"
+#include "traing/include/TrainingSetMileView.h"
+#include "traing/include/TrainingSetStepView.h"
+#include "traing/include/TraingSetPresenter.h"
+
+namespace OHOS
+{
+#define BUTTONTIME "button1"
+#define BUTTONCALULI "button2"
+#define BUTTONDISTANCE "button3"
+#define BUTTONSTEPS "button4"
+#define MAXSLECTVIEW 5
+
+    class TraingSetPresenter;
+    class TrainingSetCaluliView;
+    class TrainingSetTimeView;
+    class TrainingSetMileView;
+    class TrainingSetStepView;
+    class TraingSetView : public View<TraingSetPresenter>
+    {
+
+    public:
+        TraingSetView();
+        virtual ~TraingSetView();
+        static TraingSetView *GetInstance(void);
+
+        void OnStart() override;
+ 
+        void InitView();
+        void DeInit();
+        void PreLoad(void);
+
+        bool ChangeSetView(int16_t thisview);
+        bool ChangeSetCaloriesView(int16_t thisview);
+        bool ChangeSetStepsView(int16_t thisview);
+        bool ChangeSetDistanceView(int16_t thisview);
+        bool ChangeSetDurationView(int16_t thisview);
+        bool ClickFunc(int16_t interface);
+        void ChangeView(int16_t hideView, int16_t showView);
+        void BonusdataView(); // 配置额外数据
+
+        void SetCurrentViewId(int viewId)
+        {
+            CurrentViewId = viewId;
+        }
+        int GetCurrentViewId()
+        {
+            return CurrentViewId;
+        }
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingSetView(TraingSetView &&) = delete;
+        TraingSetView &operator=(TraingSetView &&) = delete;
+
+
+        UIScrollView *SetTagScrollView[MAXSLECTVIEW]{nullptr};
+        TrainingSetCaluliView *setcalories{nullptr};
+        TrainingSetTimeView *settime{nullptr};
+        TrainingSetMileView *setmile{nullptr};
+        TrainingSetStepView *setstep{nullptr};
+        UIScrollView *group{nullptr};
+
+        UILabelExt *labeltitle = nullptr;
+
+        UILabelExt *labelTime = nullptr;
+        UILabelExt *labelKcal = nullptr;
+        UILabelExt *labelDistance = nullptr;
+        UILabelExt *labelSteps = nullptr;
+
+        UIImageView *imagetime = nullptr;
+        UIImageView *imagcal = nullptr;
+        UIImageView *imagedistance = nullptr;
+        UIImageView *imagesteps = nullptr;
+
+        UIImageView *imagicon1 = nullptr;
+        UIImageView *imagicon2 = nullptr;
+        UIImageView *imagicon3 = nullptr;
+        UIImageView *imagicon4 = nullptr;
+
+        UIButton *butTime = nullptr;
+        UIButton *butKcal = nullptr;
+        UIButton *butDistance = nullptr;
+        UIButton *butSteps = nullptr;
+
+        bool viewiInitStatus{false};
+        int CurrentViewId;
+    };
+} // namespace OHOS
+#endif // TraingSet_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TraingView.h
new file mode 100644 (file)
index 0000000..61b9ca2
--- /dev/null
@@ -0,0 +1,57 @@
+
+#ifndef _Traing_VIEW_H
+#define _Traing_VIEW_H
+
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "TraingPresenter.h"
+namespace OHOS
+{
+#define BUTTON1 "button1"       // 按键1
+#define BUTTON2 "button2"       // 按键2
+#define BUTTON3 "button3"       // 按键3
+#define BUTTONMORE "buttonmore" // 按键 更多
+
+    class TraingPresenter;
+    class TraingView : public View<TraingPresenter>
+    {
+
+    public:
+        TraingView();
+        virtual ~TraingView();
+        static TraingView *GetInstance(void);
+
+        void OnStart() override;
+
+
+        bool AddLabel();
+        bool AddButton();
+        bool AddImageView();
+        void InitView();
+        void DeInitView();
+
+        UIView *GetView();
+
+    private:
+        TraingView(TraingView &&) = delete;
+        TraingView &operator=(TraingView &&) = delete;
+
+        UIButton *buttonmore_ = nullptr;
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+        UIButton *button3_ = nullptr;
+
+        UILabelExt *title_label = nullptr;
+        UILabelExt *btn1_label = nullptr;
+        UILabelExt *btn2_label = nullptr;
+        UILabelExt *btn3_label = nullptr;
+        UILabelExt *btnmore_label = nullptr;
+
+        UIImageView *btn1_image = nullptr;
+        UIImageView *btn2_image = nullptr;
+        UIImageView *btn3_image = nullptr;
+        UIImageView *btnmore_image = nullptr;
+    };
+} // namespace OHOS
+#endif // Traing_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetCaluliView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetCaluliView.h
new file mode 100644 (file)
index 0000000..14a123c
--- /dev/null
@@ -0,0 +1,52 @@
+/***
+ * @Date: 2024-04-18 10:57:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 11:00:03
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetCaluliView.h
+ */
+#ifndef _Training_SetCaluli_VIEW_H
+#define _Training_SetCaluli_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_label_button_ext.h"
+#include "wearable_log.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "components/ui_picker.h"
+#include "components/ui_scroll_view.h"
+
+#include "traing/include/TraingSetPresenter.h"
+#include "traing/include/TrainingSetCaluliView.h"
+
+namespace OHOS
+{
+#define BUTTONCALULIOK "buttonCaluli"
+
+    class TraingSetPresenter;
+    class TrainingSetCaluliView : public View<TraingSetPresenter>
+    {
+
+    public:
+        TrainingSetCaluliView();
+        virtual ~TrainingSetCaluliView();
+        static TrainingSetCaluliView *GetInstance(void);
+        UIScrollView *SetCaluliViewInit();
+
+        void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+        UIPicker *GetCaluliPicker();
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+
+        UILabelExt *labeltitle_ = nullptr;
+        UILabelButtonExt *buttonok_ = nullptr;
+        UIPicker *Picker_ = nullptr;
+
+        UIScrollView *SetCaluliScrollView{nullptr};
+    };
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetMileView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetMileView.h
new file mode 100644 (file)
index 0000000..2657e47
--- /dev/null
@@ -0,0 +1,64 @@
+/*** 
+ * @Date: 2024-04-18 11:59:51
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-10 10:28:21
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h
+ */
+/***
+ * @Date: 2024-04-18 11:59:51
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 16:04:47
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h
+ */
+/***
+ * @Date: 2024-04-18 10:57:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 11:00:03
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetMileView.h
+ */
+#ifndef _Training_SetMile_VIEW_H
+#define _Training_SetMile_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_label_button_ext.h"
+#include "wearable_log.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "components/ui_picker.h"
+#include "components/ui_scroll_view.h"
+
+#include "traing/include/TraingSetPresenter.h"
+#include "traing/include/TrainingSetMileView.h"
+
+namespace OHOS
+{
+#define BUTTONMILEOK "buttonMile"
+
+    class TraingSetPresenter;
+    class TrainingSetMileView : public View<TraingSetPresenter>
+    {
+
+    public:
+        TrainingSetMileView();
+        virtual ~TrainingSetMileView();
+        static TrainingSetMileView *GetInstance(void);
+        UIScrollView *SetMileViewInit();
+
+        void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+        UIPicker *GetMilePicker();
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+
+        UILabelExt *labeltitle_ = nullptr;
+        UILabelButtonExt *buttonok_ = nullptr;
+        UIPicker *Picker_ = nullptr;
+
+        UIScrollView *SetMileScrollView{nullptr};
+    };
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetStepView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetStepView.h
new file mode 100644 (file)
index 0000000..21980c3
--- /dev/null
@@ -0,0 +1,58 @@
+/***
+ * @Date: 2024-04-18 11:59:25
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 15:34:22
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetSeptView.h
+ */
+/***
+ * @Date: 2024-04-18 10:57:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 11:00:03
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetStepView.h
+ */
+#ifndef _Training_SetStep_VIEW_H
+#define _Training_SetStep_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_label_button_ext.h"
+#include "wearable_log.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "components/ui_picker.h"
+#include "components/ui_scroll_view.h"
+
+#include "traing/include/TraingSetPresenter.h"
+#include "traing/include/TrainingSetStepView.h"
+
+namespace OHOS
+{
+#define BUTTONSTEPOK "buttonStep"
+
+    class TraingSetPresenter;
+    class TrainingSetStepView : public View<TraingSetPresenter>
+    {
+
+    public:
+        TrainingSetStepView();
+        virtual ~TrainingSetStepView();
+        static TrainingSetStepView *GetInstance(void);
+        UIScrollView *SetStepViewInit();
+
+        void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+        UIPicker *GetSetpPicker();
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+
+        UILabelExt *labeltitle_ = nullptr;
+        UILabelButtonExt *buttonok_ = nullptr;
+        UIPicker *Picker_ = nullptr;
+
+        UIScrollView *SetStepScrollView{nullptr};
+    };
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetTimeView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/include/TrainingSetTimeView.h
new file mode 100644 (file)
index 0000000..1ffa1a1
--- /dev/null
@@ -0,0 +1,57 @@
+/*** 
+ * @Date: 2024-04-18 11:58:41
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-10 10:28:35
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h
+ */
+/***
+ * @Date: 2024-04-18 10:57:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 11:00:03
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TrainingSetTimeView.h
+ */
+#ifndef _Training_SetTime_VIEW_H
+#define _Training_SetTime_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_label_button_ext.h"
+#include "wearable_log.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "components/ui_picker.h"
+#include "components/ui_scroll_view.h"
+
+#include "traing/include/TraingSetPresenter.h"
+#include "traing/include/TrainingSetTimeView.h"
+
+namespace OHOS
+{
+#define BUTTONTIMEOK "buttonTime"
+
+    class TraingSetPresenter;
+    class TrainingSetTimeView : public View<TraingSetPresenter>
+    {
+
+    public:
+        TrainingSetTimeView();
+        virtual ~TrainingSetTimeView();
+        static TrainingSetTimeView *GetInstance(void);
+        UIScrollView *SetTimeViewInit();
+
+        void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+        UIPicker *GetTimePicker();
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+
+        UILabelExt *labeltitle_ = nullptr;
+        UILabelButtonExt*buttonok_ = nullptr;
+        UIPicker *Picker_ = nullptr;
+
+        UIScrollView *SetTimeScrollView{nullptr};
+    };
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingEnddataPresenter.cpp
new file mode 100644 (file)
index 0000000..1e596c9
--- /dev/null
@@ -0,0 +1,109 @@
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingEnddataPresenter.h"
+#include "UiConfig.h"
+// #include "TraingEnddataView.h"
+
+#include "NativeRegisterManager.h"
+
+namespace OHOS
+{
+
+    REGIST_SLICE(VIEW_TRAININGENDDATA, TraingEnddataView, TraingEnddataPresenter);
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingEnddataPresenter *g_pTraingEnddataPresenter = nullptr;
+
+    TraingEnddataPresenter::TraingEnddataPresenter()
+    {
+        g_pTraingEnddataPresenter = this;
+    }
+
+    TraingEnddataPresenter::~TraingEnddataPresenter()
+    {
+        g_pTraingEnddataPresenter = nullptr;
+    }
+
+    TraingEnddataPresenter *TraingEnddataPresenter::GetInstance()
+    {
+        return g_pTraingEnddataPresenter;
+    }
+
+    void TraingEnddataPresenter::OnStart()
+    {
+        Presenter<TraingEnddataView>::OnStart();
+    }
+
+    void TraingEnddataPresenter::OnPause()
+    {
+        Presenter<TraingEnddataView>::OnPause();
+    }
+
+    void TraingEnddataPresenter::OnResume()
+    {
+        Presenter<TraingEnddataView>::OnResume();
+    }
+
+    void TraingEnddataPresenter::OnStop()
+    {
+        Presenter<TraingEnddataView>::OnStop();
+    }
+
+    void TraingEnddataPresenter::NavigateBack()
+    {
+        uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+
+        // 根据前一界面切换  如果是训练卡片
+         if (preSlice == VIEW_TRAININGCRAD)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);
+        }
+        else
+        {
+            NativeAbility::GetInstance().Back();
+        }
+    }
+
+    bool TraingEnddataPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            event.GetDeltaX() > X_DRAG_OFFSET &&
+            event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))
+        {
+            NavigateBack();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingEnddataPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        if (view.GetViewId() == BUTTONBACK)
+        {
+            NavigateBack();
+        }
+        return true;
+    }
+
+    bool TraingEnddataPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NavigateBack();
+        }
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingEnddataView.cpp
new file mode 100644 (file)
index 0000000..8922ed4
--- /dev/null
@@ -0,0 +1,684 @@
+
+#include "traing/include/TraingEnddataView.h"
+
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_button.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include <cmath> // 包含数学函数库,用于四舍五入
+#include <iostream>
+#include <sstream> // 用于 std::ostringstream
+#include <string>  // 包含字符串处理库,用于使用 std::to_string
+#include <ui_scroll_view.h>
+
+/*测试打印函数*/
+#define PRINT_LINE_INFO()                                                      \
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File: %s, Line: %d\r\n", __FILE__,   \
+                __LINE__)
+#define PRINT_FUNCTION_LINE()                                                  \
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Function: %s, Line: %d\r\n",         \
+                __FUNCTION__, __LINE__)
+
+/*
+    普通运动:
+                时长,平均心率,训练强度,卡路里,目标完成度
+    算法支持运动:
+                时长,平均心率,训练强度,卡路里,
+                距离,步数,平均配速,步幅,步频,目标完成度
+*/
+#define UI_UPDATA 0
+namespace OHOS {
+
+static const int startY_Unit = 252;
+static const int startY_Value = 292;
+static const int labelHeight = 40;
+static const int labelInterval = 130;
+ColorType textColor = Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f);
+
+static const int initialY = 132;
+static const int lineHeight = 130;
+static const int iconHeight = 80;
+static const int verticalOffset = 2;
+static const int baseY = 214;
+
+static TraingEnddataView *g_pTraingEnddataView{nullptr};
+
+TraingEnddataView::TraingEnddataView() { g_pTraingEnddataView = this; }
+
+TraingEnddataView::~TraingEnddataView() {
+  DeInit();
+
+  g_pTraingEnddataView = nullptr;
+}
+
+TraingEnddataView *TraingEnddataView::GetInstance() {
+
+  return g_pTraingEnddataView;
+}
+
+// 初始化图像
+void TraingEnddataView ::InitializeImageViews() {
+  // 初始化主图标
+  InitImageView(imageIcon, 80, initialY, 54, iconHeight, "image",
+                WALKING_54_IMAGE);
+
+  InitImageView(imageLine2, 97, baseY, 80, 20, "image2",
+                LINE_IMAGE); // imageLine2
+  InitImageView(imageLine3, 97, baseY + lineHeight, 80, 20, "image3",
+                LINE_IMAGE); // imageLine3
+  InitImageView(imageLine4, 97, baseY + 2 * lineHeight, 80, 20, "image4",
+                LINE_IMAGE); // imageLine4
+  InitImageView(imageLine5, 97, baseY + 3 * lineHeight, 80, 20, "image5",
+                LINE_IMAGE); // imageLine5
+
+  bool isincludeTag = TraingModel::GetInstance()->GetSportTag();
+  if (isincludeTag) {
+    InitImageView(imageLine6, 97, baseY + 4 * lineHeight, 80, 20, "image7",
+                  LINE_IMAGE);
+    scrollView_->Add(imageLine6);
+  }
+
+  scrollView_->Add(imageLine2);
+  scrollView_->Add(imageLine3);
+  scrollView_->Add(imageLine4);
+  scrollView_->Add(imageLine5);
+
+  scrollView_->Add(imageIcon);
+}
+/*
+    InitView:初始化界面
+
+    普通运动:
+                时长,平均心率,训练强度,卡路里,目标完成度
+    算法支持运动:
+                时长,平均心率,训练强度,卡路里,目标完成度
+                距离,步数,平均配速,步幅,步频,
+
+    蓝色:距离、平均配速
+    黄色:训练时长
+    橙色:平均心率、训练强度
+    绿色:步数,步幅,步频,平均配速,卡路里,目标完成度
+*/
+void TraingEnddataView ::InitializeLabels() {
+
+  /*title and sport*/
+  InitRollLabel(labeltype, 83, 50, 300, 35, "label1", STR_EXERCISE_LIST,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitRollLabel(labelsport, 147, 140, 240, 35, "label6",
+                STR_EXERCISE_OUTDOORRUNNING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(labelduration, 146, 179, 240, 40, "label7", "13:00:22-15:00:12",
+            DEFAULT_VECTOR_FONT_FILENAME, 28);
+  // 初始化Label
+  //时长
+  InitRollLabel(labelutime, 146, startY_Unit + labelInterval * 0, 240, 40,
+                "label8", STR_TRAINING_DURATION, DEFAULT_VECTOR_FONT_FILENAME,
+                30);
+  InitLabel(labeltime, 146, startY_Value + 0 * labelInterval, 240, 60,
+            "label14", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labeltime->SetTextColor(Color::Yellow());
+  //平均心率
+  InitRollLabel(labeluheart, 146, startY_Unit + labelInterval * 1, 240, 40,
+                "label9", STR_MEAN_HEART_RATE_MIN, DEFAULT_VECTOR_FONT_FILENAME,
+                30);
+  InitLabel(labelheart, 146, startY_Value + 1 * labelInterval, 240, 60,
+            "label16", "--", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labelheart->SetTextColor(Color::Orange());
+  // 训练强度
+  InitRollLabel(labelustrong, 146, startY_Unit + labelInterval * 2, 240, 40,
+                "label11", STR_TRAINING_INTENSITY, DEFAULT_VECTOR_FONT_FILENAME,
+                30);
+  InitLabel(labelstrong, 146, startY_Value + 2 * labelInterval, 240, 60,
+            "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 30);
+  labelstrong->SetTextColor(Color::Orange());
+  //卡路里
+  InitRollLabel(labelucalorie, 146, startY_Unit + labelInterval * 3, 240, 40,
+                "label2", STR_CALORIE_SETTING, DEFAULT_VECTOR_FONT_FILENAME,
+                30);
+  InitLabel(labelcalories, 146, startY_Value + 3 * labelInterval, 240, 60,
+            "label15", "--", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labelcalories->SetTextColor(Color::Green());
+
+  //目标完成度
+  bool isincludeTag = TraingModel::GetInstance()->GetSportTag();
+  if (isincludeTag) {
+    InitRollLabel(labelutag, 146, startY_Unit + labelInterval * 4, 240, 40,
+                  "label10", STR_GOAL_ACCOMPLISHMENT_DEGREE,
+                  DEFAULT_VECTOR_FONT_FILENAME, 30);
+    labelutag->SetTextColor(textColor);
+    InitLabel(labeltag, 146, startY_Value + 4 * labelInterval, 240, 60,
+              "label18", "--", DEFAULT_VECTOR_FONT_FILENAME, 40);
+    labeltag->SetTextColor(Color::Green());
+    scrollView_->Add(labelutag);
+    scrollView_->Add(labeltag);
+  }
+
+  // 设置文本颜色
+  labelduration->SetTextColor(textColor);
+  labelutime->SetTextColor(textColor);
+  labeluheart->SetTextColor(textColor);
+  labelustrong->SetTextColor(textColor);
+  labelucalorie->SetTextColor(textColor);
+
+  scrollView_->Add(labeltype);
+  scrollView_->Add(labelsport);
+  scrollView_->Add(labeltime);
+
+  scrollView_->Add(labelutime);
+  scrollView_->Add(labeluheart);
+  scrollView_->Add(labelustrong);
+  scrollView_->Add(labelucalorie);
+
+  scrollView_->Add(labelduration);
+  scrollView_->Add(labelheart);
+  scrollView_->Add(labelstrong);
+  scrollView_->Add(labelcalories);
+}
+// 增加额外配置
+void TraingEnddataView::BonusdataView() {
+  if (!TraingModel::GetInstance()->GetIsSpecial())
+    return;
+
+  bool isincludeTag = TraingModel::GetInstance()->GetSportTag();
+  int tagflge = isincludeTag ? 1 : 0;
+
+  // 初始化线条
+
+  InitImageView(imageLine8, 97, baseY + (4 + tagflge) * lineHeight, 80, 20,
+                "image8", LINE_IMAGE); // imageLine8
+  InitImageView(imageLine9, 97, baseY + (5 + tagflge) * lineHeight, 80, 20,
+                "image9", LINE_IMAGE); // imageLine9
+  InitImageView(imageLine10, 97, baseY + (6 + tagflge) * lineHeight, 80, 20,
+                "image10", LINE_IMAGE); // imageLine10
+  InitImageView(imageLine11, 97, baseY + (7 + tagflge) * lineHeight, 80, 20,
+                "image11", LINE_IMAGE);
+  InitImageView(imageLine12, 97, baseY + (8 + tagflge) * lineHeight, 80, 20,
+                "image7", LINE_IMAGE);
+
+  scrollView_->Add(imageLine8);
+  scrollView_->Add(imageLine9);
+  scrollView_->Add(imageLine10);
+  scrollView_->Add(imageLine11);
+  scrollView_->Add(imageLine12);
+
+  // 初始化标签
+  // 距离
+  InitRollLabel(labelumile, 146, startY_Unit + labelInterval * (4 + tagflge),
+                240, 40, "label10", STR_RANGE_MILE,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(labelmile, 146, startY_Value + (4 + tagflge) * labelInterval, 240,
+            60, "label15", "--", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labelumile->SetTextColor(textColor);
+  labelmile->SetTextColor(Color::Blue());
+
+  // 步数
+  InitRollLabel(labelusteps, 146, startY_Unit + labelInterval * (5 + tagflge),
+                240, 40, "label12", STR_STEP_NUMBER,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(labelsteps, 146, startY_Value + (5 + tagflge) * labelInterval, 240,
+            60, "label17", "--", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labelusteps->SetTextColor(textColor);
+  labelsteps->SetTextColor(Color::Green());
+
+  // 平均配速
+  InitRollLabel(labeluavpace, 146, startY_Unit + labelInterval * (6 + tagflge),
+                240, 40, "label2", STR_AVG_PACE, DEFAULT_VECTOR_FONT_FILENAME,
+                30);
+  InitLabel(labelavpace, 146, startY_Value + (6 + tagflge) * labelInterval, 240,
+            60, "label17", "--", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labeluavpace->SetTextColor(textColor);
+  labelavpace->SetTextColor(Color::Green());
+
+  // 步幅
+  InitRollLabel(labelustride, 146, startY_Unit + labelInterval * (7 + tagflge),
+                240, 40, "label2", STR_STEP_LENGTH,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(labelstride, 146, startY_Value + (7 + tagflge) * labelInterval, 240,
+            60, "label17", "77", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labelustride->SetTextColor(textColor);
+  labelstride->SetTextColor(Color::Green());
+
+  // 步频
+  InitRollLabel(labelufreq, 146, startY_Unit + labelInterval * (8 + tagflge),
+                240, 40, "label2", STR_STEP_FREQUENCY,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(labelfreq, 146, startY_Value + (8 + tagflge) * labelInterval, 240,
+            60, "label17", "154", DEFAULT_VECTOR_FONT_FILENAME, 40);
+  labelufreq->SetTextColor(textColor);
+  labelfreq->SetTextColor(Color::Green());
+
+  scrollView_->Add(labelumile);
+  scrollView_->Add(labelmile);
+  scrollView_->Add(labelusteps);
+  scrollView_->Add(labelsteps);
+  scrollView_->Add(labeluavpace);
+  scrollView_->Add(labelavpace);
+  scrollView_->Add(labelustride);
+  scrollView_->Add(labelstride);
+  scrollView_->Add(labelufreq);
+  scrollView_->Add(labelfreq);
+}
+// 配置退出相关位置
+void TraingEnddataView::ExitView() {
+
+  bool isincludeTag = TraingModel::GetInstance()->GetSportTag();
+  int tagflge = isincludeTag ? 1 : 0;
+
+  if (TraingModel::GetInstance()->GetIsSpecial()) {
+    // 初始化退出(最后 要根据前方配置设置位置)
+    // 是否为特殊运动
+    // 是否包含目标
+    InitRollLabel(exitLabel, 80,
+                  (startY_Value + labelInterval * (8 + tagflge) + 100), 300, 40,
+                  "label8", STR_MORE_APP, DEFAULT_VECTOR_FONT_FILENAME, 30);
+    InitButtonExt(exitButton, 42,
+                  (startY_Value + labelInterval * (8 + tagflge) + 160), 380,
+                  100, BUTTONBACK, STR_CLOSE, 30);
+  } else {
+    InitRollLabel(exitLabel, 80,
+                  (startY_Value + labelInterval * (3 + tagflge) + 100), 300, 40,
+                  "label8", STR_MORE_APP, DEFAULT_VECTOR_FONT_FILENAME, 30);
+    InitButtonExt(exitButton, 42,
+                  (startY_Value + labelInterval * (3 + tagflge) + 160), 380,
+                  100, BUTTONBACK, STR_CLOSE, 30);
+  }
+  exitLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));
+  scrollView_->Add(exitLabel);
+  exitButton->SetOnClickListener(presenter_);
+  scrollView_->Add(exitButton);
+}
+void TraingEnddataView ::InitView() {
+
+  scrollView_ = new UIScrollView();
+
+  scrollView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                           Screen::GetInstance().GetHeight());
+  scrollView_->SetScrollBlankSize(100);
+  scrollView_->SetReboundSize(50);
+  scrollView_->SetHorizontalScrollState(false);
+  scrollView_->RequestFocus();
+  scrollView_->SetRotateFactor(1.0);
+  scrollView_->SetMaxScrollDistance(1000);
+  scrollView_->SetDragACCLevel(5);
+  scrollView_->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/
+  scrollView_->SetTouchable(true);
+  scrollView_->SetDraggable(true);
+
+  /*初始化线条*/
+  InitializeImageViews();
+
+  /*初始化label*/
+  InitializeLabels();
+
+  BonusdataView(); // 配置额外数据
+
+  ExitView(); // 配置退出组件
+
+  AddViewToRootContainer(scrollView_);
+}
+
+/* DeInit:删除组件 */
+void TraingEnddataView::DeInit() {
+  // 确保 scrollView_ 存在,并移除所有组件
+  if (scrollView_) {
+    scrollView_->RemoveAll();
+    delete scrollView_;
+    scrollView_ = nullptr;
+  }
+
+  // 删除所有 UILabelExt 类型指针
+  if (labelutime) {
+    delete labelutime;
+    labelutime = nullptr;
+  }
+  if (labelutag) {
+    delete labelutag;
+    labelutag = nullptr;
+  }
+  if (labelusteps) {
+    delete labelusteps;
+    labelusteps = nullptr;
+  }
+  if (labelumile) {
+    delete labelumile;
+    labelumile = nullptr;
+  }
+  if (labeluheart) {
+    delete labeluheart;
+    labeluheart = nullptr;
+  }
+  if (labelustrong) {
+    delete labelustrong;
+    labelustrong = nullptr;
+  }
+  if (labeluavpace) {
+    delete labeluavpace;
+    labeluavpace = nullptr;
+  }
+  if (labelufreq) {
+    delete labelufreq;
+    labelufreq = nullptr;
+  }
+  if (labelustride) {
+    delete labelustride;
+    labelustride = nullptr;
+  }
+  if (labelucalorie) {
+    delete labelucalorie;
+    labelucalorie = nullptr;
+  }
+
+  /* 删除值 label */
+  if (labeltype) {
+    delete labeltype;
+    labeltype = nullptr;
+  }
+  if (labelsport) {
+    delete labelsport;
+    labelsport = nullptr;
+  }
+  if (labelduration) {
+    delete labelduration;
+    labelduration = nullptr;
+  }
+  if (labeltag) {
+    delete labeltag;
+    labeltag = nullptr;
+  }
+  if (labeltime) {
+    delete labeltime;
+    labeltime = nullptr;
+  }
+  if (labelmile) {
+    delete labelmile;
+    labelmile = nullptr;
+  }
+  if (labelheart) {
+    delete labelheart;
+    labelheart = nullptr;
+  }
+  if (labelstrong) {
+    delete labelstrong;
+    labelstrong = nullptr;
+  }
+  if (labelsteps) {
+    delete labelsteps;
+    labelsteps = nullptr;
+  }
+  if (labelavpace) {
+    delete labelavpace;
+    labelavpace = nullptr;
+  }
+  if (labelfreq) {
+    delete labelfreq;
+    labelfreq = nullptr;
+  }
+  if (labelstride) {
+    delete labelstride;
+    labelstride = nullptr;
+  }
+  if (labelcalories) {
+    delete labelcalories;
+    labelcalories = nullptr;
+  }
+
+  /* 删除图片 label */
+  if (imageIcon) {
+    delete imageIcon;
+    imageIcon = nullptr;
+  }
+  if (imageLine2) {
+    delete imageLine2;
+    imageLine2 = nullptr;
+  }
+  if (imageLine3) {
+    delete imageLine3;
+    imageLine3 = nullptr;
+  }
+  if (imageLine4) {
+    delete imageLine4;
+    imageLine4 = nullptr;
+  }
+  if (imageLine5) {
+    delete imageLine5;
+    imageLine5 = nullptr;
+  }
+  if (imageLine6) {
+    delete imageLine6;
+    imageLine6 = nullptr;
+  }
+  if (imageLine7) {
+    delete imageLine7;
+    imageLine7 = nullptr;
+  }
+  if (imageLine8) {
+    delete imageLine8;
+    imageLine8 = nullptr;
+  }
+  if (imageLine9) {
+    delete imageLine9;
+    imageLine9 = nullptr;
+  }
+  if (imageLine10) {
+    delete imageLine10;
+    imageLine10 = nullptr;
+  }
+  if (imageLine11) {
+    delete imageLine11;
+    imageLine11 = nullptr;
+  }
+  if (imageLine12) {
+    delete imageLine12;
+    imageLine12 = nullptr;
+  }
+
+  /* 退出相关 */
+  if (exitButton) {
+    delete exitButton;
+    exitButton = nullptr;
+  }
+  if (exitLabel) {
+    delete exitLabel;
+    exitLabel = nullptr;
+  }
+
+  if (scrollView_) {
+    delete scrollView_;
+    scrollView_ = nullptr;
+  }
+}
+
+void TraingEnddataView::PreLoad(void) {
+  if (!viewiInitStatus) {
+    InitView();
+    viewiInitStatus = true;
+  }
+}
+
+void TraingEnddataView::InitData() {
+  SportData *enddata = TraingModel::GetInstance()->GetSportdata();
+
+  if (enddata == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Enddata is nullptr. Exiting InitData()...\r\n");
+    return;
+  }
+
+  // 训练图标Icon
+  std::string imageStr = TraingModel::GetInstance()->GetSportIcon(
+      enddata->sportType, enddata->sportId, 0);
+  if (!imageStr.empty()) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "imageIcon %s\r\n",
+                  imageStr.c_str());
+    if (imageIcon) // 检查 imageIcon 是否为空
+    {
+      imageIcon->SetSrc(imageStr.c_str());
+    }
+  } else {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to get image string. Skipping imageIcon update.\r\n");
+  }
+
+  // 训练类
+  UIResourceTextId typeId =
+      TraingModel::GetInstance()->GetSportTypeId(enddata->sportType);
+  if (labeltype) // 检查 labeltype 是否为空
+  {
+    labeltype->SetTextId(typeId);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sport Type ID set: %d\r\n",
+                  typeId); // 打印运动类型ID
+  }
+
+  // 运动项目
+  if (labelsport) // 检查 labelsport 是否为空
+  {
+    labelsport->SetTextId(enddata->sportId);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sport ID set: %d\r\n",
+                  enddata->sportId); // 打印运动项目ID
+  }
+
+  // 运动开始结束时间
+  std::string startTimeStr = enddata->start_time;
+  std::string endTimeStr = enddata->end_time;
+  std::string durationStr = startTimeStr + "-" + endTimeStr;
+  if (labelduration) // 检查 labelduration 是否为空
+  {
+    labelduration->SetText(durationStr.c_str());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Duration set: %s\r\n",
+                  durationStr.c_str()); // 打印运动时间段
+  }
+
+  // 运动目标
+  if (enddata->goaldegree) {
+    std::string tagStr = std::to_string(enddata->goaldegree) + "%";
+    if (labeltag) // 检查 labeltag 是否为空
+    {
+      labeltag->SetText(tagStr.c_str());
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Goal degree set: %s\r\n",
+                    tagStr.c_str()); // 打印运动目标
+    }
+  } else {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                  "Enddata tag is null. Skipping labeltag update.\r\n");
+  }
+
+  // 运动时长
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Duration of the sport: %d\r\n",
+                enddata->duration);
+  std::string timeStr = TraingModel::GetInstance()->GetTrainingTime();
+  if (labeltime) // 检查 labeltime 是否为空
+  {
+    labeltime->SetText(timeStr.c_str());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Training time set: %s\r\n",
+                  timeStr.c_str()); // 打印训练时间
+  }
+
+  // 运动距离
+  std::string mileStr = std::to_string(enddata->distance);
+  if (labelmile) // 检查 labelmile 是否为空
+  {
+    labelmile->SetText(mileStr.c_str());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Distance set: %s\r\n",
+                  mileStr.c_str()); // 打印运动距离
+  }
+
+  // 平均心率
+  std::string heartStr = std::to_string(enddata->avgheart);
+  if (labelheart) // 检查 labelheart 是否为空
+  {
+    labelheart->SetText(heartStr.c_str());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Average heart rate set: %s\r\n",
+                  heartStr.c_str()); // 打印平均心率
+  }
+
+  // 步数
+  std::string stepStr = std::to_string(enddata->steps);
+  if (labelsteps) // 检查 labelsteps 是否为空
+  {
+    labelsteps->SetText(stepStr.c_str());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Steps set: %s\r\n",
+                  stepStr.c_str()); // 打印步数
+  }
+
+  // 训练强度
+  UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity();
+  if (labelstrong) // 检查 labelstrong 是否为空
+  {
+    labelstrong->SetTextId(intensityid);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Intensity ID set: %d\r\n",
+                  intensityid); // 打印训练强度ID
+  }
+  //卡路里
+  std::string calStr = std::to_string(enddata->calories);
+  if (labelcalories) // 检查 labelcal 是否为空
+  {
+    labelcalories->SetText(calStr.c_str());
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Calories set: %s\r\n",
+                  calStr.c_str()); // 打印卡路里
+  }
+
+  //特殊配置
+  if (TraingModel::GetInstance()->GetIsSpecial()) {
+    // 平均配速
+    // 需要计算一下 是秒 需要显示 分钟''秒''
+    int totalSeconds = enddata->apc; // 总秒数
+    int minutes = totalSeconds / 60; // 计算分钟
+    int seconds = totalSeconds % 60; // 计算剩余秒数
+    // 格式化为字符串
+    std::ostringstream oss;
+    oss << minutes << "'" << seconds << "\""; // 生成 "X'Y\"" 格式的字符串
+    std::string avpaceStr = oss.str();        // 得到字符串
+    if (labelavpace)                          // 检查标签是否为空
+    {
+      labelavpace->SetText(avpaceStr.c_str());
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Average pace set: %s\r\n",
+                    avpaceStr.c_str()); // 打印平均配速
+    }
+
+    // 步频
+    std::string freqStr = std::to_string(enddata->cdc);
+    if (labelfreq) // 检查 labelfreq 是否为空
+    {
+      labelfreq->SetText(freqStr.c_str());
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Cadence set: %s\r\n",
+                    freqStr.c_str()); // 打印步频
+    }
+
+    // 步幅
+    std::string strideStr = std::to_string(enddata->std);
+    if (labelstride) // 检查 labelstride 是否为空
+    {
+      labelstride->SetText(strideStr.c_str());
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Stride length set: %s\r\n",
+                    strideStr.c_str()); // 打印步幅
+    }
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "TraingEnddataView data initialization complete.\r\n");
+}
+// 设置按键监听
+static void SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  // 增加按键监听
+  RootView::OnKeyActListener *keyactListener =
+      (RootView::OnKeyActListener *)OHOS::TraingEnddataPresenter::GetInstance();
+  RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+}
+void TraingEnddataView::OnStart() {
+
+  PreLoad();
+  InitData(); // 刷新数据
+
+  GetRootContainer()->SetDraggable(true);
+  GetRootContainer()->SetTouchable(true);
+  GetRootContainer()->SetOnDragListener(presenter_);
+
+  SetKeyActListener();
+}
+
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingModel.cpp
new file mode 100644 (file)
index 0000000..e3f1e6a
--- /dev/null
@@ -0,0 +1,2365 @@
+/***
+ * @Date: 2024-04-15 11:46:23
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-15 15:09:35
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
+ */
+#include "traing/include/TraingModel.h"
+#include "cmsis_os.h"
+#include "custom_utils.h"
+
+// #include "safemodemanager/include/SafeModeManagerModelC.h"
+
+#include "thread_adapter.h"
+#include "traing/training_card/include/TraingCardPresenter.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <cmsis_os2.h>
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <service/graphic_service.h>
+#include <sstream>
+#include <string>
+
+#include "ConfigModel.h"
+
+#ifdef BLE_SERVER_ENABLE
+#include "bleEvent.h"
+#include "bletest.h"
+#include "bleService.h"
+#endif
+
+
+#include "broadcast_feature.h"
+#include "broadcast_service.h"
+#include "custom_runtime.h"
+#include "power_display_service.h"
+#include "samgr_lite.h"
+
+#include "traingrecord/include/TraingRecordModel.h"
+
+#include "vibrator_service.h"
+#include <algorithm>
+#include <cmath>
+#include <filesystem>
+#include <fstream>
+#include <limits.h>
+#include <list>
+#include <memory>
+#include <mutex>
+#include <numeric>
+#include <queue>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <vector>
+
+
+#include "chip_system_time.h"
+#include <custom_save_runtime.h>
+
+extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm);
+extern "C" errcode_t uapi_get_timestampe_ss(uint32_t *tm);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+static void Training_Notify(void *args, const Topic topic, Request *request);
+
+using namespace OHOS;
+
+Subscriber TraingSubscirber = {
+    .identity = NULL,
+    .args = NULL,
+    .Notify = Training_Notify,
+};
+
+void TraingSubscribeTopic(Topic topic) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stepsubscribeTopic, topic=%u", topic);
+  BroadcastApi *broadcastApi = NULL;
+  IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME,
+                                                     BROADCAST_FEATURE_NAME);
+  if (api == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "stepsubscribeTopic, GetFeatureApi failed");
+    return;
+  }
+  int result =
+      api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi);
+  if (result != 0 || broadcastApi == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "stepsubscribeTopic, QueryInterface failed");
+    return;
+  }
+  broadcastApi->SubscribeTopic((IUnknown *)broadcastApi, topic,
+                               &TraingSubscirber);
+  broadcastApi->Release((IUnknown *)broadcastApi);
+}
+
+void TraingUnsubscribeTopic(Topic topic) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingUnsubscribeTopic, topic=%u",
+                topic);
+  BroadcastApi *broadcastApi = NULL;
+  IUnknown *api = SAMGR_GetInstance()->GetFeatureApi(BROADCAST_SERVICE_NAME,
+                                                     BROADCAST_FEATURE_NAME);
+  if (api == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "TraingUnsubscribeTopic, GetFeatureApi failed");
+    return;
+  }
+  int result =
+      api->QueryInterface(api, DEFAULT_VERSION, (void **)&broadcastApi);
+  if (result != 0 || broadcastApi == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "TraingUnsubscribeTopic, QueryInterface failed");
+    return;
+  }
+  broadcastApi->UnsubscribeTopic((IUnknown *)broadcastApi, topic,
+                                 &TraingSubscirber);
+  broadcastApi->Release((IUnknown *)broadcastApi);
+}
+int flag = 0;
+static void Training_Notify(void *args, const Topic topic, Request *request) {
+  #ifdef CYWEE_ACTIVITY_ENABLE
+  UNUSED(args);
+  UNUSED(topic);
+  if (request == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "request is NULL");
+    return;
+  }
+  //蓝牙开启运动
+  if (request->msgId == TOPIC_EVENT_BLE_TRAINING) {
+    training_ble *traingbleInfo = new training_ble();
+    int rets = memcpy_s(traingbleInfo, sizeof(training_ble),
+                        (training_ble *)request->data, request->len);
+    if (rets != EOK) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "memcpy_s cywee_activity_result_t fail  ret = %d", rets);
+      return;
+    }
+    // GraphicService::GetInstance()->PostGraphicEvent(
+    // std::bind(&TraingCardPresenter::send_sport_cmd,
+    //           TraingCardPresenter::GetInstance(), traingbleInfo));
+    TraingCardPresenter::GetInstance()->send_sport_cmd(traingbleInfo);
+    delete traingbleInfo;
+  }
+  //增加训练runtime控制
+  if (uapi_dev_runtime_get_train_status() == 0 ||  TraingModel::GetInstance()->GetSportState() == ExerciseState::End) {
+    return;
+  }
+  //训练基本信息更新
+  if (request->msgId == TOPIC_EVENT_ACTIVITY_UPDATE) {
+    cywee_activity_result_t *cyweeInfo = new cywee_activity_result_t();
+    int rets = memcpy_s(cyweeInfo, sizeof(cywee_activity_result_t),
+                        (cywee_activity_result_t *)request->data, request->len);
+    if (rets != EOK) {
+      delete cyweeInfo; // 处理内存分配失败的情况
+      cyweeInfo = NULL;
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "memcpy_s cywee_activity_result_t fail ret = %d", rets);
+      return;
+    }
+    TraingModel::GetInstance()->AnalysisData(cyweeInfo);
+    // 更新其他目标完成度
+    TraingModel::GetInstance()->CheckSportTag();
+    delete cyweeInfo; // 释放内存
+  }
+  //训练额外信息
+  if (request->msgId == TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE) {
+    cywee_activity_result_extre_info_t *cyweeInfo_ext =
+        new cywee_activity_result_extre_info_t();
+    int rets = memcpy_s(
+        cyweeInfo_ext, sizeof(cywee_activity_result_extre_info_t),
+        (cywee_activity_result_extre_info_t *)request->data, request->len);
+    if (rets != EOK) {
+      delete cyweeInfo_ext; // 处理内存分配失败的情况
+      cyweeInfo_ext = NULL;
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "memcpy_s cywee_activity_result_extre_info_t fail ret = %d",
+                    rets);
+      return;
+    }
+    TraingModel::GetInstance()->AnalysisExtraData(cyweeInfo_ext);
+    delete cyweeInfo_ext; // 释放内存
+  }
+  //训练心率
+  if (request->msgId == TOPIC_EVENT_HEARTRATE_UPDATA) {
+    uint8_t heart = *((u_int8_t *)(request->data)); // 进行类型转换
+    TraingModel::GetInstance()->AnalysisHeartData(heart);
+  }
+  #endif
+}
+#ifdef __cplusplus
+}
+#endif
+
+void store_sport_data() {
+  // printf("运动数据存储!\r\n");
+  OHOS::TraingModel::GetInstance()->RecordSportData();
+  return;
+}
+#if TIMER
+namespace OHOS {
+// 声明定时器变量
+static osTimerId_t g_startCounting = NULL; // 定时器
+static constexpr uint64_t MS_ONE_SECONDS = 1000;
+static int g_motionTimes{0};
+static constexpr int32 NUM_TEN = 10;
+static constexpr int16 ERROR = 0;
+static constexpr int16 SUCCESS = 1;
+static constexpr int16 NUM_TIME_MIN = 60;
+static constexpr int16 NUM_TIME_HOUR = 3600;
+static constexpr int32 NUM_TIME_DAY = 86400;
+#endif
+
+SportData *sportdata = new SportData();
+int shock_count{0}; //震动提醒
+
+TraingModel ::TraingModel() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::TraingModel()");
+  // sportdata->Initialize(); // 初始化结构体
+}
+TraingModel ::~TraingModel() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::~TraingModel()");
+  // TraingUnsubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); // 取消订阅
+  // TraingUnsubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
+  // TraingUnsubscribeTopic(TOPIC_EVENT_HEARTRATE_UPDATA);
+  // TraingUnsubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE);
+}
+TraingModel *TraingModel::GetInstance(void) {
+  static TraingModel instance;
+  return &instance;
+}
+
+void TraingModel ::Init() {
+  // TraingSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); // 进行消息订阅
+  // TraingSubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
+  // TraingSubscribeTopic(TOPIC_EVENT_HEARTRATE_UPDATA);
+  // TraingSubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE);
+}
+/*设置运动类型*/
+void TraingModel::SetSportType(Exercisetype type) { sportType_ = type; }
+/*获取训练Id->协议*/
+int TraingModel::GetBleSportId(Exercisetype sporttype, UIResourceTextId id) {
+  int offset = 0;
+
+  switch (sporttype) {
+  case Exercisetype::FITNESS: // 0~57
+    offset = 0;
+    break;
+  case Exercisetype::DANCE: // 0~9
+    offset = 58;
+    break;
+  case Exercisetype::LEISURE: // 0~23
+    offset = 58 + 10;
+    break;
+  case Exercisetype::BALL: // 0~28
+    offset = 58 + 10 + 24;
+    break;
+  case Exercisetype::WATER: // 0~23
+    offset = 58 + 10 + 24 + 29;
+    break;
+  case Exercisetype::ICE: // 0~11
+    offset = 58 + 10 + 24 + 29 + 24;
+    break;
+  case Exercisetype::EXTREME: // 0~9
+    offset = 58 + 10 + 24 + 29 + 24 + 12;
+    break;
+  case Exercisetype::OTHER: // 0~8
+    offset = 58 + 10 + 24 + 29 + 24 + 12 + 10;
+    break;
+  default:
+    offset = 0;
+    break;
+  }
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " offset %d id %d", offset, id);
+  return id - offset;
+}
+
+/*结束数据icon*/
+std::string sportImages[8] = {
+    FITNESS_54_IMAGE,  DANCE_54_IMAGE, REST_54_IMAGE,  BALL_54_IMAGE,
+    SWIMMING_54_IMAGE, ICE_54_IMAGE,   LIMIT_54_IMAGE, OTHER_54_IMAGE,
+};
+/*训练记录Icon*/
+std::string sportIcons[8] = {
+    FITNESS_IMAGE,  DANCE_IMAGE, REST_IMAGE,  BALL_IMAGE,
+    SWIMMING_IMAGE, ICE_IMAGE,   LIMIT_IMAGE, OTHER_IMAGE,
+};
+/*特殊运动icon*/
+std::string sportIcons_special[6] = {RUNNING_60_IMAGE_END, WALKING_60_IMAGE_END,
+                                     RIDING_60_IMAGE_END,  RUNNING_IMAGE,
+                                     WALKING_IMAGE,        RIDING_IMAGE};
+
+/*
+  type
+  0 是运动结束图标
+  1 是运动类型图标
+*/
+std::string TraingModel::GetSportIcon(Exercisetype sporttype,
+                                      UIResourceTextId id, uint8_t type) {
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                " GetSportIcon sporttype %d id %d type %d", sporttype, id,
+                type);
+  bool specialsport = false;
+  uint8_t specialindex = 0;
+  switch (id) {
+  case UIResourceTextId::STR_EXERCISE_OUTDOORRUNNING:
+  case UIResourceTextId::STR_EXERCISE_INDOORRUNNING:
+    specialsport = true;
+    specialindex = 0;
+    break;
+  case UIResourceTextId::STR_EXERCISE_OUTDOORWALKING:
+  case UIResourceTextId::STR_EXERCISE_INDOORWALKING:
+    specialsport = true;
+    specialindex = 1;
+    break;
+  case UIResourceTextId::STR_EXERCISE_OUTDOORBIKING:
+    specialsport = true;
+    specialindex = 2;
+    break;
+  }
+  int index = static_cast<int>(sporttype);
+  if (specialsport) {
+    // 特殊运动
+    if (type == 0) {
+      return sportIcons_special[specialindex]; //返回特殊运动大图标
+    } else {
+      return sportIcons_special[specialindex + 3]; //返回特殊运动小图标
+    }
+  }
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " GetResource index %d", index);
+  if (type == 0) {
+    return sportImages[index]; //返回运动类大图标
+  } else {
+    return sportIcons[index]; //返回运动类小图标
+  }
+  return "";
+}
+/*设置运动Id*/
+void TraingModel::SetSportEvent(UIResourceTextId id) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SetSportType %d", sportId_);
+  //需要是结束开启的运动才重新配置
+  if (sportState_ == ExerciseState::General) {
+    IsSpecialSport(id); // 设置特殊性
+    sportId_ = id;
+  }
+}
+/*获取运动Id*/
+UIResourceTextId TraingModel::GetSportEvent() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " GetSportEvent %d", sportId_);
+  return sportId_;
+}
+/*获取运动项目*/
+ExerciseClass TraingModel::GetSportId() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " GetSportType %d", sportId_);
+  // 设置结构体里面的运动类型
+  sportdata->sportId = sportId_;
+  sportdata->sportType = sportType_;
+
+  switch (sportId_) {
+    // 室外跑步 室外走路
+  case UIResourceTextId::STR_EXERCISE_OUTDOORRUNNING:
+  case UIResourceTextId::STR_EXERCISE_OUTDOORWALKING:
+    // return ExerciseClass::OUTDOOR; 统一使用室内
+
+    // 室内跑步 室内走路
+  case UIResourceTextId::STR_EXERCISE_INDOORRUNNING:
+  case UIResourceTextId::STR_EXERCISE_INDOORWALKING:
+    return ExerciseClass::INDOOR;
+
+    // 跑步机
+  case UIResourceTextId::STR_EXERCISE_TREADMILL:
+  case UIResourceTextId::STR_EXERCISE_STROLLMACHINE:
+    return ExerciseClass::TREADMILL;
+
+    // 自由训练
+  default:
+    return ExerciseClass::FREE_TRAINING;
+  }
+}
+/*判断是否为特殊运动*/
+void TraingModel::IsSpecialSport(UIResourceTextId sportId_) {
+  switch (sportId_) {
+  case UIResourceTextId::STR_EXERCISE_OUTDOORRUNNING: // 室外跑步 室外走路
+  case UIResourceTextId::STR_EXERCISE_OUTDOORWALKING:
+  case UIResourceTextId::STR_EXERCISE_INDOORRUNNING: // 室内跑步 室内走路
+  case UIResourceTextId::STR_EXERCISE_INDOORWALKING:
+  case UIResourceTextId::STR_EXERCISE_TREADMILL: // 跑步机
+  case UIResourceTextId::STR_EXERCISE_STROLLMACHINE:
+    isspecialsport_ = true;
+    break;
+  default: // 自由训练
+    isspecialsport_ = false;
+    break;
+  }
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 特殊训练 %d 训练项 %d",
+                isspecialsport_, sportId_);
+}
+
+bool TraingModel::GetIsSpecial() { return isspecialsport_; }
+/*获取目标字符串*/
+std::string TraingModel::GetTagStr() {
+  /*
+      通用目标配置: 时长、卡路里
+      不通用目标配置: 步数、距离
+
+      如果配置项是特殊目标
+                          -> 普通训练: 无训练目标
+                          -> 特殊训练: 有训练目标
+  */
+
+  std::string tagStr;
+
+  switch (sportTagType_) {
+  case ExerciseTag::Duration:
+    tagStr = std::to_string(sportTag_) + " min"; // 时长目标
+    break;
+
+  case ExerciseTag::Calories:
+    tagStr = std::to_string(sportTag_) + " kcal"; // 卡路里目标
+    break;
+
+  case ExerciseTag::Steps:
+  case ExerciseTag::Distance:
+    if (isspecialsport_) // 检查是否为特殊训练
+    {
+      // 只在特殊训练模式下使用步数和距离目标
+      if (sportTagType_ == ExerciseTag::Steps) {
+        tagStr = std::to_string(sportTag_) + " steps"; // 步数目标
+      } else {
+        tagStr = std::to_string(sportTag_) + " km"; // 距离目标
+      }
+    } else {
+      tagStr = ""; // 普通训练下不使用目标
+    }
+    break;
+
+  default:
+    tagStr = ""; // 未知目标类型
+    break;
+  }
+
+  return tagStr;
+}
+/*设置运动状态*/
+void TraingModel::SetSportState(ExerciseState state) {
+  if (state != ExerciseState::General) {
+    /*app发起的运动*/
+    if (Openingway == true) {
+      if (state == ExerciseState::Start) {
+        sportdata->duration = 0;
+      }
+      #ifdef BLE_SERVER_ENABLE
+      sendtraningstatedata(static_cast<uint8_t>(state), sportdata->duration);
+      #endif
+    }
+  }
+  sportState_ = state;
+
+  // 记录运动状态
+  if (state == ExerciseState::End) {
+    uapi_save_runtime_log(RUNTIME_LOG_SPORT_END);
+  } else if (state == ExerciseState::Continue) {
+    uapi_save_runtime_log(RUNTIME_LOG_SPORT_RESUME);
+  } else if (state == ExerciseState::Pause) {
+    uapi_save_runtime_log(RUNTIME_LOG_SPORT_PAUSE);
+  }
+}
+/*获取运动状态*/
+ExerciseState TraingModel::GetSportState() { return sportState_; }
+// 计算平均心率的函数
+double CalculateAverageHeartRate(const std::vector<int> &heartRates) {
+  if (heartRates.size() <= 2) {
+    // 如果心率数据点少于等于2,无法去掉最高和最低值
+    return 0.0; // 或者返回心率的平均值
+  }
+
+  // 创建一个副本以避免修改原始数据
+  std::vector<int> sortedHeartRates = heartRates;
+
+  // 排序
+  std::sort(sortedHeartRates.begin(), sortedHeartRates.end());
+
+  // 去掉一个最高值和一个最低值
+  sortedHeartRates.erase(sortedHeartRates.begin()); // 去掉最低值
+  sortedHeartRates.pop_back();                      // 去掉最高值
+
+  // 计算剩余心率的平均值
+  double sum = 0;
+  for (int rate : sortedHeartRates) {
+    sum += rate;
+  }
+
+  return sum / sortedHeartRates.size(); // 返回平均值
+}
+#ifdef CYWEE_ACTIVITY_ENABLE
+/*分析数据*/
+void TraingModel::AnalysisData(cywee_activity_result_t *cyweeInfo) {
+  // 不同的运动类型解析不同的数据
+  // 通用数据
+  sportdata->steps = cyweeInfo->steps;
+  sportdata->distance = cyweeInfo->distance;
+  sportdata->calories = cyweeInfo->calories;
+
+  // sportdata->cdc = cyweeInfo->step_frequency;
+  // sportdata->std = cyweeInfo->step_length;
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " pace %d", sportdata->pc);
+
+  sportdata->pc = cyweeInfo->pace;
+
+  // 更新最慢配速
+  if (sportdata->spc < sportdata->pc && sportdata->pc != 0) {
+    sportdata->spc = sportdata->pc;
+  }
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "spc %d", sportdata->spc);
+
+  // 计算平均心率
+  if (sportdata->heart > 50) {
+    sportdata->avgheart = Averageheartrate(sportdata->heart);
+  }
+
+  // 心率提醒
+  if (sportdata->heart >= user_maxHeart && user_maxHeart != 0) {
+    uapi_set_screen_on_api(); // 亮屏检测
+    if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() &&
+        (!uapi_sleep_mode_flag_get())) {
+      ui_api_vibrate_once_func();
+    }
+    if (TraingCardView::GetInstance()) {
+      GraphicService::GetInstance()->PostGraphicEvent(
+          std::bind(&TraingCardView::SetPopupViewStatus,
+                    TraingCardView::GetInstance(), HeartPopup, true));
+      if (TraingCardView::GetInstance()->GetHeartMaxLabel()) {
+        GraphicService::GetInstance()->PostGraphicEvent(
+            std::bind(&TraingCardView::SetHeartMaxLabel,
+                      TraingCardView::GetInstance(), user_maxHeart));
+      }
+    }
+  }
+}
+#endif
+
+#if 0
+    int avg_step_freq;//平均步频
+    int avg_step_len;//平均步长
+    int avg_pace;//平均配速
+    int max_step_freq;//最大步频
+    int max_pace;//最大配速
+    int activity_zone;//活动程度区间 0低度 1中度 2高度
+    int ativity_zone_moderate_duration;//中度活动时间
+    int ativity_zone_high_duration;//高度活动时间
+    int MHR_zone;//心率区间
+    int distance_motion;//体感距离
+#endif
+
+/*分析activity extra info数据*/
+#ifdef CYWEE_ACTIVITY_ENABLE
+void TraingModel::AnalysisExtraData(
+    cywee_activity_result_extre_info_t *cyweeInfo) {
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[apc:%d fpc:%d cdc:%d std:%d]",
+                cyweeInfo->avg_pace, cyweeInfo->max_pace,
+                cyweeInfo->avg_step_freq, cyweeInfo->avg_step_len);
+  //平均配速
+  if (cyweeInfo->avg_pace != 0) {
+    sportdata->apc = cyweeInfo->avg_pace;
+  }
+  //最快配速
+  if (cyweeInfo->max_pace != 0) {
+    sportdata->fpc =cyweeInfo->max_pace;
+  }
+  //平均步频
+  if (cyweeInfo->avg_step_freq != 0) {
+    sportdata->cdc = cyweeInfo->avg_step_freq;
+  }
+  //平均步长
+  if (cyweeInfo->avg_step_len != 0) {
+    sportdata->std = cyweeInfo->avg_step_len * 100; // 前者cm 后者m
+  }
+}
+#endif
+/*分析运动心率数据*/
+void TraingModel::AnalysisHeartData(uint8_t hrs) {
+  sportdata->heart = hrs;
+  SetIntensity(sportdata->heart); // 设置训练强度
+}
+
+/*打印函数*/
+void TraingModel::printf_data(SportData *data) {
+  /*打印测试一下数据*/
+  printf("\r\n****************************************\r\n");
+  printf("Sport type: %d\n", data->sportType);
+  printf("Sport ID: %d\n", data->sportId);
+  printf("Start date: %s\n", data->start_date.c_str());
+  printf("Start time: %s\n", data->start_time.c_str());
+  printf("End time: %s\n", data->end_time.c_str());
+  printf("Goal degree: %d\n", data->goaldegree);
+  printf("Duration: %d\n", data->duration);
+  printf("Distance: %d\n", data->distance);
+  printf("Average heart rate: %d\n", data->avgheart);
+  printf("Steps: %d\n", data->steps);
+  printf("Intensity: %d\n", data->intensity);
+  printf("\r\n****************************************\r\n");
+}
+/*获取数据*/
+SportData *TraingModel::GetSportdata() {
+  // printf_data(sportdata);
+  return sportdata;
+}
+/* 设置训练数据[为训练记录准备] */
+void TraingModel::SetSportdata(SportData *data) {
+  if (data != nullptr && sportdata != nullptr) {
+    sportdata->sportType = data->sportType;
+    sportdata->sportId = data->sportId;
+    sportdata->start_date = data->start_date;
+    sportdata->start_time = data->start_time;
+    sportdata->end_time = data->end_time;
+    sportdata->goaldegree = data->goaldegree;
+    sportdata->duration = data->duration;
+    sportdata->distance = data->distance;
+    sportdata->avgheart = data->avgheart;
+    sportdata->steps = data->steps;
+    sportdata->intensity = data->intensity;
+    sportdata->calories = data->calories;
+    sportdata->apc = data->apc;
+    sportdata->fpc = data->fpc;
+    sportdata->spc = data->spc;
+    sportdata->std = data->std;
+    sportdata->cdc = data->cdc;
+    printf_data(data);//打印该运动数据
+    IsSpecialSport(sportdata->sportId); // 配置训练特殊性
+  }
+}
+/*获取训练卡路里*/
+int TraingModel::GetCal() { return sportdata->calories; }
+/*获取训练目标*/
+int TraingModel::GetSportTag() { return sportdata->tag; }
+/*获取训练项目类型*/
+ExerciseTag TraingModel::GetSportTagtype() { return sportdata->sportTagType; }
+/*重置训练配置*/
+void TraingModel::ResetSharedTrainingData() {
+  sportdata->Reset();    // 重置结构体
+  heartRateData.clear(); // 清空心率数据
+
+  ClearPaceTable();  //重置配速数据
+  ClearHeartTable(); // 清空心率数据
+
+  recentHeartRates.clear();
+  delayed.clear(); // 重置 delayed 字典
+
+  while (!maxHeap.empty()) { // 清空最大堆
+    maxHeap.pop();
+  }
+  while (!minHeap.empty()) { // 清空最小堆
+    minHeap.pop();
+  }
+
+  totalHeartRate = 0;
+  countHeartRate = 0;
+  heartcount = 0;
+
+  Gettagstuats = false; // 重置训练达标标志位
+  Openstate = true;     // 开启运动开始标志位
+
+  shock_count = 0; //重置震动计数
+}
+
+uint32_t TraingModel::get_current_time() {
+  uint32_t time;
+  if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
+    return 0;
+  }
+  return time;
+}
+
+/*设置运动开始与结束*/
+void TraingModel::SetTimestamp() {
+  uint32_t time;
+  if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
+    return;
+  }
+
+  ExerciseState currentState = GetSportState(); // 获取当前运动状态
+
+  // 增加标志位互斥保障"开始"和"结束"的唯一性操作
+  if (currentState == ExerciseState::Start && !Startstate) {
+    // 设置训练 runtime 为 1 训练中
+    uapi_dev_runtime_set_train_status(1);
+    if (Openingway) {
+      // uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_HIGH);
+    }
+
+    // 更新用户数据
+    SetUserSportdata();
+
+    ResetSharedTrainingData(); // 重置共享训练数据
+
+    // printf("SetTimestamp::time:%u  \r\n", time);
+    sportdata->starttime = time;
+
+    sportdata->sportType = sportType_; // 训练类型
+    sportdata->sportId = sportId_;
+
+    IsSpecialSport(sportdata->sportId); // 配置运动特殊性状态
+
+    if (sportTag_) // 有值才设置[训练目标]
+    {
+      sportdata->sportTagType = sportTagType_;
+      sportdata->tag = sportTag_;
+    }
+
+    current_goal = GetCurrentSportTag();
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "训练目标:类型: %d  值: %d 当前目标值:%d", sportTagType_,
+                  sportTag_, current_goal);
+
+    // 设置起始日期和时间
+    SetStartDateTime();
+
+    Startstate = true;
+    Endstate = false; // 确保"开始"和"结束"状态互斥
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始运动");
+
+    //日志记录
+    if (Openingway) {
+      uapi_save_runtime_log(RUNTIME_LOG_APP_SPORT_LAUNCH); // app发起运动
+    } else {
+      uapi_save_runtime_log(RUNTIME_LOG_DIAL_SPORT_LAUNCH); //手表发起运动
+    }
+    if (isspecialsport_) {
+      uapi_save_runtime_log(RUNTIME_LOG_SPORT_SPECIAL_START); //特殊运动
+    } else {
+      uapi_save_runtime_log(RUNTIME_LOG_SPORT_NORMAL_START); //普通运动
+    }
+
+  } else if (currentState == ExerciseState::End && !Endstate) {
+    // 设置训练 runtime 为 0 训练结束
+    uapi_dev_runtime_set_train_status(0);
+    if (Openingway) {
+      // uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_SLOW);
+    }
+
+    sportdata->endtime = time;
+
+    SetEndTime();
+
+    sportState_ = ExerciseState::General;
+    Openstate = false; // 关闭运动标志位
+
+    // 记录运动数据
+    // RecordSportData();
+
+    //配置最后的训练强度(平均心率为标准)
+    SetIntensity(sportdata->avgheart);
+
+    do_custom_fileoperate_service_check_msg(
+        CUSTOM_FILEOPERATE_MSG_TYPE_SPORTDATA_SAVE, nullptr, 0);
+
+    Startstate = false;
+    Endstate = true;
+
+#if 0
+      // 重置训练目标 [发生在训练前]
+      sportTag_ = 0;
+      sportTagType_ = ExerciseTag::UNKNOW;
+#endif
+    /*运动结束并且是手表发起的运动*/
+    if (Openingway == false) {
+      #ifdef BLE_SERVER_ENABLE
+      sendtraningstateend();
+      #endif
+    }
+    /*运动结束并且是app发起的运动*/
+    else {
+      #ifdef BLE_SERVER_ENABLE
+      sendtraningstatedata(0, sportdata->duration);
+      #endif
+    }
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "结束运动");
+  }
+}
+/*设置开始时间*/
+void TraingModel::SetStartDateTime() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->[%d]\r\n",
+                sportdata->duration);
+  std::string startDate, startTime;
+  if (!GetFormattedDate(startDate, "Failed to get start date"))
+    return;
+  if (!GetFormattedTime(startTime, "Failed to get start time"))
+    return;
+
+  sportdata->start_date = startDate;
+  sportdata->start_time = startTime;
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->start_time [%s]\r\n",
+                sportdata->start_time.c_str());
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->[%d]\r\n",
+                sportdata->duration);
+}
+/*设置结束时间*/
+void TraingModel::SetEndTime() {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->[%d]\r\n",
+                sportdata->duration);
+  std::string endTime;
+  if (GetFormattedTime(endTime, "Failed to get end time")) {
+    sportdata->end_time = endTime;
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->end_time [%s]\r\n",
+                sportdata->end_time.c_str());
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->[%d]\r\n",
+                sportdata->duration);
+}
+/*获取日期字符串*/
+bool TraingModel::GetFormattedDate(std::string &dateOutput,
+                                   const char *errorMsg) {
+  char *date = (char *)malloc(9 * sizeof(char)); // 分配内存给start_date
+  if (uapi_get_YYMMDD_Time(date, '/') != ERRCODE_SUCC) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", errorMsg);
+    free(date);
+    return false;
+  }
+  dateOutput = std::string(date);
+  free(date); // 释放内存
+  return true;
+}
+/*获取时间字符串*/
+bool TraingModel::GetFormattedTime(std::string &timeOutput,
+                                   const char *errorMsg) {
+  char *time = (char *)malloc(9 * sizeof(char)); // 分配内存给start_time
+  if (uapi_get_HHMMSS_Time(time, ':', true) != ERRCODE_SUCC) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", errorMsg);
+    free(time);
+    return false;
+  }
+  timeOutput = std::string(time);
+  free(time); // 释放内存
+  return true;
+}
+/*保存数据*/
+void TraingModel::RecordSportData() {
+#if READTEST
+  if (SaveSportData() == false) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveSportData error!");
+  }
+#else
+  if (MomentumFlag) {
+    // GetGoaldegree(); // 设置目标完成度
+    if (SaveSportData()) {
+      TraingRecordModel::GetInstance().SetJsonStatus(true); 
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveSportData ok!");
+    } else {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveSportData error!");
+    }
+  }
+#endif
+}
+// 获取训练时长时间
+std::string TraingModel::GetTrainingTime() {
+  int hour = sportdata->duration / NUM_TIME_HOUR;
+  int min = (sportdata->duration % NUM_TIME_HOUR) / NUM_TIME_MIN;
+  int sec = (sportdata->duration % NUM_TIME_HOUR) % NUM_TIME_MIN;
+
+  std::ostringstream oss;
+  oss << std::setfill('0') << std::setw(2) << hour << ":" << std::setw(2) << min
+      << ":" << std::setw(2) << sec;
+
+  std::string triningtime = oss.str();
+  return triningtime;
+}
+/*解析时间戳 返回例如:13:00:22*/
+std::string TraingModel::AnalysisTimestamp(uint64_t timestamp) {
+  // 将时间戳转换为小时、分钟、秒
+  int hours = timestamp / 3600000;             // 1小时 = 3600000毫秒
+  int minutes = (timestamp % 3600000) / 60000; // 1分钟 = 60000毫秒
+  int seconds = (timestamp % 60000) / 1000;    // 1秒 = 1000毫秒
+
+  // 将小时、分钟、秒转换为字符串
+  std::string hoursStr = std::to_string(hours);
+  std::string minutesStr = std::to_string(minutes);
+  std::string secondsStr = std::to_string(seconds);
+
+  // 格式化输出为 HH:MM:SS
+  std::stringstream ss;
+  ss << std::setfill('0') << std::setw(2) << hoursStr << ":" << std::setw(2)
+     << minutesStr << ":" << std::setw(2) << secondsStr;
+
+  return ss.str();
+}
+int TraingModel::CalculateAverageHeartRate(int newHeartRate) {
+  // 将新的心率添加到数据列表
+  heartRateData.push_back(newHeartRate);
+  totalHeartRate += newHeartRate;
+  countHeartRate++;
+
+  // 将新的心率插入到堆中
+  maxHeap.push(newHeartRate);
+  minHeap.push(newHeartRate);
+
+  // 如果超过窗口大小,移除最早的心率
+  if (heartRateData.size() > windowSize) {
+    int oldestRate = heartRateData[0];
+    totalHeartRate -= oldestRate;
+    countHeartRate--;
+
+    // 将老旧值从列表中移除
+    heartRateData.erase(heartRateData.begin());
+
+    // 标记老旧值为待删除
+    delayed[oldestRate]++;
+  }
+
+  // 清理堆中的老旧值
+  while (!maxHeap.empty() && delayed[maxHeap.top()] > 0) {
+    delayed[maxHeap.top()]--;
+    maxHeap.pop();
+  }
+
+  while (!minHeap.empty() && delayed[minHeap.top()] > 0) {
+    delayed[minHeap.top()]--;
+    minHeap.pop();
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "新心率: %d, 当前心率总和: %d, 心率计数: %d", newHeartRate,
+                totalHeartRate, countHeartRate);
+
+  // 如果心率数量少于 3,直接返回当前的平均值
+  if (countHeartRate < 3) {
+    return totalHeartRate / countHeartRate; // 无法去除最大最小值
+  }
+
+  // 取出当前未被删除的最大和最小的心率
+  int maxRate = maxHeap.top();
+  int minRate = minHeap.top();
+
+  // 进行去极值后的平均计算
+  int average = (totalHeartRate - maxRate - minRate) / (countHeartRate - 2);
+
+  // 打印计算结果
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "去极值后的平均心率: %d (去掉最大值: %d, 去掉最小值: %d)",
+                average, maxRate, minRate);
+
+  return average;
+}
+// 显示心率
+int TraingModel::CalculateFilteredHeartRate(int newHeartRate) {
+  // 将新的心率添加到最近心率列表
+  recentHeartRates.push_back(newHeartRate);
+
+  // 如果超过窗口大小,移除最早的心率
+  if (recentHeartRates.size() > windowSize) {
+    recentHeartRates.erase(recentHeartRates.begin());
+  }
+
+  // 计算当前窗口中的平均心率
+  int total =
+      std::accumulate(recentHeartRates.begin(), recentHeartRates.end(), 0);
+
+  // 打印当前窗口的平均心率
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "过滤后当前窗口的平均心率: %d",
+                (total / recentHeartRates.size()));
+
+  return total / recentHeartRates.size(); // 返回计算后的平均值
+}
+int TraingModel::Averageheartrate(int newHeartRate) {
+  heartcount++;
+  totalHeartRate += newHeartRate;
+  return totalHeartRate / heartcount; // 返回计算的平均值
+}
+// 设置训练目标类型以及训练目标
+void TraingModel::SetSportTag(ExerciseTag tagtpye, int tag) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置目标 tagtpye[%d] tag[%d]",
+                tagtpye, tag);
+  sportTagType_ = tagtpye;
+  sportTag_ = tag;
+}
+
+/* 设置训练强度 */
+void TraingModel::SetIntensity(int heart) {
+  // sportdata->intensity = active_state;
+#if 1
+  /*
+      训练强度
+      220-年龄=最高心率
+
+      分为四个强度区间
+      较低强度=最高心率*59%以下
+      中等强度=最高心率*60%~69%
+      高等强度=最高心率*70%~79%
+      超高强度=最高心率*80%以上
+  */
+  // 确保最大心率为正值
+  if (user_Intensity <= 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "maxHeartRate %d is error",
+                  user_Intensity);
+    return;
+  }
+
+  // 将 heart 转换为 double 以避免整数除法
+  double heartRateAsDouble = static_cast<double>(heart);
+  double intensityPercentage =
+      (heartRateAsDouble / (double)user_Intensity) * 100;
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "heart: %d, maxHeartRate: %d, intensityPercentage: %.2f", heart,
+                HeartModel, intensityPercentage);
+
+  if (intensityPercentage < LOW_INTENSITY_THRESHOLD) {
+    // 较低强度
+    sportdata->intensity = LOW_INTENSITY;
+  } else if (intensityPercentage >= MEDIUM_INTENSITY_LOWER_THRESHOLD &&
+             intensityPercentage <= MEDIUM_INTENSITY_UPPER_THRESHOLD) {
+    // 中等强度
+    sportdata->intensity = MEDIUM_INTENSITY;
+  } else if (intensityPercentage >= HIGH_INTENSITY_LOWER_THRESHOLD &&
+             intensityPercentage <= HIGH_INTENSITY_UPPER_THRESHOLD) {
+    // 高等强度
+    sportdata->intensity = HIGH_INTENSITY;
+  } else {
+    // 超高强度
+    sportdata->intensity = VERY_HIGH_INTENSITY;
+  }
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "maxHeartRate: %d, heartRate: %d, intensityPercentage: %.2f",
+                maxHeartRate, heart, intensityPercentage);
+#endif
+}
+/*获取训练强度STR*/
+UIResourceTextId TraingModel::GetIntensity() {
+  switch (sportdata->intensity) {
+  case LOW_INTENSITY:
+    return UIResourceTextId::STR_LOWER_STRENGTH;
+    break;
+  case MEDIUM_INTENSITY:
+    return UIResourceTextId::STR_MEDIUM_STRENGTH;
+    break;
+  case HIGH_INTENSITY:
+    return UIResourceTextId::STR_HIGH_STRENGTH;
+    break;
+  case VERY_HIGH_INTENSITY:
+    return UIResourceTextId::STR_ULTRA_HIGH_STRENGTH;
+    break;
+  default:
+    return UIResourceTextId::STR_LOWER_STRENGTH;
+    break;
+  }
+}
+
+/*
+时长:10~600分钟 实际出值 秒
+距离:1~20km  实际出值 m
+步数:500~50000步 实际出值 步
+卡路里:100~1000kcal 实际出值 kcal
+*/
+
+/* 获取当前的目标值 */
+int TraingModel::GetSportTagData() {
+  if (sportdata->tag == 0 || current_goal == 0) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "sportdata->tag is 0");
+    return 0;
+  }
+
+  float goaldegree = 0.0f; // 初始化目标完成度
+
+  // 根据设置的训练目标类型去对应相对的数据
+  switch (sportdata->sportTagType) {
+  case ExerciseTag::Duration: {
+    // 计算完成度
+    goaldegree = (static_cast<float>(sportdata->duration) / current_goal) * 100;
+    break;
+  }
+  case ExerciseTag::Calories: {
+    // 计算目标完成度
+    goaldegree = (static_cast<float>(sportdata->calories) / current_goal) * 100;
+    break;
+  }
+  case ExerciseTag::Distance: {
+    // 计算目标完成度
+    goaldegree = (static_cast<float>(sportdata->distance) / current_goal) * 100;
+    break;
+  }
+  case ExerciseTag::Steps: {
+    // 计算目标完成度
+    goaldegree = (static_cast<float>(sportdata->steps) / current_goal) * 100;
+    break;
+  }
+  default:
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->sportTagType is error");
+    return 0;
+    break;
+  }
+
+  WEARABLE_LOGD(
+      WEARABLE_LOG_MODULE_APP,
+      " [goaldegree %d, sportdata->tag %d, sportdata->duration %d, "
+      "sportdata->calories %d,sportdata->distance %d, sportdata->steps %d]",
+      goaldegree, sportdata->tag, sportdata->duration, sportdata->calories,
+      sportdata->distance, sportdata->steps);
+
+  return static_cast<int>(round(goaldegree)); // 返回目标完成度
+}
+
+//获取目标值
+uint32_t TraingModel::GetCurrentSportTag() {
+  if (sportdata->tag == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->tag is 0");
+    return 0;
+  }
+
+  float goaldegree = 0.0f; // 初始化目标完成度
+
+  // 根据设置的训练目标类型去对应相对的数据
+  switch (sportdata->sportTagType) {
+  case ExerciseTag::Duration: {
+    // 转换目标时长为秒
+    return static_cast<float>(sportdata->tag * 60);
+    break;
+  }
+  case ExerciseTag::Calories: {
+    // 计算目标完成度
+    return sportdata->tag;
+    break;
+  }
+  case ExerciseTag::Distance: {
+    return static_cast<float>(sportdata->tag * 1000);
+    break;
+  }
+  case ExerciseTag::Steps: {
+    return sportdata->tag;
+    break;
+  }
+  default:
+    return 0;
+    break;
+  }
+}
+//获取是否达到目标 使用比较
+bool TraingModel::IsGetGoaldegree() {
+  if (sportdata->tag == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->tag is 0");
+    return false;
+  }
+
+  float goaldegree = 0.0f; // 初始化目标完成度
+
+  // 根据设置的训练目标类型去对应相对的数据
+  switch (sportdata->sportTagType) {
+  case ExerciseTag::Calories: {
+    // 计算目标完成度
+    if (sportdata->calories >= current_goal) {
+      return true;
+    }
+    return false;
+    break;
+  }
+  case ExerciseTag::Distance: {
+    if (sportdata->distance >= current_goal) {
+      return true;
+    }
+    return false;
+    break;
+  }
+  case ExerciseTag::Steps: {
+    if (sportdata->steps >= current_goal) {
+      return true;
+    }
+    return false;
+    break;
+  }
+  default:
+    return false;
+    break;
+  }
+}
+
+/* 获取训练目标完成百分比 */
+int TraingModel::GetGoaldegree() {
+  if (sportdata->tag == 0) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "sportdata->tag is 0");
+    return 0; // 如果目标值为 0,返回 0%
+  }
+
+  int goaldegree = GetSportTagData();
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "goaldegree %d", goaldegree);
+  return goaldegree; // 直接返回目标完成度
+}
+
+void TraingModel::updata_goal() {
+  if (sportdata->tag == 0)
+    return;
+
+  sportdata->goaldegree = GetGoaldegree();
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "sportdata->goaldegree %d",
+                sportdata->goaldegree);
+}
+
+/* 训练目标校验 */
+void TraingModel::CheckSportTag() {
+  // 运动开始才计算
+  if (sportdata->tag && sportdata->sportTagType != ExerciseTag::Duration) {
+    if (IsGetGoaldegree() && !Gettagstuats) {
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "目标完成");
+      uapi_set_screen_on_api(); // 亮屏检测
+      if (!OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) {
+        ui_api_vibrate_once_func(); // 震动提示
+      }
+      if (TraingCardView::GetInstance()) {
+        GraphicService::GetInstance()->PostGraphicEvent(
+            std::bind(&TraingCardView::SetPopupViewStatus,
+                      TraingCardView::GetInstance(), GetTagPopup, true));
+        auto animator = TraingCardView::GetInstance()->GetAnimator();
+        if (animator) {
+          animator->Start(); // 启动动画
+        }
+      }
+      Gettagstuats = true; // 更新状态
+    }
+  }
+}
+// 校验时间获取目标
+void TraingModel::CheckTimeTag() {
+  if (sportdata->tag == 0 || sportdata->sportTagType != ExerciseTag::Duration) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->tag is 0");
+    return;
+  }
+  if (sportdata->duration == current_goal && !Gettagstuats) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "目标完成");
+    uapi_set_screen_on_api(); // 亮屏检测
+    if (!OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) {
+      ui_api_vibrate_once_func(); // 震动提示
+    }
+    if (TraingCardView::GetInstance()) {
+      GraphicService::GetInstance()->PostGraphicEvent(
+          std::bind(&TraingCardView::SetPopupViewStatus,
+                    TraingCardView::GetInstance(), GetTagPopup, true));
+      auto animator = TraingCardView::GetInstance()->GetAnimator();
+      if (animator) {
+        animator->Start(); // 启动动画
+      }
+    }
+    Gettagstuats = true; // 更新状态
+  }
+}
+
+//获取运动时长
+int TraingModel::GetDuration() { return sportdata->duration; }
+/*获取训练类型Id*/
+UIResourceTextId TraingModel::GetSportTypeId(Exercisetype type) {
+  // 根据设置的训练类型去对应相对的数据
+  switch (type) {
+  // 健身类
+  case Exercisetype::FITNESS:
+    return STR_EXERCISE_LIST;
+  // 舞蹈类
+  case Exercisetype::DANCE:
+    return STR_DANCING_LIST;
+  // 休闲运动
+  case Exercisetype::LEISURE:
+    return STR_RECREATIONAL_LIST;
+  // 球类
+  case Exercisetype::BALL:
+    return STR_BALL_LIST;
+  // 水上运动
+  case Exercisetype::WATER:
+    return STR_WATER_LIST;
+  // 冰上运动
+  case Exercisetype::ICE:
+    return STR_ICE_LIST;
+  // 极限运动
+  case Exercisetype::EXTREME:
+    return STR_EXTREME_LIST;
+  // 其他
+  case Exercisetype::OTHER:
+    return STR_OTHER_LIST;
+  default:
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Not ExerciseClass type!");
+    break;
+  }
+
+  return STR_EXERCISE_LIST; // 添加默认返回值[健身类]
+}
+/*打印存储数据*/
+void TraingModel::printTrainingData(const Trainingdata &data) {
+  printf("Trainingdata:\n");
+  printf("src: %d\n", data.src);
+  printf("bt: %u\n", data.bt);
+  printf("ty: %u\n", data.ty);
+  printf("st: %u\n", data.st);
+  printf("sp: %u\n", data.sp);
+  printf("tgt: %u\n", data.tgt);
+  printf("tg: %u\n", data.tg);
+  printf("pg: %u\n", data.pg);
+  printf("du: %u\n", data.du);
+  printf("ca: %u\n", data.ca);
+  printf("di: %u\n", data.di);
+  printf("hr: %u\n", data.hr);
+  printf("stp: %u\n", data.stp);
+  printf("ti: %u\n", data.ti);
+  printf("cir: %u\n", data.cir);
+  printf("alt: %u\n", data.alt);
+}
+
+/*
+    uint32_t src; // 训练来源:0 - 手表开启的训练,1 - APP开启的训练
+    uint32_t bt;  // 运动类型:0 - 健身类,1 - 舞蹈类,2 - 休闲运动,3 - 球类,4
+   - 水上项目,5 - 冰上项目,6 - 极限运动,7 - 其他 uint32_t ty;  //
+   训练类型:自由训练 uint32_t st;  // 开始时间戳(单位:秒) uint32_t sp;  //
+   结束时间戳(单位:秒) uint32_t tgt; // 训练目标类型:0 - 距离,1 - 卡路里,2
+   - 时间,3 - 步数 uint32_t tg;  //
+   训练目标值:路程(单位:米),卡路里(单位:kcal),时间(单位:分钟),步数(单位:步)
+    uint32_t pg;  // 目标完成度(单位:%)
+    uint32_t du;  // 训练总时长(单位:秒)
+    uint32_t ca;  // 消耗卡路里(单位:kcal)
+    uint32_t di;  // 完成的距离(单位:米)
+    uint32_t hr;  // 平均心率
+    uint32_t stp; // 步数
+    uint32_t ti;  // 训练强度:0 - 较低强度,1 - 中等强度,2 - 高等强度,3 -
+   超高强度 uint32_t cir; // 圈数 uint32_t alt; // 最高海拔高度
+*/
+/*保存数据*/
+bool TraingModel::SaveSportData() {
+
+  // 配置训练存储状态
+  uapi_dev_runtime_set_train_storage_status(1);
+
+  Trainingdata data;
+  data.src = Openingway;
+  data.bt = static_cast<uint32_t>(sportdata->sportType);
+  data.ty = static_cast<uint32_t>(
+      GetBleSportId(sportdata->sportType, sportdata->sportId));
+  data.st = static_cast<uint32_t>(sportdata->starttime);
+  data.sp = static_cast<uint32_t>(sportdata->endtime);
+  data.tgt = static_cast<uint32_t>(sportdata->sportTagType);
+  if (sportdata->sportTagType == ExerciseTag::Distance) {
+    data.tg = static_cast<uint32_t>(sportdata->tag * 1000);
+  } else {
+    data.tg = static_cast<uint32_t>(sportdata->tag);
+  }
+  data.pg = static_cast<uint32_t>(sportdata->goaldegree);
+  data.du = static_cast<uint32_t>(sportdata->duration);
+  data.ca = static_cast<uint32_t>(sportdata->calories * 10);
+  data.di = static_cast<uint32_t>(sportdata->distance);
+  data.hr = static_cast<uint32_t>(sportdata->avgheart);
+  data.stp = static_cast<uint32_t>(sportdata->steps);
+  data.ti = static_cast<uint32_t>(sportdata->intensity);
+  /* 230 目前不支持【圈数】【最高海拔高度】 */
+  data.cir = 0;
+  data.alt = 0;
+  /* 配速相关 */
+  data.apc = static_cast<uint32_t>(sportdata->apc);
+  data.fpc = static_cast<uint32_t>(sportdata->fpc);
+  data.spc = static_cast<uint32_t>(sportdata->spc);
+  data.std = static_cast<uint32_t>(sportdata->std);
+  data.cdc = static_cast<uint32_t>(sportdata->cdc);
+
+  // 创建sport文件夹
+  CreateDirectoryIfNotExists(TRAINING_DATA_DIRECTORY);
+
+  // 保存数据到 bin
+  if (write_Trainingdata_data(data) != 1) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "write_Trainingdata_data is error!");
+    uapi_dev_runtime_set_train_storage_status(0); // 恢复状态
+    return false;
+  }
+
+  // 保存数据到 json
+  if (!SaveDataToJson(sportdata)) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveDataToJson is error!");
+    uapi_dev_runtime_set_train_storage_status(0); // 恢复状态
+    return false;
+  }
+
+  if (isspecialsport_) {
+    // 保存心率表
+    if (!SaveHeartTable()) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveHeartRateData is error!");
+      // uapi_dev_runtime_set_train_storage_status(0); // 恢复状态
+      // return false;
+    }
+    // 保存速度表
+    if (!SavePaceTable()) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveSpeedData is error!");
+      // uapi_dev_runtime_set_train_storage_status(0); // 恢复状态
+      // return false;
+    }
+  }
+
+  // 如果所有操作成功,则恢复训练存储状态
+  uapi_dev_runtime_set_train_storage_status(0);
+  return true;
+}
+/*设置进入方式*/
+void TraingModel::SetEntryType(ENTEYTYPE type) { entey_type = type; }
+/*获取进入方式*/
+ENTEYTYPE TraingModel::GetEntryType() { return entey_type; }
+/*设置开启方式*/
+void TraingModel::SetSportOpenWay(bool way) { Openingway = way; }
+/*设置运动是否开始*/
+void TraingModel::SetSportOpenState(bool state) { Openstate = state; }
+/*获取运动是否开始*/
+bool TraingModel::GetSportOpenState() { return Openstate; }
+/*获取运动时长*/
+uint32_t TraingModel::GetSportTime() { return sportdata->duration; }
+/*获取训练量是否达标*/
+bool TraingModel::GetMomentum() {
+#if 0
+        int caldata = TraingModel::GetInstance()->GetCal();
+        /*判断是否产生至少1Kcald的运动量*/
+        if (caldata >= 1)
+        {
+            MomentumFlag = true;
+        }
+        else
+        {
+            MomentumFlag = false;
+        }
+#endif
+  int duration = sportdata->duration;
+  //判断运动时间是否大于1分钟
+  if (duration >= 60) {
+    MomentumFlag = true;
+  } else {
+    MomentumFlag = false;
+  }
+  return MomentumFlag;
+}
+
+//用户运动数据配置
+void TraingModel::SetUserSportdata() {
+  // 获取用户的最高心率提醒
+  user_maxHeart = ConfigModel::GetInstance()->get_configData_int(
+      ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "用户最高心率提醒: %d", user_maxHeart);
+
+  // 获取用户年龄
+  user_Age = ConfigModel::GetInstance()->GetUserAge();
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "用户年龄: %d", user_Age);
+
+  // 获取自动训练设置
+  user_autoget = ConfigModel::GetInstance()->get_configData_int(
+      ConfigModel::CONFIGMODEL_ITEM_TRANING_AUTO);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "自动获取设置: %d", user_autoget);
+
+  // 获取训练频率设置
+  user_freq = ConfigModel::GetInstance()->get_configData_int(
+      ConfigModel::CONFIGMODEL_ITEM_TRANING_FREQ);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "训练频率: %d", user_freq);
+
+  user_Intensity = MAX_HEART_RATE - user_Age;
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "用户运动强度心率: %d",
+                user_Intensity);
+}
+//运动过程中更新心率配置
+void TraingModel::SetMaxHeart(int maxheart) {
+  // 获取用户运动数据配置
+  user_maxHeart = maxheart;
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "用户最高心率: %d", user_maxHeart);
+}
+/*配速表与心率表相关*/
+//清空心率表
+void TraingModel::ClearHeartTable() {
+  heartRateTable.clear(); // 清空心率数据表
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Heart Rate Table Cleared.\r\n");
+}
+//清空配速表
+void TraingModel::ClearPaceTable() {
+  paceTable.clear(); // 清空配速数据表
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Pace Table Cleared.\r\n");
+}
+// 添加心率数据
+bool TraingModel::AddHeartRateData(uint32_t timestamp, uint8_t heartRate) {
+  // 检查重复时间戳
+  for (const auto &entry : heartRateTable) {
+    if (entry.timestamp == timestamp) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "时间戳重复无法添加数据 AddHeartRateData is error!");
+      return false; // 返回重复
+    }
+  }
+
+  if (heartRateTable.size() >= MAX_ENTRIES) {
+    WEARABLE_LOGE(
+        WEARABLE_LOG_MODULE_APP,
+        "达到最大心率数据条目限制 无法添加新的数据 AddHeartRateData is error!");
+    return false; // 返回条目满了
+  }
+
+  HeartRateEntry newEntry = {timestamp, heartRate};
+  heartRateTable.push_back(newEntry);
+  return true; // 返回成功
+}
+
+// 添加配速数据
+bool TraingModel::AddPaceData(uint32_t timestamp, uint16_t pace) {
+  // 检查重复时间戳
+  for (const auto &entry : paceTable) {
+    if (entry.timestamp == timestamp) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "时间戳重复无法添加数据 AddPaceData is error!"); // 修正这里
+      return false; // 返回重复
+    }
+  }
+
+  if (paceTable.size() >= MAX_ENTRIES) {
+    WEARABLE_LOGE(
+        WEARABLE_LOG_MODULE_APP,
+        "达到配速数据条目限制 无法添加新的数据 AddPaceData is error!");
+    return false; // 返回条目满了
+  }
+
+  PaceEntry newEntry = {timestamp, pace};
+  paceTable.push_back(newEntry);
+  return true; // 返回成功
+}
+//心率表打印
+void TraingModel::PrintHeartRateTable() {
+  size_t heartRateCount = heartRateTable.size();
+  if (heartRateCount == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "心率表为空,无法打印。");
+    return;
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Heart Rate Table:");
+  for (const auto &entry : heartRateTable) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "时间戳: %u, 心率: %d",
+                  entry.timestamp, entry.heartRate);
+  }
+}
+//配速表打印
+void TraingModel::PrintPaceTable() {
+  size_t paceCount = paceTable.size();
+  if (paceCount == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "配速表为空,无法打印。");
+    return;
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Pace Table:");
+  for (const auto &entry : paceTable) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "时间戳: %u, 配速: %d",
+                  entry.timestamp, entry.pace);
+  }
+}
+// 保存心率表
+bool TraingModel::SaveHeartTable() {
+
+  //打印数组
+  PrintHeartRateTable();
+
+  CreateDirectoryIfNotExists(TRAINING_HEART_FILE);
+
+  size_t heartRateCount = heartRateTable.size();
+  if (heartRateCount == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "心率表为空,无法保存。");
+    return false;
+  }
+
+  std::string filePath =
+      TRAINING_HEART_FILE + std::to_string(sportdata->starttime) + ".bin";
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveHeartTable filePath: %s",
+                filePath.c_str());
+  std::ofstream heartRateFile(filePath, std::ios::binary);
+  if (!heartRateFile) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "无法打开文件: %s",
+                  filePath.c_str());
+    return false; // 返回失败
+  }
+
+  // 存储表数据
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateCount = %d", heartRateCount);
+  if (!heartRateFile.write(
+          reinterpret_cast<const char *>(heartRateTable.data()),
+          heartRateCount * sizeof(HeartRateEntry))) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "写入心率数据失败。");
+    return false; // 返回失败
+  }
+
+  heartRateFile.close();
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Heart Rate Table Saved.");
+  return true; // 返回成功
+}
+
+// 保存配速表
+bool TraingModel::SavePaceTable() {
+
+  //打印数组
+  PrintPaceTable();
+
+  CreateDirectoryIfNotExists(TRAINING_PACE_FILE);
+
+  size_t paceCount = paceTable.size();
+  if (paceCount == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "配速表为空,无法保存。");
+    return false;
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "paceCount = %d", paceCount);
+
+  std::string filePath =
+      TRAINING_PACE_FILE + std::to_string(sportdata->starttime) + ".bin";
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SavePaceTable filePath: %s",
+                filePath.c_str());
+
+  std::ofstream paceFile(filePath, std::ios::binary);
+  if (!paceFile) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "无法打开文件: %s",
+                  filePath.c_str());
+    return false; // 返回失败
+  }
+  // 写入配速数据
+  if (!paceFile.write(reinterpret_cast<const char *>(paceTable.data()),
+                      paceCount * sizeof(PaceEntry))) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "写入配速数据失败。");
+    return false; // 返回失败
+  }
+
+  paceFile.close();
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SavePaceTable Success.");
+  return true; // 返回成功
+}
+// 返回心率表路径
+std::string TraingModel::GetHeartTablePath(uint32_t timestamp) {
+  // 首先检查完全匹配的时间戳
+  std::string exactFilePath =
+      TRAINING_HEART_FILE + std::to_string(timestamp) + ".bin";
+  if (IsFileAccessibleAndNotEmpty(exactFilePath)) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "找到心率表: %s",
+                  exactFilePath.c_str());
+    return exactFilePath; // 返回完全匹配的文件路径
+  }
+
+  // 如果未找到,检查时间戳相差1到2秒的文件
+  for (int i = -2; i <= 2; ++i) {
+    uint32_t checkTimestamp = timestamp + i;
+    std::string filePath =
+        TRAINING_HEART_FILE + std::to_string(checkTimestamp) + ".bin";
+    if (IsFileAccessibleAndNotEmpty(filePath)) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "找到心率表: %s",
+                    filePath.c_str());
+      return filePath; // 返回找到的文件路径
+    }
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "未找到与时间戳相关的心率表。");
+  return ""; // 未找到文件
+}
+
+// 返回配速表路径
+std::string TraingModel::GetPaceTablePath(uint32_t timestamp) {
+  // 首先检查完全匹配的时间戳
+  std::string exactFilePath =
+      TRAINING_PACE_FILE + std::to_string(timestamp) + ".bin";
+  if (IsFileAccessibleAndNotEmpty(exactFilePath)) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "找到配速表: %s",
+                  exactFilePath.c_str());
+    return exactFilePath; // 返回完全匹配的文件路径
+  }
+
+  // 如果未找到,检查时间戳相差1到2秒的文件
+  for (int i = -2; i <= 2; ++i) {
+    uint32_t checkTimestamp = timestamp + i;
+    std::string filePath =
+        TRAINING_PACE_FILE + std::to_string(checkTimestamp) + ".bin";
+    if (IsFileAccessibleAndNotEmpty(filePath)) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "找到配速表: %s",
+                    filePath.c_str());
+      return filePath; // 返回找到的文件路径
+    }
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "未找到与时间戳相关的配速表。");
+  return ""; // 未找到文件
+}
+/*发送实时数据*/
+void TraingModel::SendLiveData() {
+  // msg_get_train_data_info_t data;
+  // memset(&data, 0, sizeof(msg_get_train_data_info_t));
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata->starttime %d \r\n",
+  //               sportdata->starttime);
+  // data.st = sportdata->starttime;
+  // data.hr = sportdata->heart;
+  // data.ca = sportdata->calories * 10; // app端需要乘10
+  // data.di = sportdata->distance;
+  // data.stp = sportdata->steps;
+  // data.ti = sportdata->intensity;
+  // data.pc = sportdata->pc;
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SendLiveData Begin!");
+  // sendtraningdata(&data); // 发送数据函数
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SendLiveData Stop!");
+}
+/* -------------------------------- 运动识别发起处理
+ * -------------------------------- */
+void TraingModel::set_sport_config(UIResourceTextId id) {
+  if (id >= MAXSPORTID) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "id is error");
+    return;
+  }
+  // 开始训练 ->不返回
+  NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);
+  // 配置运动项
+  SetSportEvent(id);
+  // 获取运动项目
+  ExerciseClass type = GetSportId();
+  // 开启对应的运动
+  TraingCardPresenter::GetInstance()->OpenSensor(type);
+  // 设置为手表开启运动
+  SetSportOpenWay(false);
+}
+
+/* -------------------------------------------------------------------------- */
+
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+#include <string>
+
+std::string TraingModel::DisplayMotionDuration() {
+  // 清空 motionDuration
+  motionDuration.clear();
+
+  // 重置运动次数
+  if (g_motionTimes >= NUM_TIME_DAY) {
+    g_motionTimes = 0;
+  }
+
+  // 计算和格式化运动时长
+  int hours = g_motionTimes / NUM_TIME_HOUR;
+  int minutes = (g_motionTimes % NUM_TIME_HOUR) / NUM_TIME_MIN;
+  int seconds = g_motionTimes % NUM_TIME_MIN;
+
+  std::ostringstream oss;
+  oss << std::setfill('0') << std::setw(2) << hours << ":" << std::setw(2)
+      << minutes << ":" << std::setw(2) << seconds;
+
+  motionDuration = oss.str();
+
+  // // 获取当前时间(以微秒为单位)
+  // uint32_t currentTime = static_cast<uint32_t>(
+  //     std::chrono::duration_cast<std::chrono::microseconds>(
+  //         std::chrono::system_clock::now().time_since_epoch())
+  //         .count());
+
+  // // 记录和检查上一次调用的时间
+  // static uint32_t lastCallTime = 0;
+  // if (currentTime - lastCallTime < 1000000) { // 小于1秒
+  //   return motionDuration;
+  // }
+  // lastCallTime = currentTime; // 更新最后调用时间
+
+  // 如果 g_motionTimes 不为零,进行计算和数据存储
+  if (g_motionTimes > 0) {
+    sportdata->duration = g_motionTimes; // 设置训练时长
+
+    // 每分钟进行配速和心率数据存储
+    // StoreDataIfMinutePassed();
+  }
+
+  return motionDuration; // 返回格式化的运动时长
+}
+
+// 检查并发送实时数据
+void TraingModel::SendLiveDataIfNecessary() {
+  // 检查自动获取的配置 app发起
+  if (user_autoget && Openingway) {
+    // 发送实时数据
+    if (g_motionTimes % user_freq == 0) {
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SendLiveData is OK\r\n");
+      SendLiveData(); // 发送实时数据
+    }
+  }
+}
+
+// 每5秒进行配速和心率数据存储
+void TraingModel::StoreDataIfMinutePassed() {
+  if (sportdata->duration % 5 == 0) {
+    uint32_t timestamp;
+    //进行数据的筛选
+    if (uapi_get_timestampe_ss(&timestamp) == ERRCODE_SUCC) {
+      if (sportdata->heart != 0)
+        AddHeartRateData(timestamp, sportdata->heart);
+      if (sportdata->apc != 0)
+        AddPaceData(timestamp, sportdata->apc);
+    }
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "duration:[%d] g_motionTimes[%d]\r\n",
+                sportdata->duration, g_motionTimes);
+}
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include <stdbool.h> // 确保包含该头文件以使用布尔类型
+
+// 全局变量
+static bool isPaused = false;            // 定时器暂停状态
+static uint32_t pauseStartTimestamp = 0; // 当前暂停开始的时间戳
+static uint32_t totalPausedDuration = 0; // 总暂停时长
+// static uint32_t g_motionTimes = 0; // 总运动时间
+// static TimerHandle_t g_startCounting = NULL; // 定时器句柄
+
+/* 日志错误信息 */
+void LogError(const char *msg, osStatus_t ret) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s ret = %lx!!", msg, ret);
+}
+
+/* 定时器回调函数 */
+void TraingTimerCallback(void) {
+  // 只在活动状态下进行更新
+
+  if (pauseStartTimestamp == 0) {
+    //开始时将该值设置为运动开始值
+    pauseStartTimestamp = sportdata->starttime;
+  }
+
+  uint32_t currentTimestamp =
+      OHOS::TraingModel::GetInstance()->get_current_time(); // 获取当前时间戳
+  g_motionTimes = (currentTimestamp - pauseStartTimestamp) +
+                  totalPausedDuration; // 更新运动时间
+  sportdata->duration = g_motionTimes; // 更新持续时间
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "更新运动时间。当前运动时间: %d %d %d %d", currentTimestamp,
+                pauseStartTimestamp, totalPausedDuration, g_motionTimes);
+
+  // 检查并发送实时数据
+  OHOS::TraingModel::GetInstance()->SendLiveDataIfNecessary();
+  OHOS::TraingModel::GetInstance()->CheckTimeTag();
+
+  // 记录特殊活动的心率/配速数据
+  if (OHOS::TraingModel::GetInstance()->GetIsSpecial()) {
+    OHOS::TraingModel::GetInstance()->StoreDataIfMinutePassed();
+  }
+
+  // 振动反馈
+  if ((sportdata->goaldegree >= 100) && (shock_count < 4)) {
+    shock_count++;
+    ui_api_vibrate_once_func(); // 触发振动反馈
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "触发了振动。振动计数: %d",
+                  shock_count);
+  }
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingTimerCallback 被执行。");
+}
+
+/* 启动定时器 */
+void StartTimer(void) {
+  if (g_startCounting != NULL) {
+    LogError("定时器已经存在", osError);
+    return;
+  }
+
+  g_startCounting = osTimerNew((osTimerFunc_t)TraingTimerCallback,
+                               osTimerPeriodic, NULL, NULL);
+  if (g_startCounting == NULL) {
+    LogError("定时器创建失败", osError);
+    return;
+  }
+
+  int tick = osMs2Tick(MS_ONE_SECONDS);
+  osStatus_t retTimer = osTimerStart(g_startCounting, tick);
+  if (retTimer != osOK) {
+    LogError("定时器启动失败", retTimer);
+    osTimerDelete(g_startCounting);
+    g_startCounting = NULL;
+  }
+}
+
+/* 停止并重置定时器 */
+void StopAndResetTimer(void) {
+  if (g_startCounting != NULL) {
+    osTimerStop(g_startCounting);
+    osStatus_t ret = osTimerDelete(g_startCounting);
+    if (ret != osOK) {
+      LogError("定时器删除失败", ret);
+    }
+    g_startCounting = NULL;
+    g_motionTimes = 0;
+    pauseStartTimestamp = 0;
+    totalPausedDuration = 0; // 重置总暂停时长
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "定时器已停止并重置。");
+  }
+}
+
+/* 暂停定时器 */
+void PauseTimer(void) {
+  if (g_startCounting != NULL) {
+    osTimerStop(g_startCounting);
+
+    totalPausedDuration = sportdata->duration; //记录暂停前的时间;后续加上
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "定时器已暂停。暂停开始时间戳: %u",
+                  pauseStartTimestamp);
+  }
+}
+
+/* 恢复定时器 */
+void ResumeTimer(void) {
+  if (g_startCounting != NULL) {
+
+    uint32_t currentTimestamp =
+        OHOS::TraingModel::GetInstance()->get_current_time(); // 获取当前时间戳
+    pauseStartTimestamp = currentTimestamp; // 保存暂停开始的时间戳 将这个更新
+
+    int tick = osMs2Tick(MS_ONE_SECONDS);
+    if (osTimerStart(g_startCounting, tick) != osOK) {
+      LogError("恢复定时器时启动失败", osError);
+    }
+
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "定时器已恢复。当前运动时间: %u %d",
+                  g_motionTimes, pauseStartTimestamp);
+  }
+}
+
+#ifdef __cplusplus
+}
+#endif
+/* ---------------------------------- 数据存储
+ * ---------------------------------- */
+static int32 SaveTraingDataToFile(void) {
+  time_t now = time(nullptr);
+  struct tm *timeinfo = localtime(&now);
+  char filename[20];
+  strftime(filename, sizeof(filename), "%Y%m%d.bin", timeinfo);
+
+  uint32 size = sizeof(Trainingdata);
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SaveTraingDataToFile !!");
+
+  char filePath[20];
+  sprintf(filePath, "%s%s", TRAINING_DATA_DIRECTORY, filename);
+
+  std::ofstream fd(filePath, std::ios::binary);
+  if (!fd.is_open()) {
+    if (mkdir(TRAINING_DATA_DIRECTORY, S_IRWXU) != 0) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create directory");
+      return 0;
+    }
+
+    fd.open(filePath, std::ios::binary);
+    if (!fd.is_open()) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file for write");
+      return 0;
+    }
+
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory created successfully!!");
+  }
+
+  fd.write(reinterpret_cast<const char *>(&sportdata), size);
+  fd.close();
+  return 1;
+}
+static std::vector<Trainingdata> LoadTrainingDataFromTodayFile() {
+  std::vector<Trainingdata> trainingRecords;
+
+  time_t now = time(nullptr);
+  struct tm *timeinfo = localtime(&now);
+  char filename[20];
+  strftime(filename, sizeof(filename), "%Y%m%d.bin", timeinfo);
+  // 找到训练文件夹里面的当天文件
+  char filePath[20];
+  sprintf(filePath, "%s%s", TRAINING_DATA_DIRECTORY, filename);
+
+  std::ifstream fd(filePath, std::ios::binary);
+  if (!fd.is_open()) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open today's file");
+    return trainingRecords; // Return an empty vector if file open fails
+  }
+
+  // 读取训练信息
+  while (!fd.eof()) {
+    Trainingdata record;
+    fd.read(reinterpret_cast<char *>(&record), sizeof(Trainingdata));
+    if (fd.gcount() == sizeof(Trainingdata)) {
+      trainingRecords.push_back(record);
+    }
+  }
+
+  fd.close();
+
+  return trainingRecords;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+// 获得数据个数
+static int get_Trainingdata_data_num(FILE *fp) {
+  if (fp == NULL) {
+    return 0; // 如果文件指针为空,返回0
+  }
+
+  fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾
+  long size = ftell(fp);  // 获取当前文件指针位置,即文件大小
+  fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头
+
+  return (size / sizeof(Trainingdata));
+}
+
+// 写训练bin文件
+int write_Trainingdata_data(Trainingdata data) {
+  char file_path[MAX_FILE_PATH_LENGTH] = {0};
+  char timeday[12] = {0};
+  uapi_get_YYMMDD_Time(timeday, '_');
+  snprintf(file_path, sizeof(file_path), "%s%s.bin", TRAINING_PATH, timeday);
+
+  // 检查目录是否存在,如果不存在则创建
+  struct stat st = {0};
+  if (stat(TRAINING_PATH, &st) == -1) {
+    if (mkdir(TRAINING_PATH, 0700) != 0) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create directory: %s",
+                    strerror(errno));
+      return -1; // 返回错误码
+    }
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", file_path);
+  FILE *fp = fopen(file_path, "ab+");
+  if (fp == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file for append: %s",
+                  strerror(errno));
+    fp = fopen(file_path, "wb+");
+    if (fp == NULL) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "Failed to open file for write: %s", strerror(errno));
+      return -1; // 返回错误码
+    }
+  }
+
+  int ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
+  if (ret != 1) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fwrite_data error! %d", ret);
+    fclose(fp);
+    return -1; // 返回错误码
+  }
+
+  fclose(fp); // 关闭文件
+  return 1;   // 返回成功码
+}
+
+// 读数据
+Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset) {
+  char file_path[128] = {0};
+  snprintf(file_path, sizeof(file_path), "%s%s.bin", TRAINING_PATH, timedata);
+
+  FILE *fp = fopen(file_path, "rb");
+  if (fp == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file for read: %s",
+                  strerror(errno));
+    return NULL;
+  }
+
+  Trainingdata *data = (Trainingdata *)malloc(sizeof(Trainingdata));
+  if (data == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to allocate memory for Trainingdata");
+    fclose(fp);
+    return NULL;
+  }
+
+  int num_data = get_Trainingdata_data_num(fp);
+  if (num_data <= offset) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Offset %d exceeds number of data %d", offset, num_data);
+    free(data); // 释放内存
+    fclose(fp);
+    return NULL;
+  }
+
+  fseek(fp, sizeof(Trainingdata) * offset, SEEK_SET);
+  fread(data, sizeof(Trainingdata), 1, fp);
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Data src: %d", data->src);
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Offset: %d, Size: %zu", offset,
+                sizeof(Trainingdata));
+
+  fclose(fp);  // 关闭文件
+  return data; // 返回读取的数据
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -------------------------------------------------------------------------- */
+/*检查是否存在数据*/
+bool TraingModel::CheckDataJson() {
+  // 读取record.json文件
+  std::ifstream file(TRAINING_RECORD_FILE);
+
+  // 检查文件是否打开成功
+  if (!file.is_open()) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unable to open file");
+    return false;
+  }
+
+  // 检查文件是否为空
+  file.seekg(0, std::ios::end);
+  if (file.tellg() == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File is empty");
+    file.close();
+    return false;
+  }
+
+  // 解析json
+  std::vector<SportData> sportDataVector;
+  if (!LoadDataFormJson(sportDataVector)) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadDataFormJson is error");
+    file.close();
+    return false;
+  }
+
+  // 关闭文件
+  file.close();
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckDataJson is ok");
+  return true;
+}
+
+bool TraingModel::SaveDataToJson(SportData *data) {
+  FILE *fp;
+  char *jsonStr = NULL;
+
+  // 读取现有的 JSON 数据
+  fp = fopen(TRAINING_RECORD_FILE, "r");
+  cJSON *data_root = NULL;
+  cJSON *dataArray = NULL;
+
+  if (fp != NULL) {
+    fseek(fp, 0, SEEK_END);
+    long fileSize = ftell(fp);
+    fseek(fp, 0, SEEK_SET);
+
+    jsonStr = (char *)malloc(fileSize + 1);
+    if (jsonStr != nullptr) {
+      if (fread(jsonStr, fileSize, 1, fp) == 1) {
+        data_root = cJSON_Parse(jsonStr);
+        if (data_root != NULL) {
+          dataArray = cJSON_GetObjectItem(data_root, "data");
+        }
+      }
+    }
+    fclose(fp);
+  }
+
+  if (dataArray == NULL) {
+    data_root = cJSON_CreateObject();
+    cJSON_AddItemToObject(data_root, "data", cJSON_CreateArray());
+    dataArray = cJSON_GetObjectItem(data_root, "data");
+  }
+
+  // 创建或更新数据节点
+  cJSON *sportData = cJSON_CreateObject();
+  cJSON_AddNumberToObject(sportData, "sportTypeId",
+                          int(data->sportType)); // 训练项目类 Id
+  cJSON_AddNumberToObject(sportData, "sportId", data->sportId); // 训练项目 Id
+  cJSON_AddStringToObject(sportData, "startDate",
+                          (data->start_date).c_str()); // 训练开始日期字符串
+  cJSON_AddStringToObject(sportData, "startTime",
+                          (data->start_time).c_str()); // 训练开始时间
+  cJSON_AddStringToObject(sportData, "endTime",
+                          (data->end_time).c_str()); // 训练结束时间
+  cJSON_AddNumberToObject(sportData, "goalDegree",
+                          data->goaldegree); // 训练目标完成度
+  cJSON_AddNumberToObject(sportData, "duration",
+                          data->duration); // 训练时长(秒)
+  cJSON_AddNumberToObject(sportData, "distance", data->distance); // 训练距离
+  cJSON_AddNumberToObject(sportData, "avgHeartRate",
+                          data->avgheart); // 训练平均心率
+  cJSON_AddNumberToObject(sportData, "steps", data->steps); // 训练步数
+  cJSON_AddNumberToObject(sportData, "intensity", data->intensity); // 训练强度
+  cJSON_AddNumberToObject(sportData, "apc", data->apc); // 训练平均配速
+  cJSON_AddNumberToObject(sportData, "cdc", data->cdc); // 训练步频
+  cJSON_AddNumberToObject(sportData, "std", data->std); // 训练步幅
+  cJSON_AddNumberToObject(sportData, "calories", data->calories); //卡路里
+
+  // 添加运动数据节点到数组并限制数量
+  cJSON_AddItemToArray(dataArray, sportData);
+  while (cJSON_GetArraySize(dataArray) > MAX_DATA_COUNT) {
+    cJSON_DeleteItemFromArray(dataArray, 0);
+  }
+
+  // 将更新后的 JSON 数据写入文件
+  char *jsonStrNew = cJSON_Print(data_root);
+  fp = fopen(TRAINING_RECORD_FILE, "w");
+  if (fp != NULL) {
+    fwrite(jsonStrNew, strlen(jsonStrNew), 1, fp);
+    fclose(fp);
+  }
+
+  // 释放资源
+  cJSON_Delete(data_root);
+  free(jsonStr);
+  cJSON_free(jsonStrNew);
+
+  return true;
+}
+
+/* 加载训练数据函数 */
+bool TraingModel::LoadDataFormJson(std::vector<SportData> &sportDataVector) {
+  std::ifstream file(TRAINING_RECORD_FILE);
+  if (!file.is_open()) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file");
+    return false;
+  }
+
+  std::string jsonData((std::istreambuf_iterator<char>(file)),
+                       std::istreambuf_iterator<char>());
+  file.close();
+
+  cJSON *root = cJSON_Parse(jsonData.c_str());
+  if (root == NULL) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to parse JSON: %s",
+                  cJSON_GetErrorPtr());
+    return false;
+  }
+
+  cJSON *dataArray = cJSON_GetObjectItem(root, "data");
+  if (dataArray == NULL || !cJSON_IsArray(dataArray)) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Invalid or missing 'data' array in JSON");
+    cJSON_Delete(root);
+    return false;
+  }
+
+  int dataCount = cJSON_GetArraySize(dataArray);
+  if (dataCount == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "error dataCount is 0");
+    cJSON_Delete(root);
+    return false;
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dataCount is %d", dataCount);
+
+  for (int i = 0; i < dataCount; i++) {
+    cJSON *item = cJSON_GetArrayItem(dataArray, i);
+    if (item == NULL) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid item at index %d", i);
+      continue; // 跳过无效项目
+    }
+
+    SportData sportData;
+    bool isValid = true; // 用于标记 sportData 是否有效
+
+    // 检查并获取每个字段,确保其存在且类型正确
+    if (cJSON *sportTypeIdItem = cJSON_GetObjectItem(item, "sportTypeId");
+        sportTypeIdItem && cJSON_IsNumber(sportTypeIdItem))
+      sportData.sportType = (Exercisetype)sportTypeIdItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *sportIdItem = cJSON_GetObjectItem(item, "sportId");
+        sportIdItem && cJSON_IsNumber(sportIdItem))
+      sportData.sportId = (UIResourceTextId)sportIdItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *startDateItem = cJSON_GetObjectItem(item, "startDate");
+        startDateItem && cJSON_IsString(startDateItem))
+      sportData.start_date = startDateItem->valuestring;
+    else
+      isValid = false;
+
+    if (cJSON *startTimeItem = cJSON_GetObjectItem(item, "startTime");
+        startTimeItem && cJSON_IsString(startTimeItem))
+      sportData.start_time = startTimeItem->valuestring;
+    else
+      isValid = false;
+
+    if (cJSON *endTimeItem = cJSON_GetObjectItem(item, "endTime");
+        endTimeItem && cJSON_IsString(endTimeItem))
+      sportData.end_time = endTimeItem->valuestring;
+    else
+      isValid = false;
+
+    if (cJSON *goalDegreeItem = cJSON_GetObjectItem(item, "goalDegree");
+        goalDegreeItem && cJSON_IsNumber(goalDegreeItem))
+      sportData.goaldegree = goalDegreeItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *durationItem = cJSON_GetObjectItem(item, "duration");
+        durationItem && cJSON_IsNumber(durationItem))
+      sportData.duration = durationItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *distanceItem = cJSON_GetObjectItem(item, "distance");
+        distanceItem && cJSON_IsNumber(distanceItem))
+      sportData.distance = distanceItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *avgHeartRateItem = cJSON_GetObjectItem(item, "avgHeartRate");
+        avgHeartRateItem && cJSON_IsNumber(avgHeartRateItem))
+      sportData.avgheart = avgHeartRateItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *stepsItem = cJSON_GetObjectItem(item, "steps");
+        stepsItem && cJSON_IsNumber(stepsItem))
+      sportData.steps = stepsItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *intensityItem = cJSON_GetObjectItem(item, "intensity");
+        intensityItem && cJSON_IsNumber(intensityItem))
+      sportData.intensity = intensityItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *apcItem = cJSON_GetObjectItem(item, "apc");
+        apcItem && cJSON_IsNumber(apcItem))
+      sportData.apc = apcItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *cdcItem = cJSON_GetObjectItem(item, "cdc");
+        cdcItem && cJSON_IsNumber(cdcItem))
+      sportData.cdc = cdcItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *stdItem = cJSON_GetObjectItem(item, "std");
+        stdItem && cJSON_IsNumber(stdItem))
+      sportData.std = stdItem->valueint;
+    else
+      isValid = false;
+
+    if (cJSON *caloriesItem = cJSON_GetObjectItem(item, "calories");
+        caloriesItem && cJSON_IsNumber(caloriesItem))
+      sportData.calories = caloriesItem->valueint;
+    else
+      isValid = false;
+
+    // 只有在所有字段都有效的情况下才添加 sportData 到向量中
+    if (isValid) {
+      sportDataVector.push_back(sportData);
+    } else {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid data in item %d", i);
+    }
+  }
+
+  cJSON_Delete(root);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadDataFormJson is ok");
+  return true;
+}
+
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp
new file mode 100644 (file)
index 0000000..7aa92f3
--- /dev/null
@@ -0,0 +1,127 @@
+\r
+\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "KeyInputListener.h"\r
+#include "custom_utils.h"\r
+#include "common/key_code.h"\r
+\r
+#include <iostream>\r
+#include <chrono>\r
+#include <thread>\r
+#include "traing/include/TraingNomalPresenter.h"\r
+#include "traing/training_card/include/TraingCardPresenter.h"\r
+#include "MainModel.h"\r
+#include "UiConfig.h"\r
+// #include "TraingNomalView.h"\r
+\r
+#include "NativeRegisterManager.h"\r
+namespace OHOS\r
+{\r
+\r
+    REGIST_SLICE(VIEW_TRAININGNOMAL, TraingNomalView, TraingNomalPresenter);\r
+\r
+    // 当前Presenter属性实例化的内存指针\r
+    static TraingNomalPresenter *g_pTraingNomalPresenter = nullptr;\r
+\r
+    \r
+    TraingNomalPresenter::TraingNomalPresenter()\r
+    {\r
+\r
+        g_pTraingNomalPresenter = this;\r
+    }\r
+\r
+    TraingNomalPresenter::~TraingNomalPresenter()\r
+    {\r
+\r
+        g_pTraingNomalPresenter = nullptr;\r
+    }\r
+\r
+    TraingNomalPresenter *TraingNomalPresenter::GetInstance()\r
+    {\r
+\r
+        return g_pTraingNomalPresenter;\r
+    }\r
+\r
+    void TraingNomalPresenter::OnStart()\r
+    {\r
+\r
+        Presenter<TraingNomalView>::OnStart();\r
+    }\r
+\r
+    void TraingNomalPresenter::OnPause(void)\r
+    {\r
+\r
+        Presenter<TraingNomalView>::OnPause();\r
+    }\r
+\r
+    void TraingNomalPresenter::OnResume(void)\r
+    {\r
+\r
+        Presenter<TraingNomalView>::OnResume();\r
+    }\r
+\r
+    void TraingNomalPresenter::OnStop(void)\r
+    {\r
+\r
+        Presenter<TraingNomalView>::OnStop();\r
+    }\r
+    // 回退逻辑\r
+    void TraingNomalPresenter::NavigateBack()\r
+    {\r
+        /*\r
+            准备训练界面进入:\r
+            1.[主界面] 进入\r
+            2.[traing] 进入\r
+            3.[更多]->[具体训练项]进入\r
+            4.[设置训练目标]进入 {不返回}\r
+        */\r
+        NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+    }\r
+    bool TraingNomalPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        UNUSED(view);\r
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) &&\r
+            (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY()))))\r
+        {\r
+            NavigateBack();\r
+        }\r
+        return true;\r
+    }\r
+\r
+    bool TraingNomalPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+    {\r
+        // 根据控件id查找是哪个控件触发了点击回调\r
+        if (strcmp(view.GetViewId(), BUTTONSET) == 0)\r
+        {\r
+            // 训练准备 -> 训练设置\r
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGSET);\r
+        }\r
+        if (strcmp(view.GetViewId(), BUTTONGO) == 0)\r
+        {\r
+            // 开始训练 ->不返回\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);\r
+\r
+            // 获取运动项目\r
+            ExerciseClass type = TraingModel::GetInstance()->GetSportId();\r
+            // 开启对应的运动\r
+            TraingCardPresenter::GetInstance()->OpenSensor(type);\r
+            // 设置为手表开启运动\r
+            TraingModel::GetInstance()->SetSportOpenWay(false);\r
+        }\r
+        return true;\r
+    }\r
+    bool TraingNomalPresenter::OnKeyAct(UIView &view, const KeyEvent &event)\r
+    {\r
+        unsigned short keyID = event.GetKeyId();\r
+        unsigned short keyState = event.GetState();\r
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+        {\r
+            NavigateBack();\r
+        }\r
+        return true;\r
+    }\r
+}\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingNomalView.cpp
new file mode 100644 (file)
index 0000000..7e4e204
--- /dev/null
@@ -0,0 +1,130 @@
+
+#include "traing/include/TraingNomalView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+namespace OHOS
+{
+
+    static TraingNomalView *g_pTraingNomalView{nullptr};
+
+    TraingNomalView::TraingNomalView()
+    {
+        g_pTraingNomalView = this;
+    }
+
+    TraingNomalView::~TraingNomalView()
+    {
+        DeInit();
+        g_pTraingNomalView = nullptr;
+    }
+
+    TraingNomalView *TraingNomalView::GetInstance()
+    {
+
+        return g_pTraingNomalView;
+    }
+
+    /* InitView:初始化界面*/
+    void TraingNomalView ::InitView()
+    {
+
+        UIResourceTextId sport_id = TraingModel::GetInstance()->GetSportEvent();
+
+        // 初始化Lable
+        InitLabelExt(sporttitle_, 83, 50, 300, 35, "label1", sport_id, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        AddViewToRootContainer(sporttitle_);
+        
+        // 初始化Button
+        InitButton(buttonGo_, 133, 133, 200, 200, BUTTONGO);
+        buttonGo_->SetImageSrc(GO_1_IMAGE, GO_1_IMAGE);
+
+        // 显示设置目标
+        InitButtonExt(buttonSet_, 68, 370, 330, 35, BUTTONSET, STR_SET_TARGET, 30);
+        if (TraingModel::GetInstance()->GetTagStr() != "")
+        {
+            buttonSet_->SetText((TraingModel::GetInstance()->GetTagStr()).c_str());
+        }
+        buttonSet_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); // 设置为透明按键
+        buttonSet_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+        buttonSet_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80, UIButton::PRESSED); // 设置按下时的透明度为半透明
+
+        buttonGo_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingNomalPresenter::GetInstance()));
+        buttonSet_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingNomalPresenter::GetInstance()));
+        AddViewToRootContainer(buttonGo_);
+        AddViewToRootContainer(buttonSet_);
+    }
+    /* DeInit:删除组件*/
+    void TraingNomalView::DeInit()
+    {
+
+        if (sporttitle_ != nullptr)
+        {
+            delete sporttitle_;
+            sporttitle_ = nullptr;
+        }
+        if (buttonGo_ != nullptr)
+        {
+            delete buttonGo_;
+            buttonGo_ = nullptr;
+        }
+        if (buttonSet_ != nullptr)
+        {
+            delete buttonSet_;
+            buttonSet_ = nullptr;
+        }
+    }
+
+    void TraingNomalView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    // 设置按键监听
+    static void SetKeyActListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+        // 增加按键监听
+        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingNomalPresenter::GetInstance();
+        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+    }
+    void TraingNomalView::OnStart()
+    {
+       
+
+        // 创建 draglistener 实例并设置为拖动监听器
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingNomalPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        GetRootContainer()->SetOnDragListener(draglistener);
+
+        GetRootContainer()->SetTouchable(true);
+        GetRootContainer()->SetDraggable(true);
+
+        PreLoad();
+
+        SetKeyActListener();
+    }
+
+    // 更新训练目标 [考虑 通用目标 特殊目标]
+    void TraingNomalView::UpdateTraingTag()
+    {
+        // buttonSet_->SetText();
+    }
+
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingPresenter.cpp
new file mode 100644 (file)
index 0000000..7c5dafa
--- /dev/null
@@ -0,0 +1,125 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-16 17:33:11
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingPresenter.cpp
+ */
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingPresenter.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+// #include "TraingView.h"
+#include "gfx_utils/mem_check.h"
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingPresenter *g_pTraingPresenter = nullptr;
+
+    TraingPresenter::TraingPresenter()
+    {
+        g_pTraingPresenter = this;
+#ifdef MEM_CHECK
+        MemCheck::GetInstance()->EnableLeakCheck(true);
+#endif
+    }
+
+    TraingPresenter::~TraingPresenter()
+    {
+        g_pTraingPresenter = nullptr;
+#ifdef MEM_CHECK
+        MemCheck::GetInstance()->EnableLeakCheck(false);
+#endif
+    }
+
+    TraingPresenter *TraingPresenter::GetInstance()
+    {
+        return g_pTraingPresenter;
+    }
+
+    void TraingPresenter::OnStart()
+    {
+        Presenter<TraingView>::OnStart();
+    }
+
+    void TraingPresenter::OnPause(void)
+    {
+        Presenter<TraingView>::OnPause();
+    }
+
+    void TraingPresenter::OnResume(void)
+    {
+        Presenter<TraingView>::OnResume();
+    }
+
+    void TraingPresenter::OnStop(void)
+    {
+        Presenter<TraingView>::OnStop();
+    }
+    // 回退函数 [ Slice 的 traingview {右滑只能回到applist}]
+    void TraingPresenter::NavigateBack()
+    {
+        NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+        NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素
+    }
+    bool TraingPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+            NavigateBack();
+        return true;
+    }
+
+    bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        if (strcmp(view.GetViewId(), BUTTON1) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL);
+            TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING);
+        }
+        if (strcmp(view.GetViewId(), BUTTON3) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL);
+            TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING);
+        }
+        if (strcmp(view.GetViewId(), BUTTONMORE) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGMORE);
+        }
+        if (strcmp(view.GetViewId(), BUTTON2) == 0) {
+          NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL);
+          TraingModel::GetInstance()->SetSportEvent(
+              STR_EXERCISE_FREETRAINING); //修改为自由训练
+        }
+        TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS);
+        return true;
+    }
+
+    // 增加按键事件
+    bool TraingPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) &&
+            keyState == 1 && uapi_get_screen_state() == 0)
+            NavigateBack();
+
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingSetPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingSetPresenter.cpp
new file mode 100644 (file)
index 0000000..598f034
--- /dev/null
@@ -0,0 +1,243 @@
+/***\r
+ * @Date: 2024-04-15 10:55:58\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-04-16 10:29:50\r
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetPresenter.cpp\r
+ */\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "KeyInputListener.h"\r
+#include "custom_utils.h"\r
+#include "common/key_code.h"\r
+\r
+#include <iostream>\r
+#include <chrono>\r
+#include <thread>\r
+#include "traing/include/TraingSetPresenter.h"\r
+#include "traing/training_card/include/TraingCardPresenter.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+// #include "TraingSetView.h"\r
+\r
+#define TAGTEST 0\r
+#include "NativeRegisterManager.h"\r
+namespace OHOS\r
+{\r
+\r
+    REGIST_SLICE(VIEW_TRAININGSET, TraingSetView, TraingSetPresenter);\r
+\r
+\r
+    // 当前Presenter属性实例化的内存指针\r
+    static TraingSetPresenter *g_pTraingSetPresenter = nullptr;\r
+\r
+    TraingSetPresenter::TraingSetPresenter()\r
+    {\r
+\r
+        g_pTraingSetPresenter = this;\r
+    }\r
+\r
+    TraingSetPresenter::~TraingSetPresenter()\r
+    {\r
+\r
+        g_pTraingSetPresenter = nullptr;\r
+    }\r
+\r
+    TraingSetPresenter *TraingSetPresenter::GetInstance()\r
+    {\r
+\r
+        return g_pTraingSetPresenter;\r
+    }\r
+\r
+    void TraingSetPresenter::OnStart()\r
+    {\r
+\r
+        Presenter<TraingSetView>::OnStart();\r
+    }\r
+\r
+    void TraingSetPresenter::OnPause(void)\r
+    {\r
+\r
+        Presenter<TraingSetView>::OnPause();\r
+    }\r
+\r
+    void TraingSetPresenter::OnResume(void)\r
+    {\r
+\r
+        Presenter<TraingSetView>::OnResume();\r
+    }\r
+\r
+    void TraingSetPresenter::OnStop(void)\r
+    {\r
+\r
+        Presenter<TraingSetView>::OnStop();\r
+    }\r
+    void TraingSetPresenter::NavigateBack()\r
+    {\r
+        int CardID = TraingSetView::GetInstance()->GetCurrentViewId();\r
+        // 不在设置页面 返回设置列表\r
+        if (CardID != SET_VIEW)\r
+        {\r
+            TraingSetView::GetInstance()->ChangeView(CardID, SET_VIEW);\r
+        }\r
+        else\r
+        {\r
+            NativeAbility::GetInstance().Back();\r
+        }\r
+    }\r
+    // 增加按键事件\r
+    bool TraingSetPresenter::OnKeyAct(UIView &view, const KeyEvent &event)\r
+    {\r
+        unsigned short keyID = event.GetKeyId();\r
+        unsigned short keyState = event.GetState();\r
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+        {\r
+            NavigateBack();\r
+        }\r
+        return true;\r
+    }\r
+    bool TraingSetPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        return true;\r
+    }\r
+    bool TraingSetPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+    {\r
+        int CardID = TraingSetView::GetInstance()->GetCurrentViewId();\r
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
+        {\r
+            NavigateBack();\r
+        }\r
+        UNUSED(view);\r
+        return true;\r
+    }\r
+    /* --------------------------------- 设置目标项处理 -------------------------------- */\r
+    bool TraingSetPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+    {\r
+        int CardID = TraingSetView::GetInstance()->GetCurrentViewId();\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CardID[%d]", CardID);\r
+        switch (CardID)\r
+        {\r
+        case SET_VIEW:\r
+            if (strcmp(view.GetViewId(), BUTTONTIME) == 0)\r
+            {\r
+                TraingSetView::GetInstance()->ChangeView(SET_VIEW, SET_DURATION);\r
+            }\r
+            else if (strcmp(view.GetViewId(), BUTTONCALULI) == 0)\r
+            {\r
+                TraingSetView::GetInstance()->ChangeView(SET_VIEW, SET_CALORIES);\r
+            }\r
+            else if (strcmp(view.GetViewId(), BUTTONDISTANCE) == 0)\r
+            {\r
+                TraingSetView::GetInstance()->ChangeView(SET_VIEW, SET_DISTANCE);\r
+            }\r
+            else if (strcmp(view.GetViewId(), BUTTONSTEPS) == 0)\r
+            {\r
+                TraingSetView::GetInstance()->ChangeView(SET_VIEW, SET_STEPS);\r
+            }\r
+            break;\r
+        case SET_DURATION:\r
+        case SET_CALORIES:\r
+        case SET_DISTANCE:\r
+        case SET_STEPS:\r
+            if (strcmp(view.GetViewId(), GetButtonIdFromCard(CardID)) == 0)\r
+            {\r
+                // 获取训练目标值\r
+                int tag = GetTagFromCard(CardID);\r
+                // 配置训练项\r
+                TraingModel::GetInstance()->SetSportTag(GetExerciseTagFromCard(CardID), tag);\r
+#if TAGTEST\r
+                TraingModel::GetInstance()->SetSportTag(ExerciseTag::STEP, 10); // 测试\r
+#endif\r
+                WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetButtonIdFromCard:%d tag:%d \r\n", CardID, tag);\r
+\r
+                // 回退到训练准备\r
+                NativeAbility::GetInstance().Back();\r
+#if 0\r
+                // 获取训练项目\r
+                ExerciseClass type = TraingModel::GetInstance()->GetSportId();\r
+                // 开启cywee\r
+                TraingCardPresenter::GetInstance()->OpenSensor(type);\r
+                // 设置为手表开启运动\r
+                TraingModel::GetInstance()->SetSportOpenWay(false);\r
+#endif\r
+            }\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    /**\r
+     * @brief 获取按键ID\r
+     */\r
+    const char *TraingSetPresenter::GetButtonIdFromCard(int cardID)\r
+    {\r
+        switch (cardID)\r
+        {\r
+        case SET_DURATION:\r
+            return BUTTONTIMEOK;\r
+        case SET_CALORIES:\r
+            return BUTTONCALULIOK;\r
+        case SET_DISTANCE:\r
+            return BUTTONMILEOK;\r
+        case SET_STEPS:\r
+            return BUTTONSTEPOK;\r
+        default:\r
+            return "";\r
+        }\r
+    }\r
+\r
+    /**\r
+     * @brief 获取设置目标类型\r
+     */\r
+    ExerciseTag TraingSetPresenter::GetExerciseTagFromCard(int cardID)\r
+    {\r
+        switch (cardID)\r
+        {\r
+        case SET_DURATION:\r
+            return ExerciseTag::Duration;\r
+        case SET_CALORIES:\r
+            return ExerciseTag::Calories;\r
+        case SET_DISTANCE:\r
+            return ExerciseTag::Distance;\r
+        case SET_STEPS:\r
+            return ExerciseTag::Steps;\r
+        default:\r
+            return ExerciseTag::UNKNOW;\r
+        }\r
+    }\r
+\r
+    /**\r
+     * @brief 获取设置目标\r
+     */\r
+    int TraingSetPresenter::GetTagFromCard(int cardID)\r
+    {\r
+        int selectedValue = 0;\r
+\r
+        switch (cardID)\r
+        {\r
+        case SET_DURATION:\r
+            // 获取时间选择器中选定的时间值,并加1后乘以区间值\r
+            selectedValue = TrainingSetTimeView::GetInstance()->GetTimePicker()->GetSelected();\r
+            return (selectedValue + 1) * TIME_INTERVAL;\r
+        case SET_CALORIES:\r
+            // 获取卡路里选择器中选定的卡路里值,并加1后乘以区间值\r
+            selectedValue = TrainingSetCaluliView::GetInstance()->GetCaluliPicker()->GetSelected();\r
+            return (selectedValue + 1) * CALORIES_INTERVAL;\r
+        case SET_DISTANCE:\r
+            // 获取距离选择器中选定的距离值,并加1后乘以区间值\r
+            selectedValue = TrainingSetMileView::GetInstance()->GetMilePicker()->GetSelected();\r
+            return (selectedValue + 1) * DISTANCE_INTERVAL;\r
+        case SET_STEPS:\r
+            // 获取步数选择器中选定的步数值,并加1后乘以区间值\r
+            selectedValue = TrainingSetStepView::GetInstance()->GetSetpPicker()->GetSelected();\r
+            return (selectedValue + 1) * STEPS_INTERVAL;\r
+        default:\r
+            return 0;\r
+        }\r
+    }\r
+\r
+}\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingSetView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingSetView.cpp
new file mode 100644 (file)
index 0000000..a9a2735
--- /dev/null
@@ -0,0 +1,440 @@
+\r
+#include "traing/include/TraingSetView.h"\r
+\r
+#include "common/image_cache_manager.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "UiConfig.h"\r
+#include "ui_resource_image.h"\r
+#include <ui_scroll_view.h>\r
+#include "components/ui_button.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "traing/Training_UiConfig.h"\r
+\r
+namespace OHOS\r
+{\r
+\r
+    static TraingSetView *g_pTraingSetView{nullptr};\r
+\r
+    TraingSetView::TraingSetView()\r
+    {\r
+        g_pTraingSetView = this;\r
+    }\r
+\r
+    TraingSetView::~TraingSetView()\r
+    {\r
+        DeInit();\r
+        g_pTraingSetView = nullptr;\r
+    }\r
+\r
+    TraingSetView *TraingSetView::GetInstance()\r
+    {\r
+        return g_pTraingSetView;\r
+    }\r
+    /*增加额外配置项*/\r
+    void TraingSetView ::BonusdataView()\r
+    {\r
+        InitButton(butDistance, 43, 360, 380, 100, BUTTONDISTANCE);\r
+        InitButton(butSteps, 43, 480, 380, 100, BUTTONSTEPS);\r
+        butDistance->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));\r
+        butSteps->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));\r
+        group->Add(butDistance);\r
+        group->Add(butSteps);\r
+\r
+        InitRollLabel(labelDistance, 130, 390, 150, 35, "label3", STR_DISTANCE, DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        InitRollLabel(labelSteps, 130, 510, 150, 35, "label5", STR_STEP_NUMBER,\r
+                      DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        \r
+        labelDistance->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+        labelSteps->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+        \r
+        group->Add(labelDistance);\r
+        group->Add(labelSteps);\r
+\r
+        InitImageView(imagedistance, 70, 390, 100, 100, "image5", MILEAGE_IMAGE);\r
+        InitImageView(imagesteps, 70, 510, 100, 100, "image6", WALKING_IMAGE);\r
+        InitImageView(imagicon3, 380, 400, 100, 100, "image3", ICON_IMAGE);\r
+        InitImageView(imagicon4, 380, 520, 100, 100, "image4", ICON_IMAGE);\r
+        group->Add(imagedistance);\r
+        group->Add(imagesteps);\r
+        group->Add(imagicon3);\r
+        group->Add(imagicon4);\r
+    }\r
+    /* InitView:初始化界面*/\r
+    void TraingSetView ::InitView()\r
+    {\r
+        if (group == nullptr)\r
+        {\r
+            group = new UIScrollView();\r
+            group->SetPosition(0, 0, 466, 466);\r
+            group->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+        }\r
+        // 初始化Lable\r
+        UIResourceTextId sportid = TraingModel::GetInstance()->GetSportEvent();\r
+        InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", sportid, DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        group->Add(labeltitle);\r
+\r
+        //  初始化Button\r
+        InitButton(butTime, 43, 120, 380, 100, BUTTONTIME);\r
+        InitButton(butKcal, 43, 240, 380, 100, BUTTONCALULI);\r
+        butTime->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));\r
+        butKcal->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));\r
+        group->Add(butTime);\r
+        group->Add(butKcal);\r
+\r
+        InitRollLabel(labelTime, 130, 150, 150, 35, "label2", STR_DURATION, DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        InitRollLabel(labelKcal, 130, 270, 150, 35, "label4", STR_CALORIE,\r
+                      DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        \r
+        labelTime->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+        labelKcal->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+\r
+        group->Add(labelTime);\r
+        group->Add(labelKcal);\r
+\r
+        // 初始化Image\r
+        InitImageView(imagetime, 70, 150, 100, 100, "image1", TIME_IMAGE);\r
+        InitImageView(imagcal, 70, 270, 100, 100, "image2", CALORIES_IMAGE);\r
+        InitImageView(imagicon1, 380, 160, 100, 100, "image3", ICON_IMAGE);\r
+        InitImageView(imagicon2, 380, 280, 100, 100, "image4", ICON_IMAGE);\r
+        group->Add(imagetime);\r
+        group->Add(imagcal);\r
+        group->Add(imagicon1);\r
+        group->Add(imagicon2);\r
+    }\r
+    /* DeInit:删除组件 */\r
+    void TraingSetView::DeInit()\r
+    {\r
+        group->RemoveAll();\r
+        // 删除Label\r
+        if (labeltitle != nullptr)\r
+        {\r
+            group->Remove(labeltitle);\r
+            delete labeltitle;\r
+            labeltitle = nullptr;\r
+        }\r
+        if (labelTime != nullptr)\r
+        {\r
+            group->Remove(labelTime);\r
+            delete labelTime;\r
+            labelTime = nullptr;\r
+        }\r
+        if (labelKcal != nullptr)\r
+        {\r
+            group->Remove(labelKcal);\r
+            delete labelKcal;\r
+            labelKcal = nullptr;\r
+        }\r
+        if (labelSteps != nullptr)\r
+        {\r
+            group->Remove(labelSteps);\r
+            delete labelSteps;\r
+            labelSteps = nullptr;\r
+        }\r
+        if (labelDistance != nullptr)\r
+        {\r
+            group->Remove(labelDistance);\r
+            delete labelDistance;\r
+            labelDistance = nullptr;\r
+        }\r
+        // 删除Button\r
+        if (butTime != nullptr)\r
+        {\r
+            group->Remove(butTime);\r
+            delete butTime;\r
+            butTime = nullptr;\r
+        }\r
+        if (butKcal != nullptr)\r
+        {\r
+            group->Remove(butKcal);\r
+            delete butKcal;\r
+            butKcal = nullptr;\r
+        }\r
+        if (butDistance != nullptr)\r
+        {\r
+            group->Remove(butDistance);\r
+            delete butDistance;\r
+            butDistance = nullptr;\r
+        }\r
+        if (butSteps != nullptr)\r
+        {\r
+            group->Remove(butSteps);\r
+            delete butSteps;\r
+            butSteps = nullptr;\r
+        }\r
+        // 删除Image\r
+        if (imagetime != nullptr)\r
+        {\r
+            group->Remove(imagetime);\r
+            delete imagetime;\r
+            imagetime = nullptr;\r
+        }\r
+        if (imagcal != nullptr)\r
+        {\r
+            group->Remove(imagcal);\r
+            delete imagcal;\r
+            imagcal = nullptr;\r
+        }\r
+        if (imagedistance != nullptr)\r
+        {\r
+            group->Remove(imagedistance);\r
+            delete imagedistance;\r
+            imagedistance = nullptr;\r
+        }\r
+        if (imagesteps != nullptr)\r
+        {\r
+            group->Remove(imagesteps);\r
+            delete imagesteps;\r
+            imagesteps = nullptr;\r
+        }\r
+\r
+        if (imagicon1 != nullptr)\r
+        {\r
+            group->Remove(imagicon1);\r
+            delete imagicon1;\r
+            imagicon1 = nullptr;\r
+        }\r
+        if (imagicon2 != nullptr)\r
+        {\r
+            group->Remove(imagicon2);\r
+            delete imagicon2;\r
+            imagicon2 = nullptr;\r
+        }\r
+        if (imagicon3 != nullptr)\r
+        {\r
+            group->Remove(imagicon3);\r
+            delete imagicon3;\r
+            imagicon3 = nullptr;\r
+        }\r
+        if (imagicon4 != nullptr)\r
+        {\r
+            group->Remove(imagicon4);\r
+            delete imagicon4;\r
+            imagicon4 = nullptr;\r
+        }\r
+\r
+        delete group;\r
+        group = nullptr;\r
+        delete setcalories;\r
+        setcalories = nullptr;\r
+        delete settime;\r
+        settime = nullptr;\r
+        delete setmile;\r
+        setmile = nullptr;\r
+        delete setstep;\r
+        setstep = nullptr;\r
+\r
+        // 删除数组\r
+        for (int tagnum = SET_VIEW; tagnum < MAX_SETVIEW; tagnum++)\r
+        {\r
+            SetTagScrollView[tagnum] = nullptr;\r
+        }\r
+\r
+        g_pTraingSetView = nullptr;\r
+    }\r
+\r
+    // 跳转到设置选项列表\r
+    bool TraingSetView::ChangeSetView(int16_t thisview)\r
+    {\r
+        if (SetTagScrollView[thisview] == nullptr)\r
+        {\r
+            if (group == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new container[%d] fail", thisview);\r
+                return false;\r
+            }\r
+            RootView::GetInstance()->Add(SetTagScrollView[thisview]);\r
+        }\r
+        return true;\r
+    }\r
+    bool TraingSetView::ChangeSetCaloriesView(int16_t thisview)\r
+    {\r
+        if (SetTagScrollView[thisview] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingSetView::ChangeSetCaloriesView");\r
+            setcalories = new TrainingSetCaluliView();\r
+            if (setcalories == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new scrollView[%d] fail", thisview);\r
+                return false;\r
+            }\r
+            SetTagScrollView[thisview] = setcalories->SetCaluliViewInit();\r
+            RootView::GetInstance()->Add(SetTagScrollView[thisview]);\r
+        }\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
+        return true;\r
+    }\r
+    bool TraingSetView::ChangeSetDurationView(int16_t thisview)\r
+    {\r
+        if (SetTagScrollView[thisview] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingSetView::ChangeSetDurationView");\r
+            settime = new TrainingSetTimeView();\r
+            if (settime == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new scrollView[%d] fail", thisview);\r
+                return false;\r
+            }\r
+            SetTagScrollView[thisview] = settime->SetTimeViewInit();\r
+            RootView::GetInstance()->Add(SetTagScrollView[thisview]);\r
+        }\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
+        return true;\r
+    }\r
+    bool TraingSetView::ChangeSetDistanceView(int16_t thisview)\r
+    {\r
+        if (SetTagScrollView[thisview] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingSetView::ChangeSetDistanceView");\r
+            setmile = new TrainingSetMileView();\r
+            if (setmile == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new scrollView[%d] fail", thisview);\r
+                return false;\r
+            }\r
+            SetTagScrollView[thisview] = setmile->SetMileViewInit();\r
+            RootView::GetInstance()->Add(SetTagScrollView[thisview]);\r
+        }\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
+        return true;\r
+    }\r
+    bool TraingSetView::ChangeSetStepsView(int16_t thisview)\r
+    {\r
+        if (SetTagScrollView[thisview] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingSetView::ChangeSetDistanceView");\r
+            setstep = new TrainingSetStepView();\r
+            if (setstep == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingSetView:: new scrollView[%d] fail", thisview);\r
+                return false;\r
+            }\r
+            SetTagScrollView[thisview] = setstep->SetStepViewInit();\r
+            RootView::GetInstance()->Add(SetTagScrollView[thisview]);\r
+        }\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetTagScrollView[%d] is not null", thisview);\r
+        return true;\r
+    }\r
+    /* -------------------------------------------------------------------------- */\r
+    // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。\r
+    struct SetViewMapper\r
+    {\r
+        const int16_t viewId;\r
+        bool (TraingSetView::*func)(int16_t thisView);\r
+    };\r
+\r
+    // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。\r
+    static const SetViewMapper ViewMapper[] = {\r
+        {SET_VIEW, &TraingSetView::ChangeSetView},\r
+        {SET_CALORIES, &TraingSetView::ChangeSetCaloriesView},\r
+        {SET_DURATION, &TraingSetView::ChangeSetDurationView},\r
+        {SET_STEPS, &TraingSetView::ChangeSetStepsView},\r
+        {SET_DISTANCE, &TraingSetView::ChangeSetDistanceView},\r
+    };\r
+\r
+    // 3.根据传入的interface参数执行相应视图ID关联的成员函数。\r
+    bool TraingSetView::ClickFunc(int16_t interface)\r
+    {\r
+        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[SET_VIEW]);\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "funcSize:%d interface:%d", funcSize, interface);\r
+        for (int i = 0; i < funcSize; i++)\r
+        {\r
+            if (interface == ViewMapper[i].viewId)\r
+            {\r
+                bool jug = (this->*(ViewMapper[i].func))(interface);\r
+                if (jug == false)\r
+                {\r
+                    return false;\r
+                }\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+    // 4.切换视图\r
+    void TraingSetView::ChangeView(int16_t hideView, int16_t showView)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "hideview:%d showview:%d", hideView, showView);\r
+        if (hideView > MAX_SETVIEW)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView:: BloodViewId Overstep ones bounds");\r
+            return;\r
+        }\r
+        if (ClickFunc(showView))\r
+        {\r
+            SetTagScrollView[hideView]->SetVisible(false);\r
+            if (SetTagScrollView[showView] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "set new view %d is error!", showView);\r
+                return;\r
+            }\r
+            SetTagScrollView[showView]->SetVisible(true);\r
+            SetCurrentViewId(showView); // 切换页面更换成目标ID\r
+            Draw();\r
+        }\r
+    }\r
+    /* -------------------------------------------------------------------------- */\r
+    void TraingSetView::PreLoad(void)\r
+    {\r
+        if (!viewiInitStatus)\r
+        {\r
+            InitView();\r
+            viewiInitStatus = true;\r
+        }\r
+    }\r
+    // 设置按键监听\r
+    static void SetKeyActListener()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");\r
+        // 增加按键监听\r
+        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingSetPresenter::GetInstance();\r
+        RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+    }\r
+    void TraingSetView::OnStart()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingSetView::OnStart");\r
+\r
+        group = new UIScrollView();\r
+        if (group == nullptr)\r
+        {\r
+            return;\r
+        }\r
+        group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+        group->SetScrollBlankSize(50);\r
+        group->SetReboundSize(100);\r
+        group->SetDirection(1);\r
+\r
+        // 创建 draglistener 实例并设置为拖动监听器\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingSetPresenter::GetInstance());\r
+        if (draglistener == nullptr)\r
+        {\r
+            return;\r
+        }\r
+        group->SetOnDragListener(draglistener);\r
+        group->SetTouchable(true);\r
+        group->SetDraggable(true);\r
+\r
+        PreLoad();\r
+\r
+        if (TraingModel::GetInstance()->GetIsSpecial())\r
+        {\r
+            BonusdataView();\r
+        }\r
+\r
+        SetKeyActListener();\r
+        // RootView::GetInstance()->Add(SetTagScrollView[SET_VIEW]);\r
+        // SetCurrentViewId(SET_VIEW); // 设置当前页面ID\r
+\r
+        if (group != nullptr)\r
+        {\r
+            SetTagScrollView[SET_VIEW] = group;\r
+            RootView::GetInstance()->Add(SetTagScrollView[SET_VIEW]);\r
+            SetCurrentViewId(SET_VIEW);\r
+        }\r
+    }\r
+\r
+\r
+}\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TraingView.cpp
new file mode 100644 (file)
index 0000000..fa6af93
--- /dev/null
@@ -0,0 +1,257 @@
+\r
+#include "traing/include/TraingView.h"\r
+#include "traing/include/TraingModel.h"\r
+#include <iostream>\r
+#include <string>\r
+namespace OHOS {\r
+// 按钮设置\r
+static constexpr uint16_t BUTTON_WIDHT = 140;\r
+static constexpr uint16_t BUTTON_HEIGHT = 140;\r
+static constexpr uint16_t BUTTON1_X = 86;\r
+static constexpr uint16_t BUTTON1_Y = 118;\r
+static constexpr uint16_t BUTTON2_X = 236;\r
+static constexpr uint16_t BUTTON2_Y = 118;\r
+static constexpr uint16_t BUTTON3_X = 86;\r
+static constexpr uint16_t BUTTON3_Y = 268;\r
+static constexpr uint16_t BUTTONMORE_X = 236;\r
+static constexpr uint16_t BUTTONMORE_Y = 268;\r
+\r
+// 标签设置\r
+static constexpr uint16_t LABEL_FONT_SIZE = 30;\r
+static constexpr uint16_t LABEL_X_SIZE = 120;\r
+static constexpr uint16_t LABEL_Y_SIZE = 60;\r
+static constexpr uint16_t TITLE_LABEL_X = 230;\r
+static constexpr uint16_t TITLE_LABEL_Y = 52;\r
+\r
+static constexpr uint16_t BTN1_LABEL_X = 95;\r
+static constexpr uint16_t BTN1_LABEL_Y = 205;\r
+static constexpr uint16_t BTN2_LABEL_X = 236;\r
+static constexpr uint16_t BTN2_LABEL_Y = 205;\r
+static constexpr uint16_t BTN3_LABEL_X = 95;\r
+static constexpr uint16_t BTN3_LABEL_Y = 355;\r
+\r
+// 图片设置\r
+static constexpr uint16_t BTN_IMAGE_SIZE = 100;\r
+\r
+static constexpr uint16_t BTN1_IMAGE_X = 126;\r
+static constexpr uint16_t BTN1_IMAGE_Y = 148;\r
+\r
+static constexpr uint16_t BTN2_IMAGE_X = 276;\r
+static constexpr uint16_t BTN2_IMAGE_Y = 148;\r
+\r
+static constexpr uint16_t BTN3_IMAGE_X = 129;\r
+static constexpr uint16_t BTN3_IMAGE_Y = 298;\r
+\r
+static constexpr uint16_t BTNMORE_IMAGE_X = 276;\r
+static constexpr uint16_t BTNMORE_IMAGE_Y = 324;\r
+\r
+static TraingView *g_pTraingView{nullptr};\r
+\r
+TraingView::TraingView() {\r
+  g_pTraingView = this;\r
+  TraingModel::GetInstance()->SetEntryType(APPLIST_ENTER);\r
+}\r
+\r
+TraingView::~TraingView() {\r
+  DeInitView();\r
+  g_pTraingView = nullptr;\r
+}\r
+TraingView *TraingView::GetInstance() { return g_pTraingView; }\r
+\r
+/***\r
+ * @description:\r
+ * @return\r
+ * @brief 添加标签\r
+ */\r
+bool TraingView::AddLabel() {\r
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::AddLabel");\r
+  // 初始化标签\r
+  InitRollLabel(title_label, 83, 50, 300, 35, "title_label", STR_RAPID_TRAINING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+\r
+  InitRollLabel(btn1_label, BTN1_LABEL_X, BTN1_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btu1_label", STR_EXERCISE_OUTDOORWALKING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  InitRollLabel(btn2_label, BTN2_LABEL_X, BTN2_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btu2_label", STR_EXERCISE_FREETRAINING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  InitRollLabel(btn3_label, BTN3_LABEL_X, BTN3_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btu3_label", STR_EXERCISE_OUTDOORRUNNING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  InitRollLabel(btnmore_label, BTN2_LABEL_X + 10, BTN3_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btumore_label", STR_MORE,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  return true;\r
+}\r
+\r
+bool TraingView::AddButton() {\r
+  InitButton(button1_, BUTTON1_X, BUTTON1_Y, BUTTON_WIDHT, BUTTON_HEIGHT,\r
+             BUTTON1);\r
+  button1_->SetImageSrc(BUTTONGROUND2_IMAGE, BUTTONGROUND2_IMAGE);\r
+  UIView::OnClickListener *button1Click =\r
+      static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+  button1_->SetOnClickListener(button1Click);\r
+\r
+  InitButton(button2_, BUTTON2_X, BUTTON2_Y, BUTTON_WIDHT, BUTTON_HEIGHT,\r
+             BUTTON2);\r
+  button2_->SetImageSrc(BOUTTONGROUND_IMAGE, BOUTTONGROUND_IMAGE);\r
+  UIView::OnClickListener *button2Click =\r
+      static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+  button2_->SetOnClickListener(button2Click);\r
+\r
+  InitButton(button3_, BUTTON3_X, BUTTON3_Y, BUTTON_WIDHT, BUTTON_HEIGHT,\r
+             BUTTON3);\r
+  button3_->SetImageSrc(BOUTTONGROUND_IMAGE, BOUTTONGROUND_IMAGE);\r
+  UIView::OnClickListener *button3Click =\r
+      static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+  button3_->SetOnClickListener(button3Click);\r
+\r
+  InitButton(buttonmore_, BUTTONMORE_X, BUTTONMORE_Y, BUTTON_WIDHT,\r
+             BUTTON_HEIGHT, BUTTONMORE);\r
+  buttonmore_->SetImageSrc(BUTTONGROUND2_IMAGE, BUTTONGROUND2_IMAGE);\r
+  UIView::OnClickListener *button4Click =\r
+      static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());\r
+  buttonmore_->SetOnClickListener(button4Click);\r
+\r
+  return true;\r
+}\r
+/***\r
+ * @description:\r
+ * @return\r
+ * @brief 添加图片\r
+ */\r
+bool TraingView::AddImageView() {\r
+\r
+  InitImageView(btn1_image, BTN1_IMAGE_X, BTN1_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btn1_image", WALKING_60_IMAGE);\r
+  InitImageView(btn2_image, BTN2_IMAGE_X, BTN2_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btn2_image", FREE_60_IMAGE);\r
+  InitImageView(btn3_image, BTN3_IMAGE_X, BTN3_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btn3_image", RUNNING_60_IMAGE);\r
+  InitImageView(btnmore_image, BTNMORE_IMAGE_X, BTNMORE_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btnmore_image", MORE_ICON_IMAGE);\r
+  return true;\r
+}\r
+void TraingView::InitView() {\r
+\r
+\r
+  // 初始化按键\r
+  AddButton();\r
+  // 初始化标签\r
+  AddLabel();\r
+  // 初始化图片\r
+  AddImageView();\r
+\r
+  AddViewToRootContainer(button1_);\r
+  AddViewToRootContainer(button2_);\r
+  AddViewToRootContainer(button3_);\r
+  AddViewToRootContainer(buttonmore_);\r
+\r
+  AddViewToRootContainer(title_label);\r
+  AddViewToRootContainer(btn1_label);\r
+  AddViewToRootContainer(btn2_label);\r
+  AddViewToRootContainer(btn3_label);\r
+  AddViewToRootContainer(btnmore_label);\r
+\r
+  AddViewToRootContainer(btn1_image);\r
+  AddViewToRootContainer(btn2_image);\r
+  AddViewToRootContainer(btn3_image);\r
+  AddViewToRootContainer(btnmore_image);\r
+\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitView");\r
+}\r
+\r
+void TraingView::DeInitView() {\r
+\r
+  if (buttonmore_ != nullptr) {\r
+    delete buttonmore_;\r
+    buttonmore_ = nullptr;\r
+  }\r
+  if (button1_ != nullptr) {\r
+    delete button1_;\r
+    button1_ = nullptr;\r
+  }\r
+  if (button2_ != nullptr) {\r
+    delete button2_;\r
+    button2_ = nullptr;\r
+  }\r
+  if (button3_ != nullptr) {\r
+    delete button3_;\r
+    button3_ = nullptr;\r
+  }\r
+  if (title_label != nullptr) {\r
+    delete title_label;\r
+    title_label = nullptr;\r
+  }\r
+  if (btn1_label != nullptr) {\r
+    delete btn1_label;\r
+    btn1_label = nullptr;\r
+  }\r
+  if (btn2_label != nullptr) {\r
+    delete btn2_label;\r
+    btn2_label = nullptr;\r
+  }\r
+  if (btn3_label != nullptr) {\r
+    delete btn3_label;\r
+    btn3_label = nullptr;\r
+  }\r
+  if (btnmore_label != nullptr) {\r
+    delete btnmore_label;\r
+    btnmore_label = nullptr;\r
+  }\r
+  if (btn1_image != nullptr) {\r
+    delete btn1_image;\r
+    btn1_image = nullptr;\r
+  }\r
+  if (btn2_image != nullptr) {\r
+    delete btn2_image;\r
+    btn2_image = nullptr;\r
+  }\r
+  if (btn3_image != nullptr) {\r
+    delete btn3_image;\r
+    btn3_image = nullptr;\r
+  }\r
+  if (btnmore_image != nullptr) {\r
+    delete btnmore_image;\r
+    btnmore_image = nullptr;\r
+  }\r
+}\r
+\r
+// 设置按键监听\r
+static void SetKeyActListener() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");\r
+  // 增加按键监听\r
+  RootView::OnKeyActListener *keyactListener =\r
+      (RootView::OnKeyActListener *)OHOS::TraingPresenter::GetInstance();\r
+  RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+}\r
+void TraingView::OnStart() {\r
+#if 0\r
+        printf(" data--training1_Text: %s\n", data->training1_Text.c_str());\r
+        printf(" data--training1_Image: %s\n", data->training1_Image.c_str());\r
+        printf(" data--training2_Text: %s\n", data->training2_Text.c_str());\r
+        printf(" data--training2_Image: %s\n", data->training2_Image.c_str());\r
+        printf(" data--training3_Text: %s\n", data->training3_Text.c_str());\r
+        printf(" data--training3_Image: %s\n", data->training3_Image.c_str());\r
+#endif\r
+\r
+\r
+  // 创建 draglistener 实例并设置为拖动监听器\r
+  UIView::OnDragListener *draglistener =\r
+      static_cast<UIView::OnDragListener *>(TraingPresenter::GetInstance());\r
+  if (draglistener == nullptr) {\r
+    return;\r
+  }\r
+  GetRootContainer()->SetOnDragListener(draglistener);\r
+  GetRootContainer()->SetTouchable(true);\r
+  GetRootContainer()->SetDraggable(true);\r
+\r
+  InitView();\r
+\r
+\r
+  // 增加按键监听\r
+  SetKeyActListener();\r
+}\r
+\r
+\r
+} // namespace OHOS\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetCaluliView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetCaluliView.cpp
new file mode 100644 (file)
index 0000000..f0d71cc
--- /dev/null
@@ -0,0 +1,197 @@
+/***
+ * @Date: 2024-04-18 10:57:22
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-25 10:44:58
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TrainingSetCaluliView.cpp
+ */
+/***
+ * @Date: 2024-04-18 10:57:22
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 16:07:43
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TrainingSetCaluliView.cpp
+ */
+
+#include "traing/include/TrainingSetCaluliView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "components/ui_button.h"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+namespace OHOS
+{
+
+    /***************************************************************************************/
+    // 动态生成包含指定卡路里区间内所有卡路里数的字符串数组
+    std::vector<std::string> GenerateCaluliValues(int minTime, int maxTime, int interval)
+    {
+        std::vector<std::string> values;
+        for (int i = minTime; i <= maxTime; i += interval)
+        {
+            values.push_back(std::to_string(i));
+        }
+        return values;
+    }
+    /***************************************************************************************/
+    static TrainingSetCaluliView *g_pTraingSetCaluliView{nullptr};
+
+    TrainingSetCaluliView::TrainingSetCaluliView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetCaluliView::TrainingSetCaluliView");
+        labeltitle_ = nullptr;
+        buttonok_ = nullptr;
+        Picker_ = nullptr;
+        SetCaluliScrollView = nullptr;
+        g_pTraingSetCaluliView = this;
+    }
+
+    TrainingSetCaluliView::~TrainingSetCaluliView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetCaluliView::~TrainingSetCaluliView");
+        SetCaluliScrollView->RemoveAll();
+        // 删除Label
+        if (labeltitle_ != nullptr)
+        {
+            SetCaluliScrollView->Remove(labeltitle_);
+            delete labeltitle_;
+            labeltitle_ = nullptr;
+        }
+        // 删除Button
+        if (buttonok_ != nullptr)
+        {
+            SetCaluliScrollView->Remove(buttonok_);
+            delete buttonok_;
+            buttonok_ = nullptr;
+        }
+
+        // 删除滚动选择器
+        if (Picker_ != nullptr)
+        {
+            SetCaluliScrollView->Remove(Picker_);
+            delete Picker_;
+            Picker_ = nullptr;
+        }
+
+        // 删除容器
+        if (SetCaluliScrollView != nullptr)
+        {
+            SetCaluliScrollView->RemoveAll(); // 移除容器中的所有组件
+            delete SetCaluliScrollView;
+            SetCaluliScrollView = nullptr;
+        }
+        g_pTraingSetCaluliView = nullptr;
+    }
+
+    TrainingSetCaluliView *TrainingSetCaluliView::GetInstance()
+    {
+
+        return g_pTraingSetCaluliView;
+    }
+
+    /*
+    InitUIPicker: 初始化UIPicker组件
+    @param picker: 指向UIPicker的指针
+    @param x: UIPicker的左边位置
+    @param y: UIPicker的顶部位置
+    @param width: UIPicker的宽度
+    @param height: UIPicker的高度
+    @param viewId: UIPicker的视图 ID
+    @param values: 选项数组
+    @param count: 选项数量
+    @param backgroundFontSize: 普通文本大小
+    @highlightFontSize: 高光文本大小
+    */
+    void TrainingSetCaluliView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+    {
+        // 文本大小
+        constexpr uint8_t BACKGROUND_FONT = 40;
+        constexpr uint8_t HIGHTLIGHT_FONT = 60;
+        // 获取value数组
+        int minCaluli = 100;
+        int maxCaluli = 1000;
+        int interval = 100;
+        std::vector<std::string> caluliValues = GenerateCaluliValues(minCaluli, maxCaluli, interval);
+
+        const char **values = new const char *[caluliValues.size()];
+        for (size_t i = 0; i < caluliValues.size(); i++)
+        {
+            values[i] = caluliValues[i].c_str();
+        }
+        // 创建 UIPicker
+        if (picker == nullptr)
+        {
+            picker = new UIPicker();
+        }
+
+        // 设置 UIPicker 的位置和大小
+        picker->SetPosition(x, y);
+        picker->Resize(width, height);
+        // 设置 UIPicker 的 ViewId
+        picker->SetViewId(viewId);
+        // 设置 UIPicker 的属性
+        picker->SetItemHeight(70);
+        picker->SetLoopState(true);
+        picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+        picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT);  // 设置高光文本大小
+        picker->SetValues(values, caluliValues.size());
+        // 将 UIPicker 设置为显示
+        picker->SetVisible(true);
+    }
+
+    /* InitView:初始化界面*/
+    UIScrollView *TrainingSetCaluliView ::SetCaluliViewInit()
+    {
+        /* -------------------------------------------------------------------------- */
+        SetCaluliScrollView = new UIScrollView();
+        if (SetCaluliScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetCaluliView::new SetCaluliScrollView fail");
+            return nullptr;
+        }
+        SetCaluliScrollView->SetPosition(0, 0);
+        SetCaluliScrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        SetCaluliScrollView->SetScrollBlankSize(35);
+        SetCaluliScrollView->SetReboundSize(50);
+        SetCaluliScrollView->SetDirection(1);
+        // 增加拖拽监听
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new TraingSetPresenter());
+        if (draglistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::draglistener can not be nullptr!");
+            return nullptr;
+        }
+        SetCaluliScrollView->SetOnDragListener(draglistener);
+        SetCaluliScrollView->SetTouchable(true);
+        SetCaluliScrollView->SetDraggable(true);
+        SetCaluliScrollView->SetVerticalScrollState(false); // 禁止垂直滑动
+                                                            /* -------------------------------------------------------------------------- */
+                                                            // 初始化Lable
+        InitRollLabel(labeltitle_, 83, 50, 300, 35, "label1",STR_CALORIE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        SetCaluliScrollView->Add(labeltitle_);
+
+        // 初始化UIPicker
+        InitUIPicker(Picker_, 43, 106, 380, 240, "uiPicker");
+        SetCaluliScrollView->Add(Picker_);
+        //  初始化Button
+        InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONCALULIOK, STR_OK, 30);
+        // Set additional property
+        buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
+        buttonok_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));
+        SetCaluliScrollView->Add(buttonok_);
+
+        return SetCaluliScrollView;
+    }
+    UIPicker *TrainingSetCaluliView ::GetCaluliPicker()
+    {
+        return Picker_;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetMileView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetMileView.cpp
new file mode 100644 (file)
index 0000000..e00ba0c
--- /dev/null
@@ -0,0 +1,191 @@
+/***
+ * @Date: 2024-04-18 10:57:22
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 15:10:10
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TrainingSetMileView.cpp
+ */
+
+#include "traing/include/TrainingSetMileView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "components/ui_button.h"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+namespace OHOS
+{
+
+    /***************************************************************************************/
+    // 动态生成包含指定卡路里区间内所有卡路里数的字符串数组
+    std::vector<std::string> GenerateMileValues(int minTime, int maxTime, int interval)
+    {
+        std::vector<std::string> values;
+        for (int i = minTime; i <= maxTime; i += interval)
+        {
+            values.push_back(std::to_string(i));
+        }
+        return values;
+    }
+    /***************************************************************************************/
+    static TrainingSetMileView *g_pTraingSetMileView{nullptr};
+
+    TrainingSetMileView::TrainingSetMileView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetMileView::TrainingSetMileView");
+        labeltitle_ = nullptr;
+        buttonok_ = nullptr;
+        Picker_ = nullptr;
+        SetMileScrollView = nullptr;
+        g_pTraingSetMileView = this;
+    }
+
+    TrainingSetMileView::~TrainingSetMileView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetMileView::~TrainingSetMileView");
+        SetMileScrollView->RemoveAll();
+        // 删除Label
+        if (labeltitle_ != nullptr)
+        {
+            SetMileScrollView->Remove(labeltitle_);
+            delete labeltitle_;
+            labeltitle_ = nullptr;
+        }
+        // 删除Button
+        if (buttonok_ != nullptr)
+        {
+            SetMileScrollView->Remove(buttonok_);
+            delete buttonok_;
+            buttonok_ = nullptr;
+        }
+
+        // 删除滚动选择器
+        if (Picker_ != nullptr)
+        {
+            SetMileScrollView->Remove(Picker_);
+            delete Picker_;
+            Picker_ = nullptr;
+        }
+
+        // 删除容器
+        if (SetMileScrollView != nullptr)
+        {
+            SetMileScrollView->RemoveAll(); // 移除容器中的所有组件
+            delete SetMileScrollView;
+            SetMileScrollView = nullptr;
+        }
+        g_pTraingSetMileView = nullptr;
+    }
+
+    TrainingSetMileView *TrainingSetMileView::GetInstance()
+    {
+
+        return g_pTraingSetMileView;
+    }
+
+    /*
+    InitUIPicker: 初始化UIPicker组件
+    @param picker: 指向UIPicker的指针
+    @param x: UIPicker的左边位置
+    @param y: UIPicker的顶部位置
+    @param width: UIPicker的宽度
+    @param height: UIPicker的高度
+    @param viewId: UIPicker的视图 ID
+    @param values: 选项数组
+    @param count: 选项数量
+    @param backgroundFontSize: 普通文本大小
+    @highlightFontSize: 高光文本大小
+    */
+    void TrainingSetMileView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+    {
+        // 文本大小
+        constexpr uint8_t BACKGROUND_FONT = 40;
+        constexpr uint8_t HIGHTLIGHT_FONT = 60;
+        // 获取value数组
+        int minMile = 1;
+        int maxMile = 20;
+        int interval = 1;
+        std::vector<std::string> MileValues = GenerateMileValues(minMile, maxMile, interval);
+
+        const char **values = new const char *[MileValues.size()];
+        for (size_t i = 0; i < MileValues.size(); i++)
+        {
+            values[i] = MileValues[i].c_str();
+        }
+        // 创建 UIPicker
+        if (picker == nullptr)
+        {
+            picker = new UIPicker();
+        }
+
+        // 设置 UIPicker 的位置和大小
+        picker->SetPosition(x, y);
+        picker->Resize(width, height);
+        // 设置 UIPicker 的 ViewId
+        picker->SetViewId(viewId);
+        // 设置 UIPicker 的属性
+        picker->SetItemHeight(70);
+        picker->SetLoopState(true);
+        picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+        picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT);  // 设置高光文本大小
+        picker->SetValues(values, MileValues.size());
+        // 将 UIPicker 设置为显示
+        picker->SetVisible(true);
+    }
+
+    /* InitView:初始化界面*/
+    UIScrollView *TrainingSetMileView ::SetMileViewInit()
+    {
+        /* -------------------------------------------------------------------------- */
+        SetMileScrollView = new UIScrollView();
+        if (SetMileScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetMileView::new SetMileScrollView fail");
+            return nullptr;
+        }
+        SetMileScrollView->SetPosition(0, 0);
+        SetMileScrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        SetMileScrollView->SetScrollBlankSize(35);
+        SetMileScrollView->SetReboundSize(50);
+        SetMileScrollView->SetDirection(1);
+        // 增加拖拽监听
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new TraingSetPresenter());
+        if (draglistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::draglistener can not be nullptr!");
+            return nullptr;
+        }
+        SetMileScrollView->SetOnDragListener(draglistener);
+        SetMileScrollView->SetTouchable(true);
+        SetMileScrollView->SetDraggable(true);
+        SetMileScrollView->SetVerticalScrollState(false); // 禁止垂直滑动
+        /* -------------------------------------------------------------------------- */
+        // 初始化Lable
+        InitRollLabel(labeltitle_, 83, 50, 300, 35, "label1",STR_RANGE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        SetMileScrollView->Add(labeltitle_);
+
+        // 初始化UIPicker
+        InitUIPicker(Picker_, 43, 106, 380, 240, "uiPicker");
+        SetMileScrollView->Add(Picker_);
+        //  初始化Button
+        InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONMILEOK, STR_OK, 30);
+        // Set additional property
+        buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
+        buttonok_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));
+        SetMileScrollView->Add(buttonok_);
+
+        return SetMileScrollView;
+    }
+    UIPicker *TrainingSetMileView ::GetMilePicker()
+    {
+        return Picker_;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetStepView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetStepView.cpp
new file mode 100644 (file)
index 0000000..4858ed0
--- /dev/null
@@ -0,0 +1,191 @@
+/***
+ * @Date: 2024-04-18 10:57:22
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 15:50:37
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TrainingSetStepView.cpp
+ */
+
+#include "traing/include/TrainingSetStepView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "components/ui_button.h"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+namespace OHOS
+{
+
+    /***************************************************************************************/
+    // 动态生成包含指定卡路里区间内所有卡路里数的字符串数组
+    std::vector<std::string> GenerateStepValues(int minTime, int maxTime, int interval)
+    {
+        std::vector<std::string> values;
+        for (int i = minTime; i <= maxTime; i += interval)
+        {
+            values.push_back(std::to_string(i));
+        }
+        return values;
+    }
+    /***************************************************************************************/
+    static TrainingSetStepView *g_pTraingSetStepView{nullptr};
+
+    TrainingSetStepView::TrainingSetStepView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetStepView::TrainingSetStepView");
+        labeltitle_ = nullptr;
+        buttonok_ = nullptr;
+        Picker_ = nullptr;
+        SetStepScrollView = nullptr;
+        g_pTraingSetStepView = this;
+    }
+
+    TrainingSetStepView::~TrainingSetStepView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetStepView::~TrainingSetStepView");
+        SetStepScrollView->RemoveAll();
+        // 删除Label
+        if (labeltitle_ != nullptr)
+        {
+            SetStepScrollView->Remove(labeltitle_);
+            delete labeltitle_;
+            labeltitle_ = nullptr;
+        }
+        // 删除Button
+        if (buttonok_ != nullptr)
+        {
+            SetStepScrollView->Remove(buttonok_);
+            delete buttonok_;
+            buttonok_ = nullptr;
+        }
+
+        // 删除滚动选择器
+        if (Picker_ != nullptr)
+        {
+            SetStepScrollView->Remove(Picker_);
+            delete Picker_;
+            Picker_ = nullptr;
+        }
+
+        // 删除容器
+        if (SetStepScrollView != nullptr)
+        {
+            SetStepScrollView->RemoveAll(); // 移除容器中的所有组件
+            delete SetStepScrollView;
+            SetStepScrollView = nullptr;
+        }
+        g_pTraingSetStepView = nullptr;
+    }
+
+    TrainingSetStepView *TrainingSetStepView::GetInstance()
+    {
+
+        return g_pTraingSetStepView;
+    }
+
+    /*
+    InitUIPicker: 初始化UIPicker组件
+    @param picker: 指向UIPicker的指针
+    @param x: UIPicker的左边位置
+    @param y: UIPicker的顶部位置
+    @param width: UIPicker的宽度
+    @param height: UIPicker的高度
+    @param viewId: UIPicker的视图 ID
+    @param values: 选项数组
+    @param count: 选项数量
+    @param backgroundFontSize: 普通文本大小
+    @highlightFontSize: 高光文本大小
+    */
+    void TrainingSetStepView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+    {
+        // 文本大小
+        constexpr uint8_t BACKGROUND_FONT = 40;
+        constexpr uint8_t HIGHTLIGHT_FONT = 60;
+        // 获取value数组
+        int minStep = 500;
+        int maxStep = 50000;
+        int interval = 500;
+        std::vector<std::string> StepValues = GenerateStepValues(minStep, maxStep, interval);
+
+        const char **values = new const char *[StepValues.size()];
+        for (size_t i = 0; i < StepValues.size(); i++)
+        {
+            values[i] = StepValues[i].c_str();
+        }
+        // 创建 UIPicker
+        if (picker == nullptr)
+        {
+            picker = new UIPicker();
+        }
+
+        // 设置 UIPicker 的位置和大小
+        picker->SetPosition(x, y);
+        picker->Resize(width, height);
+        // 设置 UIPicker 的 ViewId
+        picker->SetViewId(viewId);
+        // 设置 UIPicker 的属性
+        picker->SetItemHeight(70);
+        picker->SetLoopState(true);
+        picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+        picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT);  // 设置高光文本大小
+        picker->SetValues(values, StepValues.size());
+        // 将 UIPicker 设置为显示
+        picker->SetVisible(true);
+    }
+
+    /* InitView:初始化界面*/
+    UIScrollView *TrainingSetStepView ::SetStepViewInit()
+    {
+        /* -------------------------------------------------------------------------- */
+        SetStepScrollView = new UIScrollView();
+        if (SetStepScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetStepView::new SetStepScrollView fail");
+            return nullptr;
+        }
+        SetStepScrollView->SetPosition(0, 0);
+        SetStepScrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        SetStepScrollView->SetScrollBlankSize(35);
+        SetStepScrollView->SetReboundSize(50);
+        SetStepScrollView->SetDirection(1);
+        // 增加拖拽监听
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new TraingSetPresenter());
+        if (draglistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::draglistener can not be nullptr!");
+            return nullptr;
+        }
+        SetStepScrollView->SetOnDragListener(draglistener);
+        SetStepScrollView->SetTouchable(true);
+        SetStepScrollView->SetDraggable(true);
+        SetStepScrollView->SetVerticalScrollState(false); // 禁止垂直滑动
+        /* -------------------------------------------------------------------------- */
+        // 初始化Lable
+        InitRollLabel(labeltitle_, 83, 50, 300, 35, "label1", STR_STEP_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        SetStepScrollView->Add(labeltitle_);
+
+        // 初始化UIPicker
+        InitUIPicker(Picker_, 43, 106, 380, 240, "uiPicker");
+        SetStepScrollView->Add(Picker_);
+        //  初始化Button
+        InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONSTEPOK, STR_OK, 30);
+        // Set additional property
+        buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
+        buttonok_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));
+        SetStepScrollView->Add(buttonok_);
+
+        return SetStepScrollView;
+    }
+    UIPicker *TrainingSetStepView ::GetSetpPicker()
+    {
+        return Picker_;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetTimeView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/src/TrainingSetTimeView.cpp
new file mode 100644 (file)
index 0000000..219b011
--- /dev/null
@@ -0,0 +1,191 @@
+/***
+ * @Date: 2024-04-18 10:57:22
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 14:24:30
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/src/TrainingSetTimeView.cpp
+ */
+
+#include "traing/include/TrainingSetTimeView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "components/ui_button.h"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+namespace OHOS
+{
+
+    /***************************************************************************************/
+    // 动态生成包含指定卡路里区间内所有卡路里数的字符串数组
+    std::vector<std::string> GenerateTimeValues(int minTime, int maxTime, int interval)
+    {
+        std::vector<std::string> values;
+        for (int i = minTime; i <= maxTime; i += interval)
+        {
+            values.push_back(std::to_string(i));
+        }
+        return values;
+    }
+    /***************************************************************************************/
+    static TrainingSetTimeView *g_pTraingSetTimeView{nullptr};
+
+    TrainingSetTimeView::TrainingSetTimeView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetTimeView::TrainingSetTimeView");
+        labeltitle_ = nullptr;
+        buttonok_ = nullptr;
+        Picker_ = nullptr;
+        SetTimeScrollView = nullptr;
+        g_pTraingSetTimeView = this;
+    }
+
+    TrainingSetTimeView::~TrainingSetTimeView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetTimeView::~TrainingSetTimeView");
+        SetTimeScrollView->RemoveAll();
+        // 删除Label
+        if (labeltitle_ != nullptr)
+        {
+            SetTimeScrollView->Remove(labeltitle_);
+            delete labeltitle_;
+            labeltitle_ = nullptr;
+        }
+        // 删除Button
+        if (buttonok_ != nullptr)
+        {
+            SetTimeScrollView->Remove(buttonok_);
+            delete buttonok_;
+            buttonok_ = nullptr;
+        }
+
+        // 删除滚动选择器
+        if (Picker_ != nullptr)
+        {
+            SetTimeScrollView->Remove(Picker_);
+            delete Picker_;
+            Picker_ = nullptr;
+        }
+
+        // 删除容器
+        if (SetTimeScrollView != nullptr)
+        {
+            SetTimeScrollView->RemoveAll(); // 移除容器中的所有组件
+            delete SetTimeScrollView;
+            SetTimeScrollView = nullptr;
+        }
+        g_pTraingSetTimeView = nullptr;
+    }
+
+    TrainingSetTimeView *TrainingSetTimeView::GetInstance()
+    {
+
+        return g_pTraingSetTimeView;
+    }
+
+    /*
+    InitUIPicker: 初始化UIPicker组件
+    @param picker: 指向UIPicker的指针
+    @param x: UIPicker的左边位置
+    @param y: UIPicker的顶部位置
+    @param width: UIPicker的宽度
+    @param height: UIPicker的高度
+    @param viewId: UIPicker的视图 ID
+    @param values: 选项数组
+    @param count: 选项数量
+    @param backgroundFontSize: 普通文本大小
+    @highlightFontSize: 高光文本大小
+    */
+    void TrainingSetTimeView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+    {
+        // 文本大小
+        constexpr uint8_t BACKGROUND_FONT = 40;
+        constexpr uint8_t HIGHTLIGHT_FONT = 60;
+        // 获取value数组
+        int minTime = 10;
+        int maxTime = 600;
+        int interval = 10;
+        std::vector<std::string> TimeValues = GenerateTimeValues(minTime, maxTime, interval);
+
+        const char **values = new const char *[TimeValues.size()];
+        for (size_t i = 0; i < TimeValues.size(); i++)
+        {
+            values[i] = TimeValues[i].c_str();
+        }
+        // 创建 UIPicker
+        if (picker == nullptr)
+        {
+            picker = new UIPicker();
+        }
+
+        // 设置 UIPicker 的位置和大小
+        picker->SetPosition(x, y);
+        picker->Resize(width, height);
+        // 设置 UIPicker 的 ViewId
+        picker->SetViewId(viewId);
+        // 设置 UIPicker 的属性
+        picker->SetItemHeight(70);
+        picker->SetLoopState(true);
+        picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+        picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT);  // 设置高光文本大小
+        picker->SetValues(values, TimeValues.size());
+        // 将 UIPicker 设置为显示
+        picker->SetVisible(true);
+    }
+
+    /* InitView:初始化界面*/
+    UIScrollView *TrainingSetTimeView ::SetTimeViewInit()
+    {
+        /* -------------------------------------------------------------------------- */
+        SetTimeScrollView = new UIScrollView();
+        if (SetTimeScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingSetTimeView::new SetTimeScrollView fail");
+            return nullptr;
+        }
+        SetTimeScrollView->SetPosition(0, 0);
+        SetTimeScrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        SetTimeScrollView->SetScrollBlankSize(35);
+        SetTimeScrollView->SetReboundSize(50);
+        SetTimeScrollView->SetDirection(1);
+        // 增加拖拽监听
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new TraingSetPresenter());
+        if (draglistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::draglistener can not be nullptr!");
+            return nullptr;
+        }
+        SetTimeScrollView->SetOnDragListener(draglistener);
+        SetTimeScrollView->SetTouchable(true);
+        SetTimeScrollView->SetDraggable(true);
+        SetTimeScrollView->SetVerticalScrollState(false); // 禁止垂直滑动
+        /* -------------------------------------------------------------------------- */
+        // 初始化Lable
+        InitRollLabel(labeltitle_, 83, 50, 300, 35, "label1", STR_DURATION_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        SetTimeScrollView->Add(labeltitle_);
+
+        // 初始化UIPicker
+        InitUIPicker(Picker_, 43, 106, 380, 240, "uiPicker");
+        SetTimeScrollView->Add(Picker_);
+        //  初始化Button
+        InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONTIMEOK, STR_OK, 30);
+        // Set additional property
+        buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
+        buttonok_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetPresenter::GetInstance()));
+        SetTimeScrollView->Add(buttonok_);
+
+        return SetTimeScrollView;
+    }
+    UIPicker *TrainingSetTimeView ::GetTimePicker()
+    {
+        return Picker_;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSPresenter.h
new file mode 100644 (file)
index 0000000..f6e1dfc
--- /dev/null
@@ -0,0 +1,35 @@
+
+#ifndef _TraingGPS_PRESENTER_H
+#define _TraingGPS_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSView.h"
+
+namespace OHOS
+{
+    class TraingGPSView;
+
+    class TraingGPSPresenter : public Presenter<TraingGPSView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingGPSPresenter();
+        virtual ~TraingGPSPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSView.h
new file mode 100644 (file)
index 0000000..e5befee
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef _TraingGPS_VIEW_H
+#define _TraingGPS_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "TraingGPSPresenter.h"
+namespace OHOS
+{
+#define BUTTONGO "button1"
+#define BUTTONSET "button2"
+
+    class TraingGPSPresenter;
+    class TraingGPSView : public View<TraingGPSPresenter>
+    {
+
+    public:
+        TraingGPSView();
+        virtual ~TraingGPSView();
+        static TraingGPSView *GetInstance(void);
+
+        void OnStart() override;
+   
+        void InitView();
+        void DeInit();
+       
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingGPSView(TraingGPSView &&) = delete;
+        TraingGPSView &operator=(TraingGPSView &&) = delete;
+
+        UILabelExt *label1_ = nullptr;
+        UILabelExt *label2_ = nullptr;
+        UILabelExt *label3_ = nullptr;
+        UILabelExt *label4_ = nullptr;
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+        UIImageView *image1_ = nullptr;
+        UIImageView *image2_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPS_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackPresenter.h
new file mode 100644 (file)
index 0000000..980e070
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _TraingGPSback_PRESENTER_H
+#define _TraingGPSback_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSbackView.h"
+
+namespace OHOS
+{
+    class TraingGPSbackView;
+
+    class TraingGPSbackPresenter : public Presenter<TraingGPSbackView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingGPSbackPresenter();
+        virtual ~TraingGPSbackPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSbackPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        //bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSbackView.h
new file mode 100644 (file)
index 0000000..d7428f6
--- /dev/null
@@ -0,0 +1,63 @@
+
+#ifndef _TraingGPSback_VIEW_H
+#define _TraingGPSback_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "TraingGPSbackPresenter.h"
+namespace OHOS
+{
+#define BUTTONOK "button1"
+
+
+    class TraingGPSbackPresenter;
+    class TraingGPSbackView : public View<TraingGPSbackPresenter>
+    {
+
+    public:
+        TraingGPSbackView();
+        virtual ~TraingGPSbackView();
+        static TraingGPSbackView *GetInstance(void);
+
+        void OnStart() override;
+ 
+        void InitView();
+        void DeInit();
+       
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingGPSbackView(TraingGPSbackView &&) = delete;
+        TraingGPSbackView &operator=(TraingGPSbackView &&) = delete;
+       
+        UILabelExt *label1_ = nullptr;
+        UILabelExt *label2_ = nullptr;      
+        UIButton *button1_ = nullptr;   
+        UIImageView *image1_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPSback_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackPresenter.h
new file mode 100644 (file)
index 0000000..685444d
--- /dev/null
@@ -0,0 +1,35 @@
+
+#ifndef _TraingGPSlack_PRESENTER_H
+#define _TraingGPSlack_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSlackView.h"
+
+namespace OHOS
+{
+    class TraingGPSlackView;
+
+    class TraingGPSlackPresenter : public Presenter<TraingGPSlackView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingGPSlackPresenter();
+        virtual ~TraingGPSlackPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSlackPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlackView.h
new file mode 100644 (file)
index 0000000..d5d6090
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef _TraingGPSlack_VIEW_H
+#define _TraingGPSlack_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "TraingGPSlackPresenter.h"
+namespace OHOS
+{
+#define BUTTONGO "button1"
+#define BUTTONSET "button2"
+
+    class TraingGPSlackPresenter;
+    class TraingGPSlackView : public View<TraingGPSlackPresenter>
+    {
+
+    public:
+        TraingGPSlackView();
+        virtual ~TraingGPSlackView();
+        static TraingGPSlackView *GetInstance(void);
+
+        void OnStart() override;
+      
+        void InitView();
+        void DeInit();
+       
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingGPSlackView(TraingGPSlackView &&) = delete;
+        TraingGPSlackView &operator=(TraingGPSlackView &&) = delete;
+
+   
+        UILabelExt *label1_ = nullptr;
+        UILabelExt *label2_ = nullptr;
+        UILabelExt *label3_ = nullptr;
+        UILabelExt *label4_ = nullptr;
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+        UIImageView *image1_ = nullptr;
+        UIImageView *image2_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPSlack_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostPresenter.h
new file mode 100644 (file)
index 0000000..72042cc
--- /dev/null
@@ -0,0 +1,35 @@
+
+#ifndef _TraingGPSlost_PRESENTER_H
+#define _TraingGPSlost_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSlostView.h"
+
+namespace OHOS
+{
+    class TraingGPSlostView;
+
+    class TraingGPSlostPresenter : public Presenter<TraingGPSlostView>,
+                                   public UIView::OnClickListener,
+                                   public UIView::OnDragListener
+    {
+    public:
+        TraingGPSlostPresenter();
+        virtual ~TraingGPSlostPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSlostPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        //bool OnDragEnd(UIView &view, const DragEvent &event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSlostView.h
new file mode 100644 (file)
index 0000000..3eca401
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef _TraingGPSlost_VIEW_H
+#define _TraingGPSlost_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+#include "TraingGPSlostPresenter.h"
+namespace OHOS
+{
+#define BUTTONOK "button1"
+
+
+    class TraingGPSlostPresenter;
+    class TraingGPSlostView : public View<TraingGPSlostPresenter>
+    {
+
+    public:
+        TraingGPSlostView();
+        virtual ~TraingGPSlostView();
+        static TraingGPSlostView *GetInstance(void);
+
+        void OnStart() override;
+
+        void InitView();
+        void DeInit();
+       
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingGPSlostView(TraingGPSlostView &&) = delete;
+        TraingGPSlostView &operator=(TraingGPSlostView &&) = delete;
+ 
+        UILabelExt *label1_ = nullptr;
+        UILabelExt *label2_ = nullptr;      
+        UIButton *button1_ = nullptr;   
+        UIImageView *image1_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPSlost_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnotePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnotePresenter.h
new file mode 100644 (file)
index 0000000..c37597f
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _TraingGPSnote_PRESENTER_H
+#define _TraingGPSnote_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSnoteView.h"
+
+namespace OHOS
+{
+    class TraingGPSnoteView;
+
+    class TraingGPSnotePresenter : public Presenter<TraingGPSnoteView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingGPSnotePresenter();
+        virtual ~TraingGPSnotePresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSnotePresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h
new file mode 100644 (file)
index 0000000..d6f390d
--- /dev/null
@@ -0,0 +1,69 @@
+
+#ifndef _TraingGPSnote_VIEW_H
+#define _TraingGPSnote_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "TraingGPSnotePresenter.h"
+namespace OHOS
+{
+#define BUTTONBACK "button1"
+#define BUTTONGO "button2"
+
+    class TraingGPSnotePresenter;
+    class TraingGPSnoteView : public View<TraingGPSnotePresenter>
+    {
+
+    public:
+        TraingGPSnoteView();
+        virtual ~TraingGPSnoteView();
+        static TraingGPSnoteView *GetInstance(void);
+
+        void OnStart() override;
+      
+        void InitView();
+        void DeInit();
+       
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingGPSnoteView(TraingGPSnoteView &&) = delete;
+        TraingGPSnoteView &operator=(TraingGPSnoteView &&) = delete;
+
+
+        UIScrollView *scrollView1_ = nullptr;
+
+        UILabelExt *label1_ = nullptr;
+        UILabelExt *label2_ = nullptr;
+        UILabelExt *label3_ = nullptr;
+        UILabelExt *label4_ = nullptr;
+
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+
+        UIImageView *image1_ = nullptr;
+        UIImageView *image2_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPSnote_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetPresenter.h
new file mode 100644 (file)
index 0000000..e090dd7
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef _TraingGPSset_PRESENTER_H
+#define _TraingGPSset_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSsetView.h"
+
+namespace OHOS
+{
+    class TraingGPSsetView;
+
+    class TraingGPSsetPresenter : public Presenter<TraingGPSsetView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingGPSsetPresenter();
+        virtual ~TraingGPSsetPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSsetPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView& view, const DragEvent& event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSsetView.h
new file mode 100644 (file)
index 0000000..b1e5c54
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef _TraingGPSset_VIEW_H
+#define _TraingGPSset_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "TraingGPSsetPresenter.h"
+namespace OHOS
+{
+#define BUTTONTIME "button1"
+#define BUTTONMIL "button2"
+#define BUTTONCALULI "button3"
+#define BUTTONWALK "button4"
+
+    class TraingGPSsetPresenter;
+    class TraingGPSsetView : public View<TraingGPSsetPresenter>
+    {
+
+    public:
+        TraingGPSsetView();
+        virtual ~TraingGPSsetView();
+        static TraingGPSsetView *GetInstance(void);
+
+        void OnStart() override;
+ 
+        void InitView();
+        void DeInit();
+       
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingGPSsetView(TraingGPSsetView &&) = delete;
+        TraingGPSsetView &operator=(TraingGPSsetView &&) = delete;
+
+  
+        UIScrollView *scrollView1_ = nullptr;
+
+        UILabelExt *label1_ = nullptr;
+        UILabelExt *label2_ = nullptr;
+        UILabelExt *label3_ = nullptr;
+        UILabelExt *label4_ = nullptr;
+        UILabelExt *label5_ = nullptr;
+
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+        UIButton *button3_ = nullptr;
+        UIButton *button4_ = nullptr;
+
+        UIImageView *image1_ = nullptr;
+        UIImageView *image2_ = nullptr;
+        UIImageView *image3_ = nullptr;
+        UIImageView *image4_ = nullptr;
+
+        UIList *list1_ = nullptr;
+        IconAdapter *list1adapter_ = nullptr;
+        List<IconItemNode *> *list1data_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPSset_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSPresenter.cpp
new file mode 100644 (file)
index 0000000..c5d575d
--- /dev/null
@@ -0,0 +1,90 @@
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_GPS/include/TraingGPSPresenter.h"
+// #include "TraingGPSView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSPresenter *g_pTraingGPSPresenter = nullptr;
+
+    TraingGPSPresenter::TraingGPSPresenter()
+    {
+
+        g_pTraingGPSPresenter = this;
+    }
+
+    TraingGPSPresenter::~TraingGPSPresenter()
+    {
+
+        g_pTraingGPSPresenter = nullptr;
+    }
+
+    TraingGPSPresenter *TraingGPSPresenter::GetInstance()
+    {
+
+        return g_pTraingGPSPresenter;
+    }
+
+    void TraingGPSPresenter::OnStart()
+    {
+
+        Presenter<TraingGPSView>::OnStart();
+    }
+
+    void TraingGPSPresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSView>::OnPause();
+    }
+
+    void TraingGPSPresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSView>::OnResume();
+    }
+
+    void TraingGPSPresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSView>::OnStop();
+    }
+    bool TraingGPSPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingGPSPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING);
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONSET) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSSET);
+        }
+        if (strcmp(view.GetViewId(), BUTTONGO) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSView.cpp
new file mode 100644 (file)
index 0000000..e91d9f8
--- /dev/null
@@ -0,0 +1,103 @@
+
+#include "traing/training_GPS/include/TraingGPSView.h"
+
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_button.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include <ui_scroll_view.h>
+
+namespace OHOS {
+static TraingGPSView *g_pTraingGPSView{nullptr};
+
+TraingGPSView::TraingGPSView() { g_pTraingGPSView = this; }
+
+TraingGPSView::~TraingGPSView() {
+  DeInit();
+  g_pTraingGPSView = nullptr;
+}
+
+TraingGPSView *TraingGPSView::GetInstance() { return g_pTraingGPSView; }
+
+/* InitView:初始化界面*/
+void TraingGPSView ::InitView() {
+
+  // 初始化Lable
+  InitLabel(label1_, 203, 52, 195, 35, "label1", "骑行",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
+  AddViewToRootContainer(label1_);
+  InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
+  AddViewToRootContainer(label2_);
+  InitLabel(label3_, 41, 237, 54, 41, "lable3", "144",
+            DEFAULT_VECTOR_FONT_FILENAME, 35);
+  AddViewToRootContainer(label3_);
+  InitLabel(label4_, 361, 237, 54, 41, "lable4", "GPS",
+            DEFAULT_VECTOR_FONT_FILENAME, 35);
+  AddViewToRootContainer(label4_);
+  // 初始化image
+  InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_1_IMAGE);
+  InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_1_IMAGE);
+  AddViewToRootContainer(image1_);
+  AddViewToRootContainer(image2_);
+  // 初始化Button
+  InitButton(button1_, 133, 133, 200, 200, BUTTONGO);
+
+  button1_->SetImageSrc(GO_1_IMAGE, nullptr);
+
+  InitButton(button2_, 160, 370, 146, 35, BUTTONSET);
+  button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); // 设置为透明按键
+  button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+  button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80,
+                             UIButton::PRESSED); // 设置按下时的透明度为半透明
+
+  AddViewToRootContainer(button1_);
+  AddViewToRootContainer(button2_);
+}
+/* DeInit:删除组件*/
+void TraingGPSView::DeInit() {
+  // container_->RemoveAll();
+  // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+  // while (view != nullptr)
+  // {
+  //     UIView *tempView = view;
+  //     view = view->GetNextSibling();
+  //     if (tempView->GetParent())
+  //     {
+  //         static_cast<UIViewGroup
+  //         *>(tempView->GetParent())->Remove(tempView);
+  //     }
+  //     delete tempView;
+  // }
+  // delete container_;
+  // container_ = nullptr;
+}
+
+void TraingGPSView::PreLoad(void) {
+  if (!viewiInitStatus) {
+    InitView();
+    viewiInitStatus = true;
+  }
+}
+void TraingGPSView::OnStart() {
+
+  // 创建 draglistener 实例并设置为拖动监听器
+  UIView::OnDragListener *draglistener =
+      static_cast<UIView::OnDragListener *>(TraingGPSPresenter::GetInstance());
+  if (draglistener == nullptr) {
+    return;
+  }
+  GetRootContainer()->SetOnDragListener(draglistener);
+
+  GetRootContainer()->SetTouchable(true);
+  GetRootContainer()->SetDraggable(true);
+
+  PreLoad();
+}
+
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackPresenter.cpp
new file mode 100644 (file)
index 0000000..fe970f0
--- /dev/null
@@ -0,0 +1,82 @@
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_GPS/include/TraingGPSbackPresenter.h"
+// #include "TraingGPSbackView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSbackPresenter *g_pTraingGPSbackPresenter = nullptr;
+
+    TraingGPSbackPresenter::TraingGPSbackPresenter()
+    {
+
+        g_pTraingGPSbackPresenter = this;
+    }
+
+    TraingGPSbackPresenter::~TraingGPSbackPresenter()
+    {
+
+        g_pTraingGPSbackPresenter = nullptr;
+    }
+
+    TraingGPSbackPresenter *TraingGPSbackPresenter::GetInstance()
+    {
+
+        return g_pTraingGPSbackPresenter;
+    }
+
+    void TraingGPSbackPresenter::OnStart()
+    {
+
+        Presenter<TraingGPSbackView>::OnStart();
+    }
+
+    void TraingGPSbackPresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSbackView>::OnPause();
+    }
+
+    void TraingGPSbackPresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSbackView>::OnResume();
+    }
+
+    void TraingGPSbackPresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSbackView>::OnStop();
+    }
+
+    bool TraingGPSbackPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+
+        // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+        //     (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        // {
+        //     uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+        //    NativeAbility::GetInstance().ChangeSlice(preSlice);
+        // }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSbackPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONOK) == 0)
+        {
+            //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSbackView.cpp
new file mode 100644 (file)
index 0000000..98c8101
--- /dev/null
@@ -0,0 +1,101 @@
+
+#include "traing/training_GPS/include/TraingGPSbackView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+namespace OHOS
+{
+    static TraingGPSbackView *g_pTraingGPSbackView{nullptr};
+
+    TraingGPSbackView::TraingGPSbackView()
+    {
+        g_pTraingGPSbackView = this;
+    }
+
+    TraingGPSbackView::~TraingGPSbackView()
+    {
+        DeInit();
+        g_pTraingGPSbackView = nullptr;
+    }
+
+    TraingGPSbackView *TraingGPSbackView::GetInstance()
+    {
+
+        return g_pTraingGPSbackView;
+    }
+
+    /* InitView:初始化界面*/
+    void TraingGPSbackView ::InitView()
+    {
+       
+        // 初始化Lable
+       InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS连接", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        AddViewToRootContainer(label1_);
+       InitLabel(label2_, 55, 253, 146, 35, "label2", "GPS已连接,当前信号正常", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        AddViewToRootContainer(label2_);
+
+        // 初始化image
+       InitImageView(image1_, 193, 140, 40, 40, "image1", BACK_IMAGE);
+        AddViewToRootContainer(image1_);
+
+        // 初始化Button
+       InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
+        // Set additional property
+        button1_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingGPSbackPresenter::GetInstance()));
+        button1_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);
+        AddViewToRootContainer(button1_);
+    }
+    /* DeInit:删除组件*/
+    void TraingGPSbackView::DeInit()
+    {
+        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+        // while (view != nullptr)
+        // {
+        //     UIView *tempView = view;
+        //     view = view->GetNextSibling();
+        //     if (tempView->GetParent())
+        //     {
+        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+        //     }
+        //     delete tempView;
+        // }
+        // delete container_;
+        // container_ = nullptr;
+    }
+
+    void TraingGPSbackView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingGPSbackView::OnStart()
+    {
+
+
+        // 创建 draglistener 实例并设置为拖动监听器
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSbackPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        GetRootContainer()->SetOnDragListener(draglistener);
+
+        GetRootContainer()->SetTouchable(true);
+        GetRootContainer()->SetDraggable(true);
+
+        PreLoad();
+    }
+
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackPresenter.cpp
new file mode 100644 (file)
index 0000000..92f54f2
--- /dev/null
@@ -0,0 +1,90 @@
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_GPS/include/TraingGPSlackPresenter.h"
+// #include "TraingGPSlackView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSlackPresenter *g_pTraingGPSlackPresenter = nullptr;
+
+    TraingGPSlackPresenter::TraingGPSlackPresenter()
+    {
+
+        g_pTraingGPSlackPresenter = this;
+    }
+
+    TraingGPSlackPresenter::~TraingGPSlackPresenter()
+    {
+
+        g_pTraingGPSlackPresenter = nullptr;
+    }
+
+    TraingGPSlackPresenter *TraingGPSlackPresenter::GetInstance()
+    {
+
+        return g_pTraingGPSlackPresenter;
+    }
+
+    void TraingGPSlackPresenter::OnStart()
+    {
+
+        Presenter<TraingGPSlackView>::OnStart();
+    }
+
+    void TraingGPSlackPresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSlackView>::OnPause();
+    }
+
+    void TraingGPSlackPresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSlackView>::OnResume();
+    }
+
+    void TraingGPSlackPresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSlackView>::OnStop();
+    }
+    bool TraingGPSlackPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingGPSlackPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+           //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING);
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSlackPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONSET) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);
+        }
+        if (strcmp(view.GetViewId(), BUTTONGO) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSNOTE);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlackView.cpp
new file mode 100644 (file)
index 0000000..3f4ef1b
--- /dev/null
@@ -0,0 +1,117 @@
+
+#include "traing/training_GPS/include/TraingGPSlackView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+namespace OHOS
+{
+
+    static TraingGPSlackView *g_pTraingGPSlackView{nullptr};
+
+    TraingGPSlackView::TraingGPSlackView()
+    {
+        g_pTraingGPSlackView = this;
+    }
+
+    TraingGPSlackView::~TraingGPSlackView()
+    {
+        DeInit();
+        g_pTraingGPSlackView = nullptr;
+    }
+
+    TraingGPSlackView *TraingGPSlackView::GetInstance()
+    {
+
+        return g_pTraingGPSlackView;
+    }
+   
+    /* InitView:初始化界面*/
+    void TraingGPSlackView ::InitView()
+    {
+
+
+        // 初始化Lable
+       InitLabel(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        AddViewToRootContainer(label1_);
+       InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        AddViewToRootContainer(label2_);
+       InitLabel(label3_, 41, 237, 54, 41, "lable3", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        AddViewToRootContainer(label3_);
+       InitLabel(label4_, 361, 237, 54, 41, "lable4", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        AddViewToRootContainer(label4_);
+        // 初始化image
+       InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_2_IMAGE);
+       InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_2_IMAGE);
+        AddViewToRootContainer(image1_);
+        AddViewToRootContainer(image2_);
+        // 初始化Button
+       InitButton(button1_, 133, 133, 200, 200, BUTTONGO);
+        // Set additional property
+        char *button1defaultImgSrc = "/user/res/Training/Go_2.bin";
+        char *button1triggeredImgSrc = nullptr;
+        button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+
+       InitButton(button2_, 160, 370, 146, 35, BUTTONSET);
+        button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); // 设置为透明按键
+        button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+        button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80, UIButton::PRESSED); // 设置按下时的透明度为半透明
+
+        AddViewToRootContainer(button1_);
+        AddViewToRootContainer(button2_);
+    }
+    /* DeInit:删除组件*/
+    void TraingGPSlackView::DeInit()
+    {
+        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+        // while (view != nullptr)
+        // {
+        //     UIView *tempView = view;
+        //     view = view->GetNextSibling();
+        //     if (tempView->GetParent())
+        //     {
+        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+        //     }
+        //     delete tempView;
+        // }
+        // delete container_;
+        // container_ = nullptr;
+    }
+
+    void TraingGPSlackView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingGPSlackView::OnStart()
+    {
+
+
+        // 创建 draglistener 实例并设置为拖动监听器
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSlackPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        GetRootContainer()->SetOnDragListener(draglistener);
+
+        GetRootContainer()->SetTouchable(true);
+        GetRootContainer()->SetDraggable(true);
+
+        PreLoad();
+
+    }
+
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostPresenter.cpp
new file mode 100644 (file)
index 0000000..f8a81c0
--- /dev/null
@@ -0,0 +1,82 @@
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_GPS/include/TraingGPSlostPresenter.h"
+// #include "TraingGPSlostView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSlostPresenter *g_pTraingGPSlostPresenter = nullptr;
+
+    TraingGPSlostPresenter::TraingGPSlostPresenter()
+    {
+
+        g_pTraingGPSlostPresenter = this;
+    }
+
+    TraingGPSlostPresenter::~TraingGPSlostPresenter()
+    {
+
+        g_pTraingGPSlostPresenter = nullptr;
+    }
+
+    TraingGPSlostPresenter *TraingGPSlostPresenter::GetInstance()
+    {
+
+        return g_pTraingGPSlostPresenter;
+    }
+
+    void TraingGPSlostPresenter::OnStart()
+    {
+
+        Presenter<TraingGPSlostView>::OnStart();
+    }
+
+    void TraingGPSlostPresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSlostView>::OnPause();
+    }
+
+    void TraingGPSlostPresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSlostView>::OnResume();
+    }
+
+    void TraingGPSlostPresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSlostView>::OnStop();
+    }
+
+    bool TraingGPSlostPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+
+        // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+        //     (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        // {
+        //     uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+        //    NativeAbility::GetInstance().ChangeSlice(preSlice);
+        // }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSlostPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONOK) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSBACK);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSlostView.cpp
new file mode 100644 (file)
index 0000000..6ad8848
--- /dev/null
@@ -0,0 +1,100 @@
+
+#include "traing/training_GPS/include/TraingGPSlostView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+namespace OHOS
+{
+
+    static TraingGPSlostView *g_pTraingGPSlostView{nullptr};
+
+    TraingGPSlostView::TraingGPSlostView()
+    {
+        g_pTraingGPSlostView = this;
+    }
+
+    TraingGPSlostView::~TraingGPSlostView()
+    {
+        DeInit();
+        g_pTraingGPSlostView = nullptr;
+    }
+
+    TraingGPSlostView *TraingGPSlostView::GetInstance()
+    {
+
+        return g_pTraingGPSlostView;
+    }
+   
+
+    /* InitView:初始化界面*/
+    void TraingGPSlostView ::InitView()
+    {
+
+        // 初始化Lable
+       InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS丢失", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        AddViewToRootContainer(label1_);
+       InitLabel(label2_, 55, 253, 146, 35, "label2", "当前位置搜索不到GPS信号", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        AddViewToRootContainer(label2_);
+
+        // 初始化image
+       InitImageView(image1_, 193, 140, 40, 40, "image1", WARNING_IMAGE);
+        AddViewToRootContainer(image1_);
+
+        // 初始化Button
+       InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
+        // Set additional property
+        button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr);
+        AddViewToRootContainer(button1_);
+    }
+    /* DeInit:删除组件*/
+    void TraingGPSlostView::DeInit()
+    {
+        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+        // while (view != nullptr)
+        // {
+        //     UIView *tempView = view;
+        //     view = view->GetNextSibling();
+        //     if (tempView->GetParent())
+        //     {
+        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+        //     }
+        //     delete tempView;
+        // }
+        // delete container_;
+        // container_ = nullptr;
+    }
+
+    void TraingGPSlostView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingGPSlostView::OnStart()
+    {
+      
+        // 创建 draglistener 实例并设置为拖动监听器
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSlostPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        GetRootContainer()->SetOnDragListener(draglistener);
+
+        GetRootContainer()->SetTouchable(true);
+        GetRootContainer()->SetDraggable(true);
+
+        PreLoad();
+    }
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnotePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnotePresenter.cpp
new file mode 100644 (file)
index 0000000..c93bc17
--- /dev/null
@@ -0,0 +1,89 @@
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_GPS/include/TraingGPSnotePresenter.h"
+// #include "TraingGPSnoteView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSnotePresenter *g_pTraingGPSnotePresenter = nullptr;
+
+    TraingGPSnotePresenter::TraingGPSnotePresenter()
+    {
+
+        g_pTraingGPSnotePresenter = this;
+    }
+
+    TraingGPSnotePresenter::~TraingGPSnotePresenter()
+    {
+
+        g_pTraingGPSnotePresenter = nullptr;
+    }
+
+    TraingGPSnotePresenter *TraingGPSnotePresenter::GetInstance()
+    {
+
+        return g_pTraingGPSnotePresenter;
+    }
+
+    void TraingGPSnotePresenter::OnStart()
+    {
+
+        Presenter<TraingGPSnoteView>::OnStart();
+    }
+
+    void TraingGPSnotePresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSnoteView>::OnPause();
+    }
+
+    void TraingGPSnotePresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSnoteView>::OnResume();
+    }
+
+    void TraingGPSnotePresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSnoteView>::OnStop();
+    }
+    bool TraingGPSnotePresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingGPSnotePresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(preSlice);
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSnotePresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONBACK) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLACK);
+        }
+        if (strcmp(view.GetViewId(), BUTTONGO) == 0)
+        {
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLOST);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp
new file mode 100644 (file)
index 0000000..0e7dea7
--- /dev/null
@@ -0,0 +1,140 @@
+
+#include "traing/training_GPS/include/TraingGPSnoteView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+namespace OHOS
+{
+
+    static TraingGPSnoteView *g_pTraingGPSnoteView{nullptr};
+
+    TraingGPSnoteView::TraingGPSnoteView()
+    {
+        g_pTraingGPSnoteView = this;
+    }
+
+    TraingGPSnoteView::~TraingGPSnoteView()
+    {
+        DeInit();
+        g_pTraingGPSnoteView = nullptr;
+    }
+
+    TraingGPSnoteView *TraingGPSnoteView::GetInstance()
+    {
+
+        return g_pTraingGPSnoteView;
+    }
+
+   
+    /* InitView:初始化界面*/
+    void TraingGPSnoteView ::InitView()
+    {
+
+
+        // Add ScrollView to App
+        if (scrollView1_ == nullptr)
+        {
+            scrollView1_ = new UIScrollView();
+        }
+        scrollView1_->SetPosition(0, 0);        // widget's left position and top position
+        scrollView1_->Resize(466, 466);         // widget's width and height
+        scrollView1_->SetViewId("scrollView1"); // Set style
+        scrollView1_->SetReboundSize(100);
+        scrollView1_->SetScrollBlankSize(52);
+        scrollView1_->SetHorizontalScrollState(false);
+        // Add to rootView
+        AddViewToRootContainer(scrollView1_);
+        scrollView1_->SetVisible(true);
+
+        // 初始化Image
+       InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE);
+        scrollView1_->Add(image1_);
+
+        // 初始化button
+       InitButton(button1_, 118, 334, 230, 80, BUTTONBACK);
+        button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
+        scrollView1_->Add(button1_);
+
+       InitButton(button2_, 118, 434, 230, 80, BUTTONGO);
+        scrollView1_->Add(button2_);
+
+        // 初始化Lable
+       InitLabel(label1_, 160, 52, 90, 35, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label2_, 33, 215, 60, 40, "label2", "GPS仍在定位,建议等待定位\n完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label3_, 181, 357, 60, 40, "label3", "继续等待", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label4_, 181, 457, 60, 40, "label4", "直接开始", DEFAULT_VECTOR_FONT_FILENAME, 30);
+
+        scrollView1_->Add(label1_);
+        scrollView1_->Add(label2_);
+        scrollView1_->Add(label3_);
+        scrollView1_->Add(label4_);
+
+        // Add ImageView to App
+        if (image2_ == nullptr)
+        {
+            image2_ = new UIImageView();
+        }
+        image2_->SetPosition(181, 500); // widget's left position and top position
+        image2_->Resize(100, 100);       // widget's width and height
+        image2_->SetViewId("image7");    // Set style
+        // Add to rootView
+        scrollView1_->Add(image2_);
+        image2_->SetVisible(true);
+    }
+
+    /* DeInit:删除组件 */
+    void TraingGPSnoteView::DeInit()
+    {
+        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+        // while (view != nullptr)
+        // {
+        //     UIView *tempView = view;
+        //     view = view->GetNextSibling();
+        //     if (tempView->GetParent())
+        //     {
+        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+        //     }
+        //     delete tempView;
+        // }
+        // delete container_;
+        // container_ = nullptr;
+    }
+
+    void TraingGPSnoteView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingGPSnoteView::OnStart()
+    {
+
+
+        // 创建 draglistener 实例并设置为拖动监听器
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSnotePresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        GetRootContainer()->SetOnDragListener(draglistener);
+
+        GetRootContainer()->SetTouchable(true);
+        GetRootContainer()->SetDraggable(true);
+
+        PreLoad();
+
+    }
+
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetPresenter.cpp
new file mode 100644 (file)
index 0000000..1d7eb30
--- /dev/null
@@ -0,0 +1,102 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-18 12:17:50
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/src/TraingGPSsetPresenter.cpp
+ */
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_GPS/include/TraingGPSsetPresenter.h"
+// #include "TraingGPSsetView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSsetPresenter *g_pTraingGPSsetPresenter = nullptr;
+
+    TraingGPSsetPresenter::TraingGPSsetPresenter()
+    {
+
+        g_pTraingGPSsetPresenter = this;
+    }
+
+    TraingGPSsetPresenter::~TraingGPSsetPresenter()
+    {
+
+        g_pTraingGPSsetPresenter = nullptr;
+    }
+
+    TraingGPSsetPresenter *TraingGPSsetPresenter::GetInstance()
+    {
+
+        return g_pTraingGPSsetPresenter;
+    }
+
+    void TraingGPSsetPresenter::OnStart()
+    {
+
+        Presenter<TraingGPSsetView>::OnStart();
+    }
+
+    void TraingGPSsetPresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSsetView>::OnPause();
+    }
+
+    void TraingGPSsetPresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSsetView>::OnResume();
+    }
+
+    void TraingGPSsetPresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSsetView>::OnStop();
+    }
+    bool TraingGPSsetPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingGPSsetPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPS);
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSsetPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONTIME) == 0)
+        {
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETTIME);
+        }
+        if (strcmp(view.GetViewId(), BUTTONMIL) == 0)
+        {
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETDIST);
+        }
+        if (strcmp(view.GetViewId(), BUTTONCALULI) == 0)
+        {
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETCALULI);
+        }
+        if (strcmp(view.GetViewId(), BUTTONWALK) == 0)
+        {
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETSTEP);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSsetView.cpp
new file mode 100644 (file)
index 0000000..ead821e
--- /dev/null
@@ -0,0 +1,194 @@
+
+#include "traing/training_GPS/include/TraingGPSsetView.h"
+
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+namespace OHOS
+{
+    // 定义全局变量
+    static const char *imagePaths[] = {TIME_IMAGE, MILEAGE_IMAGE, CALORIES_IMAGE, WARNING_IMAGE};
+
+    static char *text[] = {"时长", "距离", "卡路里", "步数"};
+    static TraingGPSsetView *g_pTraingGPSsetView{nullptr};
+
+    TraingGPSsetView::TraingGPSsetView()
+    {
+        g_pTraingGPSsetView = this;
+    }
+
+    TraingGPSsetView::~TraingGPSsetView()
+    {
+        DeInit();
+        g_pTraingGPSsetView = nullptr;
+    }
+
+    TraingGPSsetView *TraingGPSsetView::GetInstance()
+    {
+
+        return g_pTraingGPSsetView;
+    }
+   
+    /*  Traing:初始化list  */
+    void TraingGPSsetView::InitList()
+    {
+        // Add List to App
+        if (list1_ == nullptr)
+        {
+            list1_ = new UIList();
+        }
+        list1_->SetPosition(60, 110); // widget's left position and top position
+        list1_->Resize(300, 530);     // widget's width and height
+        list1_->SetViewId("list1");   // Set style
+        list1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+        list1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+        // Set additional property
+        if (list1data_ == nullptr)
+        {
+            list1data_ = new List<IconItemNode *>();
+        }
+
+        // 使用全局变量来初始化列表项
+        for (int i = 0; i < 4; ++i)
+        {
+            IconItemNode *listData = new IconItemNode();
+            // 检查是否需要分配内存空间
+            if (listData->imagePath == nullptr)
+            {
+                listData->imagePath = new char[strlen(imagePaths[i]) + 1];
+            }
+            strcpy(listData->imagePath, imagePaths[i]);
+            listData->txt = text[i];
+            list1data_->PushBack(listData);
+
+            // 释放内存空间
+            // delete[] listData->imagePath;
+            // delete listData;
+        }
+
+        if (list1adapter_ == nullptr)
+        {
+            list1adapter_ = new IconAdapter();
+        }
+        list1adapter_->SetItemSize(190, 120);
+        list1adapter_->SetImageSize(70, 120);
+        list1adapter_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        list1adapter_->SetData(list1data_);
+        list1_->SetAdapter(list1adapter_);
+
+        // Add to scrollView1
+        // scrollView1_->Add(list1_);
+        list1_->SetVisible(true);
+    }
+    /* InitView:初始化界面*/
+    void TraingGPSsetView ::InitView()
+    {
+
+        // Add ScrollView to App
+        if (scrollView1_ == nullptr)
+        {
+            scrollView1_ = new UIScrollView();
+        }
+        scrollView1_->SetPosition(0, 0);        // widget's left position and top position
+        scrollView1_->Resize(466, 466);         // widget's width and height
+        scrollView1_->SetViewId("scrollView1"); // Set style
+        scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        scrollView1_->SetReboundSize(100);
+        scrollView1_->SetScrollBlankSize(52);
+        scrollView1_->SetHorizontalScrollState(false);
+        // Add to rootView
+        AddViewToRootContainer(scrollView1_);
+        scrollView1_->SetVisible(true);
+
+        //  初始化Button
+       InitButton(button1_, 43, 120, 380, 100, BUTTONTIME);
+       InitButton(button2_, 43, 240, 380, 100, BUTTONMIL);
+       InitButton(button3_, 43, 360, 380, 100, BUTTONCALULI);
+       InitButton(button4_, 43, 480, 380, 100, BUTTONWALK);
+        scrollView1_->Add(button1_);
+        scrollView1_->Add(button2_);
+        scrollView1_->Add(button3_);
+        scrollView1_->Add(button4_);
+
+        // 初始化Image
+       InitImageView(image1_, 380, 160, 100, 100, "image1", ICON_IMAGE);
+       InitImageView(image2_, 380, 280, 100, 100, "image2", ICON_IMAGE);
+       InitImageView(image3_, 380, 400, 100, 100, "image3", ICON_IMAGE);
+       InitImageView(image4_, 380, 520, 100, 100, "image4", ICON_IMAGE);
+        scrollView1_->Add(image1_);
+        scrollView1_->Add(image2_);
+        scrollView1_->Add(image3_);
+        scrollView1_->Add(image4_);
+
+        // 初始化Lable
+       InitLabel(label1_, 203, 52, 120, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label2_, 300, 160, 60, 35, "label2", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20);
+       InitLabel(label3_, 300, 280, 69, 23, "label3", "5 公里", DEFAULT_VECTOR_FONT_FILENAME, 20);
+       InitLabel(label4_, 300, 400, 60, 35, "label4", "500 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20);
+       InitLabel(label5_, 300, 520, 60, 35, "label5", "2000 步", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        scrollView1_->Add(label1_);
+        scrollView1_->Add(label2_);
+        scrollView1_->Add(label3_);
+        scrollView1_->Add(label4_);
+        scrollView1_->Add(label5_);
+
+        // 初始化list
+        InitList();
+        scrollView1_->Add(list1_);
+    }
+    /* DeInit:删除组件 */
+    void TraingGPSsetView::DeInit()
+    {
+        // UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+        // while (view != nullptr)
+        // {
+        //     UIView *tempView = view;
+        //     view = view->GetNextSibling();
+        //     if (tempView->GetParent())
+        //     {
+        //         static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+        //     }
+        //     delete tempView;
+        // }
+        // delete container_;
+        // container_ = nullptr;
+    }
+
+    void TraingGPSsetView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingGPSsetView::OnStart()
+    {
+
+
+        // 创建 draglistener 实例并设置为拖动监听器
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSsetPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        GetRootContainer()->SetOnDragListener(draglistener);
+
+        GetRootContainer()->SetTouchable(true);
+        GetRootContainer()->SetDraggable(true);
+
+        PreLoad();
+
+    }
+
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardPresenter.h
new file mode 100644 (file)
index 0000000..8422992
--- /dev/null
@@ -0,0 +1,83 @@
+\r
+#ifndef _TraingCard_PRESENTER_H\r
+#define _TraingCard_PRESENTER_H\r
+\r
+#include "ModelListenerSample.h"\r
+#include "Presenter.h"\r
+#include "TraingCardView.h"\r
+#include "traing/training_card/include/TrainingControlView.h"\r
+#include "traing/training_card/include/TrainingDataView.h"\r
+#include "traing/training_card/include/TrainingDetailView.h"\r
+\r
+// #include "bletest.h"\r
+\r
+#include "components/root_view.h"\r
+#include "components/ui_swipe_view.h"\r
+#include "components/ui_view.h"\r
+\r
+// #include "cywee_hal.h"\r
+// #include "cywee_service.h"\r
+\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+\r
+namespace OHOS {\r
+class TraingCardView;\r
+class TrainingControlView;\r
+class TrainingDataView;\r
+class TrainingDetailView;\r
+class TraingModel;\r
+class TraingCardPresenter : public Presenter<TraingCardView>,\r
+                            public UIView::OnClickListener,\r
+                            public UIView::OnDragListener,\r
+                            public UISwipeView::OnSwipeListener,\r
+                            public RootView::OnKeyActListener,\r
+                            public ModelListenerSample {\r
+public:\r
+  TraingCardPresenter();\r
+  virtual ~TraingCardPresenter() override;\r
+  static TraingCardPresenter *GetInstance(void);\r
+\r
+  void OnStart() override;\r
+  void OnPause() override;\r
+  void OnResume() override;\r
+  void OnStop() override;\r
+  // void OnTickEvent() override;\r
+  void Notify() override;\r
+\r
+  bool OpenSensor(ExerciseClass type);\r
+  bool ControlSensor(ExerciseState state);\r
+\r
+  void ModifiesTime();\r
+  void RefreshData(SportData *sportdata); // 更新数据\r
+\r
+  void UpdateTimeOfControl();\r
+  void UpdateTimeOfData();\r
+  void UpdateDataView();\r
+\r
+  /*蓝牙开启运动*/\r
+  #ifdef BLE_SERVER_ENABLE\r
+  bool send_sport_cmd(training_ble *cmd);\r
+  #endif\r
+\r
+\r
+  /*控制*/\r
+  void handleStartState();\r
+  void handleEndState();\r
+  void handlePauseState();\r
+  void handleContinueState();\r
+\r
+private:\r
+  // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+  bool OnClick(UIView &view, const ClickEvent &event) override;\r
+  bool OnDrag(UIView &view, const DragEvent &event) override;\r
+  void OnSwipe(UISwipeView &view) override;\r
+  bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+\r
+  int tag_ = 0;\r
+  bool opensensorstuats{false};\r
+  // bool OnDragEnd(UIView& view, const DragEvent& event) override;\r
+};\r
+} // namespace OHOS\r
+\r
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingCardView.h
new file mode 100644 (file)
index 0000000..a921c84
--- /dev/null
@@ -0,0 +1,146 @@
+/***\r
+ * @Date: 2024-04-15 11:46:23\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-04-29 11:13:01\r
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h\r
+ */\r
+#ifndef _TraingCard_VIEW_H\r
+#define _TraingCard_VIEW_H\r
+\r
+\r
+#include "View.h"\r
+#include <ui_scroll_view.h>\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_label.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_button.h"\r
+#include "components/ui_image_animator.h"\r
+#include "components/ui_label_button_ext.h"\r
+#include "components/ui_chart.h"\r
+#include "components/ui_list.h"\r
+#include "components/icon_adapter.h"\r
+#include "wearable_log.h"\r
+#include "ohos_types.h"\r
+#include "components/ui_card_page.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "traing/Training_UiConfig.h"\r
+#include "components/ui_swipe_view.h"\r
+#include "components/ui_cross_view.h"\r
+\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "traing/Training_UiConfig.h"\r
+#include "traing/training_card/include/TraingCardPresenter.h"\r
+\r
+#include "PlayersView.h"\r
+#include "traing/training_card/include/TraingDataAllView.h"\r
+#include "traing/training_card/include/TrainingControlView.h"\r
+#include "traing/training_card/include/TrainingDataView.h"\r
+#include "traing/training_card/include/TrainingDetailView.h"\r
+\r
+#include "alipay/include/AlipayModel.h"\r
+namespace OHOS\r
+{\r
+#define BUTTONEXIT "button_exit"\r
+#define BUTTONBACK "button_back"\r
+#define BUTTONWINOK "buttom_win"\r
+#define BUTTONNOTE "button_heart"\r
+\r
+    enum Control_Card\r
+    {\r
+        CONTROL = 0,\r
+        DATA,\r
+        MUSIC\r
+    };\r
+    enum PopupType\r
+    {\r
+        EndPopup,    // 结束训练弹窗\r
+        GetTagPopup, // 达到训练目标弹窗\r
+        HeartPopup,  // 达到最高心率弹窗\r
+    };\r
+    class TraingCardPresenter;\r
+    class TrainingControlView;\r
+    class TrainingDataView;\r
+    class TrainingDetailView;\r
+    class PlayersView;\r
+    class TraingCardView : public View<TraingCardPresenter>\r
+    {\r
+\r
+    public:\r
+        TraingCardView();\r
+        virtual ~TraingCardView();\r
+        static TraingCardView *GetInstance(void);\r
+\r
+        void OnStart() override;\r
+     \r
+\r
+        UICardPage *InitControlPage(void);\r
+        UICardPage *InitDataPage(void);\r
+        UICardPage *InitMusicPage(void);\r
+\r
+        UICardPage *InitDetailPage(void);\r
+\r
+        void InitView();\r
+        void DeInit();\r
+        void InitList();\r
+        void PreLoad(void);\r
+\r
+        void InitImageAnimator();\r
+        void ShowGetTagView();\r
+        void ShowEndView();\r
+        void ShowHeartView();\r
+        bool RefreshEndView();\r
+        UICrossView *GetTraingCrad();\r
+        int GetCurrentPage();\r
+        void SetPopupViewStatus(PopupType type, bool status);\r
+        UIImageAnimatorView *GetAnimator();\r
+        UILabelExt *GetHeartMaxLabel();\r
+        void SetHeartMaxLabel(int maxheart);\r
+\r
+    private:\r
+        UIView::OnDragListener *draglistener{nullptr};\r
+        TraingCardView(TraingCardView &&) = delete;\r
+        TraingCardView &operator=(TraingCardView &&) = delete;\r
+\r
+        UICrossView *swipe_ = nullptr;\r
+        UIScrollView *endView{nullptr};\r
+        UIScrollView *getView{nullptr};\r
+        UIScrollView *heartView{nullptr};\r
+        TrainingControlView *controlview_{nullptr}; // 控制卡片\r
+        TraingDataAllView *dataallview_{nullptr};      // 数据卡片\r
+        TrainingDetailView *DetailView{nullptr};   // 详细数据卡片\r
+        PlayersView *musicview_{nullptr};           // 音乐卡片\r
+\r
+        /*结束弹窗*/\r
+        UILabelExt *endtitle{nullptr};  // 结束弹窗title\r
+        UILabelExt *notelabel{nullptr}; // 提醒label\r
+        UILabelExt *endnote{nullptr};   // 是否结束\r
+        UILabelExt *endnotelabel{nullptr};\r
+        UIButton *exit{nullptr}; // 退出按键\r
+        UIButton *back{nullptr}; // 返回按键\r
+\r
+        /*达成训练目标弹窗*/\r
+        UILabelExt *labeltitle = nullptr;\r
+        UILabelExt *labeltag = nullptr;\r
+        UILabelExt *labelgettag = nullptr;\r
+        UILabelExt *labelpre = nullptr;\r
+        UILabelButtonExt *buttonok_ = nullptr;\r
+        UIImageAnimatorView *imageAnimator{nullptr};\r
+\r
+        /*最高心率提醒弹窗*/\r
+        UILabelExt *hearttitle = nullptr;\r
+        UILabelExt *labelnote = nullptr;\r
+        UIImageView *heartiamge = nullptr;\r
+        UILabelButtonExt *buttonnote_ = nullptr;\r
+\r
+        bool viewiInitStatus{false};\r
+        bool momentumFlag{false};\r
+\r
+        std::string winbasePath = "/user/res/Training/training_GIF/win/";\r
+        const ImageInfo **winimageInfos;\r
+        ImageAnimatorInfo *winimageAnimatorInfo{nullptr};\r
+    };\r
+} // namespace OHOS\r
+#endif // TraingCard_PRESENTER_H\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingDataAllView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TraingDataAllView.h
new file mode 100644 (file)
index 0000000..85c6fad
--- /dev/null
@@ -0,0 +1,75 @@
+/***
+ * @Date: 2024-06-25 10:41:08
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-09-02 09:22:33
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/TraingDataAll/include/TraingDataAllView.h
+ */
+
+#ifndef TRAING_DATA_ALL__VIEW_H
+#define TRAING_DATA_ALL__VIEW_H
+
+
+#include "View.h"
+#include "components/ui_swipe_view.h"
+#include "traing/training_card/include/TraingCardPresenter.h"
+#include "traing/training_card/include/TrainingDataView.h"
+#include "traing/training_card/include/TrainingDetailView.h"
+
+#include "components/ui_card_page.h"
+namespace OHOS {
+
+typedef enum {
+  TRAING_DATA_ALL_MAIN_VIEW = 0, // Heart rate time data chart
+  TRAING_DATA_ALL_DETAIL_VIEW,   // Detailed view
+  TRAING_DATA_ALL_MAX_VIEW,
+} TraingDataAllPageId;
+
+#define TRAING_DATA_ALL_VIEW "TraingDataAllView"
+
+class TraingCardPresenter;
+class TrainingDataView;
+class TrainingDetailView;
+
+class TraingDataAllView : public UICardPage {
+public:
+  TraingDataAllView();
+  virtual ~TraingDataAllView();
+
+  static TraingDataAllView *GetInstance(void);
+
+  UISwipeView *TraingDataAllViewInit(void);
+  void ClearAll(void);
+
+  AppGroupView *TraingDataPageInit(void);
+  AppGroupView *TraingDetailPageInit(void);
+
+  TrainingDataView *GetTrainingDataView(void);
+  TrainingDetailView *GetTrainingDetailView(void);
+
+  UISwipeView *GetTraingDataAllPageView(void);
+  void ChangeView(int16_t hideView, int16_t showView);
+
+  void InitPage(void);
+
+  void PreLoad(void) override;
+  void UnLoad(void) override;
+  bool InitView(void);
+
+private:
+  TrainingDataView *trainingDataView{nullptr};
+  TrainingDetailView *trainingDetailView{nullptr};
+  TraingDataAllView *trainingDataAllView{nullptr};
+  UISwipeView *traingDataAllPageView{nullptr};
+
+  int16_t maxPage = TRAING_DATA_ALL_MAX_VIEW;
+  UISwipeView *TraingDataAllSwipeViewList{nullptr};
+  AppGroupView *recordCard[TRAING_DATA_ALL_MAX_VIEW]{nullptr};
+
+  AppGroupView *CreatePage(uint8_t pageId);
+  bool viewiInitStatus{false};
+};
+
+} // namespace OHOS
+
+#endif // TRAING_DATA_ALL__VIEW_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingControlView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingControlView.h
new file mode 100644 (file)
index 0000000..4d67223
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved.
+ * Description: TrainingControlView.h
+ * Author:
+ * Create: 2022-04-02
+ */
+
+#ifndef Training_CONTROL_VIEW_H
+#define Training_CONTROL_VIEW_H
+
+#include "components/root_view.h"
+#include "UiConfig.h"
+#include "components/ui_card_page.h"
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_card_page.h"
+#include "traing/training_card/include/TraingCardPresenter.h"
+#include "traing/training_card/include/TrainingControlView.h"
+namespace OHOS
+{
+#define BUTTONEND "buttonend"
+#define BUTTONSTOP "buttonstop"
+#define BUTTONCONTINUE "button3"
+    class TrainingControlView : public UICardPage
+    {
+    public:
+        TrainingControlView();
+        virtual ~TrainingControlView();
+        static TrainingControlView *GetInstance(void);
+
+        void InitView(void);
+        void DeInit();
+
+        void PreLoad(void) override;
+        void UnLoad(void) override;
+
+        // 通过函数改变
+        UILabelExt *GetLabel();
+        UIButton *GetButton();
+
+        UILabelExt *GetTimeLabel();
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        bool viewiInitStatus{false};
+
+        UIButton *buttonEnd = nullptr;  // 结束按键
+        UIButton *buttonStop = nullptr; // 暂停按键
+
+        UILabelExt *labeltimer = nullptr; // 计时timer
+        UILabelExt *labelend = nullptr;
+        UILabelExt *labelstop = nullptr;
+        UILabelExt *labeltitle = nullptr;
+
+        UIImageView *imagepoint = nullptr;
+
+        void ClearAll(void);
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingDataView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingDataView.h
new file mode 100644 (file)
index 0000000..45a6ea1
--- /dev/null
@@ -0,0 +1,86 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-02 09:56:04
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h
+ */
+#ifndef _TrainingData_VIEW_H
+#define _TrainingData_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "components/ui_circle_progress.h"
+
+#include "AppGroupView.h"
+#include "components/ui_card_page.h"
+#include "ohos_types.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/training_card/include/TrainingDataView.h"
+#include "traing/training_card/include/TraingCardPresenter.h"
+namespace OHOS
+{
+#define BUTTONNOTE "button1"
+
+class TrainingDataView : public AppGroupView {
+public:
+  TrainingDataView();
+  virtual ~TrainingDataView();
+  static TrainingDataView *GetInstance(void);
+  bool InitPage(void);
+  virtual bool InitView(void *caller) override;
+  void DeInit();
+
+  UILabelExt *GetTimeLabel();
+  UILabelExt *GetHeartLabel();
+  UICircleProgress *GetProgress();
+
+  void UpdataTime();
+
+private:
+  UIView::OnDragListener *draglistener{nullptr};
+  TrainingDataView(TrainingDataView &&) = delete;
+  TrainingDataView &operator=(TrainingDataView &&) = delete;
+
+
+  UILabelExt *curtimelabel = nullptr; // 当前时间
+  UILabelExt *sportlabel = nullptr;   // 运动项目名称
+  UILabelExt *timerlabel = nullptr;   // 计时
+  UILabelExt *heartlabel = nullptr;   // 运动实时心率
+  UILabelExt *ubpmlabel = nullptr;    // 运动强度
+
+  UIImageView *image_progress = nullptr;
+  UIImageView *image_heart = nullptr;
+  UIImageView *image_lowIntensity = nullptr;       // 低等强度
+  UIImageView *image_mediumIntensity = nullptr;    // 中等强度
+  UIImageView *image_highIntensity = nullptr;      // 高等强度
+  UIImageView *image_superHighIntensity = nullptr; // 超高等强度
+
+  UICircleProgress *circleProgress = nullptr;
+
+  UIImageView *image_iconup = nullptr;
+  UIImageView *image_iconpoint = nullptr;
+
+  UIButton *buttonNote = nullptr; // 注意事项按键
+  bool viewiInitStatus{false};
+};
+} // namespace OHOS
+#endif // TraingData_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingDetailView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/TrainingDetailView.h
new file mode 100644 (file)
index 0000000..6903088
--- /dev/null
@@ -0,0 +1,76 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-22 09:43:01
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h
+ */
+#ifndef _TrainingDetail_VIEW_H
+#define _TrainingDetail_VIEW_H
+
+
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "traing/Training_UiConfig.h"
+
+#include "traing/training_card/include/TrainingDetailView.h"
+#include "traing/training_card/include/TraingCardPresenter.h"
+namespace OHOS
+{
+
+class TrainingDetailView : public AppGroupView {
+public:
+  TrainingDetailView();
+  virtual ~TrainingDetailView();
+  static TrainingDetailView *GetInstance(void);
+
+  void DeInit();
+
+  bool InitPage(void);
+  virtual bool InitView(void *caller) override;
+
+  UILabelExt *GetMileLabel();
+  UILabelExt *GetStepLabel();
+  UILabelExt *GetCalorieLabel();
+  UILabelButtonExt *Get_Intensity_Button();
+
+private:
+  UIView::OnDragListener *draglistener{nullptr};
+  TrainingDetailView(TrainingDetailView &&) = delete;
+  TrainingDetailView &operator=(TrainingDetailView &&) = delete;
+
+
+  UILabelButtonExt *intensity_button{nullptr};
+
+  UILabelExt *u_milelabel = nullptr;
+  UILabelExt *u_stepslabel = nullptr;
+  UILabelExt *u_calorielabel = nullptr;
+  UILabelExt *milelabel = nullptr;
+  UILabelExt *steplabel = nullptr;
+  UILabelExt *calorielabel = nullptr;
+
+  UIImageView *progress_image = nullptr;
+  UIImageView *lineimage2_ = nullptr;
+
+  bool viewiInitStatus{false};
+};
+} // namespace OHOS
+#endif // TraingDetail_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/Training_CardPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/Training_CardPresenter.h
new file mode 100644 (file)
index 0000000..0f3517d
--- /dev/null
@@ -0,0 +1,32 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-22 14:43:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 16:40:54
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/Training_Card/include/Training_CardPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef Training_Card_PRESENTER_H
+#define Training_Card_PRESENTER_H
+#include "components/ui_view.h"
+namespace OHOS
+{
+    class TraingOnClickListener : public UIView::OnClickListener
+    {
+    public:
+        TraingOnClickListener() {}
+        TraingOnClickListener(UIView *view) : view_(view) {}
+        ~TraingOnClickListener(){};
+        static TraingOnClickListener *GetInstance()
+        {
+            static TraingOnClickListener instance;
+            return &instance;
+        }
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+
+    private:
+        UIView *view_{nullptr};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/Training_CardView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/include/Training_CardView.h
new file mode 100644 (file)
index 0000000..e99dc92
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef _Training_Card_VIEW_H
+#define _Training_Card_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_button.h"
+#include "components/ui_card_page.h"
+#include "components/ui_chart.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "ohos_types.h"
+#include "traing/training_card/include/Training_CardView.h"
+#include "wearable_log.h"
+#include <ui_scroll_view.h>
+namespace OHOS {
+
+#define BUTTON1 "button1"       // 按键1
+#define BUTTON2 "button2"       // 按键2
+#define BUTTON3 "button3"       // 按键3
+#define BUTTONMORE "buttonmore" // 按键 更多
+
+class TraingPresenter;
+class Training_CardView : public UICardPage {
+public:
+  Training_CardView();
+  virtual ~Training_CardView();
+  static Training_CardView *GetInstance(void);
+
+  void PreLoad(void) override;
+  void UnLoad(void) override;
+
+  bool AddLabel();
+  bool AddButton();
+  bool AddImageView();
+  void InitView();
+  void DeInitView();
+
+  UIView *GetView();
+  bool InitPage(void);
+
+private:
+  Training_CardView(Training_CardView &&) = delete;
+  Training_CardView &operator=(Training_CardView &&) = delete;
+
+  UIButton *buttonmore_ = nullptr;
+  UIButton *button1_ = nullptr;
+  UIButton *button2_ = nullptr;
+  UIButton *button3_ = nullptr;
+
+  UILabelExt *title_label = nullptr;
+  UILabelExt *btn1_label = nullptr;
+  UILabelExt *btn2_label = nullptr;
+  UILabelExt *btn3_label = nullptr;
+  UILabelExt *btnmore_label = nullptr;
+
+  UIImageView *btn1_image = nullptr;
+  UIImageView *btn2_image = nullptr;
+  UIImageView *btn3_image = nullptr;
+  UIImageView *btnmore_image = nullptr;
+
+  bool viewiInitStatus{false};
+};
+} // namespace OHOS
+#endif // Traing_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp
new file mode 100644 (file)
index 0000000..a9d959a
--- /dev/null
@@ -0,0 +1,559 @@
+/***\r
+ * @Date: 2024-07-06 16:27:31\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-08-02 10:21:14\r
+ * @FilePath:\r
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp\r
+ */\r
+/***\r
+ * @Date: 2024-04-26 09:23:18\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-04-26 10:25:05\r
+ * @FilePath:\r
+ * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp\r
+ */\r
+\r
+#include "AppViewIDs.h"\r
+#include "NativeAbility.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+\r
+#include "ConfigModel.h"\r
+#include "custom_utils.h"\r
+#include "graphic_service.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "traing/training_card/include/TraingCardPresenter.h"\r
+#include "traing/training_card/include/TrainingControlView.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "vibrator_service.h"\r
+\r
+#include <chrono>\r
+#include <iomanip>\r
+#include <iostream>\r
+#include <sstream>\r
+#include <thread>\r
+#include <unordered_map>\r
+\r
+extern "C" void do_cywee_service_check_msg(int cmd, int data[]);\r
+\r
+#define MAXSPORTID 176\r
+\r
+#define DEFAULT_DASH "--"\r
+#define DATATEST 0\r
+\r
+extern "C" {\r
+void StartTimer();\r
+void StopAndResetTimer();\r
+void PauseTimer();\r
+void ResumeTimer();\r
+}\r
+#include "NativeRegisterManager.h"\r
+namespace OHOS\r
+{\r
+\r
+    REGIST_SLICE(VIEW_TRAININGCRAD, TraingCardView, TraingCardPresenter);\r
+\r
+// 当前Presenter属性实例化的内存指针\r
+static TraingCardPresenter *g_pTraingCardPresenter = nullptr;\r
+\r
+TraingCardPresenter::TraingCardPresenter() { g_pTraingCardPresenter = this; }\r
+\r
+TraingCardPresenter::~TraingCardPresenter() {\r
+  // tag_ = 0;\r
+  g_pTraingCardPresenter = nullptr;\r
+}\r
+\r
+TraingCardPresenter *TraingCardPresenter::GetInstance() {\r
+  static TraingCardPresenter instance;\r
+  return &instance;\r
+}\r
+\r
+void TraingCardPresenter::OnStart() {\r
+  Presenter<TraingCardView>::OnStart();\r
+  // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏\r
+}\r
+\r
+void TraingCardPresenter::OnPause(void) {\r
+\r
+  Presenter<TraingCardView>::OnPause();\r
+}\r
+\r
+void TraingCardPresenter::OnResume(void) {\r
+\r
+  Presenter<TraingCardView>::OnResume();\r
+}\r
+\r
+void TraingCardPresenter::OnStop(void) {\r
+\r
+  Presenter<TraingCardView>::OnStop();\r
+  // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 长亮屏\r
+}\r
+\r
+bool TraingCardPresenter::OnDrag(UIView &view, const DragEvent &event) {\r
+  UNUSED(view);\r
+  return true;\r
+}\r
+\r
+// 计时器更新timer\r
+void TraingCardPresenter::ModifiesTime() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime begin");\r
+  std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
+\r
+  /*灭屏状态不刷新UI*/\r
+  if (uapi_get_screen_state() == 1) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state is off");\r
+    return;\r
+  }\r
+\r
+  if (TimeStr.empty()) {\r
+    WEARABLE_LOGE(\r
+        WEARABLE_LOG_MODULE_APP,\r
+        "TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
+    return;\r
+  }\r
+  if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) {\r
+    TrainingControlView::GetInstance()->GetTimeLabel()->SetText(\r
+        TimeStr.c_str());\r
+  }\r
+  if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr) {\r
+    TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str());\r
+  }\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime end");\r
+}\r
+\r
+//计时器\r
+void TraingCardPresenter::UpdateTimeOfControl() {\r
+  std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
+  if (TimeStr.empty()) {\r
+    WEARABLE_LOGE(\r
+        WEARABLE_LOG_MODULE_APP,\r
+        "TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
+    return;\r
+  }\r
+  if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) {\r
+    TrainingControlView::GetInstance()->GetTimeLabel()->SetText(\r
+        TimeStr.c_str());\r
+  }\r
+}\r
+void TraingCardPresenter::UpdateTimeOfData() {\r
+  std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
+  if (TimeStr.empty()) {\r
+    WEARABLE_LOGE(\r
+        WEARABLE_LOG_MODULE_APP,\r
+        "TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
+    return;\r
+  }\r
+  if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr) {\r
+    TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str());\r
+  }\r
+}\r
+\r
+/* --------------------------------- cywee库操作\r
+ * -------------------------------- */\r
+/*开启cywee*/\r
+bool TraingCardPresenter::OpenSensor(ExerciseClass type) {\r
+  // // 防止重复开启\r
+  // if (opensensorstuats) {\r
+  //   WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OpenSensor is opening!!");\r
+  //   return false;\r
+  // }\r
+  // // 根据不同的运动项目进行不同的运动\r
+  // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardPresenter::OpenSensor!!");\r
+  // switch (type) {\r
+  // case ExerciseClass::NORMAL:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE, NULL);\r
+  //   break;\r
+  // case ExerciseClass::TREADMILL:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TREADMILL_MODE, NULL);\r
+  //   break;\r
+  // case ExerciseClass::OUTDOOR:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OUTDOOR_RUNNING_MODE, NULL);\r
+  //   break;\r
+  // case ExerciseClass::INDOOR:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_INDOOR_RUNNING_MODE, NULL);\r
+  //   break;\r
+  // case ExerciseClass::FITNESS_PEDOMETER:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_FITNESS_PEDOMETER_MODE, NULL);\r
+  //   break;\r
+  // case ExerciseClass::FREE_TRAINING:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_FREE_TRAINING_MODE, NULL);\r
+  //   break;\r
+  // default:\r
+  //   break;\r
+  // }\r
+  // opensensorstuats = true;\r
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OpenSensor--%d!!", type);\r
+  return true;\r
+}\r
+\r
+/*控制cywee*/\r
+bool TraingCardPresenter::ControlSensor(ExerciseState state) {\r
+  switch (state) {\r
+  // case ExerciseState::End:\r
+  //   // 退出进入普通模式\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE, NULL);\r
+  //   opensensorstuats = false; // 恢复标志位\r
+  //   StopAndResetTimer();      // 关闭计时器\r
+  //   break;\r
+  // case ExerciseState::Pause:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_PAUSE, 0);\r
+  //   break;\r
+  // case ExerciseState::Continue:\r
+  //   do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESUME, 0);\r
+  //   break;\r
+  default:\r
+    break;\r
+  }\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ControlSensor[%d]!!", state);\r
+  return true;\r
+}\r
+\r
+void TraingCardPresenter::RefreshData(SportData *sportdata) {\r
+  if (sportdata == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata is null");\r
+    return;\r
+  }\r
+  std::string distanceStr;\r
+  if (sportdata->distance != 0) {\r
+    double distance_km =\r
+        sportdata->distance / 1000.0; // 转换为公里并保留两位小数\r
+    std::stringstream ss;\r
+    ss << std::fixed << std::setprecision(2) << distance_km;\r
+    distanceStr = ss.str();\r
+  } else {\r
+    distanceStr = DEFAULT_DASH;\r
+  }\r
+\r
+  std::string heartStr =\r
+      (sportdata->heart != 0) ? std::to_string(sportdata->heart) : DEFAULT_DASH;\r
+  std::string stepsStr =\r
+      (sportdata->steps != 0) ? std::to_string(sportdata->steps) : DEFAULT_DASH;\r
+  std::string calorieStr = (sportdata->calories != 0)\r
+                               ? std::to_string(sportdata->calories)\r
+                               : DEFAULT_DASH;\r
+  // 训练强度刷新\r
+  UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity();\r
+  // printf("intensityid %d \r\n", intensityid);\r
+  TrainingDetailView::GetInstance()->Get_Intensity_Button()->SetTextId(\r
+      intensityid);\r
+\r
+  TrainingDataView::GetInstance()->GetProgress()->SetValue(\r
+      sportdata->goaldegree); // 目标完成度\r
+  TrainingDataView::GetInstance()->GetHeartLabel()->SetText(\r
+      heartStr.c_str()); // 心率\r
+  TrainingDetailView::GetInstance()->GetCalorieLabel()->SetText(\r
+      calorieStr.c_str()); // 卡路里\r
+  TrainingDetailView::GetInstance()->GetMileLabel()->SetText(\r
+      distanceStr.c_str()); // 距离\r
+  TrainingDetailView::GetInstance()->GetStepLabel()->SetText(\r
+      stepsStr.c_str()); // 步数\r
+\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,\r
+                "[Calories: %s, Distance: %s, Steps: %s Intensityid: %d]",\r
+                calorieStr.c_str(), distanceStr.c_str(), stepsStr.c_str(),\r
+                intensityid);\r
+  // 释放sportdata内存\r
+}\r
+#if 0\r
+    /*刷新 time 和 data */\r
+    void TraingCardPresenter::OnTickEvent()\r
+    {\r
+        // 未开启训练 直接退出\r
+        if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General)\r
+            return;\r
+        // 刷新训练数据界面 现实时间\r
+        TrainingDataView::GetInstance()->UpdataTime();\r
+        // 刷新训练数据界面 心率 卡路里 距离 步数 训练强度 目标完成度\r
+        RefreshData();\r
+    }\r
+#endif\r
+#if 1\r
+void TraingCardPresenter::Notify(void) {\r
+  // 如果未开启训练,直接退出\r
+  if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) {\r
+    return;\r
+  }\r
+\r
+  Control_Card cardId = static_cast<Control_Card>(view_->GetCurrentPage());\r
+\r
+  switch (cardId) {\r
+  case Control_Card::CONTROL: {\r
+    UpdateTimeOfControl(); // 更新控制界面的时间\r
+    break;\r
+  }\r
+  case Control_Card::DATA: {\r
+    UpdateDataView(); // 更新训练数据视图\r
+    break;\r
+  }\r
+  default:\r
+    break; // 其他情况不处理\r
+  }\r
+}\r
+\r
+void TraingCardPresenter::UpdateDataView() {\r
+  // 刷新计时\r
+  UpdateTimeOfData();\r
+\r
+  // 刷新训练数据视图,显示当前时间\r
+  GraphicService::GetInstance()->PostGraphicEvent(std::bind(\r
+      &TrainingDataView::UpdataTime, TrainingDataView::GetInstance()));\r
+\r
+  TraingModel::GetInstance()->updata_goal();\r
+\r
+  // 刷新训练数据:心率、卡路里、距离、步数、训练强度、目标完成度\r
+  SportData *sportdata = TraingModel::GetInstance()->GetSportdata();\r
+  RefreshData(sportdata);\r
+}\r
+#endif\r
+/* --------------------------------- 点击事件处理\r
+ * --------------------------------- */\r
+bool TraingCardPresenter::OnClick(UIView &view, const ClickEvent &event) {\r
+  const std::string viewId = view.GetViewId();\r
+\r
+  // 定义点击事件映射\r
+  static const std::unordered_map<std::string, std::function<void()>>\r
+      actionMap = {\r
+          // 暂停按键\r
+          {BUTTONSTOP,\r
+           [&]() {\r
+             auto currentState = TraingModel::GetInstance()->GetSportState();\r
+             if (currentState == ExerciseState::Continue ||\r
+                 currentState == ExerciseState::Start) {\r
+               handlePauseState();\r
+             } else if (currentState == ExerciseState::Pause) {\r
+               handleContinueState();\r
+             }\r
+           }},\r
+          // 结束按键\r
+          {BUTTONEND,\r
+           [&]() {\r
+             //  ControlSensor(ExerciseState::Pause);\r
+             TraingCardView::GetInstance()->SetPopupViewStatus(EndPopup, true);\r
+             TraingCardView::GetInstance()->RefreshEndView();\r
+           }},\r
+          // 确定结束\r
+          {BUTTONEXIT, [&]() { handleEndState(); }},\r
+          // 返回\r
+          {BUTTONBACK,\r
+           [&]() {\r
+             //  ControlSensor(ExerciseState::Continue);\r
+             TraingCardView::GetInstance()->SetPopupViewStatus(EndPopup, false);\r
+           }},\r
+          // 确定达到目标\r
+          {BUTTONWINOK,\r
+           [&]() {\r
+             TraingCardView::GetInstance()->GetAnimator()->Stop();\r
+             TraingCardView::GetInstance()->SetPopupViewStatus(GetTagPopup,\r
+                                                               false);\r
+           }},\r
+          // 确定心率提醒\r
+          {BUTTONNOTE,\r
+           [&]() {\r
+             TraingCardView::GetInstance()->SetPopupViewStatus(HeartPopup,\r
+                                                               false);\r
+           }},\r
+      };\r
+\r
+  // 查找并执行对应的操作\r
+  auto it = actionMap.find(viewId);\r
+  if (it != actionMap.end()) {\r
+    it->second(); // 执行操作\r
+    return true;\r
+  }\r
+\r
+  return false; // 没有匹配的操作\r
+}\r
+void TraingCardPresenter::OnSwipe(UISwipeView &view) {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnSwipe ");\r
+  UNUSED(view);\r
+  return;\r
+}\r
+bool TraingCardPresenter::OnKeyAct(UIView &view, const KeyEvent &event) {\r
+  /*消耗按键事件*/\r
+  return true;\r
+}\r
+/* -------------------------------- 协议发起运动处理\r
+ * -------------------------------- */\r
+\r
+ #ifdef BLE_SERVER_ENABLE\r
+bool TraingCardPresenter::send_sport_cmd(training_ble *cmd) {\r
+  if (cmd == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "无效的运动命令 cmd 为空!");\r
+    return false;\r
+  }\r
+\r
+  // 获取当前的运动状态\r
+  ExerciseState currentState = TraingModel::GetInstance()->GetSportState();\r
+  ExerciseState cmdstate = static_cast<ExerciseState>(cmd->controlmd);\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cmdstate:%d currentState:%d",\r
+                cmdstate, currentState);\r
+  int m_sportTag = 0;\r
+  switch (cmd->controlmd) {\r
+  case SETGOAL:\r
+    // 仅在一般状态下允许设置目标\r
+    if (currentState == ExerciseState::General) {\r
+      if (cmd->sportTagType == 0) {\r
+        //训练目标->m 需要转换 km\r
+        m_sportTag = cmd->sportTag / 1000;\r
+      } else {\r
+        m_sportTag = cmd->sportTag;\r
+      }\r
+      TraingModel::GetInstance()->SetSportTag(\r
+          static_cast<ExerciseTag>(cmd->sportTagType), m_sportTag);\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目标设置成功!\r\n");\r
+      return true;\r
+    }\r
+    break;\r
+\r
+  case SENDDATA:\r
+    // 随时允许发送实时数据\r
+    TraingModel::GetInstance()->SendLiveData();\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "实时数据发送成功!\r\n");\r
+    return true;\r
+\r
+  default:\r
+    break;\r
+  }\r
+\r
+  // 仅在一般状态下允许开始运动\r
+  if (cmdstate == ExerciseState::Start) {\r
+    if ((currentState == ExerciseState::General)) {\r
+      if (TraingCardView::GetInstance() == nullptr) {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ble 开启运动");\r
+        uapi_set_screen_on_api(); // 亮屏\r
+        NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);\r
+        // 设置目标类型和项目有且只有一次\r
+        switch (cmd->sportType) {\r
+        case 0:\r
+          TraingModel::GetInstance()->SetSportEvent(\r
+              STR_EXERCISE_OUTDOORWALKING);\r
+          OpenSensor(ExerciseClass::OUTDOOR);\r
+          break;\r
+        case 1:\r
+          TraingModel::GetInstance()->SetSportEvent(\r
+              STR_EXERCISE_OUTDOORRUNNING);\r
+          OpenSensor(ExerciseClass::OUTDOOR);\r
+          break;\r
+        case 2:\r
+          TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORBIKING);\r
+          OpenSensor(ExerciseClass::FREE_TRAINING);\r
+          break;\r
+        default:\r
+          break;\r
+        }\r
+      }\r
+      reply_APP_OpenSportModeCmd(true);\r
+      handleStartState();\r
+      return true;\r
+    } else {\r
+\r
+      reply_APP_OpenSportModeCmd(false);\r
+      // return false;\r
+    }\r
+  }\r
+  // 仅在运动状态为开始或继续时允许暂停\r
+  if (cmdstate == ExerciseState::Pause) {\r
+    if (currentState == ExerciseState::Start ||\r
+        currentState == ExerciseState::Continue) {\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ble 暂停运动");\r
+      reply_APP_SportPasueResetCmd(TraingModel::GetInstance()->GetSportTime());\r
+      handlePauseState();\r
+      return true;\r
+    }\r
+  }\r
+\r
+  // 仅在暂停状态下允许恢复运动\r
+  if (cmdstate == ExerciseState::Continue &&\r
+      currentState == ExerciseState::Pause) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ble 恢复运动");\r
+    reply_APP_SportPasueResetCmd(TraingModel::GetInstance()->GetSportTime());\r
+    handleContinueState();\r
+    return true;\r
+  }\r
+\r
+  // 仅在运动状态为开始、继续或暂停时允许结束运动\r
+  if (cmdstate == ExerciseState::End &&\r
+      (currentState == ExerciseState::Start ||\r
+       currentState == ExerciseState::Continue ||\r
+       currentState == ExerciseState::Pause)) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ble 结束运动");\r
+    uint32_t sport_time = TraingModel::GetInstance()->GetSportTime();\r
+    reply_APP_SportStopModeCmd(sport_time);\r
+    handleEndState();\r
+    return true;\r
+  }\r
+\r
+  // 如果到达这里,命令未执行\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
+                "cmd->sportType[%d],cmd->controlmd[%d],cmd->sportTagType[%d],"\r
+                "cmd->sportTag[%d]\r\n",\r
+                cmd->sportType, cmd->controlmd, cmd->sportTagType,\r
+                cmd->sportTag);\r
+\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
+                "由于状态限制,命令未执行 当前状态 %d。\r\n", currentState);\r
+  return false; // 没有执行任何命令\r
+}\r
+#endif\r
+\r
+\r
+/*训练结束*/\r
+void TraingCardPresenter::handleEndState() {\r
+  TraingModel::GetInstance()->SetSportState(ExerciseState::End);\r
+  ControlSensor(ExerciseState::End);\r
+  uapi_set_screen_on_api(); // 亮屏\r
+#if DATATEST\r
+  // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA);\r
+  // 回退\r
+  NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);\r
+  return;\r
+#endif\r
+  // 是否达到训练目标\r
+  if (TraingModel::GetInstance()->GetMomentum()) {\r
+    // 进入训练详情\r
+    NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA);\r
+    NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素\r
+  } else {\r
+    // 进入训练记录\r
+    // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING_RECORD);\r
+    if (TraingModel::GetInstance()->GetEntryType() == APPLIST_ENTER)\r
+      NativeAbility::GetInstance().ChangeSlice(\r
+          VIEW_TRAINING, TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+    else {\r
+      NativeAbility::GetInstance().ChangeSlice(\r
+          VIEW_MAIN, TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+      NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素\r
+    }\r
+    NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素\r
+  }\r
+}\r
+\r
+/*训练暂停*/\r
+void TraingCardPresenter::handlePauseState() {\r
+  uapi_set_screen_on_api(); // 亮屏\r
+  TrainingControlView::GetInstance()->GetLabel()->SetTextId(STR_RESUME);\r
+  TrainingControlView::GetInstance()->GetButton()->SetImageSrc(\r
+      SPORT_CONTINUE_IMAGE, SPORT_CONTINUE_IMAGE);\r
+  TraingModel::GetInstance()->SetSportState(ExerciseState::Pause);\r
+  PauseTimer();\r
+  ControlSensor(ExerciseState::Pause);\r
+}\r
+\r
+/*训练继续*/\r
+void TraingCardPresenter::handleContinueState() {\r
+  uapi_set_screen_on_api(); // 亮屏\r
+  TrainingControlView::GetInstance()->GetLabel()->SetTextId(STR_PAUSE);\r
+  TrainingControlView::GetInstance()->GetButton()->SetImageSrc(\r
+      SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE);\r
+  TraingModel::GetInstance()->SetSportState(ExerciseState::Continue);\r
+  ResumeTimer();\r
+  ControlSensor(ExerciseState::Continue);\r
+}\r
+\r
+/*训练开始*/\r
+void TraingCardPresenter::handleStartState() {\r
+  ControlSensor(ExerciseState::Start);\r
+  TraingModel::GetInstance()->SetSportOpenWay(true);\r
+}\r
+\r
+} // namespace OHOS\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingCardView.cpp
new file mode 100644 (file)
index 0000000..49d42be
--- /dev/null
@@ -0,0 +1,1045 @@
+\r
+#include "traing/training_card/include/TraingCardView.h"\r
+#include "UiConfig.h"\r
+#include "common/image_cache_manager.h"\r
+#include "components/ui_button.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_image.h"\r
+#include "ui_resource_string.h"\r
+#include <ui_scroll_view.h>\r
+\r
+#include "common/screen.h"\r
+#include "components/ui_digital_clock.h"\r
+#include "components/ui_label.h"\r
+#include "components/ui_label_ext.h"\r
+#include "font/ui_font.h"\r
+\r
+#include "ConfigModel.h"\r
+#include "custom_utils.h"\r
+#include "languagecode/LanguageInit.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+\r
+extern "C" {\r
+void StartTimer();\r
+void StopAndResetTimer();\r
+void PauseTimer();\r
+}\r
+\r
+namespace OHOS {\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include "pm.h"\r
+#include "pm_veto.h"\r
+/*移除睡眠否决投票*/\r
+void uapi_remove_sport_vote(void) {\r
+  uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART);\r
+  if (cnt == 1) {\r
+    uapi_pm_remove_sleep_veto(PM_ID_HEART);\r
+  } else {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,\r
+                  "Sport SERVICE MCU has delete pm_id_Sport vote");\r
+  }\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE,\r
+                "Sport SERVICE MCU SLEEP SUCCESS");\r
+}\r
+\r
+/*添加睡眠否决投票*/\r
+void uapi_add_sport_vote(void) {\r
+  uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART);\r
+  if (cnt == 0) {\r
+    uapi_pm_add_sleep_veto(PM_ID_HEART);\r
+  } else {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,\r
+                  "Sport SERVICE MCU has got pm_id_Sport vote");\r
+  }\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE,\r
+                "Sport SERVICE MCU WAKEUP SUCCESS");\r
+}\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+static const uint16_t LABEL_FONT_SIZE = 200;\r
+static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6;\r
+static const uint32_t CARD_PAGE_COLOR = 0xffd0d0d0;\r
+\r
+// 动态刷新设置\r
+static constexpr uint16_t IMAGE_SIZE_X = 120;\r
+static constexpr uint16_t IMAGE_SIZE_Y = 120;\r
+static constexpr uint16_t IMAGE_POSITION_X = 173;\r
+static constexpr uint16_t IMAGE_POSITION_Y = 100;\r
+static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SIZE = 94;\r
+static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SPEED = 30;\r
+\r
+static ImageAnimatorInfo g_imageAnimatorInfo_trainingwin[94] = {\r
+    {PNG_TRAINING_WIN_IMAGE_01,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_02,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_03,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_04,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_05,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_06,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_07,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_08,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_09,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_10,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_11,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_12,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_13,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_14,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_15,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_16,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_17,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_18,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_19,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_20,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_21,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_22,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_23,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_24,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_25,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_26,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_27,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_28,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_29,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_30,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_31,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_32,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_33,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_34,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_35,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_36,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_37,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_38,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_39,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_40,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_41,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_42,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_43,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_44,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_45,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_46,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_47,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_48,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_49,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_50,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_51,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_52,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_53,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_54,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_55,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_56,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_57,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_58,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_59,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_60,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_61,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_62,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_63,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_64,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_65,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_66,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_67,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_68,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_69,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_70,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_71,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_72,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_73,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_74,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_75,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_76,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_77,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_78,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_79,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_80,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_81,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_82,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_83,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_84,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_85,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_86,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_87,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_88,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_89,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_90,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_91,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_92,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_93,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+    {PNG_TRAINING_WIN_IMAGE_94,\r
+     {IMAGE_POSITION_X, IMAGE_POSITION_Y},\r
+     IMAGE_SIZE_X,\r
+     IMAGE_SIZE_Y,\r
+     IMG_SRC_FILE_PATH},\r
+};\r
+\r
+static TraingCardView *g_pTraingCardView{nullptr};\r
+\r
+TraingCardView::TraingCardView() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView");\r
+  if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) {\r
+    StartTimer(); // 开启计时器\r
+    TraingModel::GetInstance()->SetSportState(\r
+        ExerciseState::Start); // 设置运动状态为开始\r
+    TraingModel::GetInstance()->SetTimestamp();\r
+    // uapi_add_sport_vote(); // 保护进程\r
+  }\r
+\r
+  g_pTraingCardView = this;\r
+}\r
+\r
+TraingCardView::~TraingCardView() {\r
+\r
+  DeInit();\r
+\r
+  g_pTraingCardView = nullptr;\r
+  if (TraingModel::GetInstance()->GetSportState() == ExerciseState::End) {\r
+    StopAndResetTimer(); // 关闭计时器\r
+    TraingModel::GetInstance()->SetTimestamp();\r
+  } else {\r
+    TraingModel::GetInstance()->SetSportState(ExerciseState::Pause);\r
+    PauseTimer();\r
+    TraingCardPresenter::GetInstance()->ControlSensor(ExerciseState::Pause);\r
+  }\r
+  // uapi_remove_sport_vote(); // 移除\r
+}\r
+\r
+TraingCardView *TraingCardView::GetInstance() { return g_pTraingCardView; }\r
+\r
+/* InitView:初始化界面*/\r
+void TraingCardView ::InitView() {\r
+\r
+  if (swipe_ == nullptr) {\r
+    swipe_ = new UICrossView();\r
+    swipe_->SetPosition(0, 0, 466, 466);\r
+    swipe_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
+  }\r
+\r
+  InitControlPage();\r
+  InitDataPage();\r
+  InitMusicPage();\r
+  InitDetailPage();\r
+\r
+  swipe_->HorAdd(controlview_);\r
+  swipe_->HorAdd(dataallview_);\r
+  swipe_->HorAdd(musicview_);\r
+\r
+  ShowEndView();\r
+  ShowGetTagView();\r
+  ShowHeartView();\r
+\r
+  //  swipe_->HorAdd(DetailView);\r
+  swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE);\r
+\r
+  swipe_->SetHorCurrentPage(Control_Card::DATA); // 设置进入索引 [数据]\r
+\r
+  UISwipeView::OnSwipeListener *onSwipeListener =\r
+      static_cast<UISwipeView::OnSwipeListener *>(\r
+          OHOS::TraingCardPresenter::GetInstance());\r
+  if (onSwipeListener == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "onSwipeListener is null");\r
+    return;\r
+  }\r
+  swipe_->SetOnSwipeListener(onSwipeListener);\r
+\r
+  RootView::GetInstance()->SetOnKeyActListener(presenter_);\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over");\r
+}\r
+\r
+/* DeInit:删除组件 */\r
+void TraingCardView::DeInit() {\r
+  swipe_->RemoveAll();\r
+\r
+  /*界面*/\r
+  controlview_->RemoveAll();\r
+  dataallview_->RemoveAll();\r
+  musicview_->RemoveAll();\r
+  endView->RemoveAll();\r
+  getView->RemoveAll();\r
+  heartView->RemoveAll();\r
+  DetailView->RemoveAll();\r
+\r
+  /*标签*/\r
+  delete endtitle;\r
+  endtitle = nullptr;\r
+  delete notelabel;\r
+  notelabel = nullptr;\r
+  delete endnotelabel;\r
+  endnotelabel = nullptr;\r
+  delete endnote;\r
+  endnote = nullptr;\r
+\r
+  delete labeltitle;\r
+  labeltitle = nullptr;\r
+  delete labeltag;\r
+  labeltag = nullptr;\r
+  delete labelgettag;\r
+  labelgettag = nullptr;\r
+  delete labelpre;\r
+  labelpre = nullptr;\r
+\r
+  delete hearttitle;\r
+  hearttitle = nullptr;\r
+  delete labelnote;\r
+  labelnote = nullptr;\r
+  /*图片*/\r
+  delete heartiamge;\r
+  heartiamge = nullptr;\r
+\r
+  /*按键*/\r
+  delete exit;\r
+  exit = nullptr;\r
+  delete back;\r
+  back = nullptr;\r
+  delete buttonok_;\r
+  buttonok_ = nullptr;\r
+  delete buttonnote_;\r
+  buttonnote_ = nullptr;\r
+\r
+  /*动画*/\r
+  if (imageAnimator) {\r
+    imageAnimator->Stop();\r
+    delete imageAnimator;\r
+    imageAnimator = nullptr;\r
+  }\r
+\r
+  /*卡片*/\r
+  delete controlview_;\r
+  controlview_ = nullptr;\r
+  delete dataallview_;\r
+  dataallview_ = nullptr;\r
+  delete musicview_;\r
+  musicview_ = nullptr;\r
+  delete DetailView; //删除屏蔽卡片\r
+  DetailView = nullptr;\r
+\r
+  /*弹窗*/\r
+  delete endView;\r
+  endView = nullptr;\r
+  delete getView;\r
+  getView = nullptr;\r
+  delete heartView;\r
+  heartView = nullptr;\r
+\r
+  delete swipe_;\r
+  swipe_ = nullptr;\r
+}\r
+UICardPage *TraingCardView::InitControlPage(void) {\r
+  controlview_ = new TrainingControlView();\r
+  // controlview_->PreLoad();\r
+  if (controlview_ == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "controlview_ new fail");\r
+    return nullptr;\r
+  }\r
+  return controlview_;\r
+}\r
+UICardPage *TraingCardView::InitDataPage(void) {\r
+  dataallview_ = new TraingDataAllView();\r
+  //   dataallview_->PreLoad();\r
+  if (dataallview_ == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dataallview_ new fail");\r
+    return nullptr;\r
+  }\r
+  return dataallview_;\r
+}\r
+UICardPage *TraingCardView::InitMusicPage(void) {\r
+  musicview_ = new PlayersView();\r
+  // musicview_->PreLoad();\r
+  if (musicview_ == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "musicview_ new fail");\r
+    return nullptr;\r
+  }\r
+  return musicview_;\r
+}\r
+UICardPage *TraingCardView::InitDetailPage() {\r
+  DetailView = new TrainingDetailView();\r
+  //   DetailView->PreLoad();\r
+  DetailView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),\r
+                          Screen::GetInstance().GetHeight());\r
+  DetailView->SetStyle(STYLE_BORDER_RADIUS, 466); // 设置为圆形\r
+  if (DetailView == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DetailView new fail");\r
+    return nullptr;\r
+  }\r
+  return DetailView;\r
+}\r
+void TraingCardView::PreLoad(void) {\r
+  if (!viewiInitStatus) {\r
+    InitView();\r
+    viewiInitStatus = true;\r
+  }\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView  PreLoad");\r
+}\r
+void TraingCardView::OnStart() {\r
+  View<TraingCardPresenter>::OnStart();\r
+\r
+  swipe_ = new UICrossView();\r
+  if (swipe_ == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new fail");\r
+    return;\r
+  }\r
+  UIView::OnDragListener *listener =\r
+      static_cast<UIView::OnDragListener *>(TraingCardPresenter::GetInstance());\r
+  if (listener == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
+                  "AlarmSetWeekView:: new alarmDragListener fail");\r
+    return;\r
+  }\r
+  swipe_->SetOnDragListener(listener);\r
+\r
+  PreLoad();\r
+  swipe_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),\r
+                      Screen::GetInstance().GetHeight());\r
+  swipe_->SetTouchable(true);\r
+  swipe_->SetDraggable(true);\r
+  swipe_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR);\r
+  swipe_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
+\r
+  swipe_->EnableScreenCap(false);\r
+\r
+  swipe_->SetAnimatorTime(50);\r
+\r
+  AddViewToRootContainer(swipe_);\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new ok");\r
+}\r
+/*设置弹窗状态*/\r
+void TraingCardView::SetPopupViewStatus(PopupType type, bool status) {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type);\r
+\r
+  UIView *popupView = nullptr;\r
+  if (type == EndPopup) {\r
+    popupView = endView;\r
+  } else if (type == GetTagPopup) {\r
+    popupView = getView;\r
+  } else if (type == HeartPopup) {\r
+    popupView = heartView;\r
+  }\r
+  if (popupView == nullptr) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL");\r
+    return;\r
+  }\r
+  UIView *cardview = TraingCardView::GetInstance()->GetTraingCrad();\r
+  if (cardview != nullptr) {\r
+    cardview->SetVisible(!status);\r
+  }\r
+  popupView->SetVisible(status);\r
+  //刷新\r
+  RootView::GetInstance()->Invalidate();\r
+}\r
+/*结束弹窗界面*/\r
+void TraingCardView::ShowEndView() {\r
+  // momentumFlag = false; // 标志位还原\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView");\r
+  endView = new UIScrollView();\r
+  if (endView == nullptr) {\r
+    return;\r
+  }\r
+  endView->SetPosition(0, 0);\r
+  endView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);\r
+  endView->SetScrollBlankSize(20);\r
+  endView->SetReboundSize(50);\r
+  endView->SetDirection(1);\r
+\r
+  InitRollLabel(endtitle, 83, 50, 300, 35, "label1", STR_LOOK_OUT,\r
+                DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+  InitRollLabel(notelabel, 56, 167, 360, 80, "label2",\r
+                STR_INSUFFICIENT_EXERCISE_AMOUNT, DEFAULT_VECTOR_FONT_FILENAME,\r
+                30);\r
+  /*隐藏是否结束运动title*/\r
+  InitRollLabel(endnote, 56, 207, 360, 80, "label3", STR_END_THIS_MOVEMENT,\r
+                DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+  endnote->SetVisible(false);\r
+\r
+  endView->Add(endnote);\r
+  endView->Add(endtitle);\r
+  endView->Add(notelabel);\r
+\r
+  InitButton(exit, 111, 299, 100, 100, BUTTONBACK);\r
+  exit->SetOnClickListener(static_cast<UIView::OnClickListener *>(\r
+      TraingCardPresenter::GetInstance()));\r
+  exit->SetImageSrc(NO_IMAGE, NO_IMAGE);\r
+  InitButton(back, 256, 299, 100, 100, BUTTONEXIT);\r
+  back->SetOnClickListener(static_cast<UIView::OnClickListener *>(\r
+      TraingCardPresenter::GetInstance()));\r
+  back->SetImageSrc(YES_IMAGE, YES_IMAGE);\r
+  endView->Add(exit);\r
+  endView->Add(back);\r
+  RootView::GetInstance()->Add(endView);\r
+  endView->SetDraggable(false);\r
+  endView->SetTouchable(true);\r
+  endView->SetVisible(false); // 界面隐藏\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView end");\r
+}\r
+/*目标达成界面*/\r
+void TraingCardView::ShowGetTagView() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView");\r
+  getView = new UIScrollView();\r
+  if (getView == nullptr) {\r
+    return;\r
+  }\r
+  getView->SetPosition(0, 0);\r
+  getView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);\r
+  getView->SetScrollBlankSize(20);\r
+  getView->SetReboundSize(50);\r
+  getView->SetDirection(1);\r
+\r
+  // 初始化Lable\r
+  // InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", STR_GOAL_ACHIEVED,\r
+  //               DEFAULT_VECTOR_FONT_FILENAME, 35);\r
+  // TODO:多国语言\r
+  InitLabelExt(labeltitle, 83, 50, 300, 35, "label3", STR_GOAL_TITLE,\r
+               DEFAULT_VECTOR_FONT_FILENAME_EN, 35);\r
+  labeltitle->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+  labeltitle->SetRollSpeed(23);\r
+\r
+  getView->Add(labeltitle);\r
+  InitRollLabel(labelgettag, 103, 307, 200, 35, "label3", STR_ACCOMPLISH_GOAL,\r
+                DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+  getView->Add(labelgettag);\r
+  // DEFAULT_VECTOR_FONT_FILENAME_EN\r
+  InitLabel(labelpre, 233, 307, 160, 35, "label3", "100%",\r
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 30);\r
+  getView->Add(labelpre);\r
+\r
+  // 初始化按键\r
+  InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONWINOK, STR_OK, 30);\r
+  buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);\r
+  buttonok_->SetOnClickListener(static_cast<UIView::OnClickListener *>(\r
+      TraingCardPresenter::GetInstance()));\r
+  getView->Add(buttonok_);\r
+\r
+  InitImageAnimator();\r
+  RootView::GetInstance()->Add(getView);\r
+  getView->SetDraggable(false);\r
+  getView->SetTouchable(true);\r
+  getView->SetVisible(false); // 界面隐藏\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end");\r
+}\r
+/*最高心率提醒弹窗*/\r
+void TraingCardView::ShowHeartView() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView");\r
+  heartView = new UIScrollView();\r
+  if (heartView == nullptr) {\r
+    return;\r
+  }\r
+  heartView->SetPosition(0, 0);\r
+  heartView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);\r
+  heartView->SetScrollBlankSize(20);\r
+  heartView->SetReboundSize(50);\r
+  heartView->SetDirection(1);\r
+\r
+  // 初始化Lable\r
+  InitRollLabel(hearttitle, 83, 50, 300, 35, "label1", STR_HEARTTITLE,\r
+                DEFAULT_VECTOR_FONT_FILENAME, 35);\r
+  heartView->Add(hearttitle);\r
+\r
+  int maxheart = ConfigModel::GetInstance()->get_configData_int(\r
+      ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX);\r
+  // TODO 多国语言\r
+  std::string heartStr = "当前心率高于" + std::to_string(maxheart) + "次/分钟";\r
+  InitLabel(labelnote, 53, 269, 360, 35, "label3", heartStr.c_str(),\r
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 30);\r
+\r
+  labelnote->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+  labelnote->SetRollSpeed(23);\r
+\r
+  heartView->Add(labelnote);\r
+\r
+  InitImageView(heartiamge, 193, 149, 80, 80, "note", WARNING_IMAGE);\r
+  heartView->Add(heartiamge);\r
+\r
+  // 初始化按键\r
+  InitButtonExt(buttonnote_, 0, 366, 466, 100, BUTTONNOTE, STR_OK, 30);\r
+  buttonnote_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE);\r
+  buttonnote_->SetOnClickListener(static_cast<UIView::OnClickListener *>(\r
+      TraingCardPresenter::GetInstance()));\r
+  heartView->Add(buttonnote_);\r
+\r
+  RootView::GetInstance()->Add(heartView);\r
+  heartView->SetDraggable(false);\r
+  heartView->SetTouchable(true);\r
+  heartView->SetVisible(false); // 界面隐藏\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView end");\r
+}\r
+/*获取运动量结束弹窗界面刷新*/\r
+bool TraingCardView::RefreshEndView() {\r
+  // 获取训练卡路里判断运动量\r
+  momentumFlag = TraingModel::GetInstance()->GetMomentum();\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag);\r
+\r
+  if (momentumFlag) {\r
+    // 正常结束\r
+    endnote->SetVisible(false);\r
+    endtitle->SetTextId(STR_END_MOVEMENT);\r
+    notelabel->SetTextId(STR_END_THIS_MOVEMENT);\r
+  } else {\r
+    endtitle->SetTextId(STR_LOOK_OUT);\r
+    notelabel->SetTextId(STR_INSUFFICIENT_EXERCISE_AMOUNT);\r
+    endnote->SetVisible(true);\r
+  }\r
+  return momentumFlag;\r
+}\r
+/*初始化动画以及Taglabel*/\r
+void TraingCardView::InitImageAnimator() {\r
+  int tag = TraingModel::GetInstance()->GetSportTag();\r
+  ExerciseTag tagType = TraingModel::GetInstance()->GetSportTagtype();\r
+  std::string tagString = std::to_string(tag);\r
+  switch (tagType) {\r
+  case ExerciseTag::Duration: {\r
+    int hours = tag / 60;\r
+    int minutes = tag % 60;\r
+    int seconds = 0;\r
+    // 将小时、分钟、秒转换为字符串,并在小于10时补零\r
+    std::string hoursStr =\r
+        (hours < 10) ? "0" + std::to_string(hours) : std::to_string(hours);\r
+    std::string minutesStr = (minutes < 10) ? "0" + std::to_string(minutes)\r
+                                            : std::to_string(minutes);\r
+    std::string secondsStr = (seconds < 10) ? "0" + std::to_string(seconds)\r
+                                            : std::to_string(seconds);\r
+    tagString = hoursStr + ":" + minutesStr + ":" + secondsStr;\r
+    break;\r
+  }\r
+  case ExerciseTag::Calories: {\r
+    tagString = tagString + "kcal";\r
+    break;\r
+  }\r
+  case ExerciseTag::Distance: {\r
+    tagString = tagString + "km";\r
+    break;\r
+  }\r
+  case ExerciseTag::Steps:\r
+    tagString = tagString + "steps";\r
+    break;\r
+  default:\r
+    break;\r
+  }\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,\r
+                "tag[%d]-tagType[%d]-tagString[%s]\r\n", tag, tagType,\r
+                tagString.c_str());\r
+\r
+  // DEFAULT_VECTOR_FONT_FILENAME_EN\r
+  InitLabel(labeltag, 70, 215, 326, 97, "label2", tagString.c_str(),\r
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 80);\r
+\r
+  labeltag->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+  labeltag->SetRollSpeed(23);\r
+\r
+  labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));\r
+  getView->Add(labeltag);\r
+\r
+  // 初始化图片数组以及动画\r
+  if (imageAnimator == nullptr) {\r
+    imageAnimator = new UIImageAnimatorView();\r
+    if (imageAnimator == nullptr) {\r
+      WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,\r
+                    "AssistantAnswerView::new UIImageAnimatorView fail");\r
+      return;\r
+    }\r
+  }\r
+  imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_trainingwin,\r
+                                     DETECTION_IMAGE_ANIMATORVIEW_SIZE,\r
+                                     DETECTION_IMAGE_ANIMATORVIEW_SPEED);\r
+  imageAnimator->SetRepeat(true);\r
+  // imageAnimator->Start();\r
+\r
+  getView->Add(imageAnimator);\r
+}\r
+\r
+/*获取卡片View单例*/\r
+UICrossView *TraingCardView::GetTraingCrad() { return swipe_; }\r
+\r
+\r
+int TraingCardView::GetCurrentPage() {\r
+  return swipe_->GetCurrentPageId(0); // 获取水平页面\r
+}\r
+UIImageAnimatorView *TraingCardView::GetAnimator() { return imageAnimator; }\r
+UILabelExt *TraingCardView::GetHeartMaxLabel() { return labelnote; }\r
+void TraingCardView::SetHeartMaxLabel(int maxheart) {\r
+  if (maxheart == 0 || labelnote == nullptr)\r
+    return;\r
+  std::string heartStr;\r
+  if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) {\r
+    heartStr = "当前心率高于" + std::to_string(maxheart) + "次/分钟";\r
+  } else {\r
+    heartStr =\r
+        "Current heart rate is above " + std::to_string(maxheart) + " bpm";\r
+  }\r
+  labelnote->SetText(heartStr.c_str());\r
+}\r
+} // namespace OHOS\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingDataAllView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TraingDataAllView.cpp
new file mode 100644 (file)
index 0000000..1c92c91
--- /dev/null
@@ -0,0 +1,175 @@
+#include "traing/include/TraingModel.h"
+#include "traing/training_card/include/TrainingControlView.h"
+#include "traing/training_card/include/TrainingDataView.h"
+#include "traing/training_card/include/TrainingDetailView.h"
+#include "wearable_log.h"
+
+namespace OHOS {
+
+static TraingDataAllView *g_pTraingDataAllView{nullptr};
+
+TraingDataAllView::TraingDataAllView() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "TraingDataAllView::TraingDataAllView");
+  SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+  g_pTraingDataAllView = this;
+}
+
+TraingDataAllView::~TraingDataAllView() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+                "TraingDataAllView::~TraingDataAllView");
+  ClearAll();
+  g_pTraingDataAllView = nullptr;
+}
+
+TraingDataAllView *TraingDataAllView::GetInstance(void) {
+  return g_pTraingDataAllView;
+}
+
+void TraingDataAllView::ClearAll(void) {
+  for (int32_t i = 0; i < maxPage; i++) {
+    recordCard[i] = nullptr;
+  }
+
+  if (TraingDataAllSwipeViewList) {
+    TraingDataAllSwipeViewList->RemoveAll();
+    delete TraingDataAllSwipeViewList;
+    TraingDataAllSwipeViewList = nullptr;
+  }
+
+  delete trainingDataView;
+  trainingDataView = nullptr;
+
+  delete trainingDetailView;
+  trainingDetailView = nullptr;
+
+  delete trainingDataAllView;
+  trainingDataAllView = nullptr;
+
+  delete traingDataAllPageView;
+  traingDataAllPageView = nullptr;
+}
+
+UISwipeView *TraingDataAllView::TraingDataAllViewInit(void) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "TraingDataAllView::TraingDataAllViewInit");
+
+  TraingDataAllSwipeViewList = new UISwipeView(UISwipeView::VERTICAL);
+  if (!TraingDataAllSwipeViewList) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to create TraingDataAllSwipeViewList");
+    return nullptr;
+  }
+
+  TraingDataAllSwipeViewList->SetStyle(STYLE_BACKGROUND_COLOR,
+                                       Color::Black().full);
+  TraingDataAllSwipeViewList->SetPosition(0, 0, HORIZONTAL_RESOLUTION,
+                                          VERTICAL_RESOLUTION);
+  TraingDataAllSwipeViewList->SetDraggable(true);
+  TraingDataAllSwipeViewList->SetTouchable(true);
+
+  for (uint16_t i = 0; i < maxPage; i++) {
+    recordCard[i] = CreatePage(i);
+    if (!recordCard[i]) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordCard[%d] is nullptr", i);
+      return nullptr;
+    }
+    recordCard[i]->InitView(this);
+    TraingDataAllSwipeViewList->Add(recordCard[i]);
+  }
+
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingDataAllView InitPage complete");
+  return TraingDataAllSwipeViewList;
+}
+
+UISwipeView *TraingDataAllView::GetTraingDataAllPageView() {
+  return TraingDataAllViewInit();
+}
+
+TrainingDataView *TraingDataAllView::GetTrainingDataView(void) {
+  return trainingDataView;
+}
+
+TrainingDetailView *TraingDataAllView::GetTrainingDetailView(void) {
+  return trainingDetailView;
+}
+
+AppGroupView *TraingDataAllView::TraingDataPageInit(void) {
+  trainingDataView = new TrainingDataView();
+  if (!trainingDataView) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create TrainingDataView");
+    return nullptr;
+  }
+  return trainingDataView;
+}
+
+AppGroupView *TraingDataAllView::TraingDetailPageInit(void) {
+  trainingDetailView = new TrainingDetailView();
+  if (!trainingDetailView) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "Failed to create TrainingDetailView");
+    return nullptr;
+  }
+  return trainingDetailView;
+}
+
+struct TraingDataAllViewMapper {
+  const int16_t viewId;
+  AppGroupView *(TraingDataAllView::*func)(void);
+};
+
+static const TraingDataAllViewMapper g_pageMapper[] = {
+    {TRAING_DATA_ALL_MAIN_VIEW, &TraingDataAllView::TraingDataPageInit},
+    {TRAING_DATA_ALL_DETAIL_VIEW, &TraingDataAllView::TraingDetailPageInit},
+};
+
+AppGroupView *TraingDataAllView::CreatePage(uint8_t TraingDataAllPageId) {
+  for (const auto &mapper : g_pageMapper) {
+    if (mapper.viewId == TraingDataAllPageId) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "Creating page for TraingDataAllPageId: %d",
+                    TraingDataAllPageId);
+      return (this->*(mapper.func))();
+    }
+  }
+  return nullptr;
+}
+
+bool TraingDataAllView::InitView(void) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initializing TraingDataAllView");
+
+  if (!trainingDataAllView) {
+    trainingDataAllView = new TraingDataAllView();
+    if (!trainingDataAllView) {
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                    "Failed to create TraingDataAllView");
+      return false;
+    }
+  }
+
+  traingDataAllPageView = dynamic_cast<UISwipeView *>(
+      trainingDataAllView->GetTraingDataAllPageView());
+  if (!traingDataAllPageView) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "GetTraingDataAllPageView returned nullptr");
+    return false;
+  }
+  traingDataAllPageView->SetDraggable(true);
+  traingDataAllPageView->SetTouchable(true);
+  Add(traingDataAllPageView);
+
+  return true;
+}
+
+void TraingDataAllView::PreLoad(void) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Preloading TraingDataAllView");
+  if (!viewiInitStatus && InitView()) {
+    viewiInitStatus = true;
+  }
+}
+
+void TraingDataAllView::UnLoad(void) {
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unloading TraingDataAllView");
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingControlView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingControlView.cpp
new file mode 100644 (file)
index 0000000..1ca79f2
--- /dev/null
@@ -0,0 +1,139 @@
+
+#include "traing/training_card/include/TrainingControlView.h"
+
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_button.h"
+#include "components/ui_label_ext.h"
+#include "string"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include <chrono>
+#include <thread>
+#include <ui_scroll_view.h>
+#include "languagecode/LanguageInit.h"
+namespace OHOS {
+
+static TrainingControlView *g_pTrainingControlView{nullptr};
+
+TrainingControlView::TrainingControlView() {
+  SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+  g_pTrainingControlView = this;
+}
+
+TrainingControlView::~TrainingControlView() {
+  RemoveAll();
+  DeInit();
+  g_pTrainingControlView = nullptr;
+}
+
+TrainingControlView *TrainingControlView::GetInstance() {
+  return g_pTrainingControlView;
+}
+
+/* InitView:初始化界面*/
+/* InitView:初始化界面 */
+void TrainingControlView::InitView() {
+  // 初始化 Button
+  InitButton(buttonEnd, 91, 205, 110, 110, BUTTONEND);
+  buttonEnd->SetImageSrc(SPORT_STOP_IMAGE, SPORT_STOP_IMAGE);
+  buttonEnd->SetOnClickListener(static_cast<UIView::OnClickListener *>(
+      TraingCardPresenter::GetInstance()));
+  Add(buttonEnd);
+
+  InitButton(buttonStop, 261, 205, 110, 110, BUTTONSTOP);
+  // Set additional property based on the sport state
+  ExerciseState state = TraingModel::GetInstance()->GetSportState();
+
+  if (state == ExerciseState::Pause) {
+    buttonStop->SetImageSrc(SPORT_CONTINUE_IMAGE, SPORT_CONTINUE_IMAGE);
+  } else {
+    buttonStop->SetImageSrc(SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE);
+  }
+
+  buttonStop->SetOnClickListener(static_cast<UIView::OnClickListener *>(
+      TraingCardPresenter::GetInstance()));
+  Add(buttonStop);
+
+  // 初始化 Label
+  InitLabelExt(labeltitle, 83, 50, 300, 35, "label1", STR_TRAINING_IN_PROGRESS,
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(labeltimer, 45, 110, 360, 80, "label2", "00:00:00",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 65);
+  InitLabelExt(labelend, 81, 330, 130, 35, "label3", STR_FINISH,
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabelExt(labelstop, 251, 330, 130, 35, "label4", STR_PAUSE,
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+
+  if (state == ExerciseState::Pause) {
+    labelstop->SetTextId(STR_RESUME);
+  } else {
+    labelstop->SetTextId(STR_PAUSE);
+  }
+
+  // 添加到视图中
+  Add(labeltitle);
+  Add(labeltimer);
+  Add(labelend);
+  Add(labelstop);
+
+  // 初始化 Image
+  InitImageView(imagepoint, 193, 421, 80, 20, "image1", CONTROL_POINT_IMAGE);
+  Add(imagepoint);
+}
+
+UILabelExt *TrainingControlView::GetLabel() { return labelstop; }
+
+UIButton *TrainingControlView::GetButton() { return buttonStop; }
+
+/* DeInit:删除组件 */
+void TrainingControlView::DeInit() {
+  RemoveAll();
+  if (labeltitle != nullptr) {
+    delete labeltitle;
+    labeltitle = nullptr;
+  }
+  if (labeltimer != nullptr) {
+    delete labeltimer;
+    labeltimer = nullptr;
+  }
+  if (labelend != nullptr) {
+    delete labelend;
+    labelend = nullptr;
+  }
+  if (labelstop != nullptr) {
+    delete labelstop;
+    labelstop = nullptr;
+  }
+
+  // 删除Button
+  if (buttonEnd != nullptr) {
+    delete buttonEnd;
+    buttonEnd = nullptr;
+  }
+  if (buttonStop != nullptr) {
+    delete buttonStop;
+    buttonStop = nullptr;
+  }
+
+  // 删除Image
+  if (imagepoint != nullptr) {
+    delete imagepoint;
+    imagepoint = nullptr;
+  }
+}
+
+void TrainingControlView::PreLoad(void) {
+  if (!viewiInitStatus) {
+    InitView();
+    viewiInitStatus = true;
+  }
+}
+
+void TrainingControlView::UnLoad(void) {}
+
+UILabelExt *TrainingControlView::GetTimeLabel() { return labeltimer; }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingDataView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingDataView.cpp
new file mode 100644 (file)
index 0000000..be8bfee
--- /dev/null
@@ -0,0 +1,205 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-02 09:35:58
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp
+ */
+
+#include "traing/training_card/include/TrainingDataView.h"
+#include "traing/training_card/include/TraingCardView.h"
+
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_button.h"
+#include "components/ui_label_ext.h"
+#include "custom_runtime.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include <ui_scroll_view.h>
+
+namespace OHOS {
+
+static TrainingDataView *g_pTrainingDataView{nullptr};
+
+TrainingDataView::TrainingDataView() {
+  SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+  g_pTrainingDataView = this;
+}
+
+TrainingDataView::~TrainingDataView() {
+  DeInit();
+  g_pTrainingDataView = nullptr;
+}
+
+TrainingDataView *TrainingDataView::GetInstance() {
+  return g_pTrainingDataView;
+}
+
+/* InitView:初始化界面*/
+bool TrainingDataView ::InitPage() {
+  // 初始化Image
+  InitImageView(image_progress, 13, 13, 440, 386, "image1", PROGRESS_IMAGE);
+  InitImageView(image_heart, 88, 295, 50, 50, "image2", SPORT_HEARTRATE_IMAGE);
+  InitImageView(image_iconup, 225, 396, 16, 10, "image4", INCO_UP_IMAGE);
+  InitImageView(image_iconpoint, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE);
+  Add(image_progress);
+  Add(image_heart);
+  Add(image_iconup);
+  Add(image_iconpoint);
+
+  // 初始化进度条
+  circleProgress = new UICircleProgress();
+  circleProgress->SetPosition(0, 0);
+  circleProgress->Resize(466, 466);
+  circleProgress->SetViewId("circleProgress");
+  circleProgress->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+  circleProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+  circleProgress->SetBackgroundStyle(STYLE_LINE_WIDTH, 12);
+  circleProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6);
+  circleProgress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000);
+  circleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4fC34C);
+  circleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, 10);
+  circleProgress->SetCenterPosition(235, 235);
+  circleProgress->SetRadius(215);
+  circleProgress->SetStartAngle(215);
+  circleProgress->SetEndAngle(505);
+  circleProgress->SetCapType(CAP_ROUND);
+  circleProgress->SetValue(0);
+  Add(circleProgress);
+
+  // 初始化Lable
+  UIResourceTextId sport_id = TraingModel::GetInstance()->GetSportEvent();
+  InitLabelExt(sportlabel, 83, 120, 300, 35, "label2", sport_id,
+               DEFAULT_VECTOR_FONT_FILENAME, 30);
+  sportlabel->SetTextColor(Color::Gray());
+  //数字统一使用DEFAULT_VECTOR_FONT_FILENAME_EN
+  InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 40);
+  InitLabel(timerlabel, 0, 163, 466, 150, "label3", "00:00:00",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 80);
+  InitLabel(heartlabel, 85, 284, 230, 80, "label4", "--",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 60);
+  InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm",
+            DEFAULT_VECTOR_FONT_FILENAME, 60);
+  ubpmlabel->SetTextColor(Color::Gray());
+  Add(curtimelabel);
+  Add(sportlabel);
+  Add(timerlabel);
+  Add(heartlabel);
+  Add(ubpmlabel);
+
+  return true;
+
+#if 0
+  //  初始化Button
+  InitButton(buttonNote, 275, 350, 26, 26, BUTTONNOTE);
+  // Set additional property
+  buttonNote->SetImageSrc(NOTE_IMAGE, NOTE_IMAGE);
+  buttonNote->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingCardPresenter::GetInstance()));
+  Add(buttonNote);
+#endif
+  // 增加上拉卡片
+  // SetCoverable(true);
+}
+
+/* DeInit:删除组件 */
+void TrainingDataView::DeInit() {
+  RemoveAll();
+  if (curtimelabel != nullptr) {
+    delete curtimelabel;
+    curtimelabel = nullptr;
+  }
+  if (sportlabel != nullptr) {
+    delete sportlabel;
+    sportlabel = nullptr;
+  }
+  if (timerlabel != nullptr) {
+    delete timerlabel;
+    timerlabel = nullptr;
+  }
+  if (heartlabel != nullptr) {
+    delete heartlabel;
+    heartlabel = nullptr;
+  }
+  if (ubpmlabel != nullptr) {
+    delete ubpmlabel;
+    ubpmlabel = nullptr;
+  }
+
+  // 删除button
+  if (buttonNote != nullptr) {
+    delete buttonNote;
+    buttonNote = nullptr;
+  }
+
+  // 删除Image
+  if (image_iconup != nullptr) {
+    delete image_iconup;
+    image_iconup = nullptr;
+  }
+  if (image_iconpoint != nullptr) {
+    delete image_iconpoint;
+    image_iconpoint = nullptr;
+  }
+  if (image_heart != nullptr) {
+    delete image_heart;
+    image_heart = nullptr;
+  }
+  if (image_progress != nullptr) {
+    delete image_progress;
+    image_progress = nullptr;
+  }
+
+  //删除进度条圆圈
+  if (circleProgress != nullptr) {
+    delete circleProgress;
+    circleProgress = nullptr;
+  }
+}
+
+UILabelExt *TrainingDataView::GetTimeLabel() { return timerlabel; }
+UILabelExt *TrainingDataView::GetHeartLabel() { return heartlabel; }
+UICircleProgress *TrainingDataView::GetProgress() { return circleProgress; }
+/*更新当前时间*/
+void TrainingDataView::UpdataTime() {
+  if (curtimelabel == nullptr) // 防止刷新空组件
+    return;
+
+  // 获取当前时间
+  struct tm pTM;
+  time_t seconds;
+  time(&seconds);
+  localtime_r(&seconds, &pTM);
+
+  // 解析时间
+  int hour = pTM.tm_hour;
+  //需要判断显示的格式
+  if (uapi_dev_runtime_get_time_hour_show_model() == 12) {
+    if (pTM.tm_hour > 12)
+      hour = pTM.tm_hour - 12;
+  }
+
+  int minute = pTM.tm_min;
+
+  // 将时间和日期转换为字符串
+  std::string stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" +
+                           (minute < 10 ? "0" : "") + std::to_string(minute);
+  curtimelabel->SetText(stringtime.c_str());
+}
+
+bool TrainingDataView::InitView(void *caller) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingDataView InitView %p",
+                caller);
+  if (InitPage() == false) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDataView::InitPage fail");
+    return false;
+  }
+  SetDraggable(true);
+  SetTouchable(true);
+  return true;
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingDetailView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/TrainingDetailView.cpp
new file mode 100644 (file)
index 0000000..1fce82c
--- /dev/null
@@ -0,0 +1,157 @@
+
+#include "traing/training_card/include/TrainingDetailView.h"
+#include "traing/training_card/include/TraingCardView.h"
+
+#include "ConfigModel.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_button.h"
+#include "components/ui_label_ext.h"
+#include "languagecode/LanguageInit.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include <ui_scroll_view.h>
+namespace OHOS {
+
+static TrainingDetailView *g_pTrainingDetailView{nullptr};
+
+TrainingDetailView::TrainingDetailView() {
+  SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+  // SetStyle(STYLE_BACKGROUND_OPA, 0);
+  // SetStyle(STYLE_BORDER_RADIUS, 466);
+  g_pTrainingDetailView = this;
+}
+TrainingDetailView::~TrainingDetailView() {
+  DeInit();
+  g_pTrainingDetailView = nullptr;
+}
+
+TrainingDetailView *TrainingDetailView::GetInstance() {
+  return g_pTrainingDetailView;
+}
+
+/* InitView:初始化界面*/
+bool TrainingDetailView ::InitPage() {
+  // 初始化Image
+  InitImageView(progress_image, 0, 0, 100, 100, "image5", COLOR_PROGRESS_IMAGE);
+  // InitImageView(lineimage2_, 225, 190, 0, 0, "image", LINE_2_IMAGE);
+  if (lineimage2_ == nullptr) {
+    lineimage2_ = new UIImageView();
+  }
+  lineimage2_->SetPosition(232, 191);
+  lineimage2_->Resize(2, 82);
+  lineimage2_->SetViewId("image2");
+  lineimage2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333);
+  lineimage2_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+  lineimage2_->SetVisible(true);
+
+  Add(progress_image);
+  Add(lineimage2_);
+
+  // 初始化Lable
+  InitRollLabel(u_milelabel, 16, 234, 230, 35, "label2", STR_RANGE_SETTING,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitRollLabel(u_calorielabel, 225, 235, 230, 35, "label4",
+                STR_CALORIE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitRollLabel(u_stepslabel, 73, 362, 320, 35, "label3", STR_STEP_SETTING,
+                DEFAULT_VECTOR_FONT_FILENAME, 30);
+  //多国语言
+  if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) {
+    u_milelabel->SetText("距离(公里");
+    u_stepslabel->SetText("步数(步)");
+    u_calorielabel->SetText("卡路里(千卡)");
+  } else {
+    u_milelabel->SetText("Distance (km)");
+    u_stepslabel->SetText("Steps");
+    u_calorielabel->SetText("Calorie (kcal)");
+  }
+  u_milelabel->SetTextColor(Color::Gray());
+  u_stepslabel->SetTextColor(Color::Gray());
+  u_calorielabel->SetTextColor(Color::Gray());
+
+  //数字统一使用DEFAULT_VECTOR_FONT_FILENAME_EN
+  InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 65);
+  InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 65);
+  InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03",
+            DEFAULT_VECTOR_FONT_FILENAME_EN, 65);
+
+  Add(u_milelabel);
+  Add(u_stepslabel);
+  Add(u_calorielabel);
+  Add(milelabel);
+  Add(steplabel);
+  Add(calorielabel);
+
+  InitButtonExt(intensity_button, 103, 70, 260, 80, "button",
+                STR_LOWER_STRENGTH, 30);
+  Add(intensity_button);
+
+  SetTouchable(true);
+
+  return true;
+}
+/* DeInit:删除组件 */
+void TrainingDetailView::DeInit() {
+  RemoveAll();
+  if (u_milelabel != nullptr) {
+    delete u_milelabel;
+    u_milelabel = nullptr;
+  }
+  if (u_stepslabel != nullptr) {
+    delete u_stepslabel;
+    u_stepslabel = nullptr;
+  }
+  if (u_calorielabel != nullptr) {
+    delete u_calorielabel;
+    u_calorielabel = nullptr;
+  }
+  if (milelabel != nullptr) {
+    delete milelabel;
+    milelabel = nullptr;
+  }
+  if (steplabel != nullptr) {
+    delete steplabel;
+    steplabel = nullptr;
+  }
+  if (calorielabel != nullptr) {
+    delete calorielabel;
+    calorielabel = nullptr;
+  }
+
+  if (progress_image != nullptr) {
+    delete progress_image;
+    progress_image = nullptr;
+  }
+  if (lineimage2_ != nullptr) {
+    delete lineimage2_;
+    lineimage2_ = nullptr;
+  }
+  if (intensity_button != nullptr) {
+    delete intensity_button;
+    intensity_button = nullptr;
+  }
+}
+
+bool TrainingDetailView::InitView(void *caller) {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingDetailView InitView %p",
+                caller);
+  if (InitPage() == false) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDetailView::InitPage fail");
+    return false;
+  }
+  SetDraggable(true);
+  SetTouchable(true);
+  return true;
+}
+UILabelExt *TrainingDetailView::GetMileLabel() { return milelabel; }
+UILabelExt *TrainingDetailView::GetStepLabel() { return steplabel; }
+UILabelExt *TrainingDetailView::GetCalorieLabel() { return calorielabel; }
+UILabelButtonExt *TrainingDetailView::Get_Intensity_Button() {
+  return intensity_button;
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/Training_CardPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/Training_CardPresenter.cpp
new file mode 100644 (file)
index 0000000..9007204
--- /dev/null
@@ -0,0 +1,76 @@
+/***
+ * @Date: 2024-07-19 15:43:37
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-26 09:29:24
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardPresenter.cpp
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-16 17:36:17
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/Training_CardPresenter.cpp
+ */
+
+#include "traing/training_card/include/Training_CardPresenter.h"
+#include "traing/training_card/include/Training_CardView.h"
+#include "traing/include/TraingModel.h"
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "MainModel.h"
+
+namespace OHOS
+{
+
+    bool TraingOnClickListener::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Training_CardView::OnClick %s", view.GetViewId());
+        Training_CardView *cardpage = Training_CardView::GetInstance();
+        if (cardpage == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Training_CardView::GetInstance");
+            return false;
+        }
+        if (strcmp(view.GetViewId(), BUTTON1) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL);
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);
+            TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING);
+        }
+        if (strcmp(view.GetViewId(), BUTTON2) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL);
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);
+            TraingModel::GetInstance()->SetSportEvent(
+                STR_EXERCISE_FREETRAINING);
+        }
+        if (strcmp(view.GetViewId(), BUTTON3) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGNOMAL);
+            //  NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);
+            TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING);
+        }
+        if (strcmp(view.GetViewId(), BUTTONMORE) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGMORE);
+            //  NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);
+        }
+        // 快捷训练都属于健身类
+        TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS);
+
+        // 配置主界面回退界面
+        MainModel::GetInstance().SetFromSetCardView(true);
+        MainModel::GetInstance().SetFromCardId(TRAINING);
+        TraingModel::GetInstance()->SetEntryType(MAIN_ENTER);
+        return true;
+    }
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/Training_CardView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_card/src/Training_CardView.cpp
new file mode 100644 (file)
index 0000000..7a2fa6c
--- /dev/null
@@ -0,0 +1,253 @@
+\r
+#include "traing/training_card/include/Training_CardView.h"\r
+#include "traing/Training_UiConfig.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "traing/training_card/include/Training_CardPresenter.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include <iostream>\r
+#include <string>\r
+\r
+namespace OHOS {\r
+// 按钮设置\r
+static constexpr uint16_t BUTTON_WIDHT = 140;\r
+static constexpr uint16_t BUTTON_HEIGHT = 140;\r
+static constexpr uint16_t BUTTON1_X = 86;\r
+static constexpr uint16_t BUTTON1_Y = 118;\r
+static constexpr uint16_t BUTTON2_X = 236;\r
+static constexpr uint16_t BUTTON2_Y = 118;\r
+static constexpr uint16_t BUTTON3_X = 86;\r
+static constexpr uint16_t BUTTON3_Y = 268;\r
+static constexpr uint16_t BUTTONMORE_X = 236;\r
+static constexpr uint16_t BUTTONMORE_Y = 268;\r
+\r
+// 标签设置\r
+static constexpr uint16_t LABEL_FONT_SIZE = 30;\r
+static constexpr uint16_t LABEL_X_SIZE = 120;\r
+static constexpr uint16_t LABEL_Y_SIZE = 60;\r
+static constexpr uint16_t TITLE_LABEL_X = 230;\r
+static constexpr uint16_t TITLE_LABEL_Y = 52;\r
+\r
+static constexpr uint16_t BTN1_LABEL_X = 95;\r
+static constexpr uint16_t BTN1_LABEL_Y = 205;\r
+static constexpr uint16_t BTN2_LABEL_X = 236;\r
+static constexpr uint16_t BTN2_LABEL_Y = 205;\r
+static constexpr uint16_t BTN3_LABEL_X = 95;\r
+static constexpr uint16_t BTN3_LABEL_Y = 355;\r
+\r
+// 图片设置\r
+static constexpr uint16_t BTN_IMAGE_SIZE = 100;\r
+static constexpr uint16_t BTN1_IMAGE_X = 126;\r
+static constexpr uint16_t BTN1_IMAGE_Y = 148;\r
+\r
+static constexpr uint16_t BTN2_IMAGE_X = 276;\r
+static constexpr uint16_t BTN2_IMAGE_Y = 148;\r
+\r
+static constexpr uint16_t BTN3_IMAGE_X = 129;\r
+static constexpr uint16_t BTN3_IMAGE_Y = 298;\r
+\r
+static constexpr uint16_t BTNMORE_IMAGE_X = 276;\r
+static constexpr uint16_t BTNMORE_IMAGE_Y = 324;\r
+\r
+static Training_CardView *g_pTraining_CardView{nullptr};\r
+\r
+Training_CardView::Training_CardView() {\r
+  g_pTraining_CardView = this;\r
+  SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+}\r
+\r
+Training_CardView::~Training_CardView() {\r
+  DeInitView();\r
+  g_pTraining_CardView = nullptr;\r
+}\r
+Training_CardView *Training_CardView::GetInstance() {\r
+  return g_pTraining_CardView;\r
+}\r
+\r
+/***\r
+ * @description:\r
+ * @return\r
+ * @brief 添加标签\r
+ */\r
+bool Training_CardView::AddLabel() {\r
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::AddLabel");\r
+  // 初始化标签\r
+  InitRollLabel(title_label, 83, 50, 300, 35, "title_label", STR_RAPID_TRAINING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+\r
+  InitRollLabel(btn1_label, BTN1_LABEL_X, BTN1_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btu1_label", STR_EXERCISE_OUTDOORWALKING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  InitRollLabel(btn2_label, BTN2_LABEL_X, BTN2_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btu2_label", STR_EXERCISE_FREETRAINING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  InitRollLabel(btn3_label, BTN3_LABEL_X, BTN3_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btu3_label", STR_EXERCISE_OUTDOORRUNNING,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  InitRollLabel(btnmore_label, BTN2_LABEL_X + 10, BTN3_LABEL_Y, LABEL_X_SIZE,\r
+                LABEL_Y_SIZE, "btumore_label", STR_MORE,\r
+                DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE);\r
+  return true;\r
+}\r
+\r
+bool Training_CardView::AddButton() {\r
+  InitButton(button1_, BUTTON1_X, BUTTON1_Y, BUTTON_WIDHT, BUTTON_HEIGHT,\r
+             BUTTON1);\r
+  button1_->SetImageSrc(BUTTONGROUND2_IMAGE, BUTTONGROUND2_IMAGE);\r
+  UIView::OnClickListener *button1Click =\r
+      static_cast<UIView::OnClickListener *>(\r
+          TraingOnClickListener::GetInstance());\r
+  button1_->SetOnClickListener(button1Click);\r
+\r
+  InitButton(button2_, BUTTON2_X, BUTTON2_Y, BUTTON_WIDHT, BUTTON_HEIGHT,\r
+             BUTTON2);\r
+  button2_->SetImageSrc(BOUTTONGROUND_IMAGE, BOUTTONGROUND_IMAGE);\r
+  UIView::OnClickListener *button2Click =\r
+      static_cast<UIView::OnClickListener *>(\r
+          TraingOnClickListener::GetInstance());\r
+  button2_->SetOnClickListener(button2Click);\r
+\r
+  InitButton(button3_, BUTTON3_X, BUTTON3_Y, BUTTON_WIDHT, BUTTON_HEIGHT,\r
+             BUTTON3);\r
+  button3_->SetImageSrc(BOUTTONGROUND_IMAGE, BOUTTONGROUND_IMAGE);\r
+  UIView::OnClickListener *button3Click =\r
+      static_cast<UIView::OnClickListener *>(\r
+          TraingOnClickListener::GetInstance());\r
+  button3_->SetOnClickListener(button3Click);\r
+\r
+  InitButton(buttonmore_, BUTTONMORE_X, BUTTONMORE_Y, BUTTON_WIDHT,\r
+             BUTTON_HEIGHT, BUTTONMORE);\r
+  buttonmore_->SetImageSrc(BUTTONGROUND2_IMAGE, BUTTONGROUND2_IMAGE);\r
+  UIView::OnClickListener *button4Click =\r
+      static_cast<UIView::OnClickListener *>(\r
+          TraingOnClickListener::GetInstance());\r
+  buttonmore_->SetOnClickListener(button4Click);\r
+\r
+  return true;\r
+}\r
+/***\r
+ * @description:\r
+ * @return\r
+ * @brief 添加图片\r
+ */\r
+bool Training_CardView::AddImageView() {\r
+\r
+  InitImageView(btn1_image, BTN1_IMAGE_X, BTN1_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btn1_image", WALKING_60_IMAGE);\r
+  InitImageView(btn2_image, BTN2_IMAGE_X, BTN2_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btn2_image", FREE_60_IMAGE);\r
+  InitImageView(btn3_image, BTN3_IMAGE_X, BTN3_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btn3_image", RUNNING_60_IMAGE);\r
+  InitImageView(btnmore_image, BTNMORE_IMAGE_X, BTNMORE_IMAGE_Y, BTN_IMAGE_SIZE,\r
+                BTN_IMAGE_SIZE, "btnmore_image", MORE_ICON_IMAGE);\r
+  return true;\r
+}\r
+\r
+void Training_CardView::DeInitView() {\r
+\r
+  RemoveAll();\r
+\r
+  if (buttonmore_ != nullptr) {\r
+    delete buttonmore_;\r
+    buttonmore_ = nullptr;\r
+  }\r
+  if (button1_ != nullptr) {\r
+    delete button1_;\r
+    button1_ = nullptr;\r
+  }\r
+  if (button2_ != nullptr) {\r
+    delete button2_;\r
+    button2_ = nullptr;\r
+  }\r
+  if (button3_ != nullptr) {\r
+    delete button3_;\r
+    button3_ = nullptr;\r
+  }\r
+  if (title_label != nullptr) {\r
+    delete title_label;\r
+    title_label = nullptr;\r
+  }\r
+  if (btn1_label != nullptr) {\r
+    delete btn1_label;\r
+    btn1_label = nullptr;\r
+  }\r
+  if (btn2_label != nullptr) {\r
+    delete btn2_label;\r
+    btn2_label = nullptr;\r
+  }\r
+  if (btn3_label != nullptr) {\r
+    delete btn3_label;\r
+    btn3_label = nullptr;\r
+  }\r
+  if (btnmore_label != nullptr) {\r
+    delete btnmore_label;\r
+    btnmore_label = nullptr;\r
+  }\r
+  if (btn1_image != nullptr) {\r
+    delete btn1_image;\r
+    btn1_image = nullptr;\r
+  }\r
+  if (btn2_image != nullptr) {\r
+    delete btn2_image;\r
+    btn2_image = nullptr;\r
+  }\r
+  if (btn3_image != nullptr) {\r
+    delete btn3_image;\r
+    btn3_image = nullptr;\r
+  }\r
+  if (btnmore_image != nullptr) {\r
+    delete btnmore_image;\r
+    btnmore_image = nullptr;\r
+  }\r
+}\r
+\r
+bool Training_CardView::InitPage(void) {\r
+  // 初始化按键\r
+  if (AddButton() != true) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
+                  "Training_CardView::InitPage AddButton failed");\r
+    return false;\r
+  }\r
+  // 初始化标签\r
+  if (AddLabel() != true) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
+                  "Training_CardView::InitPage AddLabel failed");\r
+    return false;\r
+  }\r
+  // 初始化图片\r
+  if (AddImageView() != true) {\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,\r
+                  "Training_CardView::InitPage AddImageView failed");\r
+    return false;\r
+  }\r
+\r
+  Add(button1_);\r
+  Add(button2_);\r
+  Add(button3_);\r
+  Add(buttonmore_);\r
+\r
+  Add(title_label);\r
+\r
+  Add(btn1_label);\r
+  Add(btn2_label);\r
+  Add(btn3_label);\r
+  Add(btnmore_label);\r
+\r
+  Add(btn1_image);\r
+  Add(btn2_image);\r
+  Add(btn3_image);\r
+  Add(btnmore_image);\r
+\r
+  return true;\r
+}\r
+void Training_CardView::PreLoad(void) {\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Training_CardView::PreLoad");\r
+  if (!viewiInitStatus) {\r
+    InitPage();\r
+    viewiInitStatus = true;\r
+  }\r
+}\r
+\r
+void Training_CardView::UnLoad(void) {\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Training_CardView::UnLoad");\r
+}\r
+} // namespace OHOS\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticAdapter.h
new file mode 100644 (file)
index 0000000..5b776cf
--- /dev/null
@@ -0,0 +1,59 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 17:36:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:47:13
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingAquaticAapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingAquatic_ADAPTER_H
+#define TraingAquatic_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingAquaticItem;
+
+    class TraingAquaticAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingAquaticAdapter();
+        virtual ~TraingAquaticAdapter();
+
+        void SetData(std::list<TraingAquaticItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingAquaticItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingAquaticItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticItemView.h
new file mode 100644 (file)
index 0000000..1a81a0f
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef TraingAquatic_ITEM_VIEW_H
+#define TraingAquatic_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_aquatic/include/TraingAquaticAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingAquaticItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingAquaticItemView();
+        virtual ~TraingAquaticItemView();
+        virtual void SetItemInfo(const TraingAquaticItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingAquaticIndex();
+        UIResourceTextId GetTraingAquaticId();
+
+    private:
+        TraingAquaticItemView(const TraingAquaticItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingAquaticItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticModel.h
new file mode 100644 (file)
index 0000000..a67183a
--- /dev/null
@@ -0,0 +1,47 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:18:34
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:23:48
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingAquaticModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingAquatic_MODEL_H
+#define TraingAquatic_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingAquaticPresenter.h"
+#include "traing/training_list_aquatic/include/TraingAquaticAdapter.h"
+
+namespace OHOS
+{
+    class TraingAquaticModel
+    {
+    public:
+        static TraingAquaticModel &GetInstance(void);
+        void InitTraingAquaticListItem();
+        const TraingAquaticItem *GetTraingAquaticlistItems() const;
+        uint8_t GetTraingAquaticListNum() const;
+        // const std::map<TraingAquaticIndex, AppViewId> &GetTraingAquaticIdToViewId() const;
+
+    private:
+        TraingAquaticModel();
+        TraingAquaticModel(const TraingAquaticModel &);
+        TraingAquaticModel &operator=(const TraingAquaticModel &);
+        virtual ~TraingAquaticModel();
+        static const uint16_t TraingAquaticListMaxNum = 17;
+        TraingAquaticItem TraingAquatics[TraingAquaticListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+        // std::map<int, AppViewId> TraingAquaticIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticPresenter.h
new file mode 100644 (file)
index 0000000..ce02a9b
--- /dev/null
@@ -0,0 +1,53 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-26 09:57:18
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingAquaticPresenter.h
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:55:10
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingAquaticPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingAquatic_PRESENTER_H
+#define _TraingAquatic_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingAquaticView.h"
+
+namespace OHOS
+{
+    class TraingAquaticView;
+    class TraingAquaticModel;
+    class TraingAquaticPresenter : public Presenter<TraingAquaticView>,
+                                   public UIView::OnClickListener,
+                                   public RootView::OnKeyActListener,
+                                   public UIView::OnDragListener
+    {
+    public:
+        TraingAquaticPresenter();
+        virtual ~TraingAquaticPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingAquaticPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingAquaticModel *p_TraingAquaticModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/include/TraingAquaticView.h
new file mode 100644 (file)
index 0000000..ced206d
--- /dev/null
@@ -0,0 +1,57 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 11:15:59
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingAquaticView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingAquatic_VIEW_H
+#define TraingAquatic_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_list.h"
+#include "traing/training_list_aquatic/include/TraingAquaticAdapter.h"
+#include "traing/training_list_aquatic/include/TraingAquaticModel.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+
+namespace OHOS
+{
+    class TraingAquaticPresenter;
+    class TraingAquaticModel;
+    class TraingAquaticView : public View<TraingAquaticPresenter>, public UIViewGroup
+    {
+
+    public:
+        TraingAquaticView();
+        virtual ~TraingAquaticView();
+        static TraingAquaticView *GetInstance(void);
+
+        void OnStart() override;
+
+
+        UIList *GetList();
+        void AddToTraingAquaticList(const TraingAquaticItem &item);
+
+    private:
+      void InitView(void);
+      void DeInitView(void);
+      void InitList();
+      void InitScrollView();
+      void SetKeyActListener(void);
+      void PreLoad(void);
+
+    private:
+        UIScrollView *scrollView = nullptr;
+        TraingAquaticAdapter *p_TraingAquaticListAdapter{nullptr};
+        UIList *TraingAquaticList = nullptr;
+        bool viewInitStatus{false};
+    };
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticAdapter.cpp
new file mode 100644 (file)
index 0000000..2970c18
--- /dev/null
@@ -0,0 +1,87 @@
+#include "traing/training_list_aquatic/include/TraingAquaticAdapter.h"
+#include "traing/training_list_aquatic/include/TraingAquaticModel.h"
+#include "traing/training_list_aquatic/include/TraingAquaticItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingAquaticAdapter::TraingAquaticAdapter() {}
+
+    TraingAquaticAdapter::~TraingAquaticAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingAquaticAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingAquaticAdapter::SetData(std::list<TraingAquaticItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingAquaticItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingAquaticAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingAquaticItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingAquaticItem itemData = *it;
+        TraingAquaticItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingAquaticItemView();
+        }
+        else
+        {
+            item = static_cast<TraingAquaticItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingAquaticAdapter::AddItem(const TraingAquaticItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticItemView.cpp
new file mode 100644 (file)
index 0000000..5b1ae56
--- /dev/null
@@ -0,0 +1,105 @@
+#include "traing/training_list_aquatic/include/TraingAquaticItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingAquaticItemView::TraingAquaticItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingAquaticItemView::~TraingAquaticItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingAquaticItemView::SetItemInfo(const TraingAquaticItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_WATER_LIST:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_MAX_ID:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_WATER_LIST) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingAquaticItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingAquaticItemView::GetTraingAquaticIndex() {
+  return sItemInfo.id;
+}
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingAquaticItemView::GetTraingAquaticId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticModel.cpp
new file mode 100644 (file)
index 0000000..3dfa0e3
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+#include "traing/training_list_aquatic/include/TraingAquaticModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingAquaticModel::TraingAquaticModel() {}
+
+TraingAquaticModel::~TraingAquaticModel() {}
+
+TraingAquaticModel &TraingAquaticModel::GetInstance() {
+  static TraingAquaticModel instance;
+  return instance;
+}
+
+void TraingAquaticModel::InitTraingAquaticListItem() {
+  TraingAquaticItem defaultItems[] = {
+      {VIEW_TRAININGNOMAL, STR_WATER_LIST},
+      {VIEW_TRAININGNOMAL, STR_WATER_ACTIVITIES},
+      {VIEW_TRAININGNOMAL, STR_WATER_SAILING},
+      {VIEW_TRAININGNOMAL, STR_WATER_SURFING},
+      {VIEW_TRAININGNOMAL, STR_WATER_WHITEWATERRAFTING},
+      {VIEW_TRAININGNOMAL, STR_WATER_CANOEING},
+      {VIEW_TRAININGNOMAL, STR_WATER_KAYAKING},
+      {VIEW_TRAININGNOMAL, STR_WATER_ROWING},
+      {VIEW_TRAININGNOMAL, STR_WATER_MOTORBOAT},
+      {VIEW_TRAININGNOMAL, STR_WATER_SUP},
+      {VIEW_TRAININGNOMAL, STR_WATER_SCUBADIVING},
+      {VIEW_TRAININGNOMAL, STR_WATER_DIVING},
+      {VIEW_TRAININGNOMAL, STR_WATER_KITESURFING},
+      {VIEW_TRAININGNOMAL, STR_WATER_WAKEBOARDING},
+      {VIEW_TRAININGNOMAL, STR_WATER_POLO},
+      {VIEW_TRAININGNOMAL, STR_WATER_WINDSURFING},
+      {VIEW_TRAININGNOMAL, STR_WATER_DRIFTING},
+      {VIEW_TRAININGNOMAL, STR_WATER_FITNESS},
+      {VIEW_TRAININGNOMAL, STR_WATER_SPORTS},
+      {VIEW_TRAININGNOMAL, STR_MAX_ID},
+  };
+
+  for (int i = 0; i < TraingAquaticListMaxNum; i++) {
+    TraingAquatics[i] = defaultItems[i];
+  }
+}
+
+const TraingAquaticItem *TraingAquaticModel::GetTraingAquaticlistItems() const {
+  return TraingAquatics;
+}
+uint8_t TraingAquaticModel::GetTraingAquaticListNum() const {
+  return TraingAquaticListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticPresenter.cpp
new file mode 100644 (file)
index 0000000..92b376f
--- /dev/null
@@ -0,0 +1,124 @@
+
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_aquatic/include/TraingAquaticItemView.h"
+#include "traing/training_list_aquatic/include/TraingAquaticPresenter.h"
+#include "traing/training_list_aquatic/include/TraingAquaticView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+// #include "TraingAquaticView.h"
+
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGAQUATIC, TraingAquaticView, TraingAquaticPresenter);
+
+    extern const char *Aquatic_buttons[];
+    extern char *Aquatic_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingAquaticPresenter *g_pTraingAquaticPresenter = nullptr;
+
+    TraingAquaticPresenter::TraingAquaticPresenter()
+    {
+        p_TraingAquaticModel = &TraingAquaticModel::GetInstance();
+        g_pTraingAquaticPresenter = this;
+    }
+
+    TraingAquaticPresenter::~TraingAquaticPresenter()
+    {
+
+        g_pTraingAquaticPresenter = nullptr;
+    }
+
+    TraingAquaticPresenter *TraingAquaticPresenter::GetInstance()
+    {
+
+        return g_pTraingAquaticPresenter;
+    }
+
+    void TraingAquaticPresenter::OnStart()
+    {
+        p_TraingAquaticModel->InitTraingAquaticListItem();
+        Presenter<TraingAquaticView>::OnStart();
+    }
+
+    void TraingAquaticPresenter::OnPause(void)
+    {
+        Presenter<TraingAquaticView>::OnPause();
+    }
+
+    void TraingAquaticPresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingAquaticItem *itemInfo = p_TraingAquaticModel->GetTraingAquaticlistItems();
+        for (int i = 0; i < p_TraingAquaticModel->GetTraingAquaticListNum(); i++)
+        {
+            view_->AddToTraingAquaticList(itemInfo[i]);
+        }
+        Presenter<TraingAquaticView>::OnResume();
+    }
+
+    void TraingAquaticPresenter::OnStop(void)
+    {
+
+        Presenter<TraingAquaticView>::OnStop();
+    }
+    bool TraingAquaticPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingAquaticPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingAquaticPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        TraingAquaticItemView *itemView = static_cast<TraingAquaticItemView *>(&view);
+        // 传递训练项目
+        AppViewId viewId = itemView->GetTraingAquaticIndex();
+        UIResourceTextId sportid = itemView->GetTraingAquaticId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+    bool TraingAquaticPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_aquatic/src/TraingAquaticView.cpp
new file mode 100644 (file)
index 0000000..6769b0b
--- /dev/null
@@ -0,0 +1,121 @@
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_aquatic/include/TraingAquaticPresenter.h"
+#include "traing/training_list_aquatic/include/TraingAquaticView.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingAquaticView *g_pTraingAquaticView{nullptr};
+
+TraingAquaticView::TraingAquaticView() { g_pTraingAquaticView = this; }
+
+TraingAquaticView::~TraingAquaticView() { 
+  DeInitView();
+  g_pTraingAquaticView = nullptr; }
+
+TraingAquaticView *TraingAquaticView::GetInstance() {
+  return g_pTraingAquaticView;
+}
+
+void TraingAquaticView::AddToTraingAquaticList(const TraingAquaticItem &item) {
+  if (p_TraingAquaticListAdapter) {
+    p_TraingAquaticListAdapter->AddItem(item);
+  }
+}
+
+void TraingAquaticView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingAquaticPresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingAquaticView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingAquaticView::InitList() {
+  if (p_TraingAquaticListAdapter == nullptr) {
+    p_TraingAquaticListAdapter = new TraingAquaticAdapter();
+  }
+  p_TraingAquaticListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingAquaticList == nullptr) {
+    TraingAquaticList = new UIList();
+  }
+  TraingAquaticList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                                 VERTICAL_RESOLUTION);
+  TraingAquaticList->SetThrowDrag(true);
+  TraingAquaticList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingAquaticList->SetMaxScrollDistance(1000);
+  TraingAquaticList->SetSwipeACCLevel(200);
+  TraingAquaticList->SetDragACCLevel(5);
+  TraingAquaticList->SetRotateFactor(1);
+  TraingAquaticList->RequestFocus();
+}
+
+void TraingAquaticView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingAquaticView::DeInitView() {
+  if (viewInitStatus) {
+
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingAquaticListAdapter) {
+          delete p_TraingAquaticListAdapter;
+          p_TraingAquaticListAdapter = nullptr;
+        }
+        if (TraingAquaticList) {
+          delete TraingAquaticList;
+          TraingAquaticList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+  }
+}
+
+void TraingAquaticView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingAquaticView::OnStart() {
+  View<TraingAquaticPresenter>::OnStart();
+
+  PreLoad();
+
+
+  if (scrollView && TraingAquaticList) {
+    scrollView->Add(TraingAquaticList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingAquaticListAdapter) {
+      TraingAquaticList->SetAdapter(p_TraingAquaticListAdapter);
+    }
+  }
+}
+
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallAdapter.h
new file mode 100644 (file)
index 0000000..32b517a
--- /dev/null
@@ -0,0 +1,51 @@
+
+#ifndef TraingBall_ADAPTER_H
+#define TraingBall_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingBallItem;
+
+    class TraingBallAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingBallAdapter();
+        virtual ~TraingBallAdapter();
+
+        void SetData(std::list<TraingBallItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingBallItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingBallItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallItemView.h
new file mode 100644 (file)
index 0000000..2a1582d
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef TraingBall_ITEM_VIEW_H
+#define TraingBall_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_ball/include/TraingBallAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingBallItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingBallItemView();
+        virtual ~TraingBallItemView();
+        virtual void SetItemInfo(const TraingBallItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingBallIndex();
+        UIResourceTextId GetTraingBallId();
+
+    private:
+        TraingBallItemView(const TraingBallItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingBallItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallModel.h
new file mode 100644 (file)
index 0000000..7e71b63
--- /dev/null
@@ -0,0 +1,47 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:18:34
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 16:08:21
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/include/TraingBallModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingBall_MODEL_H
+#define TraingBall_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingBallPresenter.h"
+#include "traing/training_list_ball/include/TraingBallAdapter.h"
+
+namespace OHOS
+{
+    class TraingBallModel
+    {
+    public:
+        static TraingBallModel &GetInstance(void);
+        void InitTraingBallListItem();
+        const TraingBallItem *GetTraingBalllistItems() const;
+        uint8_t GetTraingBallListNum() const;
+        // const std::map<TraingBallIndex, AppViewId> &GetTraingBallIdToViewId() const;
+
+    private:
+        TraingBallModel();
+        TraingBallModel(const TraingBallModel &);
+        TraingBallModel &operator=(const TraingBallModel &);
+        virtual ~TraingBallModel();
+        static const uint16_t TraingBallListMaxNum = 31;
+        TraingBallItem TraingBalls[TraingBallListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+        // std::map<int, AppViewId> TraingBallIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallPresenter.h
new file mode 100644 (file)
index 0000000..236e251
--- /dev/null
@@ -0,0 +1,53 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-26 09:49:56
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/include/TraingBallPresenter.h
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:49:35
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingBallPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingBall_PRESENTER_H
+#define _TraingBall_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingBallView.h"
+
+namespace OHOS
+{
+    class TraingBallView;
+    class TraingBallModel;
+    class TraingBallPresenter : public Presenter<TraingBallView>,
+                                public UIView::OnClickListener,
+                                public RootView::OnKeyActListener,
+                                public UIView::OnDragListener
+    {
+    public:
+        TraingBallPresenter();
+        virtual ~TraingBallPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingBallPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+       
+        TraingBallModel *p_TraingBallModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/include/TraingBallView.h
new file mode 100644 (file)
index 0000000..3424f16
--- /dev/null
@@ -0,0 +1,57 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 11:15:59
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/include/TraingBallView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingBall_VIEW_H
+#define TraingBall_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_ball/include/TraingBallAdapter.h"
+#include "traing/training_list_ball/include/TraingBallModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingBallPresenter;
+class TraingBallModel;
+class TraingBallView : public View<TraingBallPresenter>, public UIViewGroup {
+
+public:
+  TraingBallView();
+  virtual ~TraingBallView();
+  static TraingBallView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  void AddToTraingBallList(const TraingBallItem &item);
+
+private:
+  void InitView(void);
+  void InitList();
+  void InitScrollView();
+  void DeInitView(void);
+  void PreLoad(void);
+  void SetKeyActListener(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingBallAdapter *p_TraingBallListAdapter{nullptr};
+  UIList *TraingBallList = nullptr;
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallAdapter.cpp
new file mode 100644 (file)
index 0000000..681e562
--- /dev/null
@@ -0,0 +1,87 @@
+#include "traing/training_list_ball/include/TraingBallAdapter.h"
+#include "traing/training_list_ball/include/TraingBallModel.h"
+#include "traing/training_list_ball/include/TraingBallItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingBallAdapter::TraingBallAdapter() {}
+
+    TraingBallAdapter::~TraingBallAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingBallAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingBallAdapter::SetData(std::list<TraingBallItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingBallItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingBallAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingBallItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingBallItem itemData = *it;
+        TraingBallItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingBallItemView();
+        }
+        else
+        {
+            item = static_cast<TraingBallItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingBallAdapter::AddItem(const TraingBallItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallItemView.cpp
new file mode 100644 (file)
index 0000000..dd4062c
--- /dev/null
@@ -0,0 +1,103 @@
+#include "traing/training_list_ball/include/TraingBallItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingBallItemView::TraingBallItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingBallItemView::~TraingBallItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingBallItemView::SetItemInfo(const TraingBallItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_BALL_LIST_TITLE:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_BALL_LIST:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_BALL_LIST_TITLE) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingBallItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingBallItemView::GetTraingBallIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingBallItemView::GetTraingBallId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallModel.cpp
new file mode 100644 (file)
index 0000000..2b2348c
--- /dev/null
@@ -0,0 +1,77 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:51:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:56:44
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_ball/src/TraingBallModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_ball/include/TraingBallModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingBallModel::TraingBallModel() {}
+
+TraingBallModel::~TraingBallModel() {}
+
+TraingBallModel &TraingBallModel::GetInstance() {
+  static TraingBallModel instance;
+  return instance;
+}
+
+void TraingBallModel::InitTraingBallListItem() {
+  TraingBallItem defaultItems[] = {
+      {VIEW_TRAININGNOMAL, STR_BALL_LIST_TITLE},
+      {VIEW_TRAININGNOMAL, STR_BALL_GAMES},
+      {VIEW_TRAININGNOMAL, STR_BALL_BADMINTON},
+      {VIEW_TRAININGNOMAL, STR_BALL_TABLETENNIS},
+      {VIEW_TRAININGNOMAL, STR_BALL_TENNIS},
+      {VIEW_TRAININGNOMAL, STR_BALL_BILLIARDS},
+      {VIEW_TRAININGNOMAL, STR_BALL_BOWLING},
+      {VIEW_TRAININGNOMAL, STR_BALL_VOLLEYBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_SHUTTLECOCK},
+      {VIEW_TRAININGNOMAL, STR_BALL_HANDBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_BASEBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_SOFTBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_CRICKET},
+      {VIEW_TRAININGNOMAL, STR_BALL_FOOTBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_BEACHSOCCER},
+      {VIEW_TRAININGNOMAL, STR_BALL_BEACHVOLLEYBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_CROQUET},
+      {VIEW_TRAININGNOMAL, STR_BALL_HOCKEY},
+      {VIEW_TRAININGNOMAL, STR_BALL_SQUASH},
+      {VIEW_TRAININGNOMAL, STR_BALL_SEPAKTAKRAW},
+      {VIEW_TRAININGNOMAL, STR_BALL_DODGEBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_BASKETBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_SOCCER},
+      {VIEW_TRAININGNOMAL, STR_BALL_GOLF},
+      {VIEW_TRAININGNOMAL, STR_BALL_POLO},
+      {VIEW_TRAININGNOMAL, STR_BALL_RACQUETBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_RUGBY},
+      {VIEW_TRAININGNOMAL, STR_BALL_GATEBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_PICKLEBALL},
+      {VIEW_TRAININGNOMAL, STR_BALL_LACROSSE},
+      {VIEW_TRAININGNOMAL, STR_BALL_LIST},
+  };
+
+  for (int i = 0; i < TraingBallListMaxNum; i++) {
+    TraingBalls[i] = defaultItems[i];
+  }
+}
+
+const TraingBallItem *TraingBallModel::GetTraingBalllistItems() const {
+  return TraingBalls;
+}
+uint8_t TraingBallModel::GetTraingBallListNum() const {
+  return TraingBallListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallPresenter.cpp
new file mode 100644 (file)
index 0000000..916e4a6
--- /dev/null
@@ -0,0 +1,124 @@
+
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_ball/include/TraingBallItemView.h"
+#include "traing/training_list_ball/include/TraingBallPresenter.h"
+#include "traing/training_list_ball/include/TraingBallView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+// #include "TraingBallView.h"
+
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGBALL, TraingBallView, TraingBallPresenter);
+
+    extern const char *Ball_buttons[];
+    extern char *Ball_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingBallPresenter *g_pTraingBallPresenter = nullptr;
+
+    TraingBallPresenter::TraingBallPresenter()
+    {
+        p_TraingBallModel = &TraingBallModel::GetInstance();
+        g_pTraingBallPresenter = this;
+    }
+
+    TraingBallPresenter::~TraingBallPresenter()
+    {
+
+        g_pTraingBallPresenter = nullptr;
+    }
+
+    TraingBallPresenter *TraingBallPresenter::GetInstance()
+    {
+
+        return g_pTraingBallPresenter;
+    }
+
+    void TraingBallPresenter::OnStart()
+    {
+        p_TraingBallModel->InitTraingBallListItem();
+        Presenter<TraingBallView>::OnStart();
+    }
+
+    void TraingBallPresenter::OnPause(void)
+    {
+        Presenter<TraingBallView>::OnPause();
+    }
+
+    void TraingBallPresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingBallItem *itemInfo = p_TraingBallModel->GetTraingBalllistItems();
+        for (int i = 0; i < p_TraingBallModel->GetTraingBallListNum(); i++)
+        {
+            view_->AddToTraingBallList(itemInfo[i]);
+        }
+        Presenter<TraingBallView>::OnResume();
+    }
+
+    void TraingBallPresenter::OnStop(void)
+    {
+
+        Presenter<TraingBallView>::OnStop();
+    }
+    bool TraingBallPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingBallPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingBallPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        TraingBallItemView *itemView = static_cast<TraingBallItemView *>(&view);
+        // 传递训练项目
+        AppViewId viewId = itemView->GetTraingBallIndex();
+        UIResourceTextId sportid = itemView->GetTraingBallId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+
+    bool TraingBallPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ball/src/TraingBallView.cpp
new file mode 100644 (file)
index 0000000..5ca38c4
--- /dev/null
@@ -0,0 +1,119 @@
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_ball/include/TraingBallPresenter.h"
+#include "traing/training_list_ball/include/TraingBallView.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingBallView *g_pTraingBallView{nullptr};
+
+TraingBallView::TraingBallView() { g_pTraingBallView = this; }
+
+TraingBallView::~TraingBallView() { 
+  DeInitView();
+  g_pTraingBallView = nullptr; }
+
+TraingBallView *TraingBallView::GetInstance() { return g_pTraingBallView; }
+
+void TraingBallView::AddToTraingBallList(const TraingBallItem &item) {
+  if (p_TraingBallListAdapter) {
+    p_TraingBallListAdapter->AddItem(item);
+  }
+}
+
+void TraingBallView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingBallPresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingBallView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingBallView::InitList() {
+  if (p_TraingBallListAdapter == nullptr) {
+    p_TraingBallListAdapter = new TraingBallAdapter();
+  }
+  p_TraingBallListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingBallList == nullptr) {
+    TraingBallList = new UIList();
+  }
+  TraingBallList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                              VERTICAL_RESOLUTION);
+  TraingBallList->SetThrowDrag(true);
+  TraingBallList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingBallList->SetMaxScrollDistance(1000);
+  TraingBallList->SetSwipeACCLevel(200);
+  TraingBallList->SetDragACCLevel(5);
+  TraingBallList->SetRotateFactor(1);
+  TraingBallList->RequestFocus();
+}
+
+void TraingBallView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingBallView::DeInitView() {
+  if (viewInitStatus) {
+
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingBallListAdapter) {
+          delete p_TraingBallListAdapter;
+          p_TraingBallListAdapter = nullptr;
+        }
+        if (TraingBallList) {
+          delete TraingBallList;
+          TraingBallList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+ 
+  }
+}
+
+void TraingBallView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingBallView::OnStart() {
+
+
+  PreLoad();
+
+  if (scrollView && TraingBallList) {
+    scrollView->Add(TraingBallList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingBallListAdapter) {
+      TraingBallList->SetAdapter(p_TraingBallListAdapter);
+    }
+  }
+}
+
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceAdapter.h
new file mode 100644 (file)
index 0000000..4cb14c9
--- /dev/null
@@ -0,0 +1,58 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:09:52
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 14:20:36
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingDanceAdapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingDance_ADAPTER_H
+#define TraingDance_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "ui_resource_string.h"
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingDanceItem;
+
+    class TraingDanceAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingDanceAdapter();
+        virtual ~TraingDanceAdapter();
+
+        void SetData(std::list<TraingDanceItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingDanceItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingDanceItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceItemView.h
new file mode 100644 (file)
index 0000000..8ee77f7
--- /dev/null
@@ -0,0 +1,40 @@
+
+
+#ifndef TraingDance_ITEM_VIEW_H
+#define TraingDance_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_dance/include/TraingDanceAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingDanceItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingDanceItemView();
+        virtual ~TraingDanceItemView();
+        virtual void SetItemInfo(const TraingDanceItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingDanceIndex();
+        UIResourceTextId GetTraingDanceId();
+    private:
+        TraingDanceItemView(const TraingDanceItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingDanceItem sItemInfo = {VIEW_INVALID, STR_DANCING_GENERAL};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceModel.h
new file mode 100644 (file)
index 0000000..b0a874b
--- /dev/null
@@ -0,0 +1,47 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 15:23:46
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 15:36:18
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/include/TraingDanceModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingDance_MODEL_H
+#define TraingDance_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingDancePresenter.h"
+#include "traing/training_list_dance/include/TraingDanceAdapter.h"
+
+namespace OHOS
+{
+    class TraingDanceModel
+    {
+    public:
+        static TraingDanceModel &GetInstance(void);
+        void InitTraingDanceListItem();
+        const TraingDanceItem *GetTraingDancelistItems() const;
+        uint8_t GetTraingDanceListNum() const;
+        // const std::map<TraingDanceIndex, AppViewId> &GetTraingDanceIdToViewId() const;
+
+    private:
+        TraingDanceModel();
+        TraingDanceModel(const TraingDanceModel &);
+        TraingDanceModel &operator=(const TraingDanceModel &);
+        virtual ~TraingDanceModel();
+        static const uint16_t TraingDanceListMaxNum = 12;
+        TraingDanceItem TraingDances[TraingDanceListMaxNum] = {VIEW_INVALID, STR_DANCING_GENERAL};
+        // std::map<int, AppViewId> TraingDanceIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDancePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDancePresenter.h
new file mode 100644 (file)
index 0000000..9994802
--- /dev/null
@@ -0,0 +1,47 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 09:44:11
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 14:22:01
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingDancePresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingDance_PRESENTER_H
+#define _TraingDance_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingDanceView.h"
+
+namespace OHOS
+{
+    class TraingDanceView;
+    class TraingDanceModel;
+    class TraingDancePresenter : public Presenter<TraingDanceView>,
+                                 public UIView::OnClickListener,
+                                 public RootView::OnKeyActListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingDancePresenter();
+        virtual ~TraingDancePresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingDancePresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingDanceModel *p_TraingDanceModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/include/TraingDanceView.h
new file mode 100644 (file)
index 0000000..0a4c248
--- /dev/null
@@ -0,0 +1,47 @@
+
+#ifndef TraingDance_VIEW_H
+#define TraingDance_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_dance/include/TraingDanceAdapter.h"
+#include "traing/training_list_dance/include/TraingDanceModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingDancePresenter;
+class TraingDanceModel;
+class TraingDanceView : public View<TraingDancePresenter>, public UIViewGroup {
+
+public:
+  TraingDanceView();
+  virtual ~TraingDanceView();
+  static TraingDanceView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  void AddToTraingDanceList(const TraingDanceItem &item);
+
+private:
+  void InitView(void);
+  void InitList();
+  void InitScrollView();
+  void DeInitView(void);
+  void PreLoad(void);
+  void SetKeyActListener(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingDanceAdapter *p_TraingDanceListAdapter{nullptr};
+  UIList *TraingDanceList = nullptr;
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceAdapter.cpp
new file mode 100644 (file)
index 0000000..4faf50d
--- /dev/null
@@ -0,0 +1,95 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:12:53
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 15:27:47
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_dance/src/TraingDanceAdapter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "traing/training_list_dance/include/TraingDanceAdapter.h"
+#include "traing/training_list_dance/include/TraingDanceModel.h"
+#include "traing/training_list_dance/include/TraingDanceItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingDanceAdapter::TraingDanceAdapter() {}
+
+    TraingDanceAdapter::~TraingDanceAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingDanceAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingDanceAdapter::SetData(std::list<TraingDanceItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingDanceItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingDanceAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingDanceItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingDanceItem itemData = *it;
+        TraingDanceItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingDanceItemView();
+        }
+        else
+        {
+            item = static_cast<TraingDanceItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingDanceAdapter::AddItem(const TraingDanceItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceItemView.cpp
new file mode 100644 (file)
index 0000000..6ba3435
--- /dev/null
@@ -0,0 +1,103 @@
+#include "traing/training_list_dance/include/TraingDanceItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingDanceItemView::TraingDanceItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingDanceItemView::~TraingDanceItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingDanceItemView::SetItemInfo(const TraingDanceItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_DANCING_TITLE:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_DANCING_LIST:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_DANCING_TITLE) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingDanceItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingDanceItemView::GetTraingDanceIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingDanceItemView::GetTraingDanceId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceModel.cpp
new file mode 100644 (file)
index 0000000..02048fc
--- /dev/null
@@ -0,0 +1,52 @@
+
+
+#include "traing/training_list_dance/include/TraingDanceModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingDanceModel::TraingDanceModel() {}
+
+TraingDanceModel::~TraingDanceModel() {}
+
+TraingDanceModel &TraingDanceModel::GetInstance() {
+  static TraingDanceModel instance;
+  return instance;
+}
+
+// static char *text[] = {"一般舞蹈", "肚皮舞", "爵士舞", "拉丁舞", "芭蕾",
+// "街舞", "广场舞", "尊巴", "社交舞", "踢踏舞"};
+
+void TraingDanceModel::InitTraingDanceListItem() {
+  int index = 0;
+
+  // 为 TraingDances 数组赋值
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_TITLE};   // title
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_GENERAL}; // general
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_BELLY};   // belly
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_JAZZ};    // jazz
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_LATIN};   // latin
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_BALLET};  // ballet
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_STREET};  // street
+  TraingDances[index++] = {VIEW_TRAININGNOMAL,
+                           STR_DANCING_PUBLICSQUARE}; // public square
+  TraingDances[index++] = {VIEW_TRAININGNOMAL, STR_DANCING_ZUMBA}; // zumba
+  TraingDances[index++] = {VIEW_TRAININGNOMAL,
+                           STR_DANCING_SOCIALDANCE}; // social dance
+  TraingDances[index++] = {VIEW_TRAININGNOMAL,
+                           STR_DANCING_TAPDANCE};               // tap dance
+  TraingDances[index] = {VIEW_TRAININGNOMAL, STR_DANCING_LIST}; // end
+}
+
+const TraingDanceItem *TraingDanceModel::GetTraingDancelistItems() const {
+  return TraingDances;
+}
+uint8_t TraingDanceModel::GetTraingDanceListNum() const {
+  return TraingDanceListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDancePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDancePresenter.cpp
new file mode 100644 (file)
index 0000000..47a5642
--- /dev/null
@@ -0,0 +1,123 @@
+
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_dance/include/TraingDanceItemView.h"
+#include "traing/training_list_dance/include/TraingDancePresenter.h"
+#include "traing/training_list_dance/include/TraingDanceView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGDANCE, TraingDanceView, TraingDancePresenter);
+
+    extern const char *Dance_buttons[];
+    extern char *Dance_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingDancePresenter *g_pTraingDancePresenter = nullptr;
+
+    TraingDancePresenter::TraingDancePresenter()
+    {
+        p_TraingDanceModel = &TraingDanceModel::GetInstance();
+        g_pTraingDancePresenter = this;
+    }
+
+    TraingDancePresenter::~TraingDancePresenter()
+    {
+
+        g_pTraingDancePresenter = nullptr;
+    }
+
+    TraingDancePresenter *TraingDancePresenter::GetInstance()
+    {
+
+        return g_pTraingDancePresenter;
+    }
+
+    void TraingDancePresenter::OnStart()
+    {
+        p_TraingDanceModel->InitTraingDanceListItem();
+        Presenter<TraingDanceView>::OnStart();
+    }
+
+    void TraingDancePresenter::OnPause(void)
+    {
+        Presenter<TraingDanceView>::OnPause();
+    }
+
+    void TraingDancePresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingDanceItem *itemInfo = p_TraingDanceModel->GetTraingDancelistItems();
+        for (int i = 0; i < p_TraingDanceModel->GetTraingDanceListNum(); i++)
+        {
+            view_->AddToTraingDanceList(itemInfo[i]);
+        }
+        Presenter<TraingDanceView>::OnResume();
+    }
+
+    void TraingDancePresenter::OnStop(void)
+    {
+
+        Presenter<TraingDanceView>::OnStop();
+    }
+    bool TraingDancePresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingDancePresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingDancePresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        // 传递训练项目
+        TraingDanceItemView *itemView = static_cast<TraingDanceItemView *>(&view);
+        AppViewId viewId = itemView->GetTraingDanceIndex();
+        UIResourceTextId sportid = itemView->GetTraingDanceId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+
+    bool TraingDancePresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_dance/src/TraingDanceView.cpp
new file mode 100644 (file)
index 0000000..52a7042
--- /dev/null
@@ -0,0 +1,120 @@
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_dance/include/TraingDancePresenter.h"
+#include "traing/training_list_dance/include/TraingDanceView.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingDanceView *g_pTraingDanceView{nullptr};
+
+TraingDanceView::TraingDanceView() { g_pTraingDanceView = this; }
+
+TraingDanceView::~TraingDanceView() { 
+  DeInitView();
+  g_pTraingDanceView = nullptr; }
+
+TraingDanceView *TraingDanceView::GetInstance() { return g_pTraingDanceView; }
+
+void TraingDanceView::AddToTraingDanceList(const TraingDanceItem &item) {
+  if (p_TraingDanceListAdapter) {
+    p_TraingDanceListAdapter->AddItem(item);
+  }
+}
+
+void TraingDanceView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingDancePresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingDanceView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingDanceView::InitList() {
+  if (p_TraingDanceListAdapter == nullptr) {
+    p_TraingDanceListAdapter = new TraingDanceAdapter();
+  }
+  p_TraingDanceListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingDanceList == nullptr) {
+    TraingDanceList = new UIList();
+  }
+  TraingDanceList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                              VERTICAL_RESOLUTION);
+  TraingDanceList->SetThrowDrag(true);
+  TraingDanceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingDanceList->SetMaxScrollDistance(1000);
+  TraingDanceList->SetSwipeACCLevel(200);
+  TraingDanceList->SetDragACCLevel(5);
+  TraingDanceList->SetRotateFactor(1);
+  TraingDanceList->RequestFocus();
+}
+
+void TraingDanceView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingDanceView::DeInitView() {
+  if (viewInitStatus) {
+
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingDanceListAdapter) {
+          delete p_TraingDanceListAdapter;
+          p_TraingDanceListAdapter = nullptr;
+        }
+        if (TraingDanceList) {
+          delete TraingDanceList;
+          TraingDanceList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+
+  }
+}
+
+void TraingDanceView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingDanceView::OnStart() {
+
+  PreLoad();
+
+
+  if (scrollView && TraingDanceList) {
+    scrollView->Add(TraingDanceList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingDanceListAdapter) {
+      TraingDanceList->SetAdapter(p_TraingDanceListAdapter);
+    }
+
+  }
+}
+
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessAdapter.h
new file mode 100644 (file)
index 0000000..ffa57e7
--- /dev/null
@@ -0,0 +1,57 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:09:52
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 14:21:09
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingFitnessAdapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingFitness_ADAPTER_H
+#define TraingFitness_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingFitnessItem;
+
+    class TraingFitnessAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingFitnessAdapter();
+        virtual ~TraingFitnessAdapter();
+
+        void SetData(std::list<TraingFitnessItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingFitnessItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingFitnessItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessItemView.h
new file mode 100644 (file)
index 0000000..ca58ea1
--- /dev/null
@@ -0,0 +1,36 @@
+
+
+#ifndef TraingFitness_ITEM_VIEW_H
+#define TraingFitness_ITEM_VIEW_H
+
+#include "AppViewIDs.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "ohos_types.h"
+#include "traing/training_list_fitness/include/TraingFitnessAdapter.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingFitnessItemView : public UIViewGroup {
+public:
+  explicit TraingFitnessItemView();
+  virtual ~TraingFitnessItemView();
+  virtual void SetItemInfo(const TraingFitnessItem itemInfo);
+  virtual void SetUpChild();
+  AppViewId GetTraingFitnessIndex();
+  UIResourceTextId GetTraingFitnessId();
+
+private:
+  TraingFitnessItemView(const TraingFitnessItemView &);
+  UIImageView sbackground; // 背景
+  UIImageView sicon;       // 箭头
+  UILabelExt sLabel;       // 标签
+  TraingFitnessItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+};
+
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h
new file mode 100644 (file)
index 0000000..8780384
--- /dev/null
@@ -0,0 +1,42 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-09-06 18:47:14
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessModel.h
+ */
+
+#ifndef TraingFitness_MODEL_H
+#define TraingFitness_MODEL_H
+
+#include "AppViewIDs.h"
+#include "TraingFitnessPresenter.h"
+#include "UiConfig.h"
+#include "traing/training_list_fitness/include/TraingFitnessAdapter.h"
+#include <cstdint>
+#include <map>
+
+namespace OHOS {
+class TraingFitnessModel {
+public:
+  static TraingFitnessModel &GetInstance(void);
+  void InitTraingFitnessListItem();
+  const TraingFitnessItem *GetTraingFitnesslistItems() const;
+  uint8_t GetTraingFitnessListNum() const;
+  // const std::map<TraingFitnessIndex, AppViewId> &GetTraingFitnessIdToViewId()
+  // const;
+
+private:
+  TraingFitnessModel();
+  TraingFitnessModel(const TraingFitnessModel &);
+  TraingFitnessModel &operator=(const TraingFitnessModel &);
+  virtual ~TraingFitnessModel();
+  static const uint16_t TraingFitnessListMaxNum = 60;
+
+  TraingFitnessItem TraingFitnesss[TraingFitnessListMaxNum] = {
+      VIEW_INVALID, STR_EXERCISE_GENERAL};
+  bool btConnectStatus{false};
+};
+} // namespace OHOS
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessPresenter.h
new file mode 100644 (file)
index 0000000..709a443
--- /dev/null
@@ -0,0 +1,62 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-26 10:00:13
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessPresenter.h
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 09:40:03
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:02:30
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/include/TraingFitnessPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 09:44:11
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 11:29:03
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingFitnessPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingFitness_PRESENTER_H
+#define _TraingFitness_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingFitnessView.h"
+
+namespace OHOS
+{
+    class TraingFitnessView;
+    class TraingFitnessModel;
+    class TraingFitnessPresenter : public Presenter<TraingFitnessView>,
+                                   public UIView::OnClickListener,
+                                   public UIView::OnDragListener,
+                                   public RootView::OnKeyActListener
+
+    {
+    public:
+        TraingFitnessPresenter();
+        virtual ~TraingFitnessPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingFitnessPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingFitnessModel *p_TraingFitnessModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/include/TraingFitnessView.h
new file mode 100644 (file)
index 0000000..48e1a5f
--- /dev/null
@@ -0,0 +1,51 @@
+
+
+#ifndef TraingFitness_VIEW_H
+#define TraingFitness_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_fitness/include/TraingFitnessAdapter.h"
+#include "traing/training_list_fitness/include/TraingFitnessModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingFitnessPresenter;
+class TraingFitnessModel;
+class TraingFitnessView : public View<TraingFitnessPresenter>,
+                          public UIViewGroup {
+
+public:
+  TraingFitnessView();
+  virtual ~TraingFitnessView();
+  static TraingFitnessView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  UIScrollView *GetScrollView();
+
+  void AddToTraingFitnessList(const TraingFitnessItem &item);
+
+private:
+  void InitView(void);
+  void DeInitView(void);
+  void InitList();
+  void InitScrollView();
+  void SetKeyActListener(void);
+  void PreLoad(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingFitnessAdapter *p_TraingFitnessListAdapter{nullptr};
+  UIList *TraingFitnessList = nullptr;
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessAdapter.cpp
new file mode 100644 (file)
index 0000000..36cbba2
--- /dev/null
@@ -0,0 +1,95 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:12:53
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 11:16:09
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessAdapter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "traing/training_list_fitness/include/TraingFitnessAdapter.h"
+#include "traing/training_list_fitness/include/TraingFitnessModel.h"
+#include "traing/training_list_fitness/include/TraingFitnessItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingFitnessAdapter::TraingFitnessAdapter() {}
+
+    TraingFitnessAdapter::~TraingFitnessAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingFitnessAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingFitnessAdapter::SetData(std::list<TraingFitnessItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingFitnessItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingFitnessAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingFitnessItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingFitnessItem itemData = *it;
+        TraingFitnessItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingFitnessItemView();
+        }
+        else
+        {
+            item = static_cast<TraingFitnessItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingFitnessAdapter::AddItem(const TraingFitnessItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessItemView.cpp
new file mode 100644 (file)
index 0000000..5e85353
--- /dev/null
@@ -0,0 +1,105 @@
+#include "traing/training_list_fitness/include/TraingFitnessItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingFitnessItemView::TraingFitnessItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingFitnessItemView::~TraingFitnessItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingFitnessItemView::SetItemInfo(const TraingFitnessItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_EXERCISE_TITLE:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_EXERCISE_LIST:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_EXERCISE_TITLE) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingFitnessItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingFitnessItemView::GetTraingFitnessIndex() {
+  return sItemInfo.id;
+}
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingFitnessItemView::GetTraingFitnessId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessModel.cpp
new file mode 100644 (file)
index 0000000..d963706
--- /dev/null
@@ -0,0 +1,103 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 18:34:15
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 18:36:25
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_fitness/include/TraingFitnessModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "ui_resource_image.h"
+namespace OHOS {
+
+TraingFitnessModel::TraingFitnessModel() {}
+
+TraingFitnessModel::~TraingFitnessModel() {}
+
+TraingFitnessModel &TraingFitnessModel::GetInstance() {
+  static TraingFitnessModel instance;
+  return instance;
+}
+UIResourceTextId text[] = {
+    STR_EXERCISE_TITLE, // title 健身运动
+    STR_EXERCISE_OUTDOORWALKING,
+    STR_EXERCISE_OUTDOORRUNNING,
+    STR_EXERCISE_OUTDOORBIKING,
+    STR_EXERCISE_GENERAL,
+    STR_EXERCISE_FREETRAINING,
+    STR_EXERCISE_RESISTANCETRAINING,
+    STR_EXERCISE_SPINBIKE,
+    STR_EXERCISE_TREADMILL,
+    STR_EXERCISE_STROLLMACHINE,
+    STR_EXERCISE_HIIT,
+    STR_EXERCISE_CROSSFIT,
+    STR_EXERCISE_GROUPCALISTHENICS,
+    STR_EXERCISE_YOGA,
+    STR_EXERCISE_YOGACAT,
+    STR_EXERCISE_YOGACOW,
+    STR_EXERCISE_YOGACOBRA,
+    STR_EXERCISE_YOGAHERO1,
+    STR_EXERCISE_YOGAHERO2,
+    STR_EXERCISE_YOGAHERO3,
+    STR_EXERCISE_YOGAROLLING,
+    STR_EXERCISE_INDOORWALKING,
+    STR_EXERCISE_INDOORRUNNING,
+    STR_EXERCISE_JUMPINGROPE,
+    STR_EXERCISE_PILATES,
+    STR_EXERCISE_CROSS_FIT,
+    STR_EXERCISE_FUNCTIONALTRAINING,
+    STR_EXERCISE_PHYSICALTRAINING,
+    STR_EXERCISE_TAEKWONDO,
+    STR_EXERCISE_BOXING,
+    STR_EXERCISE_KICKBOXING,
+    STR_EXERCISE_KARATE,
+    STR_EXERCISE_FENCING,
+    STR_EXERCISE_CORETRAINING,
+    STR_EXERCISE_BODYCOMBAT,
+    STR_EXERCISE_KENDO,
+    STR_EXERCISE_HORIZONTALBAR,
+    STR_EXERCISE_PARALLELBARS,
+    STR_EXERCISE_CIRCUIT,
+    STR_EXERCISE_AEROBICS,
+    STR_EXERCISE_CALISTHENICE,
+    STR_EXERCISE_P90X,
+    STR_EXERCISE_KETTLEBELLTRAINING,
+    STR_EXERCISE_MIXEDMARTIALARTS,
+    STR_EXERCISE_STAIRCLIMBINGMACHINE,
+    STR_EXERCISE_WEIGHTLIFTING,
+    STR_EXERCISE_BARRE,
+    STR_EXERCISE_HANDCYCLING,
+    STR_EXERCISE_TRACKFIELD,
+    STR_EXERCISE_WRESTLING,
+    STR_EXERCISE_MINDBODY,
+    STR_EXERCISE_FLEXIBILITY,
+    STR_EXERCISE_MIXEDCARDIO,
+    STR_EXERCISE_TRADITIONALSTRENGTHTRAINING,
+    STR_EXERCISE_CROSSTRAINING,
+    STR_EXERCISE_GYMNASTICS,
+    STR_EXERCISE_STEPTRAINING,
+    STR_EXERCISE_ELLIPTICALTRAINER,
+    STR_EXERCISE_ROWINGMACHINE,
+    STR_EXERCISE_LIST, //健身类
+};
+
+void TraingFitnessModel::InitTraingFitnessListItem() {
+  for (int i = 0; i < TraingFitnessListMaxNum; ++i) // 更新循环以适应 59 个元素
+  {
+    TraingFitnesss[i] = {VIEW_TRAININGNOMAL, text[i]};
+  }
+}
+const TraingFitnessItem *TraingFitnessModel::GetTraingFitnesslistItems() const {
+  return TraingFitnesss;
+}
+uint8_t TraingFitnessModel::GetTraingFitnessListNum() const {
+  return TraingFitnessListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessPresenter.cpp
new file mode 100644 (file)
index 0000000..985fa59
--- /dev/null
@@ -0,0 +1,151 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:19
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 19:51:06
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_fitness/src/TraingFitnessPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:19
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 14:23:32
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingFitnessPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_fitness/include/TraingFitnessItemView.h"
+#include "traing/training_list_fitness/include/TraingFitnessPresenter.h"
+#include "traing/training_list_fitness/include/TraingFitnessView.h"
+// #include "TraingFitnessView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGFITNESS, TraingFitnessView, TraingFitnessPresenter);
+
+    extern const char *Fitness_buttons[];
+    extern char *Fitness_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingFitnessPresenter *g_pTraingFitnessPresenter = nullptr;
+
+    TraingFitnessPresenter::TraingFitnessPresenter()
+    {
+        p_TraingFitnessModel = &TraingFitnessModel::GetInstance();
+        g_pTraingFitnessPresenter = this;
+    }
+
+    TraingFitnessPresenter::~TraingFitnessPresenter()
+    {
+
+        g_pTraingFitnessPresenter = nullptr;
+    }
+
+    TraingFitnessPresenter *TraingFitnessPresenter::GetInstance()
+    {
+
+        return g_pTraingFitnessPresenter;
+    }
+
+    void TraingFitnessPresenter::OnStart()
+    {
+        p_TraingFitnessModel->InitTraingFitnessListItem();
+        Presenter<TraingFitnessView>::OnStart();
+    }
+
+    void TraingFitnessPresenter::OnPause(void)
+    {
+        Presenter<TraingFitnessView>::OnPause();
+    }
+
+    void TraingFitnessPresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingFitnessItem *itemInfo = p_TraingFitnessModel->GetTraingFitnesslistItems();
+        for (int i = 0; i < p_TraingFitnessModel->GetTraingFitnessListNum(); i++)
+        {
+            view_->AddToTraingFitnessList(itemInfo[i]);
+        }
+        Presenter<TraingFitnessView>::OnResume();
+    }
+
+    void TraingFitnessPresenter::OnStop(void)
+    {
+
+        Presenter<TraingFitnessView>::OnStop();
+    }
+    bool TraingFitnessPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingFitnessPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingFitnessPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        TraingFitnessItemView *itemView = static_cast<TraingFitnessItemView *>(&view);
+        AppViewId viewId = itemView->GetTraingFitnessIndex();
+        UIResourceTextId sportid = itemView->GetTraingFitnessId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+
+    bool TraingFitnessPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+#if 0
+    bool TraingFitnessPresenter::OnPress(UIView &view, const PressEvent &event)
+    {
+        if (&view == TraingFitnessView::GetInstance()->GetScrollView())
+        {
+            TraingFitnessView::GetInstance()->GetScrollView()->RequestFocus();
+            return true;
+        }
+        else if (&view == TraingFitnessView::GetInstance()->GetList())
+        {
+            TraingFitnessView::GetInstance()->GetList()->RequestFocus();
+            return true;
+        }
+        return false;
+    }
+#endif
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_fitness/src/TraingFitnessView.cpp
new file mode 100644 (file)
index 0000000..6a93662
--- /dev/null
@@ -0,0 +1,122 @@
+#include "traing/training_list_fitness/include/TraingFitnessView.h"
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_fitness/include/TraingFitnessPresenter.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingFitnessView *g_pTraingFitnessView{nullptr};
+
+TraingFitnessView::TraingFitnessView() { g_pTraingFitnessView = this; }
+
+TraingFitnessView::~TraingFitnessView() { 
+  DeInitView();
+  g_pTraingFitnessView = nullptr; }
+
+TraingFitnessView *TraingFitnessView::GetInstance() {
+  return g_pTraingFitnessView;
+}
+
+void TraingFitnessView::AddToTraingFitnessList(const TraingFitnessItem &item) {
+  if (p_TraingFitnessListAdapter) {
+    p_TraingFitnessListAdapter->AddItem(item);
+  }
+}
+
+void TraingFitnessView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingFitnessPresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingFitnessView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingFitnessView::InitList() {
+  if (p_TraingFitnessListAdapter == nullptr) {
+    p_TraingFitnessListAdapter = new TraingFitnessAdapter();
+  }
+  p_TraingFitnessListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingFitnessList == nullptr) {
+    TraingFitnessList = new UIList();
+  }
+  TraingFitnessList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                                 VERTICAL_RESOLUTION);
+  TraingFitnessList->SetThrowDrag(true);
+  TraingFitnessList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingFitnessList->SetMaxScrollDistance(1000);
+  TraingFitnessList->SetSwipeACCLevel(200);
+  TraingFitnessList->SetDragACCLevel(5);
+  TraingFitnessList->SetRotateFactor(1);
+  TraingFitnessList->RequestFocus();
+}
+
+void TraingFitnessView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingFitnessView::DeInitView() {
+  if (viewInitStatus) {
+ 
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingFitnessListAdapter) {
+          delete p_TraingFitnessListAdapter;
+          p_TraingFitnessListAdapter = nullptr;
+        }
+        if (TraingFitnessList) {
+          delete TraingFitnessList;
+          TraingFitnessList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+  
+  }
+}
+
+void TraingFitnessView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingFitnessView::OnStart() {
+ 
+  PreLoad();
+
+
+  if (scrollView && TraingFitnessList) {
+    scrollView->Add(TraingFitnessList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingFitnessListAdapter) {
+      TraingFitnessList->SetAdapter(p_TraingFitnessListAdapter);
+    }
+
+  }
+}
+
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceAdapter.h
new file mode 100644 (file)
index 0000000..d5afbe9
--- /dev/null
@@ -0,0 +1,66 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:09:52
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-30 11:26:25
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingIceAdapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:09:52
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-28 19:54:05
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingIceAdapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingIce_ADAPTER_H
+#define TraingIce_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingIceItem;
+
+    class TraingIceAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingIceAdapter();
+        virtual ~TraingIceAdapter();
+
+        void SetData(std::list<TraingIceItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingIceItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingIceItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceItemView.h
new file mode 100644 (file)
index 0000000..b060ed2
--- /dev/null
@@ -0,0 +1,39 @@
+
+
+#ifndef TraingIce_ITEM_VIEW_H
+#define TraingIce_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_ice/include/TraingIceAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingIceItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingIceItemView();
+        virtual ~TraingIceItemView();
+        virtual void SetItemInfo(const TraingIceItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingIceIndex();
+        UIResourceTextId GetTraingIceId();
+
+    private:
+        TraingIceItemView(const TraingIceItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingIceItem sItemInfo = {VIEW_INVALID, STR_ICE_SPORTS};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceModel.h
new file mode 100644 (file)
index 0000000..7ce9b80
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef TraingIce_MODEL_H
+#define TraingIce_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingIcePresenter.h"
+#include "traing/training_list_ice/include/TraingIceAdapter.h"
+
+namespace OHOS
+{
+    class TraingIceModel
+    {
+    public:
+        static TraingIceModel &GetInstance(void);
+        void InitTraingIceListItem();
+        const TraingIceItem *GetTraingIcelistItems() const;
+        uint8_t GetTraingIceListNum() const;
+        // const std::map<TraingIceIndex, AppViewId> &GetTraingIceIdToViewId() const;
+
+    private:
+        TraingIceModel();
+        TraingIceModel(const TraingIceModel &);
+        TraingIceModel &operator=(const TraingIceModel &);
+        virtual ~TraingIceModel();
+        static const uint16_t TraingIceListMaxNum = 14;
+        TraingIceItem TraingIces[TraingIceListMaxNum] = {VIEW_INVALID, STR_ICE_SPORTS};
+        // std::map<int, AppViewId> TraingIceIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIcePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIcePresenter.h
new file mode 100644 (file)
index 0000000..51d7f65
--- /dev/null
@@ -0,0 +1,47 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 09:44:11
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 14:22:01
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/include/TraingIcePresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingIce_PRESENTER_H
+#define _TraingIce_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingIceView.h"
+
+namespace OHOS
+{
+    class TraingIceView;
+    class TraingIceModel;
+    class TraingIcePresenter : public Presenter<TraingIceView>,
+                               public UIView::OnClickListener,
+                               public RootView::OnKeyActListener,
+                               public UIView::OnDragListener
+    {
+    public:
+        TraingIcePresenter();
+        virtual ~TraingIcePresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingIcePresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingIceModel *p_TraingIceModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/include/TraingIceView.h
new file mode 100644 (file)
index 0000000..c50229f
--- /dev/null
@@ -0,0 +1,48 @@
+
+#ifndef TraingIce_VIEW_H
+#define TraingIce_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_ice/include/TraingIceAdapter.h"
+#include "traing/training_list_ice/include/TraingIceModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingIcePresenter;
+class TraingIceModel;
+class TraingIceView : public View<TraingIcePresenter>, public UIViewGroup {
+
+public:
+  TraingIceView();
+  virtual ~TraingIceView();
+  static TraingIceView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  void AddToTraingIceList(const TraingIceItem &item);
+
+private:
+  void InitView(void);
+  void DeInitView(void);
+  void InitList();
+  void InitScrollView();
+  void SetKeyActListener(void);
+  void PreLoad(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingIceAdapter *p_TraingIceListAdapter{nullptr};
+  UIList *TraingIceList = nullptr;
+
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceAdapter.cpp
new file mode 100644 (file)
index 0000000..4416328
--- /dev/null
@@ -0,0 +1,95 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:12:53
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 15:27:45
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceAdapter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "traing/training_list_ice/include/TraingIceAdapter.h"
+#include "traing/training_list_ice/include/TraingIceModel.h"
+#include "traing/training_list_ice/include/TraingIceItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingIceAdapter::TraingIceAdapter() {}
+
+    TraingIceAdapter::~TraingIceAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingIceAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingIceAdapter::SetData(std::list<TraingIceItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingIceItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingIceAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingIceItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingIceItem itemData = *it;
+        TraingIceItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingIceItemView();
+        }
+        else
+        {
+            item = static_cast<TraingIceItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingIceAdapter::AddItem(const TraingIceItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceItemView.cpp
new file mode 100644 (file)
index 0000000..da24e2a
--- /dev/null
@@ -0,0 +1,103 @@
+#include "traing/training_list_ice/include/TraingIceItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingIceItemView::TraingIceItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingIceItemView::~TraingIceItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingIceItemView::SetItemInfo(const TraingIceItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_ICE_LIST:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_MAX_ID:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_ICE_LIST) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingIceItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingIceItemView::GetTraingIceIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingIceItemView::GetTraingIceId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceModel.cpp
new file mode 100644 (file)
index 0000000..b2d16f8
--- /dev/null
@@ -0,0 +1,64 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 18:34:15
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 18:36:25
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_ice/src/TraingIceModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_ice/include/TraingIceModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingIceModel::TraingIceModel() {}
+
+TraingIceModel::~TraingIceModel() {}
+
+TraingIceModel &TraingIceModel::GetInstance() {
+  static TraingIceModel instance;
+  return instance;
+}
+// static char *text[] = {"一般冰上运动", "溜冰", "冰球", "冰石壶/冰壶",
+// "雪上摩托车", "雪橇", "冬季两项", "越野滑雪", "滑雪", "单板滑雪/滑雪板",
+// "雪鞋健行", "雪地运动"};
+
+// 使用一个数组来存储文本字符串
+UIResourceTextId iceSports[] = {STR_ICE_LIST,
+                                STR_ICE_SPORTS,
+                                STR_ICE_SKATING,
+                                STR_ICE_HOCKEY,
+                                STR_ICE_CURLING,
+                                STR_ICE_SNOWMOBILING,
+                                STR_ICE_SLED,
+                                STR_ICE_BIATHLON,
+                                STR_ICE_CROSSCOUNTRYSKING,
+                                STR_ICE_SKIING,
+                                STR_ICE_SNOWBOARDING,
+                                STR_ICE_SNOWSHOEING,
+                                STR_ICE_SNOWSPORTS,
+                                STR_MAX_ID};
+void TraingIceModel::InitTraingIceListItem() {
+
+  // 使用循环来初始化 TraingIces 数组
+  for (int index = 0; index < sizeof(iceSports) / sizeof(iceSports[0]);
+       ++index) {
+    TraingIces[index] = {VIEW_TRAININGNOMAL, iceSports[index]};
+  }
+}
+
+const TraingIceItem *TraingIceModel::GetTraingIcelistItems() const {
+  return TraingIces;
+}
+uint8_t TraingIceModel::GetTraingIceListNum() const {
+  return TraingIceListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIcePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIcePresenter.cpp
new file mode 100644 (file)
index 0000000..4e1bc42
--- /dev/null
@@ -0,0 +1,122 @@
+
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_ice/include/TraingIceItemView.h"
+#include "traing/training_list_ice/include/TraingIcePresenter.h"
+#include "traing/training_list_ice/include/TraingIceView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGICE, TraingIceView, TraingIcePresenter);
+
+    extern const char *Ice_buttons[];
+    extern char *Ice_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingIcePresenter *g_pTraingIcePresenter = nullptr;
+
+    TraingIcePresenter::TraingIcePresenter()
+    {
+        p_TraingIceModel = &TraingIceModel::GetInstance();
+        g_pTraingIcePresenter = this;
+    }
+
+    TraingIcePresenter::~TraingIcePresenter()
+    {
+
+        g_pTraingIcePresenter = nullptr;
+    }
+
+    TraingIcePresenter *TraingIcePresenter::GetInstance()
+    {
+
+        return g_pTraingIcePresenter;
+    }
+
+    void TraingIcePresenter::OnStart()
+    {
+        p_TraingIceModel->InitTraingIceListItem();
+        Presenter<TraingIceView>::OnStart();
+    }
+
+    void TraingIcePresenter::OnPause(void)
+    {
+        Presenter<TraingIceView>::OnPause();
+    }
+
+    void TraingIcePresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingIceItem *itemInfo = p_TraingIceModel->GetTraingIcelistItems();
+        for (int i = 0; i < p_TraingIceModel->GetTraingIceListNum(); i++)
+        {
+            view_->AddToTraingIceList(itemInfo[i]);
+        }
+        Presenter<TraingIceView>::OnResume();
+    }
+
+    void TraingIcePresenter::OnStop(void)
+    {
+
+        Presenter<TraingIceView>::OnStop();
+    }
+    bool TraingIcePresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingIcePresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingIcePresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        TraingIceItemView *itemView = static_cast<TraingIceItemView *>(&view);
+        AppViewId viewId = itemView->GetTraingIceIndex();
+        UIResourceTextId sportid = itemView->GetTraingIceId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+
+    bool TraingIcePresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_ice/src/TraingIceView.cpp
new file mode 100644 (file)
index 0000000..ace4ad7
--- /dev/null
@@ -0,0 +1,122 @@
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_ice/include/TraingIcePresenter.h"
+#include "traing/training_list_ice/include/TraingIceView.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingIceView *g_pTraingIceView{nullptr};
+
+TraingIceView::TraingIceView() { g_pTraingIceView = this; }
+
+TraingIceView::~TraingIceView() { 
+  DeInitView();
+  g_pTraingIceView = nullptr; }
+
+TraingIceView *TraingIceView::GetInstance() {
+  return g_pTraingIceView;
+}
+
+void TraingIceView::AddToTraingIceList(const TraingIceItem &item) {
+  if (p_TraingIceListAdapter) {
+    p_TraingIceListAdapter->AddItem(item);
+  }
+}
+
+void TraingIceView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingIcePresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingIceView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingIceView::InitList() {
+  if (p_TraingIceListAdapter == nullptr) {
+    p_TraingIceListAdapter = new TraingIceAdapter();
+  }
+  p_TraingIceListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingIceList == nullptr) {
+    TraingIceList = new UIList();
+  }
+  TraingIceList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                                 VERTICAL_RESOLUTION);
+  TraingIceList->SetThrowDrag(true);
+  TraingIceList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingIceList->SetMaxScrollDistance(1000);
+  TraingIceList->SetSwipeACCLevel(200);
+  TraingIceList->SetDragACCLevel(5);
+  TraingIceList->SetRotateFactor(1);
+  TraingIceList->RequestFocus();
+}
+
+void TraingIceView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingIceView::DeInitView() {
+  if (viewInitStatus) {
+   
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingIceListAdapter) {
+          delete p_TraingIceListAdapter;
+          p_TraingIceListAdapter = nullptr;
+        }
+        if (TraingIceList) {
+          delete TraingIceList;
+          TraingIceList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+  
+  }
+}
+
+void TraingIceView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingIceView::OnStart() {
+
+  PreLoad();
+
+  if (scrollView && TraingIceList) {
+    scrollView->Add(TraingIceList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingIceListAdapter) {
+      TraingIceList->SetAdapter(p_TraingIceListAdapter);
+    }
+  
+  }
+  
+}
+
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitAdapter.h
new file mode 100644 (file)
index 0000000..6b35a6a
--- /dev/null
@@ -0,0 +1,59 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 17:04:41
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 11:16:42
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingLimitAdapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingLimit_ADAPTER_H
+#define TraingLimit_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingLimitItem;
+
+    class TraingLimitAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingLimitAdapter();
+        virtual ~TraingLimitAdapter();
+
+        void SetData(std::list<TraingLimitItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingLimitItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingLimitItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitItemView.h
new file mode 100644 (file)
index 0000000..b77a884
--- /dev/null
@@ -0,0 +1,40 @@
+
+
+#ifndef TraingLimit_ITEM_VIEW_H
+#define TraingLimit_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_limit/include/TraingLimitAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingLimitItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingLimitItemView();
+        virtual ~TraingLimitItemView();
+        virtual void SetItemInfo(const TraingLimitItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingLimitIndex();
+        UIResourceTextId GetTraingLimitId();
+
+    private:
+        TraingLimitItemView(const TraingLimitItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingLimitItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitModel.h
new file mode 100644 (file)
index 0000000..317d9dd
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef TraingLimit_MODEL_H
+#define TraingLimit_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingLimitPresenter.h"
+#include "traing/training_list_limit/include/TraingLimitAdapter.h"
+
+namespace OHOS
+{
+    class TraingLimitModel
+    {
+    public:
+        static TraingLimitModel &GetInstance(void);
+        void InitTraingLimitListItem();
+        const TraingLimitItem *GetTraingLimitlistItems() const;
+        uint8_t GetTraingLimitListNum() const;
+        // const std::map<TraingLimitIndex, AppViewId> &GetTraingLimitIdToViewId() const;
+
+    private:
+        TraingLimitModel();
+        TraingLimitModel(const TraingLimitModel &);
+        TraingLimitModel &operator=(const TraingLimitModel &);
+        virtual ~TraingLimitModel();
+        static const uint16_t TraingLimitListMaxNum = 12;
+        TraingLimitItem TraingLimits[TraingLimitListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+        // std::map<int, AppViewId> TraingLimitIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitPresenter.h
new file mode 100644 (file)
index 0000000..4ab2cd3
--- /dev/null
@@ -0,0 +1,47 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:20:50
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingLimitPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingLimit_PRESENTER_H
+#define _TraingLimit_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingLimitView.h"
+
+namespace OHOS
+{
+    class TraingLimitView;
+    class TraingLimitModel;
+    class TraingLimitPresenter : public Presenter<TraingLimitView>,
+                                 public UIView::OnClickListener,
+                                 public RootView::OnKeyActListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingLimitPresenter();
+        virtual ~TraingLimitPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingLimitPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingLimitModel *p_TraingLimitModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/include/TraingLimitView.h
new file mode 100644 (file)
index 0000000..cf722e8
--- /dev/null
@@ -0,0 +1,57 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:21:13
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingLimitView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingLimit_VIEW_H
+#define TraingLimit_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_limit/include/TraingLimitAdapter.h"
+#include "traing/training_list_limit/include/TraingLimitModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingLimitPresenter;
+class TraingLimitModel;
+class TraingLimitView : public View<TraingLimitPresenter>, public UIViewGroup {
+
+public:
+  TraingLimitView();
+  virtual ~TraingLimitView();
+  static TraingLimitView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  void AddToTraingLimitList(const TraingLimitItem &item);
+
+private:
+  void InitView(void);
+  void DeInitView(void);
+  void InitList();
+  void InitScrollView();
+  void SetKeyActListener(void);
+  void PreLoad(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingLimitAdapter *p_TraingLimitListAdapter{nullptr};
+  UIList *TraingLimitList = nullptr;
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitAdapter.cpp
new file mode 100644 (file)
index 0000000..bd847e0
--- /dev/null
@@ -0,0 +1,87 @@
+#include "traing/training_list_limit/include/TraingLimitAdapter.h"
+#include "traing/training_list_limit/include/TraingLimitModel.h"
+#include "traing/training_list_limit/include/TraingLimitItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingLimitAdapter::TraingLimitAdapter() {}
+
+    TraingLimitAdapter::~TraingLimitAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingLimitAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingLimitAdapter::SetData(std::list<TraingLimitItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingLimitItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingLimitAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingLimitItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingLimitItem itemData = *it;
+        TraingLimitItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingLimitItemView();
+        }
+        else
+        {
+            item = static_cast<TraingLimitItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingLimitAdapter::AddItem(const TraingLimitItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitItemView.cpp
new file mode 100644 (file)
index 0000000..89b1398
--- /dev/null
@@ -0,0 +1,103 @@
+#include "traing/training_list_limit/include/TraingLimitItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingLimitItemView::TraingLimitItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingLimitItemView::~TraingLimitItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingLimitItemView::SetItemInfo(const TraingLimitItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_EXTREME_LIST:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_MAX_ID:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_EXTREME_LIST) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingLimitItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingLimitItemView::GetTraingLimitIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingLimitItemView::GetTraingLimitId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitModel.cpp
new file mode 100644 (file)
index 0000000..3486a59
--- /dev/null
@@ -0,0 +1,44 @@
+
+
+#include "traing/training_list_limit/include/TraingLimitModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingLimitModel::TraingLimitModel() {}
+
+TraingLimitModel::~TraingLimitModel() {}
+
+TraingLimitModel &TraingLimitModel::GetInstance() {
+  static TraingLimitModel instance;
+  return instance;
+}
+
+// static char *text[] = {"一般极限运动", "滑板", "攀岩", "高空弹跳/蹦极",
+// "跑酷", "BMX", "定向越野", "跳伞", "赛车", "铁人三项运动"};
+// 创建一个字符串数组,存储所有极限运动的 UI 资源标识符
+UIResourceTextId extremeSports[] = {
+    STR_EXTREME_LIST,          STR_EXTREME_SPORTS,
+    STR_EXTREME_SKATEBOARDING, STR_EXTREME_ROCKCLIMBING,
+    STR_EXTREME_BUNGEEJUMPING, STR_EXTREME_PARKOUR,
+    STR_EXTREME_BMX,           STR_EXTREME_ORIENTEERING,
+    STR_EXTREME_PARACHUTE,     STR_EXTREME_RACING,
+    STR_EXTREME_TRIATHLONS,    STR_MAX_ID};
+void TraingLimitModel::InitTraingLimitListItem() {
+  for (int index = 0; index < sizeof(extremeSports) / sizeof(extremeSports[0]);
+       ++index) {
+    TraingLimits[index] = {VIEW_TRAININGNOMAL, extremeSports[index]};
+  }
+}
+const TraingLimitItem *TraingLimitModel::GetTraingLimitlistItems() const {
+  return TraingLimits;
+}
+uint8_t TraingLimitModel::GetTraingLimitListNum() const {
+  return TraingLimitListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitPresenter.cpp
new file mode 100644 (file)
index 0000000..ecdde1c
--- /dev/null
@@ -0,0 +1,122 @@
+\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+\r
+#include "KeyInputListener.h"\r
+#include "custom_utils.h"\r
+#include "common/key_code.h"\r
+\r
+#include <iostream>\r
+#include <chrono>\r
+#include <thread>\r
+#include "traing/training_list_limit/include/TraingLimitItemView.h"\r
+#include "traing/training_list_limit/include/TraingLimitPresenter.h"\r
+#include "traing/training_list_limit/include/TraingLimitView.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+// #include "TraingLimitView.h"\r
+\r
+\r
+#include "NativeRegisterManager.h"\r
+namespace OHOS\r
+{\r
+    REGIST_SLICE(VIEW_TRAININGLIMIT, TraingLimitView, TraingLimitPresenter);\r
+\r
+    extern const char *Limit_buttons[];\r
+    extern char *Limit_text[];\r
+\r
+    // 当前Presenter属性实例化的内存指针\r
+    static TraingLimitPresenter *g_pTraingLimitPresenter = nullptr;\r
+\r
+    TraingLimitPresenter::TraingLimitPresenter()\r
+    {\r
+        p_TraingLimitModel = &TraingLimitModel::GetInstance();\r
+        g_pTraingLimitPresenter = this;\r
+    }\r
+\r
+    TraingLimitPresenter::~TraingLimitPresenter()\r
+    {\r
+\r
+        g_pTraingLimitPresenter = nullptr;\r
+    }\r
+\r
+    TraingLimitPresenter *TraingLimitPresenter::GetInstance()\r
+    {\r
+\r
+        return g_pTraingLimitPresenter;\r
+    }\r
+\r
+    void TraingLimitPresenter::OnStart()\r
+    {\r
+        p_TraingLimitModel->InitTraingLimitListItem();\r
+        Presenter<TraingLimitView>::OnStart();\r
+    }\r
+\r
+    void TraingLimitPresenter::OnPause(void)\r
+    {\r
+        Presenter<TraingLimitView>::OnPause();\r
+    }\r
+\r
+    void TraingLimitPresenter::OnResume(void)\r
+    {\r
+        if (view_ == nullptr)\r
+        {\r
+            return;\r
+        }\r
+        const TraingLimitItem *itemInfo = p_TraingLimitModel->GetTraingLimitlistItems();\r
+        for (int i = 0; i < p_TraingLimitModel->GetTraingLimitListNum(); i++)\r
+        {\r
+            view_->AddToTraingLimitList(itemInfo[i]);\r
+        }\r
+        Presenter<TraingLimitView>::OnResume();\r
+    }\r
+\r
+    void TraingLimitPresenter::OnStop(void)\r
+    {\r
+\r
+        Presenter<TraingLimitView>::OnStop();\r
+    }\r
+    bool TraingLimitPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        return true;\r
+    }\r
+    bool TraingLimitPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+    {\r
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);\r
+        }\r
+        UNUSED(view);\r
+        return true;\r
+    }\r
+\r
+    bool TraingLimitPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+    {\r
+        UNUSED(event);\r
+        TraingLimitItemView *itemView = static_cast<TraingLimitItemView *>(&view);\r
+        AppViewId viewId = itemView->GetTraingLimitIndex();\r
+        UIResourceTextId sportid = itemView->GetTraingLimitId();\r
+        TraingModel::GetInstance()->SetSportEvent(sportid);\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);\r
+        if (viewId < VIEW_MAX_INTER_APP)\r
+        {\r
+            NativeAbility::GetInstance().EnterSlice(viewId);\r
+            return true;\r
+        }\r
+        return false;\r
+    }\r
+    bool TraingLimitPresenter::OnKeyAct(UIView &view, const KeyEvent &event)\r
+    {\r
+        unsigned short keyID = event.GetKeyId();\r
+        unsigned short keyState = event.GetState();\r
+\r
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+        {\r
+            NativeAbility::GetInstance().Back();\r
+        }\r
+        return true;\r
+    }\r
+}\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_limit/src/TraingLimitView.cpp
new file mode 100644 (file)
index 0000000..2fbb6cf
--- /dev/null
@@ -0,0 +1,123 @@
+#include "UiConfig.h"\r
+#include "components/ui_label_ext.h"\r
+#include "traing/Training_UiConfig.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "traing/training_list_limit/include/TraingLimitPresenter.h"\r
+#include "traing/training_list_limit/include/TraingLimitView.h"\r
+#include "ui_resource_string.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "wearable_log.h"\r
+#include <memory>\r
+\r
+\r
+namespace OHOS {\r
+static TraingLimitView *g_pTraingLimitView{nullptr};\r
+\r
+TraingLimitView::TraingLimitView() { g_pTraingLimitView = this; }\r
+\r
+TraingLimitView::~TraingLimitView() { \r
+  DeInitView();\r
+  g_pTraingLimitView = nullptr; }\r
+\r
+TraingLimitView *TraingLimitView::GetInstance() {\r
+  return g_pTraingLimitView;\r
+}\r
+\r
+void TraingLimitView::AddToTraingLimitList(const TraingLimitItem &item) {\r
+  if (p_TraingLimitListAdapter) {\r
+    p_TraingLimitListAdapter->AddItem(item);\r
+  }\r
+}\r
+\r
+void TraingLimitView::SetKeyActListener() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");\r
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(\r
+      TraingLimitPresenter::GetInstance());\r
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);\r
+}\r
+\r
+void TraingLimitView::InitScrollView() {\r
+  if (scrollView == nullptr) {\r
+    scrollView = new UIScrollView();\r
+  }\r
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),\r
+                          Screen::GetInstance().GetHeight());\r
+  scrollView->SetTouchable(true);\r
+  scrollView->SetDraggable(true);\r
+  scrollView->SetDirection(1);\r
+  scrollView->SetHorizontalScrollState(false);\r
+  scrollView->SetOnDragListener(presenter_);\r
+  scrollView->SetYScrollBarVisible(true);\r
+}\r
+\r
+void TraingLimitView::InitList() {\r
+  if (p_TraingLimitListAdapter == nullptr) {\r
+    p_TraingLimitListAdapter = new TraingLimitAdapter();\r
+  }\r
+  p_TraingLimitListAdapter->SetItemClickListener(presenter_);\r
+\r
+  if (TraingLimitList == nullptr) {\r
+    TraingLimitList = new UIList();\r
+  }\r
+  TraingLimitList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,\r
+                                 VERTICAL_RESOLUTION);\r
+  TraingLimitList->SetThrowDrag(true);\r
+  TraingLimitList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+  TraingLimitList->SetMaxScrollDistance(1000);\r
+  TraingLimitList->SetSwipeACCLevel(200);\r
+  TraingLimitList->SetDragACCLevel(5);\r
+  TraingLimitList->SetRotateFactor(1);\r
+  TraingLimitList->RequestFocus();\r
+}\r
+\r
+void TraingLimitView::InitView() {\r
+  InitScrollView();\r
+  InitList();\r
+  SetKeyActListener();\r
+}\r
+\r
+void TraingLimitView::DeInitView() {\r
+  if (viewInitStatus) {\r
+\r
+      if (scrollView) {\r
+        scrollView->RemoveAll();\r
+        if (p_TraingLimitListAdapter) {\r
+          delete p_TraingLimitListAdapter;\r
+          p_TraingLimitListAdapter = nullptr;\r
+        }\r
+        if (TraingLimitList) {\r
+          delete TraingLimitList;\r
+          TraingLimitList = nullptr;\r
+        }\r
+        delete scrollView;\r
+        scrollView = nullptr;\r
+      }\r
+ \r
+  }\r
+}\r
+\r
+void TraingLimitView::PreLoad() {\r
+  if (!viewInitStatus) {\r
+    InitView();\r
+    viewInitStatus = true;\r
+  }\r
+}\r
+\r
+void TraingLimitView::OnStart() {\r
+\r
+  PreLoad();\r
+\r
+\r
+  if (scrollView && TraingLimitList) {\r
+    scrollView->Add(TraingLimitList);\r
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+    AddViewToRootContainer(scrollView);\r
+    if (p_TraingLimitListAdapter) {\r
+      TraingLimitList->SetAdapter(p_TraingLimitListAdapter);\r
+    }\r
+ \r
+  }\r
+}\r
+\r
+\r
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreAdapter.h
new file mode 100644 (file)
index 0000000..0389fd3
--- /dev/null
@@ -0,0 +1,57 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-05-08 09:52:10
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/include/TraingMoreAdapter.h
+ */
+
+#ifndef TraingMore_ADAPTER_H
+#define TraingMore_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+        const char *logo;
+    } TraingMoreItem;
+
+    class TraingMoreAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingMoreAdapter();
+        virtual ~TraingMoreAdapter();
+
+        void SetData(std::list<TraingMoreItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingMoreItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingMoreItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreItemView.h
new file mode 100644 (file)
index 0000000..78505d6
--- /dev/null
@@ -0,0 +1,47 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:12:32
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-30 11:05:58
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_more/include/TraingMoreItemView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingMore_ITEM_VIEW_H
+#define TraingMore_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_more/include/TraingMoreAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingMoreItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingMoreItemView();
+        virtual ~TraingMoreItemView();
+        virtual void SetItemInfo(const TraingMoreItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingMoreIndex();
+        UIResourceTextId GetTraingMoreId();
+
+    private:
+        TraingMoreItemView(const TraingMoreItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        UIImageView slogo;       // 图标
+        TraingMoreItem sItemInfo = {VIEW_INVALID, STR_ICE_SPORTS,nullptr};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreModel.h
new file mode 100644 (file)
index 0000000..ffa0b51
--- /dev/null
@@ -0,0 +1,45 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-25 16:01:16
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/include/TraingMoreModel.h
+ */
+
+#ifndef TraingMore_MODEL_H
+#define TraingMore_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingMorePresenter.h"
+#include "traing/training_list_more/include/TraingMoreAdapter.h"
+
+namespace OHOS
+{
+    class TraingMoreModel
+    {
+    public:
+        static TraingMoreModel &GetInstance(void);
+        void InitTraingMoreListItem();
+        const TraingMoreItem *GetTraingMorelistItems() const;
+        uint8_t GetTraingMoreListNum() const;
+        // const std::map<TraingMoreIndex, AppViewId> &GetTraingMoreIdToViewId() const;
+
+    private:
+        TraingMoreModel();
+        TraingMoreModel(const TraingMoreModel &);
+        TraingMoreModel &operator=(const TraingMoreModel &);
+        virtual ~TraingMoreModel();
+        static const uint16_t TraingMoreListMaxNum = 9;
+        TraingMoreItem TraingMores[TraingMoreListMaxNum] = {VIEW_INVALID, STR_ICE_SPORTS, nullptr};
+        // std::map<int, AppViewId> TraingMoreIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMorePresenter.h
new file mode 100644 (file)
index 0000000..20f1123
--- /dev/null
@@ -0,0 +1,53 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-26 09:44:33
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/include/TraingMorePresenter.h
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 09:44:11
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 14:22:01
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_more/include/TraingMorePresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingMore_PRESENTER_H
+#define _TraingMore_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingMoreView.h"
+
+namespace OHOS
+{
+    class TraingMoreView;
+    class TraingMoreModel;
+    class TraingMorePresenter : public Presenter<TraingMoreView>,
+                                public UIView::OnClickListener,
+                                public RootView::OnKeyActListener,
+                                public UIView::OnDragListener
+    {
+    public:
+        TraingMorePresenter();
+        virtual ~TraingMorePresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+        void NavigateBack();
+
+        static TraingMorePresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+        TraingMoreModel *p_TraingMoreModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/include/TraingMoreView.h
new file mode 100644 (file)
index 0000000..4b61080
--- /dev/null
@@ -0,0 +1,47 @@
+
+#ifndef TraingMore_VIEW_H
+#define TraingMore_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_more/include/TraingMoreAdapter.h"
+#include "traing/training_list_more/include/TraingMoreModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingMorePresenter;
+class TraingMoreModel;
+class TraingMoreView : public View<TraingMorePresenter>, public UIViewGroup {
+
+public:
+  TraingMoreView();
+  virtual ~TraingMoreView();
+  static TraingMoreView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  void AddToTraingMoreList(const TraingMoreItem &item);
+
+private:
+  void InitView(void);
+  void InitList();
+  void InitScrollView();
+  void DeInitView(void);
+  void PreLoad(void);
+  void SetKeyActListener(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingMoreAdapter *p_TraingMoreListAdapter{nullptr};
+  UIList *TraingMoreList = nullptr;
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreAdapter.cpp
new file mode 100644 (file)
index 0000000..956366b
--- /dev/null
@@ -0,0 +1,95 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:12:53
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 15:27:45
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreAdapter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "traing/training_list_more/include/TraingMoreAdapter.h"
+#include "traing/training_list_more/include/TraingMoreModel.h"
+#include "traing/training_list_more/include/TraingMoreItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingMoreAdapter::TraingMoreAdapter() {}
+
+    TraingMoreAdapter::~TraingMoreAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingMoreAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingMoreAdapter::SetData(std::list<TraingMoreItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingMoreItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingMoreAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingMoreItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingMoreItem itemData = *it;
+        TraingMoreItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingMoreItemView();
+        }
+        else
+        {
+            item = static_cast<TraingMoreItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingMoreAdapter::AddItem(const TraingMoreItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreItemView.cpp
new file mode 100644 (file)
index 0000000..8b217d9
--- /dev/null
@@ -0,0 +1,119 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-27 11:13:16
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 11:47:02
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreItemView.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_more/include/TraingMoreItemView.h"
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+namespace OHOS {
+
+TraingMoreItemView::TraingMoreItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+  Add(&slogo);
+}
+
+TraingMoreItemView::~TraingMoreItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+  Remove(&slogo);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingMoreItemView::SetItemInfo(const TraingMoreItem itemInfo) {  
+    sItemInfo = itemInfo;  
+
+    // 先设置所有视图的可见性  
+    bool isVisible = false;
+    bool label_isVisible = false;  
+    SetTouchable(false); // 默认不触摸  
+
+    switch (itemInfo.id) {  
+        case VIEW_TRAININGMORE:  
+            sLabel.SetTextId(STR_TRAINING);  
+            sLabel.SetPosition(90, 50, 200, 35);  
+            isVisible = false;
+            label_isVisible = true; // 只有label可见  
+            SetHeight(120);  
+            break;  
+
+        case VIEW_INVALID:  
+            isVisible = false; // 全部不可见  
+            label_isVisible = false;  
+            SetHeight(60);  
+            break;  
+
+        default:  
+            sLabel.SetTextId(itemInfo.labelid);  
+            slogo.SetSrc(itemInfo.logo);  
+            sLabel.SetPosition(105, 33, 200, 35);  
+            isVisible = true; // 所有元素可见  
+            label_isVisible = true; 
+            SetHeight(120);  
+            SetTouchable(true);  
+            break;  
+    }  
+
+    // 设置各个组件的可见性  
+    sLabel.SetVisible(label_isVisible);  
+    sicon.SetVisible(isVisible);  
+    sbackground.SetVisible(isVisible);  
+    slogo.SetVisible(isVisible);  
+
+    // 调整对齐方式  
+    if (itemInfo.id == VIEW_INVALID) {  
+        sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);  
+    } else if (itemInfo.id == VIEW_TRAININGMORE) {  
+        sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);  
+    } else {  
+        sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);  
+    }  
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingMoreItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  slogo.SetPosition(40, 32);
+  slogo.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(105, 33, 200, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  // sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list的中每个组件的在list的下标
+/// @return 返回下标
+AppViewId TraingMoreItemView::GetTraingMoreIndex() { return sItemInfo.id; }
+
+UIResourceTextId TraingMoreItemView::GetTraingMoreId() {
+  return sItemInfo.labelid;
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreModel.cpp
new file mode 100644 (file)
index 0000000..b2843a2
--- /dev/null
@@ -0,0 +1,63 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-25 16:00:57
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreModel.cpp
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 18:34:15
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 18:36:25
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_more/src/TraingMoreModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_more/include/TraingMoreModel.h"
+#include "traing/Training_UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+namespace OHOS
+{
+
+    TraingMoreModel::TraingMoreModel() {}
+
+    TraingMoreModel::~TraingMoreModel() {}
+
+    TraingMoreModel &TraingMoreModel::GetInstance()
+    {
+        static TraingMoreModel instance;
+        return instance;
+    }
+
+    void TraingMoreModel::InitTraingMoreListItem()
+    {
+        int index = 0;
+        TraingMores[index++] = {VIEW_TRAININGMORE, STR_TRAINING, nullptr};
+        TraingMores[index++] = {VIEW_TRAININGFITNESS, STR_EXERCISE_LIST, FITNESS_IMAGE};
+        TraingMores[index++] = {VIEW_TRAININGDANCE, STR_DANCING_LIST, DANCE_IMAGE};
+        TraingMores[index++] = {VIEW_TRAININGREST, STR_RECREATIONAL_LIST, REST_IMAGE};
+        TraingMores[index++] = {VIEW_TRAININGBALL, STR_BALL_LIST, BALL_IMAGE};
+        // TraingMores[4] = {VIEW_TRAININGAQUATIC, STR_WATER_LIST, SWIMMING_IMAGE};水上运动
+        TraingMores[index++] = {VIEW_TRAININGICE, STR_ICE_LIST, ICE_IMAGE};
+        TraingMores[index++] = {VIEW_TRAININGLIMIT, STR_EXTREME_LIST, LIMIT_IMAGE};
+        TraingMores[index++] = {VIEW_TRAININGOTHER, STR_OTHER_LIST, OTHER_IMAGE};
+        TraingMores[index++] = {VIEW_INVALID, STR_TRAINING, nullptr};
+    }
+
+    const TraingMoreItem *TraingMoreModel::GetTraingMorelistItems() const
+    {
+        return TraingMores;
+    }
+    uint8_t TraingMoreModel::GetTraingMoreListNum() const
+    {
+        return TraingMoreListMaxNum;
+    }
+
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMorePresenter.cpp
new file mode 100644 (file)
index 0000000..c2b400a
--- /dev/null
@@ -0,0 +1,183 @@
+\r
+\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+\r
+#include "KeyInputListener.h"\r
+#include "custom_utils.h"\r
+#include "common/key_code.h"\r
+\r
+#include <iostream>\r
+#include <chrono>\r
+#include <thread>\r
+#include "traing/training_list_more/include/TraingMoreItemView.h"\r
+#include "traing/training_list_more/include/TraingMorePresenter.h"\r
+#include "traing/training_list_more/include/TraingMoreView.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "traing/include/TraingModel.h"\r
+// #include "TraingMoreView.h"\r
+\r
+#include "NativeRegisterManager.h"\r
+namespace OHOS\r
+{\r
+    REGIST_SLICE(VIEW_TRAININGMORE, TraingMoreView, TraingMorePresenter);\r
+\r
+    extern const char *More_buttons[];\r
+    extern char *More_text[];\r
+\r
+    // 当前Presenter属性实例化的内存指针\r
+    static TraingMorePresenter *g_pTraingMorePresenter = nullptr;\r
+\r
+    TraingMorePresenter::TraingMorePresenter()\r
+    {\r
+        p_TraingMoreModel = &TraingMoreModel::GetInstance();\r
+        g_pTraingMorePresenter = this;\r
+    }\r
+\r
+    TraingMorePresenter::~TraingMorePresenter()\r
+    {\r
+\r
+        g_pTraingMorePresenter = nullptr;\r
+    }\r
+\r
+    TraingMorePresenter *TraingMorePresenter::GetInstance()\r
+    {\r
+\r
+        return g_pTraingMorePresenter;\r
+    }\r
+\r
+    void TraingMorePresenter::OnStart()\r
+    {\r
+        p_TraingMoreModel->InitTraingMoreListItem();\r
+        Presenter<TraingMoreView>::OnStart();\r
+    }\r
+\r
+    void TraingMorePresenter::OnPause(void)\r
+    {\r
+        Presenter<TraingMoreView>::OnPause();\r
+    }\r
+\r
+    void TraingMorePresenter::OnResume(void)\r
+    {\r
+        if (view_ == nullptr)\r
+        {\r
+            return;\r
+        }\r
+        const TraingMoreItem *itemInfo = p_TraingMoreModel->GetTraingMorelistItems();\r
+        for (int i = 0; i < p_TraingMoreModel->GetTraingMoreListNum(); i++)\r
+        {\r
+            view_->AddToTraingMoreList(itemInfo[i]);\r
+        }\r
+        Presenter<TraingMoreView>::OnResume();\r
+    }\r
+\r
+    void TraingMorePresenter::OnStop(void)\r
+    {\r
+\r
+        Presenter<TraingMoreView>::OnStop();\r
+    }\r
+    void TraingMorePresenter::NavigateBack()\r
+    {\r
+        uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
+\r
+        // 根据前一界面切换\r
+        if (preSlice == VIEW_TRAININGENDDATA)\r
+        {\r
+            if (TraingModel::GetInstance()->GetEntryType() == APPLIST_ENTER)\r
+                NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING, TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+            else\r
+            {\r
+                NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+                NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素\r
+            }\r
+        }\r
+        else\r
+        {\r
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+        }\r
+    }\r
+    bool TraingMorePresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        return true;\r
+    }\r
+    bool TraingMorePresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+    {\r
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
+        {\r
+            NavigateBack();\r
+        }\r
+        UNUSED(view);\r
+        return true;\r
+    }\r
+\r
+    bool TraingMorePresenter::OnClick(UIView &view, const ClickEvent &event)\r
+    {\r
+        UNUSED(event);\r
+        TraingMoreItemView *itemView = static_cast<TraingMoreItemView *>(&view);\r
+        AppViewId viewId = itemView->GetTraingMoreIndex();\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);\r
+        /*\r
+            VIEW_TRAININGLIMIT,   // 极限运动列表\r
+            VIEW_TRAININGICE,     // 冰上运动列表\r
+            VIEW_TRAININGFITNESS, // 健身运动列表\r
+            VIEW_TRAININGDANCE,   // 舞蹈运动列表\r
+            VIEW_TRAININGREST,    // 休闲运动列表\r
+            VIEW_TRAININGBALL,    // 球类运动列表\r
+            VIEW_TRAININGAQUATIC, // 水上运动列表\r
+            VIEW_TRAININGOTHER,   // 其他列表\r
+        */\r
+        // 设置训练类型\r
+        switch (viewId)\r
+        {\r
+        case VIEW_TRAININGLIMIT:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::EXTREME);\r
+            break;\r
+        case VIEW_TRAININGICE:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::ICE);\r
+            break;\r
+        case VIEW_TRAININGFITNESS:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS);\r
+            break;\r
+        case VIEW_TRAININGDANCE:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::DANCE);\r
+            break;\r
+        case VIEW_TRAININGREST:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::LEISURE);\r
+            break;\r
+        case VIEW_TRAININGBALL:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::BALL);\r
+            break;\r
+        case VIEW_TRAININGOTHER:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::OTHER);\r
+            break;\r
+#if 0\r
+        case VIEW_TRAININGAQUATIC:\r
+            TraingModel::GetInstance()->SetSportType(Exercisetype::WATER);\r
+            break;\r
+#endif\r
+        default:\r
+            break;\r
+        }\r
+        if (viewId < VIEW_MAX_INTER_APP)\r
+        {\r
+            NativeAbility::GetInstance().EnterSlice(viewId);\r
+            return true;\r
+        }\r
+        return false;\r
+    }\r
+    bool TraingMorePresenter::OnKeyAct(UIView &view, const KeyEvent &event)\r
+    {\r
+        unsigned short keyID = event.GetKeyId();\r
+        unsigned short keyState = event.GetState();\r
+\r
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+        {\r
+            NavigateBack();\r
+        }\r
+        return true;\r
+    }\r
+}\r
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_more/src/TraingMoreView.cpp
new file mode 100644 (file)
index 0000000..6627d50
--- /dev/null
@@ -0,0 +1,120 @@
+#include "traing/training_list_more/include/TraingMoreView.h"\r
+#include "UiConfig.h"\r
+#include "components/ui_label_ext.h"\r
+#include "traing/Training_UiConfig.h"\r
+#include "traing/include/TraingModel.h"\r
+#include "traing/training_list_more/include/TraingMorePresenter.h"\r
+#include "ui_resource_string.h"\r
+#include "uicomponents/UIComponents.h"\r
+#include "wearable_log.h"\r
+#include <memory>\r
+\r
+namespace OHOS {\r
+static TraingMoreView *g_pTraingMoreView{nullptr};\r
+\r
+TraingMoreView::TraingMoreView() { g_pTraingMoreView = this; }\r
+\r
+TraingMoreView::~TraingMoreView() { \r
+  DeInitView();\r
+  g_pTraingMoreView = nullptr; }\r
+\r
+TraingMoreView *TraingMoreView::GetInstance() { return g_pTraingMoreView; }\r
+\r
+void TraingMoreView::AddToTraingMoreList(const TraingMoreItem &item) {\r
+  if (p_TraingMoreListAdapter) {\r
+    p_TraingMoreListAdapter->AddItem(item);\r
+  }\r
+}\r
+\r
+void TraingMoreView::SetKeyActListener() {\r
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");\r
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(\r
+      TraingMorePresenter::GetInstance());\r
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);\r
+}\r
+\r
+void TraingMoreView::InitScrollView() {\r
+  if (scrollView == nullptr) {\r
+    scrollView = new UIScrollView();\r
+  }\r
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),\r
+                          Screen::GetInstance().GetHeight());\r
+  scrollView->SetTouchable(true);\r
+  scrollView->SetDraggable(true);\r
+  scrollView->SetDirection(1);\r
+  scrollView->SetHorizontalScrollState(false);\r
+  scrollView->SetOnDragListener(presenter_);\r
+  scrollView->SetYScrollBarVisible(true);\r
+}\r
+\r
+void TraingMoreView::InitList() {\r
+  if (p_TraingMoreListAdapter == nullptr) {\r
+    p_TraingMoreListAdapter = new TraingMoreAdapter();\r
+  }\r
+  p_TraingMoreListAdapter->SetItemClickListener(presenter_);\r
+\r
+  if (TraingMoreList == nullptr) {\r
+    TraingMoreList = new UIList();\r
+  }\r
+  TraingMoreList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,\r
+                              VERTICAL_RESOLUTION);\r
+  TraingMoreList->SetThrowDrag(true);\r
+  TraingMoreList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+  TraingMoreList->SetMaxScrollDistance(1000);\r
+  TraingMoreList->SetSwipeACCLevel(200);\r
+  TraingMoreList->SetDragACCLevel(5);\r
+  TraingMoreList->SetRotateFactor(1);\r
+  TraingMoreList->RequestFocus();\r
+}\r
+\r
+void TraingMoreView::InitView() {\r
+  InitScrollView();\r
+  InitList();\r
+  SetKeyActListener();\r
+}\r
+\r
+void TraingMoreView::DeInitView() {\r
+  if (viewInitStatus) {\r
+\r
+      if (scrollView) {\r
+        scrollView->RemoveAll();\r
+        if (p_TraingMoreListAdapter) {\r
+          delete p_TraingMoreListAdapter;\r
+          p_TraingMoreListAdapter = nullptr;\r
+        }\r
+        if (TraingMoreList) {\r
+          delete TraingMoreList;\r
+          TraingMoreList = nullptr;\r
+        }\r
+        delete scrollView;\r
+        scrollView = nullptr;\r
+      }\r
+ \r
+  }\r
+}\r
+\r
+void TraingMoreView::PreLoad() {\r
+  if (!viewInitStatus) {\r
+    InitView();\r
+    viewInitStatus = true;\r
+  }\r
+}\r
+\r
+void TraingMoreView::OnStart() {\r
+\r
+  PreLoad();\r
+\r
+\r
+  if (scrollView && TraingMoreList) {\r
+    scrollView->Add(TraingMoreList);\r
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);\r
+    AddViewToRootContainer(scrollView);\r
+    if (p_TraingMoreListAdapter) {\r
+      TraingMoreList->SetAdapter(p_TraingMoreListAdapter);\r
+    }\r
+\r
+  }\r
+}\r
+\r
+\r
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherAdapter.h
new file mode 100644 (file)
index 0000000..f6df12f
--- /dev/null
@@ -0,0 +1,59 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 17:36:30
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:47:13
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_aquatic/include/TraingOtherAapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingOther_ADAPTER_H
+#define TraingOther_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingOtherItem;
+
+    class TraingOtherAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingOtherAdapter();
+        virtual ~TraingOtherAdapter();
+
+        void SetData(std::list<TraingOtherItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingOtherItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingOtherItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherItemView.h
new file mode 100644 (file)
index 0000000..210fdb4
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef TraingOther_ITEM_VIEW_H
+#define TraingOther_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingOtherItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingOtherItemView();
+        virtual ~TraingOtherItemView();
+        virtual void SetItemInfo(const TraingOtherItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingOtherIndex();
+        UIResourceTextId GetTraingOtherId();
+
+    private:
+        TraingOtherItemView(const TraingOtherItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingOtherItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherModel.h
new file mode 100644 (file)
index 0000000..7edbb1c
--- /dev/null
@@ -0,0 +1,55 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 19:21:24
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:33:05
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/include/TraingOtherModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:18:34
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 18:03:00
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/include/TraingOtherModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingOther_MODEL_H
+#define TraingOther_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingOtherPresenter.h"
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+
+namespace OHOS
+{
+    class TraingOtherModel
+    {
+    public:
+        static TraingOtherModel &GetInstance(void);
+        void InitTraingOtherListItem();
+        const TraingOtherItem *GetTraingOtherlistItems() const;
+        uint8_t GetTraingOtherListNum() const;
+        // const std::map<TraingOtherIndex, AppViewId> &GetTraingOtherIdToViewId() const;
+
+    private:
+        TraingOtherModel();
+        TraingOtherModel(const TraingOtherModel &);
+        TraingOtherModel &operator=(const TraingOtherModel &);
+        virtual ~TraingOtherModel();
+        static const uint16_t TraingOtherListMaxNum = 11;
+        TraingOtherItem TraingOthers[TraingOtherListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+        // std::map<int, AppViewId> TraingOtherIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherPresenter.h
new file mode 100644 (file)
index 0000000..5e301bd
--- /dev/null
@@ -0,0 +1,47 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:23:56
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingOtherPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingOther_PRESENTER_H
+#define _TraingOther_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingOtherView.h"
+
+namespace OHOS
+{
+    class TraingOtherView;
+    class TraingOtherModel;
+    class TraingOtherPresenter : public Presenter<TraingOtherView>,
+                                 public UIView::OnClickListener,
+                                 public RootView::OnKeyActListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingOtherPresenter();
+        virtual ~TraingOtherPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingOtherPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingOtherModel *p_TraingOtherModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/include/TraingOtherView.h
new file mode 100644 (file)
index 0000000..9ca24f6
--- /dev/null
@@ -0,0 +1,59 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-27 11:15:59
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/include/TraingOtherView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingOther_VIEW_H
+#define TraingOther_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+#include "traing/training_list_other/include/TraingOtherModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingOtherPresenter;
+class TraingOtherModel;
+class TraingOtherView : public View<TraingOtherPresenter>, public UIViewGroup {
+
+public:
+  TraingOtherView();
+  virtual ~TraingOtherView();
+  static TraingOtherView *GetInstance(void);
+
+  void OnStart() override;
+
+
+
+  UIList *GetList();
+  void AddToTraingOtherList(const TraingOtherItem &item);
+
+private:
+  void InitView(void);
+  void DeInitView(void);
+  void InitList();
+  void InitScrollView();
+  void SetKeyActListener(void);
+  void PreLoad(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingOtherAdapter *p_TraingOtherListAdapter{nullptr};
+  UIList *TraingOtherList = nullptr;
+
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherAdapter.cpp
new file mode 100644 (file)
index 0000000..f8da3b5
--- /dev/null
@@ -0,0 +1,95 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 19:21:41
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 19:24:17
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherAdapter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "traing/training_list_other/include/TraingOtherAdapter.h"
+#include "traing/training_list_other/include/TraingOtherModel.h"
+#include "traing/training_list_other/include/TraingOtherItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingOtherAdapter::TraingOtherAdapter() {}
+
+    TraingOtherAdapter::~TraingOtherAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingOtherAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingOtherAdapter::SetData(std::list<TraingOtherItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingOtherItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingOtherAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingOtherItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingOtherItem itemData = *it;
+        TraingOtherItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingOtherItemView();
+        }
+        else
+        {
+            item = static_cast<TraingOtherItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingOtherAdapter::AddItem(const TraingOtherItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherItemView.cpp
new file mode 100644 (file)
index 0000000..c96ad43
--- /dev/null
@@ -0,0 +1,105 @@
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_other/include/TraingOtherItemView.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingOtherItemView::TraingOtherItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingOtherItemView::~TraingOtherItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingOtherItemView::SetItemInfo(const TraingOtherItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_OTHER_LIST:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_MAX_ID:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_OTHER_LIST) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingOtherItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingOtherItemView::GetTraingOtherIndex() {
+  return sItemInfo.id;
+}
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingOtherItemView::GetTraingOtherId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherModel.cpp
new file mode 100644 (file)
index 0000000..55d623f
--- /dev/null
@@ -0,0 +1,58 @@
+
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:51:45
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 17:56:44
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherModel.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "traing/training_list_other/include/TraingOtherModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingOtherModel::TraingOtherModel() {}
+
+TraingOtherModel::~TraingOtherModel() {}
+
+TraingOtherModel &TraingOtherModel::GetInstance() {
+  static TraingOtherModel instance;
+  return instance;
+}
+
+TraingOtherItem defaultItems[] = {
+    {VIEW_TRAININGNOMAL, STR_OTHER_LIST},
+    {VIEW_TRAININGNOMAL, STR_OTHER_ELEVATOR},
+    {VIEW_TRAININGNOMAL, STR_OTHER_ESCALATOR},
+    {VIEW_TRAININGNOMAL, STR_OTHER_GARDENING},
+    {VIEW_TRAININGNOMAL, STR_OTHER_HORSEWORK},
+    {VIEW_TRAININGNOMAL, STR_OTHER_INVEHICLE},
+    {VIEW_TRAININGNOMAL, STR_OTHER_MEDITATION},
+    {VIEW_TRAININGNOMAL, STR_OTHER_STILL},
+    {VIEW_TRAININGNOMAL, STR_OTHER_TILTING},
+    {VIEW_TRAININGNOMAL, STR_OTHER_WHEELCHAIR},
+    {VIEW_TRAININGNOMAL, STR_MAX_ID},
+};
+void TraingOtherModel::InitTraingOtherListItem() {
+
+  for (int i = 0; i < TraingOtherListMaxNum; i++) {
+    TraingOthers[i] = defaultItems[i];
+  }
+}
+
+const TraingOtherItem *TraingOtherModel::GetTraingOtherlistItems() const {
+  return TraingOthers;
+}
+uint8_t TraingOtherModel::GetTraingOtherListNum() const {
+  return TraingOtherListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherPresenter.cpp
new file mode 100644 (file)
index 0000000..d9b0d42
--- /dev/null
@@ -0,0 +1,138 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:19
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 19:51:06
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_other/src/TraingOtherPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:19
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 14:23:32
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingOtherPresenter.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_other/include/TraingOtherItemView.h"
+#include "traing/training_list_other/include/TraingOtherPresenter.h"
+#include "traing/training_list_other/include/TraingOtherView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+// #include "TraingOtherView.h"
+
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGOTHER, TraingOtherView, TraingOtherPresenter);
+
+    extern const char *Other_buttons[];
+    extern char *Other_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingOtherPresenter *g_pTraingOtherPresenter = nullptr;
+
+    TraingOtherPresenter::TraingOtherPresenter()
+    {
+        p_TraingOtherModel = &TraingOtherModel::GetInstance();
+        g_pTraingOtherPresenter = this;
+    }
+
+    TraingOtherPresenter::~TraingOtherPresenter()
+    {
+
+        g_pTraingOtherPresenter = nullptr;
+    }
+
+    TraingOtherPresenter *TraingOtherPresenter::GetInstance()
+    {
+
+        return g_pTraingOtherPresenter;
+    }
+
+    void TraingOtherPresenter::OnStart()
+    {
+        p_TraingOtherModel->InitTraingOtherListItem();
+        Presenter<TraingOtherView>::OnStart();
+    }
+
+    void TraingOtherPresenter::OnPause(void)
+    {
+        Presenter<TraingOtherView>::OnPause();
+    }
+
+    void TraingOtherPresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingOtherItem *itemInfo = p_TraingOtherModel->GetTraingOtherlistItems();
+        for (int i = 0; i < p_TraingOtherModel->GetTraingOtherListNum(); i++)
+        {
+            view_->AddToTraingOtherList(itemInfo[i]);
+        }
+        Presenter<TraingOtherView>::OnResume();
+    }
+
+    void TraingOtherPresenter::OnStop(void)
+    {
+
+        Presenter<TraingOtherView>::OnStop();
+    }
+    bool TraingOtherPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingOtherPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingOtherPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        TraingOtherItemView *itemView = static_cast<TraingOtherItemView *>(&view);
+        AppViewId viewId = itemView->GetTraingOtherIndex();
+        UIResourceTextId sportid = itemView->GetTraingOtherId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+    bool TraingOtherPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_other/src/TraingOtherView.cpp
new file mode 100644 (file)
index 0000000..f6c9ae4
--- /dev/null
@@ -0,0 +1,121 @@
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_other/include/TraingOtherPresenter.h"
+#include "traing/training_list_other/include/TraingOtherView.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingOtherView *g_pTraingOtherView{nullptr};
+
+TraingOtherView::TraingOtherView() { g_pTraingOtherView = this; }
+
+TraingOtherView::~TraingOtherView() { 
+  DeInitView();
+  g_pTraingOtherView = nullptr; }
+
+TraingOtherView *TraingOtherView::GetInstance() {
+  return g_pTraingOtherView;
+}
+
+void TraingOtherView::AddToTraingOtherList(const TraingOtherItem &item) {
+  if (p_TraingOtherListAdapter) {
+    p_TraingOtherListAdapter->AddItem(item);
+  }
+}
+
+void TraingOtherView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingOtherPresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingOtherView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingOtherView::InitList() {
+  if (p_TraingOtherListAdapter == nullptr) {
+    p_TraingOtherListAdapter = new TraingOtherAdapter();
+  }
+  p_TraingOtherListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingOtherList == nullptr) {
+    TraingOtherList = new UIList();
+  }
+  TraingOtherList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                                 VERTICAL_RESOLUTION);
+  TraingOtherList->SetThrowDrag(true);
+  TraingOtherList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingOtherList->SetMaxScrollDistance(1000);
+  TraingOtherList->SetSwipeACCLevel(200);
+  TraingOtherList->SetDragACCLevel(5);
+  TraingOtherList->SetRotateFactor(1);
+  TraingOtherList->RequestFocus();
+}
+
+void TraingOtherView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingOtherView::DeInitView() {
+  if (viewInitStatus) {
+  
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingOtherListAdapter) {
+          delete p_TraingOtherListAdapter;
+          p_TraingOtherListAdapter = nullptr;
+        }
+        if (TraingOtherList) {
+          delete TraingOtherList;
+          TraingOtherList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+
+  }
+}
+
+void TraingOtherView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingOtherView::OnStart() {
+
+  PreLoad();
+
+
+  if (scrollView && TraingOtherList) {
+    scrollView->Add(TraingOtherList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingOtherListAdapter) {
+      TraingOtherList->SetAdapter(p_TraingOtherListAdapter);
+    }
+  }
+}
+
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestAdapter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestAdapter.h
new file mode 100644 (file)
index 0000000..90153b6
--- /dev/null
@@ -0,0 +1,59 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 17:04:41
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 11:16:42
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_Rest/include/TraingRestAdapter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingRest_ADAPTER_H
+#define TraingRest_ADAPTER_H
+#include <list>
+#include <string>
+#include "components/ui_list.h"
+#include "components/abstract_adapter.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_checkbox.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+
+
+// 列表的适配器
+namespace OHOS
+{
+
+    typedef struct
+    {
+        AppViewId id;
+        UIResourceTextId labelid; // 标签
+    } TraingRestItem;
+
+    class TraingRestAdapter : public AbstractAdapter
+    {
+    public:
+        explicit TraingRestAdapter();
+        virtual ~TraingRestAdapter();
+
+        void SetData(std::list<TraingRestItem> &data);
+
+        virtual uint16_t GetCount(void) override;
+
+        virtual UIView *GetView(UIView *inView, int16_t index) override;
+
+        virtual void AddItem(const TraingRestItem &item);
+
+        void SetItemClickListener(UIView::OnClickListener *itemclicklistener)
+        {
+            itemClickListener = itemclicklistener;
+        }
+
+    private:
+        std::list<TraingRestItem> listData;
+        UIView::OnClickListener *itemClickListener{nullptr};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestItemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestItemView.h
new file mode 100644 (file)
index 0000000..1c20f9b
--- /dev/null
@@ -0,0 +1,55 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 17:05:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:54:57
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_Rest/include/TraingRestItemView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-26 17:05:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-26 18:24:58
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_Rest/include/TraingRestItemView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingRest_ITEM_VIEW_H
+#define TraingRest_ITEM_VIEW_H
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "components/ui_view_group.h"
+#include "components/ui_checkbox.h"
+#include "components/ui_image_view.h"
+#include "traing/training_list_rest/include/TraingRestAdapter.h"
+#include "components/ui_label_button.h"
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "ohos_types.h"
+
+namespace OHOS
+{
+    class TraingRestItemView : public UIViewGroup
+    {
+    public:
+        explicit TraingRestItemView();
+        virtual ~TraingRestItemView();
+        virtual void SetItemInfo(const TraingRestItem itemInfo);
+        virtual void SetUpChild();
+        AppViewId GetTraingRestIndex();
+        UIResourceTextId GetTraingRestId();
+
+    private:
+        TraingRestItemView(const TraingRestItemView &);
+        UIImageView sbackground; // 背景
+        UIImageView sicon;       // 箭头
+        UILabelExt sLabel;       // 标签
+        TraingRestItem sItemInfo = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+    };
+
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestModel.h
new file mode 100644 (file)
index 0000000..3e18324
--- /dev/null
@@ -0,0 +1,47 @@
+/*** 
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-29 15:18:34
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:55:09
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/include/TraingRestModel.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingRest_MODEL_H
+#define TraingRest_MODEL_H
+
+#include <cstdint>
+#include <map>
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "components/ui_label_ext.h"
+#include"ui_resource_string.h"
+#include "UiConfig.h"
+#include "TraingRestPresenter.h"
+#include "traing/training_list_rest/include/TraingRestAdapter.h"
+
+namespace OHOS
+{
+    class TraingRestModel
+    {
+    public:
+        static TraingRestModel &GetInstance(void);
+        void InitTraingRestListItem();
+        const TraingRestItem *GetTraingRestlistItems() const;
+        uint8_t GetTraingRestListNum() const;
+        // const std::map<TraingRestIndex, AppViewId> &GetTraingRestIdToViewId() const;
+
+    private:
+        TraingRestModel();
+        TraingRestModel(const TraingRestModel &);
+        TraingRestModel &operator=(const TraingRestModel &);
+        virtual ~TraingRestModel();
+        static const uint16_t TraingRestListMaxNum = 26;
+        TraingRestItem TraingRests[TraingRestListMaxNum] = {VIEW_INVALID, STR_EXERCISE_GENERAL};
+        // std::map<int, AppViewId> TraingRestIdToViewId;
+        bool btConnectStatus{false};
+    };
+}
+
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestPresenter.h
new file mode 100644 (file)
index 0000000..3821dea
--- /dev/null
@@ -0,0 +1,47 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:55:20
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_list_limit/include/TraingRestPresenter.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef _TraingRest_PRESENTER_H
+#define _TraingRest_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingRestView.h"
+
+namespace OHOS
+{
+    class TraingRestView;
+    class TraingRestModel;
+    class TraingRestPresenter : public Presenter<TraingRestView>,
+                                public UIView::OnClickListener,
+                                public RootView::OnKeyActListener,
+                                public UIView::OnDragListener
+    {
+    public:
+        TraingRestPresenter();
+        virtual ~TraingRestPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingRestPresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        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; // 增加按键事件
+
+        TraingRestModel *p_TraingRestModel{nullptr};
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/include/TraingRestView.h
new file mode 100644 (file)
index 0000000..6af9069
--- /dev/null
@@ -0,0 +1,57 @@
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-03-19 17:37:18
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-29 15:55:33
+ * @FilePath:
+ * /sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/include/TraingRestView.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
+ * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef TraingRest_VIEW_H
+#define TraingRest_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_list.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+#include "traing/training_list_rest/include/TraingRestAdapter.h"
+#include "traing/training_list_rest/include/TraingRestModel.h"
+#include "ui_resource_string.h"
+
+namespace OHOS {
+class TraingRestPresenter;
+class TraingRestModel;
+class TraingRestView : public View<TraingRestPresenter>, public UIViewGroup {
+
+public:
+  TraingRestView();
+  virtual ~TraingRestView();
+  static TraingRestView *GetInstance(void);
+
+  void OnStart() override;
+
+
+  UIList *GetList();
+  void AddToTraingRestList(const TraingRestItem &item);
+
+private:
+  void InitView(void);
+  void DeInitView(void);
+  void InitList();
+  void InitScrollView();
+  void SetKeyActListener(void);
+  void PreLoad(void);
+
+private:
+  UIScrollView *scrollView = nullptr;
+  TraingRestAdapter *p_TraingRestListAdapter{nullptr};
+  UIList *TraingRestList = nullptr;
+  bool viewInitStatus{false};
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestAdapter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestAdapter.cpp
new file mode 100644 (file)
index 0000000..cf46b93
--- /dev/null
@@ -0,0 +1,87 @@
+#include "traing/training_list_rest/include/TraingRestAdapter.h"
+#include "traing/training_list_rest/include/TraingRestModel.h"
+#include "traing/training_list_rest/include/TraingRestItemView.h"
+
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    TraingRestAdapter::TraingRestAdapter() {}
+
+    TraingRestAdapter::~TraingRestAdapter()
+    {
+        listData.clear();
+    }
+
+    uint16_t TraingRestAdapter::GetCount(void)
+    {
+        return listData.size();
+    }
+
+    void TraingRestAdapter::SetData(std::list<TraingRestItem> &data)
+    {
+        if (!listData.empty())
+        {
+            listData.clear();
+        }
+        std::list<TraingRestItem>::iterator it;
+        for (it = data.begin(); it != data.end(); it++)
+        {
+            listData.push_back(*it);
+        }
+    }
+
+    /// @brief 为列表的每一项创建一个视图
+    /// @param inView 一个指向已存在的视图对象的指
+    /// @param index 要创建的视图在列表中的索引l。
+    /// @return 返回该视图对象
+    UIView *TraingRestAdapter::GetView(UIView *inView, int16_t index)
+    {
+
+        // 1.先检查列表数据是否为空,若为空则返回空指针
+        if (listData.empty())
+        {
+            return nullptr;
+        }
+        // 2.接着检查索引是否小于0,若小于0则返回空指针
+        if (index < 0)
+        {
+            return nullptr;
+        }
+        // 3.检查是否超出列表数据大小,若超出则返回空指针
+        size_t uindex = index;
+        if (uindex >= listData.size())
+        {
+            return nullptr;
+        }
+        // 4.通过迭代器访问列表中指定索引位置的元素,将其赋值给itemData变量
+        std::list<TraingRestItem>::iterator it = listData.begin();
+        for (int i = 0; i < index; i++)
+        {
+            it++;
+        }
+        TraingRestItem itemData = *it;
+        TraingRestItemView *item = nullptr;
+        /*
+            5.根据传入的inView参数是否已经存在一个视图对象,
+            若为空则创建一个新的MessageItemView对象,
+           否则将inView转换成MessageItemView类型的指针
+        */
+        if (inView == nullptr)
+        {
+            item = new TraingRestItemView();
+        }
+        else
+        {
+            item = static_cast<TraingRestItemView *>(inView);
+        }
+        item->SetItemInfo(itemData);
+        item->SetOnClickListener(itemClickListener);
+        return item;
+    }
+
+    void TraingRestAdapter::AddItem(const TraingRestItem &item)
+    {
+        listData.push_back(item);
+    }
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestItemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestItemView.cpp
new file mode 100644 (file)
index 0000000..1b2e5cc
--- /dev/null
@@ -0,0 +1,103 @@
+#include "traing/training_list_rest/include/TraingRestItemView.h"
+#include "UiConfig.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+
+namespace OHOS {
+
+TraingRestItemView::TraingRestItemView() {
+  SetPosition(
+      0, 0, 380,
+      120); // 每一个itemview宽高要配置好,因为加到list都是以这个视图为基准
+  SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+  SetStyle(STYLE_BACKGROUND_OPA, 255);
+  SetTouchable(true);
+  SetUpChild();
+  Add(&sbackground);
+  Add(&sicon);
+  Add(&sLabel);
+}
+
+TraingRestItemView::~TraingRestItemView() {
+  Remove(&sbackground);
+  Remove(&sicon);
+  Remove(&sLabel);
+}
+
+/// @brief 设置item的信息
+/// @param itemInfo
+void TraingRestItemView::SetItemInfo(const TraingRestItem itemInfo) {
+  sItemInfo = itemInfo;
+
+  // 先设置所有视图的可见性
+  bool isVisible = false;
+  bool label_isVisible = false;
+  uint32_t color = Color::White().full;
+  SetTouchable(false); // 默认不触摸
+
+  switch (itemInfo.labelid) {
+  case STR_RECREATIONAL_LIST:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(90, 50, 200, 35);
+    isVisible = false;
+    label_isVisible = true;      // 只有label可见
+    color = Color::Green().full; // 设置label为绿色
+    SetHeight(120);
+    break;
+
+  case STR_MAX_ID:
+    isVisible = false; // 全部不可见
+    label_isVisible = false;
+    SetHeight(60);
+    break;
+
+  default:
+    sLabel.SetTextId(itemInfo.labelid);
+    sLabel.SetPosition(40, 33, 240, 35);
+    isVisible = true; // 所有元素可见
+    label_isVisible = true;
+    SetHeight(120);
+    SetTouchable(true);
+    break;
+  }
+
+  // 设置各个组件的可见性
+  sLabel.SetVisible(label_isVisible);
+  sicon.SetVisible(isVisible);
+  sbackground.SetVisible(isVisible);
+  sLabel.SetStyle(STYLE_TEXT_COLOR, color);
+
+  // 调整对齐方式
+  if (itemInfo.labelid == STR_RECREATIONAL_LIST) {
+    sLabel.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  } else {
+    sLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+  }
+}
+
+/// @brief 设置每一个itemview上的组件
+void TraingRestItemView::SetUpChild() {
+  sbackground.SetSrc(PNG_SETTING_BACKGROUND_IMAGE);
+
+  sicon.SetPosition(330, 40);
+  sicon.SetSrc(ICON_IMAGE);
+  sicon.SetStyle(STYLE_IMAGE_OPA, OPA_OPAQUE);
+
+  sLabel.SetPosition(40, 33, 240, 35);
+  sLabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+  sLabel.SetRollSpeed(23);
+  sLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+}
+
+/// @brief 获取list中每个组件的下标
+/// @return 返回下标
+AppViewId TraingRestItemView::GetTraingRestIndex() { return sItemInfo.id; }
+
+/// @brief 获取list中每个组件的运动Id
+/// @return 返回下标
+UIResourceTextId TraingRestItemView::GetTraingRestId() {
+  return sItemInfo.labelid;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestModel.cpp
new file mode 100644 (file)
index 0000000..6084100
--- /dev/null
@@ -0,0 +1,69 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-09-06 19:00:18
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_list_rest/src/TraingRestModel.cpp
+ */
+
+#include "traing/training_list_rest/include/TraingRestModel.h"
+#include "AppViewIDs.h"
+#include "UiConfig.h"
+#include "common/image_cache_manager.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_image.h"
+#include "ui_resource_string.h"
+namespace OHOS {
+
+TraingRestModel::TraingRestModel() {}
+
+TraingRestModel::~TraingRestModel() {}
+
+TraingRestModel &TraingRestModel::GetInstance() {
+  static TraingRestModel instance;
+  return instance;
+}
+
+void TraingRestModel::InitTraingRestListItem() {
+  TraingRestItem defaultItems[] = {
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_LIST},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SPORTS},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SKATING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_MARTIALARTS},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TAICHI},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HULAHOOP},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_DISCSPORT},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_DARTS},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_ARCHERY},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HORSERIDING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_BATTLEGAME},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_KITE},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TUGOFWAR},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SWING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_STAIRCLIMBING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_OBSTACLERACE},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_FISHING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HUNTING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_SCOOTERRIDING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_PARAGLIDING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_TEAMSPORTS},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_FINESSGAMING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_HIKING},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_EQUESTRIANSPORTS},
+      {VIEW_TRAININGNOMAL, STR_RECREATIONAL_PLAY},
+      {VIEW_TRAININGNOMAL, STR_MAX_ID},
+  };
+
+  for (int i = 0; i < TraingRestListMaxNum; i++) {
+    TraingRests[i] = defaultItems[i];
+  }
+}
+
+const TraingRestItem *TraingRestModel::GetTraingRestlistItems() const {
+  return TraingRests;
+}
+uint8_t TraingRestModel::GetTraingRestListNum() const {
+  return TraingRestListMaxNum;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestPresenter.cpp
new file mode 100644 (file)
index 0000000..21ac474
--- /dev/null
@@ -0,0 +1,121 @@
+
+#include "AppViewIDs.h"
+#include "components/ui_label_ext.h"
+#include "ui_resource_string.h"
+#include "NativeAbility.h"
+
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "common/key_code.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/training_list_rest/include/TraingRestItemView.h"
+#include "traing/training_list_rest/include/TraingRestPresenter.h"
+#include "traing/training_list_rest/include/TraingRestView.h"
+#include "traing/include/TraingModel.h"
+#include "uicomponents/UIComponents.h"
+// #include "TraingRestView.h"
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_TRAININGREST, TraingRestView, TraingRestPresenter);
+
+    extern const char *Rest_buttons[];
+    extern char *Rest_text[];
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingRestPresenter *g_pTraingRestPresenter = nullptr;
+
+    TraingRestPresenter::TraingRestPresenter()
+    {
+        p_TraingRestModel = &TraingRestModel::GetInstance();
+        g_pTraingRestPresenter = this;
+    }
+
+    TraingRestPresenter::~TraingRestPresenter()
+    {
+
+        g_pTraingRestPresenter = nullptr;
+    }
+
+    TraingRestPresenter *TraingRestPresenter::GetInstance()
+    {
+
+        return g_pTraingRestPresenter;
+    }
+
+    void TraingRestPresenter::OnStart()
+    {
+        p_TraingRestModel->InitTraingRestListItem();
+        Presenter<TraingRestView>::OnStart();
+    }
+
+    void TraingRestPresenter::OnPause(void)
+    {
+        Presenter<TraingRestView>::OnPause();
+    }
+
+    void TraingRestPresenter::OnResume(void)
+    {
+        if (view_ == nullptr)
+        {
+            return;
+        }
+        const TraingRestItem *itemInfo = p_TraingRestModel->GetTraingRestlistItems();
+        for (int i = 0; i < p_TraingRestModel->GetTraingRestListNum(); i++)
+        {
+            view_->AddToTraingRestList(itemInfo[i]);
+        }
+        Presenter<TraingRestView>::OnResume();
+    }
+
+    void TraingRestPresenter::OnStop(void)
+    {
+
+        Presenter<TraingRestView>::OnStop();
+    }
+    bool TraingRestPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool TraingRestPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingRestPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        TraingRestItemView *itemView = static_cast<TraingRestItemView *>(&view);
+        AppViewId viewId = itemView->GetTraingRestIndex();
+        UIResourceTextId sportid = itemView->GetTraingRestId();
+        TraingModel::GetInstance()->SetSportEvent(sportid);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d\n", viewId);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            NativeAbility::GetInstance().EnterSlice(viewId);
+            return true;
+        }
+        return false;
+    }
+
+    bool TraingRestPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_list_rest/src/TraingRestView.cpp
new file mode 100644 (file)
index 0000000..42853f3
--- /dev/null
@@ -0,0 +1,119 @@
+#include "traing/training_list_rest/include/TraingRestView.h"
+#include "UiConfig.h"
+#include "components/ui_label_ext.h"
+#include "traing/Training_UiConfig.h"
+#include "traing/include/TraingModel.h"
+#include "traing/training_list_rest/include/TraingRestPresenter.h"
+#include "ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
+#include "wearable_log.h"
+#include <memory>
+
+namespace OHOS {
+static TraingRestView *g_pTraingRestView{nullptr};
+
+TraingRestView::TraingRestView() { g_pTraingRestView = this; }
+
+TraingRestView::~TraingRestView() {
+  DeInitView();
+  g_pTraingRestView = nullptr;
+}
+
+TraingRestView *TraingRestView::GetInstance() { return g_pTraingRestView; }
+
+void TraingRestView::AddToTraingRestList(const TraingRestItem &item) {
+  if (p_TraingRestListAdapter) {
+    p_TraingRestListAdapter->AddItem(item);
+  }
+}
+
+void TraingRestView::SetKeyActListener() {
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener");
+  auto keyActListener = static_cast<RootView::OnKeyActListener *>(
+      TraingRestPresenter::GetInstance());
+  RootView::GetInstance()->SetOnKeyActListener(keyActListener);
+}
+
+void TraingRestView::InitScrollView() {
+  if (scrollView == nullptr) {
+    scrollView = new UIScrollView();
+  }
+  scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
+                          Screen::GetInstance().GetHeight());
+  scrollView->SetTouchable(true);
+  scrollView->SetDraggable(true);
+  scrollView->SetDirection(1);
+  scrollView->SetHorizontalScrollState(false);
+  scrollView->SetOnDragListener(presenter_);
+  scrollView->SetYScrollBarVisible(true);
+}
+
+void TraingRestView::InitList() {
+  if (p_TraingRestListAdapter == nullptr) {
+    p_TraingRestListAdapter = new TraingRestAdapter();
+  }
+  p_TraingRestListAdapter->SetItemClickListener(presenter_);
+
+  if (TraingRestList == nullptr) {
+    TraingRestList = new UIList();
+  }
+  TraingRestList->SetPosition(43, 0, HORIZONTAL_RESOLUTION,
+                              VERTICAL_RESOLUTION);
+  TraingRestList->SetThrowDrag(true);
+  TraingRestList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+  TraingRestList->SetMaxScrollDistance(1000);
+  TraingRestList->SetSwipeACCLevel(200);
+  TraingRestList->SetDragACCLevel(5);
+  TraingRestList->SetRotateFactor(1);
+  TraingRestList->RequestFocus();
+}
+
+void TraingRestView::InitView() {
+  InitScrollView();
+  InitList();
+  SetKeyActListener();
+}
+
+void TraingRestView::DeInitView() {
+  if (viewInitStatus) {
+  
+      if (scrollView) {
+        scrollView->RemoveAll();
+        if (p_TraingRestListAdapter) {
+          delete p_TraingRestListAdapter;
+          p_TraingRestListAdapter = nullptr;
+        }
+        if (TraingRestList) {
+          delete TraingRestList;
+          TraingRestList = nullptr;
+        }
+        delete scrollView;
+        scrollView = nullptr;
+      }
+ 
+  }
+}
+
+void TraingRestView::PreLoad() {
+  if (!viewInitStatus) {
+    InitView();
+    viewInitStatus = true;
+  }
+}
+
+void TraingRestView::OnStart() {
+
+  PreLoad();
+ 
+
+  if (scrollView && TraingRestList) {
+    scrollView->Add(TraingRestList);
+    scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+    AddViewToRootContainer(scrollView);
+    if (p_TraingRestListAdapter) {
+      TraingRestList->SetAdapter(p_TraingRestListAdapter);
+    }
+  }
+}
+
+} // namespace OHOS
\ No newline at end of file