595 lines
20 KiB
C++
595 lines
20 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2025. All rights reserved.
|
|
*
|
|
* Description: TjdUiAppSettingListItemView.cpp
|
|
*
|
|
* Author: luziquan@ss-tjd.com
|
|
*
|
|
* Create: 2025-03-31
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
#include "TjdUiAppSettingListItemView.h"
|
|
#include "TjdUiAppIds.h"
|
|
#include "TjdUiAppListModel.h"
|
|
#include "TjdUiAppSettingCommonPresenter.h"
|
|
#include "TjdUiAppSettingLanguagePresenter.h"
|
|
#include "TjdUiAppSettingModel.h"
|
|
#include "TjdUiAppSettingPage.h"
|
|
#include "TjdUiAppSettingPasswordPresenter.h"
|
|
#include "TjdUiAppSettingPowerSavingView.h"
|
|
#include "TjdUiAppSettingPresenter.h"
|
|
#include "TjdUiAppSettingWatchfaceMenuPresenter.h"
|
|
#include "TjdUiImageIds.h"
|
|
#include "TjdUiMultiLanguageExt.h"
|
|
#include "TjdUiUtils.h"
|
|
#include "common/image_cache_manager.h"
|
|
|
|
#define SETTING_IMAGE_BIN_PATH TJD_IMAGE_PATH "img_setting.bin"
|
|
|
|
namespace TJD {
|
|
|
|
CommonItemView::CommonItemView(const NormalItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(450, 128);
|
|
SetTouchable(true);
|
|
SetViewIndex(itemInfo.index);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
|
|
icon_.SetPosition(16, 19, 90, 90);
|
|
if (itemInfo.imageInfo != nullptr) {
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
}
|
|
|
|
name_.Resize(220, 54);
|
|
name_.SetPosition(120, (GetHeight() >> 1) - (name_.GetHeight() >> 1));
|
|
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
|
|
Add(&icon_);
|
|
Add(&name_);
|
|
}
|
|
|
|
void CommonItemView::RefreshItem(const NormalItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
name_.SetTextId(itemInfo.name);
|
|
TjdUiUtils::AutoAlignHorizontalCenter(name_, GetWidth());
|
|
TjdUiUtils::AutoAlignVerticalCenter(name_, GetHeight());
|
|
}
|
|
|
|
bool CommonItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
TjdUiAppSettingCommonPresenter::GetInstance()->OnClickItem(static_cast<CommonSelectItem>(itemInfo_.index));
|
|
return UIView::OnClickEvent(event);
|
|
}
|
|
|
|
LanguageItemView::LanguageItemView(const LanguageItemInfo &itemInfo)
|
|
{
|
|
Resize(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, 42);
|
|
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(377, 49, 44, 31);
|
|
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_SETTING_SELECTED, SETTING_IMAGE_BIN_PATH);
|
|
if (image != nullptr) {
|
|
selectIcon_.SetSrc(image);
|
|
}
|
|
|
|
Add(&name_);
|
|
Add(&selectIcon_);
|
|
}
|
|
|
|
void LanguageItemView::RefreshItem(const LanguageItemInfo &itemInfo, int16_t index)
|
|
{
|
|
name_.SetText(itemInfo.name.c_str());
|
|
if (itemInfo.index == TjdUiAppSettingLanguagePresenter::GetInstance()->GetLanguageSelect()) {
|
|
selectIcon_.SetVisible(true);
|
|
} else {
|
|
selectIcon_.SetVisible(false);
|
|
}
|
|
}
|
|
|
|
bool LanguageItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
|
while (childView != nullptr) {
|
|
static_cast<LanguageItemView *>(childView)->selectIcon_.SetVisible(false);
|
|
childView = childView->GetNextSibling();
|
|
}
|
|
selectIcon_.IsVisible() ? selectIcon_.SetVisible(false) : selectIcon_.SetVisible(true);
|
|
TjdUiAppSettingLanguagePresenter::GetInstance()->SetLanguageSelect(static_cast<language_enum>(GetViewIndex()));
|
|
return true;
|
|
}
|
|
|
|
MotionOverTimeItemView::MotionOverTimeItemView(const OverTimeItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(450, 128);
|
|
SetTouchable(true);
|
|
SetViewIndex(itemInfo.index);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
|
|
icon_.SetPosition(16, 20, 88, 88);
|
|
if (itemInfo.imageInfo != nullptr) {
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
}
|
|
|
|
name_.Resize(220, GetHeight());
|
|
name_.SetPosition(120, 0);
|
|
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
|
|
Add(&icon_);
|
|
Add(&name_);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_RADIO_ON, SETTING_IMAGE_BIN_PATH);
|
|
unSelectRes_ = images.LoadOneInMultiRes(IMG_SETTING_RADIO_OFF, SETTING_IMAGE_BIN_PATH);
|
|
|
|
switch_.SetPosition(382, 44, 40, 40);
|
|
switch_.SetTouchable(false);
|
|
switch_.SetSrc(unSelectRes_);
|
|
|
|
Add(&switch_);
|
|
}
|
|
|
|
void MotionOverTimeItemView::RefreshItem(const OverTimeItemInfo &itemInfo, int16_t index)
|
|
{
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
name_.SetText(itemInfo.name.c_str());
|
|
|
|
uint32_t motionOutTime = TjdUiAppSettingModel::GetInstance()->GetMotionOutTime();
|
|
int selectIndex = (motionOutTime / 3600) - 7;
|
|
if (selectIndex >= 0 && selectIndex < 4) {
|
|
if (GetViewIndex() == selectIndex) {
|
|
switch_.SetSrc(selectRes_);
|
|
} else {
|
|
switch_.SetSrc(unSelectRes_);
|
|
}
|
|
}
|
|
TjdUiUtils::AutoAlignHorizontalCenter(name_, GetWidth());
|
|
TjdUiUtils::AutoAlignVerticalCenter(name_, GetHeight());
|
|
}
|
|
|
|
bool MotionOverTimeItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
uint32_t time = GetViewIndex() + 7;
|
|
// time单位秒,转换成小时
|
|
time = time * 3600;
|
|
TjdUiAppSettingModel::GetInstance()->SetMotionOutTime(time);
|
|
|
|
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
|
while (childView != nullptr) {
|
|
static_cast<MotionOverTimeItemView *>(childView)->switch_.SetSrc(unSelectRes_);
|
|
childView = childView->GetNextSibling();
|
|
}
|
|
|
|
if (switch_.GetImageInfo()->resId == selectRes_->resId) {
|
|
switch_.SetSrc(unSelectRes_);
|
|
} else {
|
|
switch_.SetSrc(selectRes_);
|
|
}
|
|
switch_.Invalidate();
|
|
|
|
return true;
|
|
}
|
|
|
|
LeftKeyItemView::LeftKeyItemView(const NormalItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(450, 128);
|
|
SetTouchable(true);
|
|
SetViewIndex(itemInfo.index);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
|
|
icon_.Resize(92, 92);
|
|
icon_.SetPosition(16, GetHeight() / 2 - icon_.GetHeight() / 2);
|
|
icon_.SetAutoEnable(false);
|
|
icon_.SetResizeMode(OHOS::UIImageView::COVER);
|
|
if (itemInfo.imageInfo != nullptr) {
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
}
|
|
|
|
name_.Resize(220, 54);
|
|
name_.SetPosition(120, (GetHeight() >> 1) - (name_.GetHeight() >> 1));
|
|
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
|
|
Add(&icon_);
|
|
Add(&name_);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_RADIO_ON, SETTING_IMAGE_BIN_PATH);
|
|
unSelectRes_ = images.LoadOneInMultiRes(IMG_SETTING_RADIO_OFF, SETTING_IMAGE_BIN_PATH);
|
|
|
|
switch_.SetPosition(382, 44, 40, 40);
|
|
switch_.SetTouchable(false);
|
|
switch_.SetSrc(selectRes_);
|
|
|
|
Add(&switch_);
|
|
}
|
|
|
|
void LeftKeyItemView::RefreshItem(const NormalItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
name_.SetTextId(itemInfo.name);
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
|
|
int32_t selectIndex = -1;
|
|
auto sliceId = TjdUiAppSettingModel::GetInstance()->GetLeftKeySetting();
|
|
auto *appList = TjdUiAppListModel::GetInstance().GetApplistItems();
|
|
for (uint32_t i = 0; i < TjdUiAppListModel::GetInstance().GetAppListNum(); ++i) {
|
|
if (appList[i].appItem.id == sliceId) {
|
|
selectIndex = sliceId;
|
|
}
|
|
}
|
|
|
|
if (selectIndex == -1) {
|
|
selectIndex = TJD_APP_VIEW_SPORT;
|
|
}
|
|
|
|
if (itemInfo.index == selectIndex) {
|
|
switch_.SetSrc(selectRes_);
|
|
} else {
|
|
switch_.SetSrc(unSelectRes_);
|
|
}
|
|
TjdUiUtils::AutoAlignHorizontalCenter(name_, GetWidth());
|
|
TjdUiUtils::AutoAlignVerticalCenter(name_, GetHeight());
|
|
}
|
|
|
|
bool LeftKeyItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
TjdUiAppSettingModel::GetInstance()->SetLeftKeySetting(itemInfo_.index);
|
|
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
|
while (childView != nullptr) {
|
|
static_cast<LeftKeyItemView *>(childView)->switch_.SetSrc(unSelectRes_);
|
|
childView = childView->GetNextSibling();
|
|
}
|
|
|
|
if (switch_.GetImageInfo()->resId == selectRes_->resId) {
|
|
switch_.SetSrc(unSelectRes_);
|
|
} else {
|
|
switch_.SetSrc(selectRes_);
|
|
}
|
|
switch_.Invalidate();
|
|
return true;
|
|
}
|
|
|
|
AnimationItemView::AnimationItemView(const NormalItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(450, 128);
|
|
SetTouchable(true);
|
|
SetViewIndex(itemInfo.index);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
|
|
icon_.SetPosition(16, 19, 90, 90);
|
|
if (itemInfo.imageInfo != nullptr) {
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
}
|
|
|
|
name_.Resize(220, 54);
|
|
name_.SetPosition(120, (GetHeight() >> 1) - (name_.GetHeight() >> 1));
|
|
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
|
|
Add(&icon_);
|
|
Add(&name_);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_SELECTED, SETTING_IMAGE_BIN_PATH);
|
|
|
|
selectIcon_.SetPosition(348, 45, 72, 38);
|
|
selectIcon_.SetTouchable(false);
|
|
selectIcon_.SetSrc(selectRes_);
|
|
|
|
Add(&selectIcon_);
|
|
}
|
|
|
|
void AnimationItemView::RefreshItem(const NormalItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
name_.SetTextId(itemInfo.name);
|
|
int16_t curAnimation = TjdUiAppSettingModel::GetInstance()->GetAnimation();
|
|
selectIcon_.SetVisible(curAnimation == itemInfo.index);
|
|
TjdUiUtils::AutoAlignHorizontalCenter(name_, GetWidth());
|
|
TjdUiUtils::AutoAlignVerticalCenter(name_, GetHeight());
|
|
}
|
|
|
|
bool AnimationItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
|
while (childView != nullptr) {
|
|
static_cast<AnimationItemView *>(childView)->selectIcon_.SetVisible(false);
|
|
childView = childView->GetNextSibling();
|
|
}
|
|
TjdUiAppSettingModel::GetInstance()->SetAnimation(itemInfo_.index);
|
|
selectIcon_.SetVisible(selectIcon_.IsVisible() == false);
|
|
return true;
|
|
}
|
|
|
|
WatchfaceMainItemView::WatchfaceMainItemView(const NoIconItemInfo &itemInfo)
|
|
{
|
|
Resize(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, 42);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_STRETCH);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
name_.SetHeight(GetHeight());
|
|
name_.SetX(42);
|
|
|
|
Add(&name_);
|
|
}
|
|
|
|
void WatchfaceMainItemView::RefreshItem(const NoIconItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
SetViewIndex(itemInfo.index);
|
|
name_.SetTextId(itemInfo.name);
|
|
}
|
|
|
|
bool WatchfaceMainItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
int16_t viewindex = GetViewIndex();
|
|
TjdUiAppSettingWatchfaceMenuPresenter::GetInstance()->OnClickItemView(itemInfo_.index);
|
|
return true;
|
|
}
|
|
|
|
WatchfaceMenuItemView::WatchfaceMenuItemView(const NormalItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(450, 128);
|
|
SetTouchable(true);
|
|
SetViewIndex(itemInfo.index);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, 64);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
|
|
icon_.SetPosition(16, 19, 90, 90);
|
|
if (itemInfo.imageInfo != nullptr) {
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
}
|
|
|
|
name_.Resize(220, GetHeight());
|
|
name_.SetPosition(120, 0);
|
|
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 40);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
|
|
Add(&icon_);
|
|
Add(&name_);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_SELECTED, SETTING_IMAGE_BIN_PATH);
|
|
|
|
selectIcon_.SetPosition(348, 45, 72, 38);
|
|
selectIcon_.SetTouchable(false);
|
|
selectIcon_.SetSrc(selectRes_);
|
|
|
|
Add(&selectIcon_);
|
|
}
|
|
|
|
void WatchfaceMenuItemView::RefreshItem(const NormalItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
icon_.SetSrc(itemInfo.imageInfo);
|
|
name_.SetTextId(itemInfo.name);
|
|
int16_t curWatchFaceMenuStyle = TjdUiAppSettingModel::GetInstance()->GetWatchFaceMenuStyle();
|
|
selectIcon_.SetVisible(curWatchFaceMenuStyle == itemInfo.index);
|
|
TjdUiUtils::AutoAlignHorizontalCenter(name_, GetWidth());
|
|
TjdUiUtils::AutoAlignVerticalCenter(name_, GetHeight());
|
|
}
|
|
|
|
bool WatchfaceMenuItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
|
while (childView != nullptr) {
|
|
static_cast<WatchfaceMenuItemView *>(childView)->selectIcon_.SetVisible(false);
|
|
childView = childView->GetNextSibling();
|
|
}
|
|
TjdUiAppListModel::GetInstance().SetCurrentStyle(static_cast<E_MenuStyle>(itemInfo_.index));
|
|
selectIcon_.SetVisible(selectIcon_.IsVisible() == false);
|
|
return true;
|
|
}
|
|
|
|
KeepScreenItemView::KeepScreenItemView(const NoIconItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(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, 42);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_STRETCH);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
name_.SetHeight(GetHeight());
|
|
name_.SetX(42);
|
|
|
|
Add(&name_);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_RADIO_ON, SETTING_IMAGE_BIN_PATH);
|
|
unSelectRes_ = images.LoadOneInMultiRes(IMG_SETTING_RADIO_OFF, SETTING_IMAGE_BIN_PATH);
|
|
|
|
selectIcon_.SetPosition(382, 44, 40, 40);
|
|
selectIcon_.SetTouchable(false);
|
|
selectIcon_.SetSrc(selectRes_);
|
|
|
|
Add(&selectIcon_);
|
|
}
|
|
|
|
void KeepScreenItemView::RefreshItem(const NoIconItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
name_.SetTextId(itemInfo.name);
|
|
if (itemInfo_.index * 60 == TjdUiAppSettingModel::GetInstance()->GetKeepScreenTime()) {
|
|
selectIcon_.SetSrc(selectRes_);
|
|
} else {
|
|
selectIcon_.SetSrc(unSelectRes_);
|
|
}
|
|
}
|
|
|
|
bool KeepScreenItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
TjdUiAppSettingModel::GetInstance()->SetKeepScreenSec(itemInfo_.index * 60);
|
|
OHOS::UIView *childView = static_cast<OHOS::UITransformList *>(GetParent())->GetChildrenHead();
|
|
while (childView != nullptr) {
|
|
static_cast<KeepScreenItemView *>(childView)->selectIcon_.SetSrc(unSelectRes_);
|
|
childView = childView->GetNextSibling();
|
|
}
|
|
|
|
if (selectIcon_.GetImageInfo()->resId == selectRes_->resId) {
|
|
selectIcon_.SetSrc(unSelectRes_);
|
|
} else {
|
|
selectIcon_.SetSrc(selectRes_);
|
|
}
|
|
selectIcon_.Invalidate();
|
|
return true;
|
|
}
|
|
|
|
PowerSavingItemView::PowerSavingItemView(const PowerSavingItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(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, 42);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_STRETCH);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
name_.SetHeight(GetHeight());
|
|
name_.SetX(42);
|
|
|
|
Add(&name_);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_OPEN, SETTING_IMAGE_BIN_PATH);
|
|
unSelectRes_ = images.LoadOneInMultiRes(IMG_SETTING_CLOSE, SETTING_IMAGE_BIN_PATH);
|
|
|
|
switch_.SetPosition(346, 45, 72, 38);
|
|
switch_.SetTouchable(false);
|
|
switch_.SetSrc(unSelectRes_);
|
|
|
|
Add(&switch_);
|
|
}
|
|
|
|
void PowerSavingItemView::RefreshItem(const PowerSavingItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
SetViewIndex(itemInfo.index);
|
|
switch_.SetVisible(itemInfo.isSwtich);
|
|
name_.SetTextId(itemInfo.name);
|
|
TjdUiUtils::AutoAlignVerticalCenter(name_, GetHeight());
|
|
}
|
|
|
|
bool PowerSavingItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
if (itemInfo_.index == 0) {
|
|
if (switch_.IsVisible()) {
|
|
if (switch_.GetImageInfo()->resId == selectRes_->resId) {
|
|
// switch_.SetSrc(unSelectRes_);
|
|
} else {
|
|
// switch_.SetSrc(selectRes_);
|
|
TjdUiAppSettingPowerSavingView::GetInstance()->ShowEnterView();
|
|
}
|
|
}
|
|
} else if (itemInfo_.index == 1) {
|
|
TjdUiAppSettingPowerSavingView::GetInstance()->ShowDialogView();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
PasswordItemView::PasswordItemView(const PasswordItemInfo &itemInfo)
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(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, 42);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_STRETCH);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_LEFT, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
name_.SetHeight(GetHeight());
|
|
name_.SetX(42);
|
|
|
|
selectRes_ = images.LoadOneInMultiRes(IMG_SETTING_OPEN, SETTING_IMAGE_BIN_PATH);
|
|
unSelectRes_ = images.LoadOneInMultiRes(IMG_SETTING_CLOSE, SETTING_IMAGE_BIN_PATH);
|
|
|
|
switch_.SetPosition(346, 45, 72, 38);
|
|
switch_.SetTouchable(false);
|
|
switch_.SetSrc(unSelectRes_);
|
|
|
|
Add(&name_);
|
|
Add(&switch_);
|
|
}
|
|
|
|
void PasswordItemView::RefreshItem(const PasswordItemInfo &itemInfo, int16_t index)
|
|
{
|
|
itemInfo_ = itemInfo;
|
|
SetViewIndex(itemInfo.index);
|
|
name_.SetTextId(itemInfo.name);
|
|
switch_.SetVisible(itemInfo.isSwtich);
|
|
if (TjdUiAppSettingModel::GetInstance()->GetPasswordEnable()) {
|
|
switch_.SetSrc(selectRes_);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
name_.SetStyle(OHOS::STYLE_TEXT_OPA, 0xff);
|
|
} else {
|
|
switch_.SetSrc(unSelectRes_);
|
|
if (itemInfo_.index == 1 && itemInfo_.isSwtich == false) {
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0x66202020);
|
|
name_.SetStyle(OHOS::STYLE_TEXT_OPA, 0xff * 0.4);
|
|
} else {
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff202020);
|
|
name_.SetStyle(OHOS::STYLE_TEXT_OPA, 0xff);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool PasswordItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
int16_t viewindex = GetViewIndex();
|
|
bool isOpen = switch_.GetImageInfo()->resId == selectRes_->resId;
|
|
if (isOpen) {
|
|
switch_.SetSrc(unSelectRes_);
|
|
TjdUiAppSettingPasswordPresenter::GetInstance()->OnClickItemView(itemInfo_.index, false);
|
|
} else {
|
|
switch_.SetSrc(selectRes_);
|
|
TjdUiAppSettingPasswordPresenter::GetInstance()->OnClickItemView(itemInfo_.index, true);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace TJD
|