962 lines
36 KiB
C++
962 lines
36 KiB
C++
#include "TjdUiAppAlarmView.h"
|
||
#include "TjdUiAppAlarmAdapter.h"
|
||
#include "TjdUiAppAlarmModel.h"
|
||
#include "TjdUiAppAlarmPresenter.h"
|
||
#include "TjdUiImageIds.h"
|
||
#include "TjdUiMemManage.h"
|
||
#include "TjdUiMultiLanguageExt.h"
|
||
#include "TjdUiUtils.h"
|
||
#include "common/image_cache_manager.h"
|
||
#include "debug_print.h"
|
||
#include "rtc_api.h"
|
||
#include "service_alarm.h"
|
||
#include "style.h"
|
||
#include "sys_config.h"
|
||
#include <stdio.h>
|
||
#include <string>
|
||
|
||
#define ENABLE_PRINT_INFO 1
|
||
#if ENABLE_PRINT_INFO
|
||
#define static_print_info(...) sys_ui_log_i(__VA_ARGS__) // 一般信息打印宏控制
|
||
#define static_print_warn(...) sys_ui_log_w(__VA_ARGS__) // 警告信息打印一般常开
|
||
#define static_print_error(...) sys_ui_log_e(__VA_ARGS__) // 错误信息打印一般常开
|
||
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__) // 调试信息打印
|
||
#else
|
||
#define static_print_info(...)
|
||
#define static_print_warn(...)
|
||
#define static_print_error(...)
|
||
#define static_print_debug(...)
|
||
#endif
|
||
|
||
using namespace OHOS;
|
||
|
||
namespace TJD {
|
||
|
||
#define ALARM_CONFIRM_CANCEL_BIN_PATH TJD_IMAGE_PATH "img_confirm_cancel.bin"
|
||
|
||
uint8_t TjdUiAppAlarmView::MaxAlarmCount = 0;
|
||
static constexpr int16_t ADD_ICON_TOP = 18;
|
||
static constexpr int16_t ADD_ICON_BOTTON = 18 + 110;
|
||
static constexpr int16_t GRADIENT_HIDE_DISTANCE = (VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2 - ADD_ICON_BOTTON;
|
||
// clang-format off
|
||
static constexpr int16_t ANIMATOR_TIME = 500;
|
||
|
||
static inline int16_t HorizontalCenter(int16_t width, int16_t parentWidth) { return (parentWidth - width) / 2; }
|
||
|
||
static inline int16_t VerticalCenter(int16_t height, int16_t parentHeight) { return (parentHeight - height) / 2; }
|
||
|
||
static inline void InitLabelHorCenter(OHOS::UILabel &label, uint8_t size, int16_t y, int16_t target, const char *text)
|
||
{
|
||
label.SetFont(TJD_VECTOR_FONT_FILENAME, size);
|
||
label.SetText(text);
|
||
label.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label.SetPosition(HorizontalCenter(label.GetWidth(), target), y);
|
||
}
|
||
|
||
static inline void InitLabelVerCenter(OHOS::UILabel &label, uint8_t size, int16_t x, int16_t target, const char *text)
|
||
{
|
||
label.SetFont(TJD_VECTOR_FONT_FILENAME, size);
|
||
label.SetText(text);
|
||
label.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label.SetPosition(x, VerticalCenter(label.GetHeight(), target));
|
||
}
|
||
|
||
static inline void InitLabelCenter(OHOS::UILabel &label, uint8_t size, int16_t parentWidth, int16_t parentHeight, const char *text)
|
||
{
|
||
label.SetFont(TJD_VECTOR_FONT_FILENAME, size);
|
||
label.SetText(text);
|
||
label.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label.SetPosition(HorizontalCenter(label.GetWidth(), parentWidth), VerticalCenter(label.GetHeight(), parentHeight));
|
||
}
|
||
// clang-format on
|
||
|
||
void AlarmAddAnimatorCallback::Callback(UIView *view)
|
||
{
|
||
printf("AlarmAddAnimatorCallback::Callback\n");
|
||
uint8_t opa;
|
||
if (view->GetOpaScale() == 0) {
|
||
needHide_ = false;
|
||
} else if (view->GetOpaScale() == 255) {
|
||
needHide_ = true;
|
||
}
|
||
|
||
if (needHide_) {
|
||
opa = EasingEquation::QuadEaseInOut(255, 0, animator_->GetRunTime(), animator_->GetTime());
|
||
printf("opa:%d\n", opa);
|
||
view->SetOpaScale(opa);
|
||
} else {
|
||
opa = EasingEquation::QuadEaseInOut(0, 255, animator_->GetRunTime(), animator_->GetTime());
|
||
printf("opa:%d\n", opa);
|
||
view->SetOpaScale(opa);
|
||
}
|
||
}
|
||
|
||
bool AlarmUIScrollView::OnDragStartEvent(const OHOS::DragEvent &event)
|
||
{
|
||
if (TjdUiAppAlarmPresenter::GetInstance()->GetCurrentView() != ALARM_HOME_VIEW) {
|
||
return true;
|
||
}
|
||
|
||
isOnStart_ = true;
|
||
return OHOS::UIScrollViewNested::OnDragStartEvent(event);
|
||
}
|
||
|
||
bool AlarmUIScrollView::OnDragEvent(const OHOS::DragEvent &event)
|
||
{
|
||
if (!isOnStart_) {
|
||
return true;
|
||
}
|
||
|
||
if (TjdUiAppAlarmPresenter::GetInstance()->GetCurrentView() != ALARM_HOME_VIEW) {
|
||
return true;
|
||
}
|
||
return OHOS::UIScrollViewNested::OnDragEvent(event);
|
||
}
|
||
|
||
bool AlarmUIScrollView::OnDragEndEvent(const OHOS::DragEvent &event)
|
||
{
|
||
if (!isOnStart_) {
|
||
return true;
|
||
}
|
||
isOnStart_ = false;
|
||
|
||
if (TjdUiAppAlarmPresenter::GetInstance()->GetCurrentView() != ALARM_HOME_VIEW) {
|
||
return true;
|
||
}
|
||
return OHOS::UIScrollViewNested::OnDragEndEvent(event);
|
||
}
|
||
|
||
static TjdUiAppAlarmView *g_pv_UiAppAlarmView = nullptr;
|
||
|
||
TjdUiAppAlarmView::TjdUiAppAlarmView() { g_pv_UiAppAlarmView = this; }
|
||
|
||
TjdUiAppAlarmView::~TjdUiAppAlarmView() { g_pv_UiAppAlarmView = nullptr; }
|
||
|
||
TjdUiAppAlarmView *TjdUiAppAlarmView::GetInstance(void) { return g_pv_UiAppAlarmView; }
|
||
|
||
void TjdUiAppAlarmView::OnStart()
|
||
{
|
||
static_print_info("TjdUiAppAlarmView::%s", __func__);
|
||
TjdUiAppAlarmView::MaxAlarmCount = TjdUiAppAlarmModel::GetInstance().GetAlarmMaxNumber();
|
||
TjdUiAppAlarmModel::GetInstance().SetTimeFormat(presenter_->GetTimeType());
|
||
tjd_service_alarm_open();
|
||
|
||
if (containerAll_ == nullptr) {
|
||
containerAll_ = new AlarmUIScrollView();
|
||
containerAll_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
|
||
// containerAll_->SetOnDragListener(presenter_);
|
||
}
|
||
|
||
InitTargetView(AlarmView::ALARM_HOME_VIEW);
|
||
InitTargetView(AlarmView::ALARM_EDIT_VIEW);
|
||
InitTargetView(AlarmView::ALARM_TIME_SET_VIEW);
|
||
InitTargetView(AlarmView::ALARM_CYCLE_SET_VIEW);
|
||
InitTargetView(AlarmView::ALARM_SET_FAIL_VIEW);
|
||
|
||
AddViewToRootContainer(containerAll_);
|
||
ShowView(AlarmView::ALARM_HOME_VIEW);
|
||
}
|
||
|
||
void TjdUiAppAlarmView::OnStop()
|
||
{
|
||
static_print_info("TjdUiAppAlarmView::%s", __func__);
|
||
ImageCacheManager::GetInstance().UnloadAllInMultiRes(ALARM_CONFIRM_CANCEL_BIN_PATH);
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
}
|
||
|
||
void TjdUiAppAlarmView::InitTargetView(AlarmView index)
|
||
{
|
||
if (viewManager_[index] != nullptr) {
|
||
return;
|
||
}
|
||
|
||
// clang-format off
|
||
switch (index) {
|
||
case ALARM_HOME_VIEW: viewManager_[index] = new AlarmHomeView(&homeContainer_); break;
|
||
case ALARM_EDIT_VIEW: viewManager_[index] = new AlarmEditView(&editContainer_); break;
|
||
case ALARM_TIME_SET_VIEW: viewManager_[index] = new AlarmSetTimeView(&setTimeContainer_); break;
|
||
case ALARM_CYCLE_SET_VIEW: viewManager_[index] = new AlarmCycleSetView(&setCycleContainer_); break;
|
||
case ALARM_SET_FAIL_VIEW: viewManager_[index] = new AlarmSetFailView(&setFailContainer_); break;
|
||
case ALARM_DEL_REMIND_VIEW: viewManager_[index] = new AlarmDeleteRemindView(&deleteRemindContainer_); break;
|
||
default: break;
|
||
}
|
||
// clang-format on
|
||
|
||
if (viewManager_[index] == nullptr) {
|
||
return;
|
||
}
|
||
|
||
viewManager_[index]->SetPosition(0, 0);
|
||
viewManager_[index]->Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
||
viewManager_[index]->SetVisible(false);
|
||
containerAll_->Add(viewManager_[index]);
|
||
}
|
||
|
||
void TjdUiAppAlarmView::ShowView(AlarmView showIndex)
|
||
{
|
||
if (showIndex < 0 || showIndex >= AlarmView::ALARM_VIEW_MAX) {
|
||
return;
|
||
}
|
||
|
||
InitTargetView(showIndex);
|
||
|
||
if (presenter_->currentView_ >= 0 && presenter_->currentView_ < AlarmView::ALARM_VIEW_MAX &&
|
||
viewManager_[presenter_->currentView_] != nullptr) {
|
||
viewManager_[presenter_->currentView_]->HideView();
|
||
}
|
||
|
||
if (viewManager_[showIndex] != nullptr) {
|
||
viewManager_[showIndex]->ShowView();
|
||
}
|
||
|
||
presenter_->currentView_ = showIndex;
|
||
}
|
||
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*---------------------------------- Class AlarmHomeView ---------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
|
||
AlarmHomeView::AlarmHomeView(AlarmHomeView **container)
|
||
{
|
||
*container = this;
|
||
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
||
if (OHOS::PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) {
|
||
SetOnDragListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
}
|
||
|
||
// InitLabelHorCenter(label_, 34, 304, OHOS::HORIZONTAL_RESOLUTION, "添加闹钟");
|
||
label_.SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
||
label_.SetTextId(STR_ID_289);
|
||
label_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label_.SetPosition(HorizontalCenter(label_.GetWidth(), 466), 304);
|
||
|
||
auto imageRes = imgManager.LoadOneInMultiRes(IMG_ALARM_FIRST_ADD, ALARM_BIN_PATH);
|
||
firstAdd_.SetPosition(168, 138, 130, 130);
|
||
firstAdd_.SetTouchable(true);
|
||
firstAdd_.SetOnClickListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
firstAdd_.SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::PRESSED);
|
||
firstAdd_.SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::INACTIVE);
|
||
firstAdd_.SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::RELEASED);
|
||
if (imageRes != nullptr) {
|
||
firstAdd_.SetImageSrc(imageRes, imageRes);
|
||
}
|
||
|
||
imageRes = imgManager.LoadOneInMultiRes(IMG_ALARM_ADD, ALARM_BIN_PATH);
|
||
add_.SetPosition(178, 18, 110, 110);
|
||
add_.SetTouchable(true);
|
||
add_.SetOnClickListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
add_.SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::PRESSED);
|
||
add_.SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::INACTIVE);
|
||
add_.SetStyleForState(STYLE_BACKGROUND_OPA, 0, UIButton::RELEASED);
|
||
if (imageRes != nullptr) {
|
||
add_.SetImageSrc(imageRes, imageRes);
|
||
}
|
||
|
||
adapter_ = new TjdAlarmAdapter();
|
||
TjdUiAppAlarmModel::GetInstance().LoadAlarmData(g_pv_UiAppAlarmView->GetAdapter()->GetList());
|
||
list_.SetPosition(0, 0);
|
||
list_.Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
|
||
list_.SetThrowDrag(true);
|
||
list_.EnableAutoAlign(true);
|
||
list_.SetScrollBlankSize((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
list_.SetReboundSize((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
list_.SetSelectPosition(VERTICAL_RESOLUTION / 2); // middle position
|
||
list_.SetScrollStateListener(&list_);
|
||
list_.SetMaxScrollDistance(400);
|
||
list_.SetAdapter(adapter_);
|
||
list_.ScrollBy((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
|
||
callback_ = new AlarmAddAnimatorCallback(&add_);
|
||
AlarmAddAnimator_ = new Animator(callback_, &add_, ANIMATOR_TIME, false);
|
||
|
||
Add(&list_);
|
||
Add(&label_);
|
||
Add(&add_);
|
||
Add(&firstAdd_);
|
||
}
|
||
|
||
AlarmHomeView::~AlarmHomeView()
|
||
{
|
||
if (AlarmAddAnimator_ != nullptr) {
|
||
AlarmAddAnimator_->Stop();
|
||
delete AlarmAddAnimator_;
|
||
AlarmAddAnimator_ = nullptr;
|
||
}
|
||
if (callback_ != nullptr) {
|
||
delete callback_;
|
||
callback_ = nullptr;
|
||
}
|
||
if (adapter_ != nullptr) {
|
||
delete adapter_;
|
||
adapter_ = nullptr;
|
||
}
|
||
RemoveAll();
|
||
}
|
||
|
||
void AlarmHomeView::ShowView()
|
||
{
|
||
SetVisible(true);
|
||
g_pv_UiAppAlarmView->GetAdapter()->DeleteListAllItem();
|
||
TjdUiAppAlarmModel::GetInstance().LoadAlarmData(g_pv_UiAppAlarmView->GetAdapter()->GetList());
|
||
SwitchHomeType(adapter_->GetCount() > 0 ? false : true);
|
||
g_pv_UiAppAlarmView->homeContainer_->list_.RefreshList();
|
||
list_.ScrollTo(0);
|
||
list_.ScrollBy((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
TjdUiUtils::ViewRequestFocus(list_);
|
||
}
|
||
|
||
void AlarmHomeView::SwitchHomeType(bool isFirst)
|
||
{
|
||
if (!isFirst) {
|
||
label_.SetVisible(false);
|
||
firstAdd_.SetVisible(false);
|
||
list_.SetVisible(true);
|
||
if (adapter_->GetCount() < TjdUiAppAlarmView::MaxAlarmCount)
|
||
add_.SetVisible(true);
|
||
else if (adapter_->GetCount() == TjdUiAppAlarmView::MaxAlarmCount)
|
||
add_.SetVisible(false);
|
||
} else {
|
||
list_.SetVisible(false);
|
||
add_.SetVisible(false);
|
||
label_.SetVisible(true);
|
||
firstAdd_.SetVisible(true);
|
||
}
|
||
}
|
||
|
||
bool AlarmHomeView::HomeList::OnDragStartEvent(const DragEvent &event)
|
||
{
|
||
uint8_t direction = event.GetDragDirection();
|
||
if (direction == DragEvent::DIRECTION_LEFT_TO_RIGHT || direction == DragEvent::DIRECTION_RIGHT_TO_LEFT) {
|
||
scrollEnable = false;
|
||
return false;
|
||
}
|
||
UIList::OnDragStartEvent(event);
|
||
return true;
|
||
}
|
||
|
||
bool AlarmHomeView::HomeList::OnDragEvent(const DragEvent &event)
|
||
{
|
||
if (!scrollEnable)
|
||
return false;
|
||
|
||
UIView *otherView = &(TjdUiAppAlarmView::GetInstance()->homeContainer_->add_);
|
||
if (this->GetChildrenHead() != nullptr && otherView->IsVisible()) {
|
||
// printf("%s:: firstItem y:%d otherView y:%d \n",__func__, firstItem->GetY(),
|
||
// (otherView->GetY()+otherView->GetHeight())+5);
|
||
|
||
InteractiveProcessing(otherView);
|
||
}
|
||
|
||
auto adapter = TjdUiAppAlarmView::GetInstance()->homeContainer_->GetAdapter();
|
||
|
||
if (adapter) {
|
||
printf("line:%d========adapter->GetCount()=%d====================\n", __LINE__, adapter->GetCount());
|
||
if (adapter->GetCount() <= 1) //当闹钟数小于等于1时,不允许滑动闹钟列表
|
||
return true;
|
||
else
|
||
UIList::OnDragEvent(event);
|
||
} else {
|
||
printf("AlarmHomeView::HomeList::OnDragStartEvent adapter is null line:%d\n", __LINE__);
|
||
UIList::OnDragEvent(event);
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
bool AlarmHomeView::HomeList::OnDragEndEvent(const DragEvent &event)
|
||
{
|
||
if (!scrollEnable) {
|
||
scrollEnable = true;
|
||
return false;
|
||
}
|
||
|
||
UIList::OnDragEndEvent(event);
|
||
return true;
|
||
}
|
||
|
||
void AlarmHomeView::HomeList::OnScrollEnd(int16_t index, UIView *view)
|
||
{
|
||
UIView *otherView = &(TjdUiAppAlarmView::GetInstance()->homeContainer_->add_);
|
||
if (this->GetChildrenHead() != nullptr && otherView->IsVisible()) {
|
||
|
||
// printf("%s:: this->GetChildrenHead() y:%d\n",__func__, this->GetChildrenHead()->GetY());
|
||
|
||
InteractiveProcessing(otherView);
|
||
}
|
||
}
|
||
|
||
void AlarmHomeView::HomeList::OnItemSelected(int16_t index, OHOS::UIView *view)
|
||
{
|
||
if (view != nullptr) {
|
||
itemViewSele = static_cast<TjdAlarmItemView *>(view);
|
||
// itemViewSele->SelectedChange();
|
||
|
||
if (preItemViewSele != nullptr && preItemViewSele != itemViewSele) {
|
||
// preItemViewSele->Reset();
|
||
}
|
||
preItemViewSele = itemViewSele;
|
||
}
|
||
}
|
||
|
||
void AlarmHomeView::HomeList::InteractiveProcessing(UIView *view)
|
||
{
|
||
UIView *otherView = view;
|
||
|
||
int16_t listY = this->GetChildrenHead()->GetY();
|
||
int16_t deltaY = listY - ADD_ICON_BOTTON;
|
||
deltaY = deltaY < 0 ? 0 : (deltaY > 45 ? 45 : deltaY);
|
||
|
||
uint8_t opa = static_cast<uint8_t>(((float)deltaY / GRADIENT_HIDE_DISTANCE) * 100);
|
||
opa *= 2.55;
|
||
otherView->SetStyle(STYLE_IMAGE_OPA, opa);
|
||
otherView->Invalidate();
|
||
}
|
||
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*-------------------------------- Class AlarmSetTimeView --------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
|
||
AlarmSetTimeView::AlarmSetTimeView(AlarmSetTimeView **container)
|
||
{
|
||
*container = this;
|
||
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
||
SetOnDragListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
// timePick.InitView("时间设置", TjdUiAppAlarmPresenter::GetInstance()->GetTimeType());
|
||
// timePick.SetPosition(0, 0, 466, 466);
|
||
// timePick.SetEnterColor(0xffffb811);
|
||
// timePick.SetBorderColor(0xffffb811);
|
||
// auto imageRes = imgManager.LoadOneInMultiRes(IMG_ALARM_GOU, ALARM_BIN_PATH);
|
||
// timePick.SetSrc(imageRes);
|
||
|
||
// timePick.SetTitle("时间设置");
|
||
timePick.SetTitleId(STR_ID_290);
|
||
timePick.SetEnterViewType(TjdUIEnterViewBase::EnterViewType::OK);
|
||
timePick.SetPosition(0, 0, 466, 466);
|
||
timePick.SetHighlightColor(0xffffb811);
|
||
auto imageRes = imgManager.LoadOneInMultiRes(IMG_CONFIRM_CANCEL_CONFIRM, ALARM_CONFIRM_CANCEL_BIN_PATH);
|
||
timePick.SetOkSrc(imageRes);
|
||
timePick.SetItemSelectdEnterListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
Add(&timePick);
|
||
}
|
||
|
||
void AlarmSetTimeView::ShowView()
|
||
{
|
||
struct rtc_class_ops *rtc_handle = tjd_driver_rtc_get_ops();
|
||
struct rtc_time local_time;
|
||
rtc_handle->get_rtc_time(&local_time);
|
||
AlarmViewBase::ShowView();
|
||
timePick.SetTime(local_time.tm_hour, local_time.tm_min);
|
||
timePick.SetPosition(0, 0);
|
||
}
|
||
|
||
void AlarmSetTimeView::HideView()
|
||
{
|
||
OHOS::FocusManager::GetInstance()->ClearFocus();
|
||
AlarmViewBase::HideView();
|
||
}
|
||
|
||
// void AlarmSetTimeView::AlarmTimeSetting::SelectPickerCallback(OHOS::UIPicker &view)
|
||
// {
|
||
// printf("AlarmTimeSetting::SelectPickerCallback\n");
|
||
// TjdUiUtils::ViewRequestFocus(view);
|
||
// }
|
||
|
||
// void AlarmSetTimeView::AlarmTimeSetting::EnterCallback(int32_t hour, int32_t minute)
|
||
// {
|
||
// if (g_pv_UiAppAlarmView->setTimeContainer_->enterView_ == ALARM_HOME_VIEW) {
|
||
// g_pv_UiAppAlarmView->setTimeContainer_->hour_ = hour;
|
||
// g_pv_UiAppAlarmView->setTimeContainer_->minute_ = minute;
|
||
// TjdUiAppAlarmView::GetInstance()->ShowView(ALARM_CYCLE_SET_VIEW);
|
||
// g_pv_UiAppAlarmView->setCycleContainer_->enterView_ = ALARM_TIME_SET_VIEW;
|
||
// } else if (g_pv_UiAppAlarmView->setTimeContainer_->enterView_ == ALARM_EDIT_VIEW) {
|
||
// uint8_t index = g_pv_UiAppAlarmView->editContainer_->selectedItemInfo_.index;
|
||
// printf("AlarmTimeSetting::EnterCallback index:%d, hour:%d, minute:%d\n", index, hour, minute);
|
||
// TjdUiAppAlarmModel::GetInstance().EditAlarmTimeToSQL(index, hour, minute);
|
||
// g_pv_UiAppAlarmView->ShowView(ALARM_EDIT_VIEW);
|
||
// AlarmItem item = g_pv_UiAppAlarmView->editContainer_->selectedItemInfo_;
|
||
// item.hour = hour;
|
||
// item.minute = minute;
|
||
// g_pv_UiAppAlarmView->editContainer_->SelectedCallback(item);
|
||
// }
|
||
// }
|
||
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*------------------------------- Class AlarmCycleSetView --------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
|
||
AlarmCycleSetView::AlarmCycleSetView(AlarmCycleSetView **container)
|
||
{
|
||
*container = this;
|
||
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
||
SetOnDragListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
// InitLabelHorCenter(label_, 28, 16, OHOS::HORIZONTAL_RESOLUTION, "重复");
|
||
label_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
label_.SetTextId(STR_ID_291);
|
||
label_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label_.SetPosition(HorizontalCenter(label_.GetWidth(), 466), 16);
|
||
|
||
confirm_.SetPosition(187, 352, 92, 92);
|
||
// confirm_.SetStyle(STYLE_BACKGROUND_COLOR, 0xffffb811);
|
||
// confirm_.SetStyle(STYLE_BORDER_RADIUS, 0);
|
||
confirm_.SetOnClickListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
auto imageRes = imgManager.LoadOneInMultiRes(IMG_CONFIRM_CANCEL_CONFIRM, ALARM_CONFIRM_CANCEL_BIN_PATH);
|
||
// confirm_.SetImagePosition((362 - 52) / 2, (86 - 36) / 2);
|
||
confirm_.SetImageSrc(imageRes, imageRes);
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
weekLabels[i].InitWeekLabel(i + 1);
|
||
weekLabels[i].SetPosition(80 + (80 + 34) * i, 115);
|
||
Add(&(weekLabels[i]));
|
||
}
|
||
for (int i = 3; i < 7; i++) {
|
||
weekLabels[i].InitWeekLabel(i + 1);
|
||
weekLabels[i].SetPosition(22 + (80 + 34) * (i - 3), 227);
|
||
Add(&(weekLabels[i]));
|
||
}
|
||
|
||
Add(&label_);
|
||
Add(&confirm_);
|
||
}
|
||
|
||
void AlarmCycleSetView::ShowView()
|
||
{
|
||
AlarmViewBase::ShowView();
|
||
for (int i = 0; i < 7; i++) {
|
||
weekLabels[i].SetIsOn(false);
|
||
}
|
||
}
|
||
|
||
uint8_t AlarmCycleSetView::GetCycle()
|
||
{
|
||
uint8_t cycle = 0;
|
||
for (int i = 0; i < 7; i++) {
|
||
if (weekLabels[i].GetIsOn()) {
|
||
cycle |= 1 << i;
|
||
}
|
||
}
|
||
return cycle;
|
||
}
|
||
|
||
void AlarmCycleSetView::UpdateLabelBackgroundColor(uint8_t cycle_mode)
|
||
{
|
||
for (int i = 0; i < 7; i++) {
|
||
if ((cycle_mode & 1 << i) == 1 << i) {
|
||
weekLabels[i].SetIsOn(true);
|
||
} else {
|
||
weekLabels[i].SetIsOn(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
void AlarmCycleSetView::ConfirmCallback()
|
||
{
|
||
printf("AlarmCycleSetView::ConfirmCallback\n");
|
||
if (enterView_ == ALARM_TIME_SET_VIEW) {
|
||
uint8_t hour = g_pv_UiAppAlarmView->setTimeContainer_->hour_;
|
||
uint8_t minute = g_pv_UiAppAlarmView->setTimeContainer_->minute_;
|
||
printf("repeat:%d\n", TjdUiAppAlarmModel::GetInstance().GetWhetherAlarmIsSetToRepeat(GetCycle(), hour, minute));
|
||
|
||
if (TjdUiAppAlarmModel::GetInstance().GetWhetherAlarmIsSetToRepeat(GetCycle(), hour, minute))
|
||
g_pv_UiAppAlarmView->ShowView(ALARM_SET_FAIL_VIEW);
|
||
else {
|
||
TjdUiAppAlarmModel::GetInstance().AddAlarmToSQL(GetCycle(), hour, minute);
|
||
g_pv_UiAppAlarmView->ShowView(ALARM_HOME_VIEW);
|
||
}
|
||
|
||
} else if (enterView_ == ALARM_EDIT_VIEW) {
|
||
uint8_t index = g_pv_UiAppAlarmView->editContainer_->selectedItemInfo_.index;
|
||
TjdUiAppAlarmModel::GetInstance().EditAlarmCycleToSQL(index, GetCycle());
|
||
g_pv_UiAppAlarmView->ShowView(ALARM_EDIT_VIEW);
|
||
AlarmItem item = g_pv_UiAppAlarmView->editContainer_->selectedItemInfo_;
|
||
item.cycle_mode = GetCycle();
|
||
g_pv_UiAppAlarmView->editContainer_->SelectedCallback(item);
|
||
}
|
||
}
|
||
|
||
void AlarmCycleSetView::WeekLabel::InitWeekLabel(uint8_t id)
|
||
{
|
||
id_ = id;
|
||
Resize(80, 80);
|
||
SetTouchable(true);
|
||
SetOnClickListener(this);
|
||
SetTextId(convertDay(id_));
|
||
SetStyle(STYLE_BORDER_RADIUS, 40);
|
||
SetStyle(STYLE_BACKGROUND_OPA, 0xff);
|
||
SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
||
SetStyle(STYLE_BACKGROUND_COLOR, 0xff262626);
|
||
SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
||
SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
}
|
||
|
||
bool AlarmCycleSetView::WeekLabel::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
if (isOn_) {
|
||
isOn_ = false;
|
||
SetStyle(STYLE_BACKGROUND_COLOR, 0xff262626);
|
||
SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
|
||
} else {
|
||
isOn_ = true;
|
||
SetStyle(STYLE_BACKGROUND_COLOR, 0xfff8b618);
|
||
SetStyle(STYLE_TEXT_COLOR, 0xff000000);
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
void AlarmCycleSetView::WeekLabel::SetIsOn(bool isOn)
|
||
{
|
||
isOn_ = isOn;
|
||
if (isOn_) {
|
||
SetStyle(STYLE_BACKGROUND_COLOR, 0xfff8b618);
|
||
SetStyle(STYLE_TEXT_COLOR, 0xff000000);
|
||
} else {
|
||
SetStyle(STYLE_BACKGROUND_COLOR, 0xff262626);
|
||
SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
|
||
}
|
||
}
|
||
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*--------------------------------- Class AlarmEditView ----------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
/*----------------------------------------------------------------------------------------*/
|
||
|
||
AlarmEditView::AlarmEditView(AlarmEditView **container)
|
||
{
|
||
*container = this;
|
||
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
||
SetOnDragListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
// InitLabelHorCenter(label_, 28, 16, OHOS::HORIZONTAL_RESOLUTION, "编辑");
|
||
label_.SetFont(TJD_VECTOR_FONT_FILENAME, 28);
|
||
label_.SetTextId(STR_ID_69);
|
||
label_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
||
label_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
||
label_.SetPosition(HorizontalCenter(label_.GetWidth(), 466), 16);
|
||
|
||
list_.SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
|
||
list_.SetThrowDrag(true);
|
||
list_.EnableAutoAlign(true);
|
||
list_.SetScrollBlankSize((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
list_.SetReboundSize((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
list_.SetSelectPosition(VERTICAL_RESOLUTION / 2); // middle position
|
||
list_.SetMaxScrollDistance(400);
|
||
list_.SetAdapter(&adapter_);
|
||
list_.SetScrollStateListener(&list_);
|
||
list_.SetStartItem(adapter_.GetEditItem(0));
|
||
|
||
delete_.SetPosition(187, 380, 93, 93);
|
||
delete_.SetOnClickListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
auto imageRes = imgManager.LoadOneInMultiRes(IMG_ALARM_DELETE, ALARM_BIN_PATH);
|
||
delete_.SetImageSrc(imageRes, imageRes);
|
||
delete_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff62626);
|
||
|
||
Add(&list_);
|
||
Add(&label_);
|
||
Add(&delete_);
|
||
}
|
||
|
||
void AlarmEditView::SelectedCallback(AlarmItem selectedItemInfo)
|
||
{
|
||
EditUnion data;
|
||
selectedItemInfo_ = selectedItemInfo;
|
||
|
||
data.time.hour = selectedItemInfo_.hour;
|
||
data.time.minute = selectedItemInfo_.minute;
|
||
adapter_.SetEditItem(0, data);
|
||
|
||
data.cycle_mode = selectedItemInfo_.cycle_mode;
|
||
adapter_.SetEditItem(1, data);
|
||
|
||
list_.ScrollTo(0);
|
||
list_.ScrollBy((VERTICAL_RESOLUTION - ALARM_ITEM_H) / 2);
|
||
}
|
||
|
||
AlarmEditView::AlarmEditItemView::AlarmEditItemView()
|
||
{
|
||
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
||
|
||
SetTouchable(true);
|
||
SetOnClickListener(this);
|
||
SetPosition(8, 0, 450, 120);
|
||
SetStyle(STYLE_MARGIN_BOTTOM, 13);
|
||
SetStyle(STYLE_BORDER_RADIUS, 60);
|
||
SetStyle(STYLE_BACKGROUND_COLOR, 0xff262626);
|
||
|
||
mainLabel_.SetPosition(42, 18, 355, 55);
|
||
mainLabel_.SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
|
||
mainLabel_.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP);
|
||
mainLabel_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_40);
|
||
|
||
minorLabel_.SetPosition(44, 69, 353, 36);
|
||
minorLabel_.SetStyle(STYLE_TEXT_COLOR, 0xff969696);
|
||
minorLabel_.SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
|
||
minorLabel_.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_TOP);
|
||
minorLabel_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_24);
|
||
|
||
image_.SetPosition(397, 47, 15, 26);
|
||
auto imageRes = imgManager.LoadOneInMultiRes(IMG_ALARM_MORE, ALARM_BIN_PATH);
|
||
image_.SetSrc(imageRes);
|
||
|
||
Add(&mainLabel_);
|
||
Add(&minorLabel_);
|
||
Add(&image_);
|
||
}
|
||
|
||
bool AlarmEditView::AlarmEditItemView::OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
||
{
|
||
if (index_ == 0) {
|
||
g_pv_UiAppAlarmView->ShowView(ALARM_TIME_SET_VIEW);
|
||
g_pv_UiAppAlarmView->setTimeContainer_->enterView_ = ALARM_EDIT_VIEW;
|
||
g_pv_UiAppAlarmView->setTimeContainer_->timePick.SetTime(data_.time.hour, data_.time.minute);
|
||
} else if (index_ == 1) {
|
||
g_pv_UiAppAlarmView->ShowView(ALARM_CYCLE_SET_VIEW);
|
||
g_pv_UiAppAlarmView->setCycleContainer_->enterView_ = ALARM_EDIT_VIEW;
|
||
g_pv_UiAppAlarmView->setCycleContainer_->UpdateLabelBackgroundColor(data_.cycle_mode);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
void AlarmEditView::AlarmEditItemView::SetEditItemLabelText()
|
||
{
|
||
if (index_ == 0) {
|
||
std::string timeText;
|
||
TjdUITimePicker::TimePickerType type = TjdUITimePicker::TimePickerType::TIME_PICKER_24_HOUR;
|
||
if (TjdUiAppAlarmPresenter::GetInstance()->GetTimeType() == type) {
|
||
timeText = CheckTimeIsNeedFillZero(data_.time.hour) + ":" + CheckTimeIsNeedFillZero(data_.time.minute);
|
||
} else {
|
||
// timeText = "上午 ";
|
||
timeText = std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_299)) + " ";
|
||
uint8_t hour = data_.time.hour;
|
||
if (hour > 12) {
|
||
// timeText = "下午 ";
|
||
timeText = std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_300)) + " ";
|
||
hour = hour - 12;
|
||
}
|
||
timeText += CheckTimeIsNeedFillZero(hour) + ":" + CheckTimeIsNeedFillZero(data_.time.minute);
|
||
}
|
||
SetMainLabelText(timeText.c_str());
|
||
SetMinorLabelText(FontGlobalManager::GetInstance()->GetText(STR_ID_305)); //"更改时间");
|
||
|
||
} else {
|
||
std::string cycle;
|
||
std::string repeat = FontGlobalManager::GetInstance()->GetText(STR_ID_291); //"重复";
|
||
|
||
cycle = buildCycleString(data_.cycle_mode);
|
||
SetMainLabelText(cycle.c_str());
|
||
SetMinorLabelText(repeat.c_str());
|
||
}
|
||
}
|
||
|
||
UIView *AlarmEditView::EditAdapter::GetView(UIView *inView, int16_t index)
|
||
{
|
||
if (index >= 2 || index < 0) {
|
||
return nullptr;
|
||
}
|
||
return &(item_[index]);
|
||
}
|
||
|
||
void AlarmEditView::EditAdapter::SetEditItem(uint8_t index, EditUnion data)
|
||
{
|
||
item_[index].SetIndex(index);
|
||
item_[index].SetEditItemData(data);
|
||
item_[index].SetEditItemLabelText();
|
||
}
|
||
|
||
bool AlarmEditView::EditList::OnDragStartEvent(const OHOS::DragEvent &event)
|
||
{
|
||
uint8_t direction = event.GetDragDirection();
|
||
if (direction == DragEvent::DIRECTION_LEFT_TO_RIGHT || direction == DragEvent::DIRECTION_RIGHT_TO_LEFT) {
|
||
scrollEnable_ = false;
|
||
return false;
|
||
}
|
||
UIList::OnDragStartEvent(event);
|
||
return true;
|
||
}
|
||
|
||
bool AlarmEditView::EditList::OnDragEvent(const OHOS::DragEvent &event)
|
||
{
|
||
if (!scrollEnable_)
|
||
return false;
|
||
|
||
UIList::OnDragEvent(event);
|
||
|
||
if (startItem_ != nullptr) {
|
||
UIView *otherView = &(TjdUiAppAlarmView::GetInstance()->editContainer_->label_);
|
||
|
||
if (otherView->IsVisible() && (startItem_->GetY() <= (otherView->GetY() + otherView->GetHeight()) + 5)) {
|
||
otherView->SetVisible(false);
|
||
} else if (!otherView->IsVisible() && (startItem_->GetY() > (otherView->GetY() + otherView->GetHeight()) + 5)) {
|
||
otherView->SetVisible(true);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool AlarmEditView::EditList::OnDragEndEvent(const OHOS::DragEvent &event)
|
||
{
|
||
if (!scrollEnable_) {
|
||
scrollEnable_ = true;
|
||
return false;
|
||
}
|
||
|
||
UIList::OnDragEndEvent(event);
|
||
return true;
|
||
}
|
||
|
||
void AlarmEditView::EditList::OnScrollEnd(int16_t index, UIView *view)
|
||
{
|
||
if (startItem_ != nullptr) {
|
||
UIView *otherView = &(TjdUiAppAlarmView::GetInstance()->editContainer_->label_);
|
||
|
||
if (otherView->IsVisible() && (startItem_->GetY() <= (otherView->GetY() + otherView->GetHeight()) + 5)) {
|
||
otherView->SetVisible(false);
|
||
} else if (!otherView->IsVisible() && (startItem_->GetY() > (otherView->GetY() + otherView->GetHeight()) + 5)) {
|
||
otherView->SetVisible(true);
|
||
}
|
||
}
|
||
}
|
||
|
||
AlarmSetFailView::AlarmSetFailView(AlarmSetFailView **container)
|
||
{
|
||
printf("AlarmSetFailView::AlarmSetFailView\n");
|
||
*container = this;
|
||
SetOnDragListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
label_.SetPosition(88, 192, 289, 50);
|
||
label_.SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
|
||
label_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
label_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_34);
|
||
// label_.SetText("闹钟设置重复\n 本次添加无效!");
|
||
label_.SetTextId(STR_ID_563);
|
||
|
||
Add(&label_);
|
||
|
||
timer_ = new GraphicTimer(
|
||
3000,
|
||
[](void *arg) {
|
||
printf("AlarmSetFailView::timer_ callback\n");
|
||
TjdUiAppAlarmView::GetInstance()->ShowView(ALARM_HOME_VIEW);
|
||
},
|
||
nullptr);
|
||
}
|
||
|
||
#pragma region 闹钟删除提醒界面
|
||
AlarmDeleteRemindView::AlarmDeleteRemindView(AlarmDeleteRemindView **container)
|
||
{
|
||
*container = this;
|
||
SetOnDragListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
lbTip_.SetPosition(0, 145, 466, 47);
|
||
lbTip_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
// lbTip_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
lbTip_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_36);
|
||
// lbTip_.SetText("是否确认删除本条闹钟");
|
||
lbTip_.SetTextId(STR_ID_561);
|
||
|
||
lbFormat_.SetPosition(167, 199, 57, 28);
|
||
lbFormat_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
lbFormat_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
lbFormat_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_30);
|
||
lbFormat_.SetText("下午");
|
||
|
||
lbTimeStamp_.SetPosition(235, 200, 65, 26);
|
||
lbTimeStamp_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
lbTimeStamp_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
lbTimeStamp_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_36);
|
||
lbTimeStamp_.SetText("5:00");
|
||
|
||
lbRepeat_.SetPosition(85, 260, 296, 28);
|
||
lbRepeat_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
|
||
lbRepeat_.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
|
||
lbRepeat_.SetFont(TJD_VECTOR_FONT_FILENAME, TJD_FONT_SIZE_30);
|
||
lbRepeat_.SetText("重复:一、二、五、六");
|
||
|
||
auto imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_CONFIRM_CANCEL_CANCEL,
|
||
ALARM_CONFIRM_CANCEL_BIN_PATH);
|
||
imgCancel_.SetPosition(103, 326, 92, 92);
|
||
imgCancel_.SetSrc(imgInfo);
|
||
// imgCancel_.SetViewId("imgCancel_");
|
||
imgCancel_.SetTouchable(true);
|
||
imgCancel_.SetOnClickListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
imgInfo = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_CONFIRM_CANCEL_CONFIRM,
|
||
ALARM_CONFIRM_CANCEL_BIN_PATH);
|
||
imgConfirm_.SetPosition(271, 326, 92, 92);
|
||
imgConfirm_.SetSrc(imgInfo);
|
||
// imgConfirm_.SetViewId("imgConfirm_");
|
||
imgConfirm_.SetTouchable(true);
|
||
imgConfirm_.SetOnClickListener(TjdUiAppAlarmPresenter::GetInstance());
|
||
|
||
Add(&lbTip_);
|
||
Add(&lbFormat_);
|
||
Add(&lbTimeStamp_);
|
||
Add(&lbRepeat_);
|
||
Add(&imgCancel_);
|
||
Add(&imgConfirm_);
|
||
}
|
||
|
||
void AlarmDeleteRemindView::ShowView()
|
||
{
|
||
UpdateView();
|
||
SetVisible(true);
|
||
}
|
||
|
||
void AlarmDeleteRemindView::HideView() { SetVisible(false); }
|
||
|
||
void AlarmDeleteRemindView::UpdateView()
|
||
{
|
||
uint8_t hour = g_pv_UiAppAlarmView->setTimeContainer_->hour_;
|
||
uint8_t minute = g_pv_UiAppAlarmView->setTimeContainer_->minute_;
|
||
auto itemInView = TjdUiAppAlarmView::GetInstance()->itemView_;
|
||
if (itemInView == nullptr)
|
||
return;
|
||
|
||
bool format = static_cast<bool>(TjdUiAppAlarmPresenter::GetInstance()->GetTimeType());
|
||
lbFormat_.SetVisible(format);
|
||
|
||
auto itemInfo = itemInView->GetItemInfo();
|
||
|
||
std::string timeText = CheckTimeIsNeedFillZero(itemInfo.hour) + ":" + CheckTimeIsNeedFillZero(itemInfo.minute);
|
||
lbTimeStamp_.SetText(timeText.c_str());
|
||
|
||
TjdUITimePicker::TimePickerType type = TjdUITimePicker::TimePickerType::TIME_PICKER_24_HOUR;
|
||
if (TjdUiAppAlarmPresenter::GetInstance()->GetTimeType() == type) {
|
||
lbTimeStamp_.SetX((466 - lbTimeStamp_.GetWidth()) / 2);
|
||
lbTimeStamp_.Invalidate();
|
||
} else {
|
||
// std::string str = "上午 ";
|
||
std::string str = std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_299)) + " ";
|
||
uint8_t hour = itemInfo.hour;
|
||
if (hour > 12) {
|
||
// str = "下午 ";
|
||
str = std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_300)) + " ";
|
||
hour = hour - 12;
|
||
}
|
||
lbFormat_.SetText(str.c_str());
|
||
|
||
lbTimeStamp_.SetX(235);
|
||
}
|
||
|
||
std::string cycle = std::string(FontGlobalManager::GetInstance()->GetText(STR_ID_291)) + std::string(": ") +
|
||
std::string(itemInView->GetWeekStr());
|
||
lbRepeat_.SetText(cycle.c_str());
|
||
lbRepeat_.SetX((466 - lbRepeat_.GetWidth()) / 2);
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
} // namespace TJD
|