90 lines
2.7 KiB
C++
90 lines
2.7 KiB
C++
#include "TjdUiAppWalletAdapter.h"
|
|
#include "NativeAbility.h"
|
|
#include "TjdUiAppWalletView.h"
|
|
#include "TjdUiMultiLanguageExt.h"
|
|
#include "style.h"
|
|
#include "ui_checkbox.h"
|
|
|
|
namespace TJD {
|
|
|
|
static int16_t HorizontalCenter(int16_t width) { return (OHOS::HORIZONTAL_RESOLUTION - width) / 2; }
|
|
WalletCaseItemView::WalletCaseItemView(WalletCaseInfo &info)
|
|
{
|
|
Resize(450, 110);
|
|
SetStyle(OHOS::STYLE_MARGIN_TOP, 4);
|
|
SetStyle(OHOS::STYLE_MARGIN_BOTTOM, 4);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, 55);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff262626);
|
|
|
|
SetTouchable(true);
|
|
|
|
Add(&icon_);
|
|
Add(&name_);
|
|
Add(&boundIcon_);
|
|
}
|
|
|
|
WalletCaseItemView::~WalletCaseItemView() { RemoveAll(); }
|
|
|
|
bool WalletCaseItemView::OnClickEvent(const OHOS::ClickEvent &event)
|
|
{
|
|
int16_t index_ = GetViewIndex();
|
|
if (index_ == 0 || index_ == 8) {
|
|
return false;
|
|
}
|
|
TjdUiAppWalletView::GetInstance()->ChooseWalletItem(static_cast<WalletItemIndex>(index_));
|
|
return OHOS::UIView::OnClickEvent(event);
|
|
}
|
|
|
|
void WalletCaseItemView::UpdateView(WalletCaseInfo &info)
|
|
{
|
|
SetViewIndex(info.index);
|
|
icon_.SetPosition(16, 12, 84, 84);
|
|
name_.SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
|
name_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
name_.SetText(info.name);
|
|
icon_.SetSrc(info.imgInfo);
|
|
name_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
name_.SetPosition(HorizontalCenter(name_.GetWidth()), 30);
|
|
if (info.type == WalletType::WALLET_TYPE_HIDE) {
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0);
|
|
} else {
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
}
|
|
|
|
boundIcon_.SetPosition(397, 34);
|
|
boundIcon_.SetSrc(info.boundInfo);
|
|
|
|
if (sql_bt_get_qrcode_exist(info.qrcodeType))
|
|
boundIcon_.SetVisible(true);
|
|
else
|
|
boundIcon_.SetVisible(false);
|
|
}
|
|
|
|
TjdUiAppWalletAdapter::~TjdUiAppWalletAdapter() {}
|
|
|
|
OHOS::UIView *TjdUiAppWalletAdapter::GetView(OHOS::UIView *inView, int16_t index)
|
|
{
|
|
OHOS::List<WalletCaseInfo> &settingList_ = TjdUiAppWalletView::GetInstance()->GetWalletItemList();
|
|
if (settingList_.IsEmpty() || index > settingList_.Size() - 1 || index < 0) {
|
|
return nullptr;
|
|
}
|
|
|
|
OHOS::ListNode<WalletCaseInfo> *node = settingList_.Begin();
|
|
for (uint16_t i = 0; i < index; i++) {
|
|
node = node->next_;
|
|
}
|
|
|
|
if (inView == nullptr) {
|
|
itemView_ = new WalletCaseItemView(node->data_);
|
|
} else {
|
|
itemView_ = static_cast<WalletCaseItemView *>(inView);
|
|
}
|
|
|
|
itemView_->UpdateView(node->data_);
|
|
return itemView_;
|
|
}
|
|
|
|
uint16_t TjdUiAppWalletAdapter::GetCount() { return TjdUiAppWalletView::GetInstance()->GetWalletItemList().Size(); }
|
|
|
|
} // namespace TJD
|