From 40eb064972507d3b3feda1a2b54fd86f126cdd2f Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 3 Sep 2024 18:08:04 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=A4=A9=E6=B0=94card?= =?utf8?q?=E5=9B=9E=E9=80=80=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../main/include/MainPresenterSample.h | 3 +- .../nativeui/main/src/MainPresenterSample.cpp | 24 +++++++--- .../weather/include/WeatherControlView.h | 3 +- .../weather/src/MainWeatherPresenter.cpp | 22 ++++----- .../nativeui/weather/src/MainWeatherView.cpp | 45 ++++++++++--------- .../weather/src/WeatherControlView.cpp | 13 ++++-- 6 files changed, 67 insertions(+), 43 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h index 8b58ce58c..91cc6fb7f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-01 15:10:34 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-23 11:41:32 + * @LastEditTime: 2024-09-03 17:53:43 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h */ @@ -93,6 +93,7 @@ namespace OHOS private: void LogCardTransition(CardId previous, CardId current); void ResetSleepCardView(); + void ResetWeatherCardView(); void StartHeartRateDetection(); void UpdateWatchFace(); void UpdateWeather(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index f3f82bbc9..d053c321c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -413,14 +413,19 @@ namespace OHOS LogCardTransition(previousCardId, currentCardId); HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::CARDCHECK); } -#if 1 + // 从睡眠卡片跳转到其他卡片时切换到睡眠卡片主界面 if (previousCardId == SLEEP && currentCardId != SLEEP) { LogCardTransition(previousCardId, currentCardId); ResetSleepCardView(); } -#endif + if (previousCardId == WEATHER && currentCardId != WEATHER) + { + LogCardTransition(previousCardId, currentCardId); + ResetWeatherCardView(); + } + // 更新上一个卡片的值 previousCardId = currentCardId; @@ -446,9 +451,6 @@ namespace OHOS UpdateWeather(); break; - // case SLEEP: - // ResetSleepCardView(); - // break; } } /*打印日志*/ @@ -468,6 +470,18 @@ namespace OHOS } } } + /*天气卡片*/ + void MainPresenterSample::ResetWeatherCardView() + { + if(WeatherControlView::GetInstance()) + { + auto weatherSwipView = WeatherControlView::GetInstance()->GetWeatherSwipView(); + if (weatherSwipView->GetCurrentPage() != 0) + { + weatherSwipView->SetCurrentPage(0); + } + } + } /*心率卡片*/ void MainPresenterSample::StartHeartRateDetection() { diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherControlView.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherControlView.h index 8ada8cdf4..edad327c3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherControlView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 10:02:35 + * @LastEditTime: 2024-09-03 18:01:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherControlView.h */ #ifndef WEATHER_CONTROL_VIEW_H @@ -25,6 +25,7 @@ namespace OHOS void PreLoad(void) override; void UnLoad(void) override; bool UpdateWeatherControlViewVisibility(); + UISwipeView *GetWeatherSwipView(void); private: void ClearAll(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp index f4e5fef9f..2961a7f2e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp @@ -105,7 +105,7 @@ namespace OHOS void MainWeatherPresenter::OnSwipe(UISwipeView &view) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainWeatherPresenter::OnSwipe,current tab index = %d", view.GetCurrentPage()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainWeatherPresenter::OnSwipe,current tab index = %d", view.GetCurrentPage()); // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the view index = %d,dragging direction = %d,current tab index = %d", view.GetViewIndex(), view.GetDirection(), view.GetCurrentPage()); if (view.GetCurrentPage() == MAINWEATHERVIEW) { @@ -115,16 +115,16 @@ namespace OHOS void WeatherControlViewOnSwipeListener::OnSwipe(UISwipeView &view) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherControlViewOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage()); - if (view.GetCurrentPage() == MAINWEATHERVIEW) - { - view.SetIntercept(false); - //MainWeatherView::GetInstance()->GetFutureWeatherView()->GetFutureWeatherList()->RefreshList(); - } - else - { - view.SetIntercept(true); - } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlViewOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage()); + // if (view.GetCurrentPage() == MAINWEATHERVIEW) + // { + // view.SetIntercept(false); + // //MainWeatherView::GetInstance()->GetFutureWeatherView()->GetFutureWeatherList()->RefreshList(); + // } + // else + // { + // view.SetIntercept(true); + // } return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp index c7f874e78..69919a45f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 10:09:11 + * @LastEditTime: 2024-09-03 18:01:48 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp */ #include "weather/include/MainWeatherView.h" @@ -79,32 +79,35 @@ namespace OHOS UISwipeView *MainWeatherView::MainWeatherViewInit(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainWeatherView::MainWeatherViewInit"); - weatherSwipeViewList = new UISwipeView(UISwipeView::VERTICAL); if (nullptr == weatherSwipeViewList) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherSwipeViewList new fail!!"); - return nullptr; - } - - weatherSwipeViewList->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - weatherSwipeViewList->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); // 0 : X; 0 : Y - weatherSwipeViewList->SetAnimatorTime(50); // 50:animator drag time(ms) - weatherSwipeViewList->SetViewId(MAIN_WEATHER_VIEW); - weatherSwipeViewList->SetDraggable(true); - weatherSwipeViewList->SetTouchable(true); - weatherSwipeViewList->SetVisible(false); - for (uint16_t i = 0; i < maxPage; i++) - { - recordCard[i] = CreatePage(i); - if (nullptr == recordCard[i]) + weatherSwipeViewList = new UISwipeView(UISwipeView::VERTICAL); + if (nullptr == weatherSwipeViewList) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordCard[%d] is nullptr!!", i); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherSwipeViewList new fail!!"); return nullptr; } - recordCard[i]->InitView(this); - weatherSwipeViewList->Add(recordCard[i]); + + weatherSwipeViewList->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + weatherSwipeViewList->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); // 0 : X; 0 : Y + weatherSwipeViewList->SetAnimatorTime(50); // 50:animator drag time(ms) + weatherSwipeViewList->SetViewId(MAIN_WEATHER_VIEW); + weatherSwipeViewList->SetDraggable(true); + weatherSwipeViewList->SetTouchable(true); + weatherSwipeViewList->SetVisible(false); + for (uint16_t i = 0; i < maxPage; i++) + { + recordCard[i] = CreatePage(i); + if (nullptr == recordCard[i]) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordCard[%d] is nullptr!!", i); + return nullptr; + } + recordCard[i]->InitView(this); + weatherSwipeViewList->Add(recordCard[i]); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainWeatherView InitPage over!!"); } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainWeatherView InitPage over!!"); return weatherSwipeViewList; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp index d2e9c941b..1eb0079d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 10:04:22 + * @LastEditTime: 2024-09-03 18:01:21 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp */ #include "weather/include/WeatherControlView.h" @@ -66,7 +66,7 @@ namespace OHOS return true; } - //天气数据有效初始化该视图 + // 天气数据有效初始化该视图 bool WeatherControlView::InitializeWeatherSwipeView() { weatherSwipView = mainWeatherView->MainWeatherViewInit(); @@ -83,14 +83,14 @@ namespace OHOS return false; } - weatherSwipView->SetOnSwipeListener(weatherOnSwipeListener); + // weatherSwipView->SetOnSwipeListener(weatherOnSwipeListener); weatherSwipView->SetVisible(false); Add(weatherSwipView); return true; } - //无天气数据则初始化该视图 + // 无天气数据则初始化该视图 bool WeatherControlView::InitializeWeatherDataErrorView() { weatherScrllView = mainWeatherView->WeatherDataErrorViewPageInit(); @@ -164,4 +164,9 @@ namespace OHOS // Weather's usage scenes is complicated, so we do not release it's resources inner slice. } + UISwipeView *WeatherControlView::GetWeatherSwipView(void) + { + return weatherSwipView; + } + } \ No newline at end of file -- 2.17.1