/*---------------------------------------------------------------------------- * Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved. * * Description: * * Author: liangjianfei * * Create: 2024-5 *--------------------------------------------------------------------------*/ #include "TjdUiAppStartUpItemView.h" #include "TjdUiAppStartUpView.h" #include "TjdUiImageIds.h" #include "TjdUiMultiLanguageExt.h" #include "common/image_cache_manager.h" namespace TJD { #define STARTUP_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_startup.bin" // timer = new GraphicTimer(300, TimerCallback, nullptr); // GraphicService::GetInstance()->PostGraphicEvent( // std::bind([](void *arg) { TjdStartUpView::GetInstance()->ChangedView(DETAIL_VIEW, SELECT_VIEW); }, arg)); StartUpItemView::StartUpItemView(const StartUpItemInfo &itemInfo) { SetPosition(8, 0, 450, 128); SetTouchable(true); SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff); SetStyle(OHOS::STYLE_BORDER_RADIUS, 64); SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020); SetViewIndex(itemInfo.index); name_.SetFont(TJD_VECTOR_FONT_FILENAME, 34); name_.SetText(itemInfo.name.c_str()); name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_STRETCH); name_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER); name_.SetHeight(GetHeight()); name_.SetX(42); selectIcon_.SetPosition(382, 44, 40, 40); selectRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STARTUP_ICON_SELECT, STARTUP_IMAGE_BIN_PATH); unSelectRes_ = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_STARTUP_ICON_NO, STARTUP_IMAGE_BIN_PATH); Add(&name_); Add(&selectIcon_); } void StartUpItemView::RefreshItem(const StartUpItemInfo &itemInfo, int16_t index) { name_.SetText(itemInfo.name.c_str()); if (itemInfo.index == TjdStartUpPresenter::GetInstance()->GetLanguageSelect()) { selectIcon_.SetSrc(selectRes_); } else { selectIcon_.SetSrc(unSelectRes_); } } bool StartUpItemView::OnClickEvent(const OHOS::ClickEvent &event) { OHOS::UIView *childView = static_cast(GetParent())->GetChildrenHead(); while (childView != nullptr) { static_cast(childView)->selectIcon_.SetSrc(unSelectRes_); childView = childView->GetNextSibling(); } if (selectIcon_.GetImageInfo()->resId == selectRes_->resId) { selectIcon_.SetSrc(unSelectRes_); } else { selectIcon_.SetSrc(selectRes_); } selectIcon_.Invalidate(); TjdStartUpPresenter *presenter = TjdStartUpPresenter::GetInstance(); if (presenter == nullptr) { return false; } presenter->SetLanguageSelect(static_cast(GetViewIndex())); presenter->StartJumpTimer(StartUpView::DETAIL_VIEW); return true; } } // namespace TJD