+/***\r
+ * @Date: 2024-08-06 18:11:47\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-08-27 18:27:41\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h\r
+ */\r
#ifndef START_COUNTDOWN_VIEW_H\r
#define START_COUNTDOWN_VIEW_H\r
\r
static constexpr const char *EndButton_ImagePath = "/user/res/countdown/COUNTDOWM_END.bin"; // 结束返回按钮图片\r
static constexpr const char *CountDown_Play_ImagePath = "/user/res/countdown/COUNTDOWM_PLAY.bin"; // 开始倒计时image\r
static constexpr const char *CountDown_PAUSE_ImagePath = "/user/res/countdown/COUNTDOWM_PAUSE.bin"; // 暂停倒计时image\r
- static constexpr const char * RepeatButtonImagePath = "/user/res/countdown/repeat_button.bin";\r
+ static constexpr const char *RepeatButtonImagePath = "/user/res/countdown/repeat_button.bin";\r
static constexpr const char *VectorImagesPath = "/user/res/countdown/COUNTDOWM_VECTOR.bin";\r
+ static constexpr const char *VectorBigImagesPath = "/user/res/countdown/Vector_Big.bin";\r
static constexpr const char *PlayOrPauseToggleButton_ViewID = "PlayOrPauseToggleButton"; // 暂停和开始toggleButton视图id\r
static constexpr const char *STARTCOUNTDOWNVIEWRETURNBUTTON = "StartCountDownViewReturnButton";\r
static constexpr const char *STARTCOUNTDOWNVIEW = "StartCountDownView";\r
- static constexpr const char * RepeatButtonViewID = "RepeatButtonViewID";\r
+ static constexpr const char *RepeatButtonViewID = "RepeatButtonViewID";\r
class StartCountDownView\r
{\r
\r
UILabelExt *GetShowCountDownTimelabel(void); // 获取显示倒计时时间标签\r
UILabelExt *GetShowTheRingTimelabel(void); // 获取显示响铃时间标签\r
UIToggleButton *GetPlayOrPauseToggleButton(void);\r
- UIButton * GetRepeatButton(void);\r
+ UIButton *GetRepeatButton(void);\r
\r
+ void SetEndView();\r
+ void SetImageAndLabel(bool state);\r
+ void ShowEndView(bool state);\r
private:\r
UIScrollView *scrollView = nullptr;\r
UILabelExt *Title = nullptr;\r
UILabelExt *showCountDownTimelabel = nullptr;\r
UILabelExt *showTheRingTime = nullptr;\r
UIImageView *vectorImage = nullptr;\r
+\r
+ UILabelExt *showTheEndRingTime = nullptr;\r
+ UIImageView *vectorbigImage = nullptr;\r
+\r
UIToggleButton *play_or_pause_toggleButton = nullptr;\r
UIButton *endbutton = nullptr;\r
- UIButton * RepeatButton = nullptr;\r
+ UIButton *RepeatButton = nullptr;\r
bool viewInitStatus{false};\r
};\r
} // namespace OHOS\r
/*触发铃声的开始*/\r
void CountDownModel::RequestStartRingtone(void)\r
{\r
- if(true != ConfigModel::GetInstance()->GetDnotdisturb())\r
+ if (true != ConfigModel::GetInstance()->GetDnotdisturb())\r
{\r
PostRingtoneEvent(&CountDownModel::StartRingtonePlayback);\r
}\r
MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetVisible(false);\r
MainCountDownView::GetInstance()->GetStartCountDownView()->GetRepeatButton()->SetVisible(true);\r
CountDownModel::GetInstance()->CountDown_StopTimer(); // 停止定时器\r
- MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->SetTextId(STR_COUNTDOWN_ENDS);//倒计时结束\r
- MainCountDownView::GetInstance()->GetStartCountDownView()->GetShowCountDownTimelabel()->ForceResetText();\r
- // 进行倒计时结束时的额外操作,比如播放声音、显示通知等\r
- // CountDownModel::GetInstance()->StartRingtonePlayback();\r
+\r
+ /*倒计时结束 显示大图标 */\r
+ MainCountDownView::GetInstance()->GetStartCountDownView()->ShowEndView(true);\r
+\r
+ // 进行倒计时结束时的额外操作,播放声音等\r
CountDownModel::GetInstance()->RequestStartRingtone();\r
}\r
else\r
Title->SetPosition(83, 50, 300, 35);
Title->SetStyle(STYLE_TEXT_FONT, 30);
Title->SetStyle(STYLE_LINE_HEIGHT, 35);
- Title->SetTextId(STR_COUNT_DOWN);//倒计时
+ Title->SetTextId(STR_COUNT_DOWN); // 倒计时
Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
Title->SetRollSpeed(70);
timePicker->SetPosition(74, 121, 320, 180);
timePicker->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
timePicker->SetStyle(STYLE_BORDER_RADIUS, 51);
- timePicker->SetItemHeight(60); // 设置时间选择器中每个项目的高度。
- timePicker->EnableSecond(true); // 设置在时间选择器中启用秒。
- timePicker->SetSelected(CountDownModel::GetInstance()->GetCountDownTime().c_str()); // 设置时间选择器中当前选择的时间。
- timePicker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xa8, 0x00, 0xff)); // 设置时间选择器中的文本颜色。
- timePicker->SetLoopState(UITimePicker::PickerType::PICKER_HOUR, true); // 设置是否开启循环 :时
- timePicker->SetLoopState(UITimePicker::PickerType::PICKER_MIN, true); // 设置是否开启循环:分
- timePicker->SetLoopState(UITimePicker::PickerType::PICKER_SEC, true); // 设置是否开启循环:秒
- timePicker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, 60); // 设置突出显示文本的字体名称和大小。
- timePicker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 设置背景文本的字体名称和大小。
+ timePicker->SetItemHeight(60); // 设置时间选择器中每个项目的高度。
+ timePicker->EnableSecond(true); // 设置在时间选择器中启用秒。
+ timePicker->SetSelected(CountDownModel::GetInstance()->GetCountDownTime().c_str()); // 设置时间选择器中当前选择的时间。
+ timePicker->SetTextColor(Color::GetColorFromRGBA(0x80, 0x80, 0x80, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+ // timePicker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xa8, 0x00, 0xff)); // 设置时间选择器中的文本颜色。
+ timePicker->SetLoopState(UITimePicker::PickerType::PICKER_HOUR, true); // 设置是否开启循环 :时
+ timePicker->SetLoopState(UITimePicker::PickerType::PICKER_MIN, true); // 设置是否开启循环:分
+ timePicker->SetLoopState(UITimePicker::PickerType::PICKER_SEC, true); // 设置是否开启循环:秒
+ timePicker->SetHighlightFont(GILROY_BOLD_FONT, 55); // 设置突出显示文本的字体名称和大小。
+ timePicker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 50); // 设置背景文本的字体名称和大小。
UITimePicker::SelectedListener *selectTimeListener =
(UITimePicker::SelectedListener *)OHOS::MainCountDownPresenter::GetInstance();
timePicker->RegisterSelectedListener(selectTimeListener);
return scrollView;
}
- UITimePicker * CountDownTimeConfigView::GetTimePicker(void)
+ UITimePicker *CountDownTimeConfigView::GetTimePicker(void)
{
return timePicker;
}
#include "countdown/include/CountDownModel.h"\r
#include "common/key_code.h"\r
#include <custom_utils.h>\r
+#include "countdown/include/StartCountDownView.h"\r
/*倒计时的主界面*/\r
-\r
+#include "gfx_utils/mem_check.h"\r
namespace OHOS\r
{\r
static constexpr const char *OneMinuteTime = "00:01:00"; // 1分钟\r
\r
MainCountDownPresenter::MainCountDownPresenter()\r
{\r
-\r
+#ifdef MEM_CHECK\r
+ MemCheck::GetInstance()->EnableLeakCheck(true);\r
+#endif\r
g_pMainCountDownPresenter = this;\r
}\r
\r
CountDownModel::GetInstance()->CountDown_StopTimer(); // 清理定时器资源\r
CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources(); // 清理播放器资源\r
g_pMainCountDownPresenter = nullptr;\r
+#ifdef MEM_CHECK\r
+ MemCheck::GetInstance()->EnableLeakCheck(false);\r
+#endif\r
}\r
\r
MainCountDownPresenter *MainCountDownPresenter::GetInstance()\r
bool MainCountDownPresenter::OnClick(UIView &view, const ClickEvent &event)\r
{\r
UNUSED(event);\r
+\r
MainCountDownView *p_MainCountDownView = MainCountDownView::GetInstance();\r
+ StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance();\r
+\r
if (p_MainCountDownView == nullptr)\r
{\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView::GetInstance fail!!");\r
\r
if (strcmp(view.GetViewId(), STARTCOUNTDOWN_BUTTON) == 0) // 在自定义倒计时界面点击开始按钮跳转到开始倒计时界面\r
{\r
- UITimePicker * timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker();\r
- if(nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue()))\r
+ UITimePicker *timePicker = CountDownTimeConfigView::GetInstance()->GetTimePicker();\r
+\r
+ if (nullptr != timePicker && ("00:00:00" != timePicker->GetSelectValue()))\r
{\r
CountDownModel::GetInstance()->SetCountDownTime(timePicker->GetSelectValue()); // 设置倒计时时间\r
CountDownModel::GetInstance()->SetRingTime(timePicker->GetSelectValue()); // 设置响铃时间\r
if (strcmp(view.GetViewId(), COUNTDOWNTIMENOTNULLVIEWRETURNBUTTON) == 0) // 从倒计时不为空视图退到自定义倒计时界面\r
{\r
p_MainCountDownView->ChangeView(COUNTDOWN_TIMENOTNULL, TIMECONFIG_COUNTDOWN);\r
+ /*结束视图恢复*/\r
+ if (p_StartCountDownView == nullptr)\r
+ return false;\r
+ p_StartCountDownView->ShowEndView(false);\r
return true;\r
}\r
\r
MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetTouchable(true);\r
MainCountDownView::GetInstance()->GetStartCountDownView()->GetPlayOrPauseToggleButton()->SetState(false);\r
p_MainCountDownView->ChangeView(START_COUNTDOWN, MAIN_COUNTDOWN);\r
+\r
return true;\r
}\r
\r
// repeat button cb\r
- if(0 == strcmp(view.GetViewId(), RepeatButtonViewID))\r
+ if (0 == strcmp(view.GetViewId(), RepeatButtonViewID))\r
{\r
// close prompt\r
CountDownModel::GetInstance()->StopRingtonePlaybackAndReleaseResources();\r
\r
+ /*结束视图恢复*/\r
+ if (p_StartCountDownView == nullptr)\r
+ return false;\r
+ p_StartCountDownView->ShowEndView(false);\r
+\r
// set param & change view\r
CountDownModel *model = CountDownModel::GetInstance();\r
const std::string timeValue = model->GetBackupCountDownTime();\r
\r
if (nullptr != p_MainCountDownView->GetStartCountDownView())\r
{\r
+\r
p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str());\r
p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(CountDownModel::GetInstance()->GetRingTime().c_str());\r
\r
bool MainCountDownPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
{\r
CountDownModel *p_CountDownModel = CountDownModel::GetInstance();\r
+ StartCountDownView *p_StartCountDownView = StartCountDownView::GetInstance();\r
+ if (p_CountDownModel == nullptr || p_StartCountDownView == nullptr)\r
+ return false;\r
+\r
switch (state)\r
{\r
case UICheckBox::SELECTED:\r
p_CountDownModel->CountDown_StartTimer(COUNTDOWN_TIMER_DURATION);\r
p_CountDownModel->CountDown_ResumeTimer(COUNTDOWN_TIMER_DURATION);\r
+ /*视图恢复*/\r
+ p_StartCountDownView->SetImageAndLabel(true);\r
+ p_StartCountDownView->ShowEndView(false);\r
break;\r
case UICheckBox::UNSELECTED:\r
p_CountDownModel->CountDown_PauseTimer();\r
+ /*进行视图隐藏*/\r
+ p_StartCountDownView->SetImageAndLabel(false);\r
break;\r
default:\r
break;\r
#include "countdown/include/CountDownModel.h"\r
#include "UiConfig.h"\r
#include "wearable_log.h"\r
+#include "uicomponents/UIComponents.h"\r
\r
/*开始倒计时*/\r
namespace OHOS\r
scrollView = nullptr;\r
}\r
}\r
+ void StartCountDownView::SetEndView()\r
+ {\r
+ /*最后显示图片*/\r
+ InitImageView(vectorbigImage, 183, 120, 100, 100, "image", VectorBigImagesPath);\r
+\r
+ /*显示时间字符串*/\r
+ std::string EndTimeStr = CountDownModel::GetInstance()->GetCountDownTime();\r
+ InitLabel(showTheEndRingTime, 83, 240, 300, 47, "title", EndTimeStr.c_str(), GILROY_BOLD_FONT, 40);\r
\r
+ /*结束前先隐藏*/\r
+ vectorbigImage->SetVisible(false);\r
+ showTheEndRingTime->SetVisible(false);\r
+ }\r
UIScrollView *StartCountDownView::StartCountDownViewInit()\r
{\r
if (scrollView == nullptr)\r
RepeatButton->SetOnClickListener(RepeatButtonClick);\r
RepeatButton->SetVisible(false);\r
\r
+ SetEndView();\r
+\r
/* ----------------------------------- Add ---------------------------------- */\r
scrollView->Add(Title);\r
scrollView->Add(showCountDownTimelabel);\r
scrollView->Add(endbutton);\r
scrollView->Add(play_or_pause_toggleButton);\r
scrollView->Add(RepeatButton);\r
+ scrollView->Add(vectorbigImage);\r
+ scrollView->Add(showTheEndRingTime);\r
}\r
\r
return scrollView;\r
{\r
return RepeatButton;\r
}\r
+\r
+ void StartCountDownView::SetImageAndLabel(bool state)\r
+ {\r
+ if (vectorImage == nullptr || showTheRingTime == nullptr)\r
+ return;\r
+\r
+ vectorImage->SetVisible(state);\r
+ showTheRingTime->SetVisible(state);\r
+ }\r
+ /*结束状态更新*/\r
+ void StartCountDownView::ShowEndView(bool state)\r
+ {\r
+ if (vectorImage == nullptr || showTheRingTime == nullptr || showCountDownTimelabel == nullptr)\r
+ return;\r
+\r
+ vectorImage->SetVisible(!state);\r
+ showTheRingTime->SetVisible(!state);\r
+ showCountDownTimelabel->SetVisible(!state);\r
+\r
+ vectorbigImage->SetVisible(state);\r
+ showTheEndRingTime->SetVisible(state);\r
+ }\r
}
\ No newline at end of file
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a18b31f5acbc24f407be8fd9a329237d0c66d05ab52839b927c945a20a56f9ac
+size 6824