From: Caisking <3449750381@qq.com> Date: Wed, 11 Sep 2024 10:29:19 +0000 (+0800) Subject: #389密码-最后一个数字没有动画效果 X-Git-Tag: release_V1.2.70_20241020_135402~485^2~5^2~21 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=117f08d7c86f170f2e45affbaf453f936957140c;p=mirrors%2FFD230.git #389密码-最后一个数字没有动画效果 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h b/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h index 995b85ccd..ff260ae41 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h @@ -37,6 +37,8 @@ namespace OHOS void ResetLockState(); // 获取已经点击个数 uint8_t GetPointNum(); + //配置已经点击的个数 + void SetPointNum(uint8_t num); // 配置用户密码 void SetUserPassWord(const std::string &password); // ble进行解锁 diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp index 40175f14a..dca516bdf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp @@ -66,9 +66,13 @@ namespace OHOS passcount++; inputpassword_ += std::to_string(num); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目前inputpassword_: %s", inputpassword_.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目前inputpassword_: %s %d ", inputpassword_.c_str(),passcount); - // 检查当前输入密码的长度 + /* + 检查当前输入密码的长度 等于6个 会进行清除 + 但是不设置passcount==0 + 我需要传一个6过去显示 然后过一秒再配置0 + */ if (passcount >= PASSWORDNUM) { if (IsPasswordMatch()) @@ -81,7 +85,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "密码不匹配,已清空输入"); } - passcount = 0; // 重置输入计数 + // passcount = 0; // 重置输入计数 ClearPassword(); // 清空输入密码 } } @@ -126,6 +130,15 @@ namespace OHOS return passcount; } + /** + * @brief 设置当前输入的数字个数 + * @param uint8_t 当前输入的数字个数 + */ + void CodedLockModel::SetPointNum(uint8_t num) + { + passcount = num; + } + // ================== 输入密码管理 ================== /** diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp index ed91c90b3..e123d3dfc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp @@ -64,29 +64,36 @@ namespace OHOS { Presenter::OnStop(); } - void CodedLockPresenter::JudgeMatch() - { - /*进行现状密码打印*/ - // CodedLockModel::GetInstance()->GetInputPassword(); - // CodedLockModel::GetInstance()->GetPassword(); - - /*每次点击完成 更新 点击图片*/ - int num = CodedLockModel::GetInstance()->GetPointNum(); - CodedLockView::GetInstance()->UpdatePointShow(num); - - /*每次点击完成判断 是否 完成密码匹配*/ - if (CodedLockModel::GetInstance()->IsLockState()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "回到主界面"); - /*关锁*/ - uapi_dev_runtime_set_lock_status(0); - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - /*设置表盘状态*/ - MainModel::GetInstance().setDialState(DialState::LOCK, false); - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JudgeMatch is Ok"); - } + void CodedLockPresenter::JudgeMatch() + { + const int REQUIRED_POINTS = 6; + int num = CodedLockModel::GetInstance()->GetPointNum(); + CodedLockView::GetInstance()->UpdatePointShow(num); + + if (num == REQUIRED_POINTS) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "num is 6, sleeping for 1s"); + CodedLockModel::GetInstance()->SetPointNum(0); + + if (CodedLockModel::GetInstance()->IsLockState()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Returning to main interface"); + //解锁 + uapi_dev_runtime_set_lock_status(0); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + //恢复表盘状态 + MainModel::GetInstance().setDialState(DialState::LOCK, false); + } + else + { + CodedLockView::GetInstance()->UpdatePointShow(0); + } + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JudgeMatch is Ok"); + } + bool CodedLockPresenter::OnClick(UIView &view, const ClickEvent &event) { if (strcmp(view.GetViewId(), LOCK_BUTTON_ONE) == 0) diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp index 92f2f54dc..84f23c01d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp @@ -2,288 +2,283 @@ * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-08-09 14:41:32 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockView.cpp */ #include "codedlock/include/CodedLockView.h" #include "codedlock/include/CodedLockPresenter.h" -#include "common/image_cache_manager.h" #include "UiConfig.h" -#include "ui_resource_image.h" +#include "common/image_cache_manager.h" #include "components/ui_button.h" -#include "uicomponents/UIComponents.h" -#include "ui_resource_string.h" #include "components/ui_scroll_view.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" +#include "uicomponents/UIComponents.h" -namespace OHOS -{ +namespace OHOS { - static CodedLockView *g_pCodedLockView{nullptr}; +static CodedLockView *g_pCodedLockView{nullptr}; - static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; +static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; - // 定义默认颜色和激活颜色 - static const uint32_t activeColor = 0xffaaaaaa; - static const uint32_t defaultColor = 0xff191919; +// 定义默认颜色和激活颜色 +static const uint32_t activeColor = 0xffaaaaaa; +static const uint32_t defaultColor = 0xff191919; #define UI_IMAGE_TEST 1 - CodedLockView::CodedLockView() - { - g_pCodedLockView = this; - } +CodedLockView::CodedLockView() { g_pCodedLockView = this; } - CodedLockView::~CodedLockView() - { - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); - g_pCodedLockView = nullptr; - } +CodedLockView::~CodedLockView() { + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + g_pCodedLockView = nullptr; +} - CodedLockView *CodedLockView::GetInstance() - { - return g_pCodedLockView; - } +CodedLockView *CodedLockView::GetInstance() { return g_pCodedLockView; } - void CodedLockView::InitButtonsView() - { - // 第一行 - InitLabelButton(button_one, 30, 90, 130, 88, LOCK_BUTTON_ONE, "1", 40); - button_one->SetOnClickListener(presenter_); - container_->Add(button_one); - - InitLabelButton(button_two, 168, 90, 130, 88, LOCK_BUTTON_TWO, "2", 40); - button_two->SetOnClickListener(presenter_); - container_->Add(button_two); - - InitLabelButton(button_three, 305, 90, 130, 88, LOCK_BUTTON_THREE, "3", 40); - button_three->SetOnClickListener(presenter_); - container_->Add(button_three); - - // 第二行 - InitLabelButton(button_four, 30, 185, 130, 88, LOCK_BUTTON_FOUR, "4", 40); - button_four->SetOnClickListener(presenter_); - container_->Add(button_four); - - InitLabelButton(button_five, 168, 185, 130, 88, LOCK_BUTTON_FIVE, "5", 40); - button_five->SetOnClickListener(presenter_); - container_->Add(button_five); - - InitLabelButton(button_six, 305, 185, 130, 88, LOCK_BUTTON_SIX, "6", 40); - button_six->SetOnClickListener(presenter_); - container_->Add(button_six); - - // 第三行 - InitLabelButton(button_seven, 30, 280, 130, 88, LOCK_BUTTON_SEVEN, "7", 40); - button_seven->SetOnClickListener(presenter_); - container_->Add(button_seven); - - InitLabelButton(button_eight, 168, 280, 130, 88, LOCK_BUTTON_EIGHT, "8", 40); - button_eight->SetOnClickListener(presenter_); - container_->Add(button_eight); - - InitLabelButton(button_nine, 305, 280, 130, 88, LOCK_BUTTON_NINE, "9", 40); - button_nine->SetOnClickListener(presenter_); - container_->Add(button_nine); - - // 第四行 (0) - InitLabelButton(button_zero, 168, 375, 130, 88, LOCK_BUTTON_ZERO, "0", 40); - button_zero->SetOnClickListener(presenter_); - container_->Add(button_zero); - - // InitLabelButton(button_delete, 230, 390, 130, 88, LOCK_BUTTON_DELETE, " ", 40); - // button_delete->SetOnClickListener(presenter_); - // container_->Add(button_delete); - } - void CodedLockView::InitImagesView() - { - std::vector points = { - {&point_one, 140, 55, "image1", defaultColor, 0xff, 100}, - {&point_two, 175, 55, "image1", defaultColor, 0xff, 100}, - {&point_three, 210, 55, "image1", defaultColor, 0xff, 100}, - {&point_four, 245, 55, "image1", defaultColor, 0xff, 100}, - {&point_five, 280, 55, "image1", defaultColor, 0xff, 100}, - {&point_six, 310, 55, "image1", defaultColor, 0xff, 100}, - }; - - for (const auto &config : points) - { - InitializePoint(config.imageView, config.x, config.y, (config.viewId).c_str(), config.backgroundColor, config.backgroundOpa, config.borderRadius); - } - } +void CodedLockView::InitButtonsView() { + // 第一行 + InitLabelButton(button_one, 30, 90, 130, 88, LOCK_BUTTON_ONE, "1", 40); + button_one->SetOnClickListener(presenter_); + container_->Add(button_one); - void CodedLockView::InitializePoint(UIImageView **imageView, int x, int y, const char *viewId, uint32_t backgroundColor, uint8_t backgroundOpa, int borderRadius) - { - if (*imageView == nullptr) - { - *imageView = new UIImageView(); - } - - (*imageView)->SetPosition(x, y); - (*imageView)->Resize(20, 20); - (*imageView)->SetViewId(viewId); - (*imageView)->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - (*imageView)->SetStyle(STYLE_BACKGROUND_OPA, backgroundOpa); - (*imageView)->SetStyle(STYLE_BORDER_RADIUS, borderRadius); - - container_->Add(*imageView); - } - void CodedLockView::UpdatePointShow(int num) - { + InitLabelButton(button_two, 168, 90, 130, 88, LOCK_BUTTON_TWO, "2", 40); + button_two->SetOnClickListener(presenter_); + container_->Add(button_two); + + InitLabelButton(button_three, 305, 90, 130, 88, LOCK_BUTTON_THREE, "3", 40); + button_three->SetOnClickListener(presenter_); + container_->Add(button_three); + + // 第二行 + InitLabelButton(button_four, 30, 185, 130, 88, LOCK_BUTTON_FOUR, "4", 40); + button_four->SetOnClickListener(presenter_); + container_->Add(button_four); + + InitLabelButton(button_five, 168, 185, 130, 88, LOCK_BUTTON_FIVE, "5", 40); + button_five->SetOnClickListener(presenter_); + container_->Add(button_five); + + InitLabelButton(button_six, 305, 185, 130, 88, LOCK_BUTTON_SIX, "6", 40); + button_six->SetOnClickListener(presenter_); + container_->Add(button_six); + + // 第三行 + InitLabelButton(button_seven, 30, 280, 130, 88, LOCK_BUTTON_SEVEN, "7", 40); + button_seven->SetOnClickListener(presenter_); + container_->Add(button_seven); + + InitLabelButton(button_eight, 168, 280, 130, 88, LOCK_BUTTON_EIGHT, "8", 40); + button_eight->SetOnClickListener(presenter_); + container_->Add(button_eight); - if (point_one == nullptr || point_two == nullptr || point_three == nullptr || - point_four == nullptr || point_five == nullptr || point_six == nullptr) - return; + InitLabelButton(button_nine, 305, 280, 130, 88, LOCK_BUTTON_NINE, "9", 40); + button_nine->SetOnClickListener(presenter_); + container_->Add(button_nine); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdatePointShow Num %d", num); + // 第四行 (0) + InitLabelButton(button_zero, 168, 375, 130, 88, LOCK_BUTTON_ZERO, "0", 40); + button_zero->SetOnClickListener(presenter_); + container_->Add(button_zero); + + // InitLabelButton(button_delete, 230, 390, 130, 88, LOCK_BUTTON_DELETE, " ", + // 40); button_delete->SetOnClickListener(presenter_); + // container_->Add(button_delete); +} +void CodedLockView::InitImagesView() { + std::vector points = { + {&point_one, 140, 55, "image1", defaultColor, 0xff, 100}, + {&point_two, 175, 55, "image1", defaultColor, 0xff, 100}, + {&point_three, 210, 55, "image1", defaultColor, 0xff, 100}, + {&point_four, 245, 55, "image1", defaultColor, 0xff, 100}, + {&point_five, 280, 55, "image1", defaultColor, 0xff, 100}, + {&point_six, 310, 55, "image1", defaultColor, 0xff, 100}, + }; + + for (const auto &config : points) { + InitializePoint(config.imageView, config.x, config.y, + (config.viewId).c_str(), config.backgroundColor, + config.backgroundOpa, config.borderRadius); + } +} + +void CodedLockView::InitializePoint(UIImageView **imageView, int x, int y, + const char *viewId, + uint32_t backgroundColor, + uint8_t backgroundOpa, int borderRadius) { + if (*imageView == nullptr) { + *imageView = new UIImageView(); + } + + (*imageView)->SetPosition(x, y); + (*imageView)->Resize(20, 20); + (*imageView)->SetViewId(viewId); + (*imageView)->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); + (*imageView)->SetStyle(STYLE_BACKGROUND_OPA, backgroundOpa); + (*imageView)->SetStyle(STYLE_BORDER_RADIUS, borderRadius); + + container_->Add(*imageView); +} +void CodedLockView::UpdatePointShow(int num) { + + if (point_one == nullptr || point_two == nullptr || point_three == nullptr || + point_four == nullptr || point_five == nullptr || point_six == nullptr) + return; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdatePointShow Num %d", num); #if UI_IMAGE_TEST - switch (num) - { - case 0: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - break; - case 1: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 2: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 3: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 4: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 5: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - case 6: - point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - point_six->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - break; - default: - break; - } + switch (num) { + case 0: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 1: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 2: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 3: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 4: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 5: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + break; + case 6: + point_one->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_two->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_three->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_four->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_five->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + point_six->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + break; + default: + break; + } #else - // 更新所有点的颜色 - for (int i = 1; i <= 6; ++i) - { - UIImageView *point = nullptr; - switch (i) - { - case 1: - point = point_one; - break; - case 2: - point = point_two; - break; - case 3: - point = point_three; - break; - case 4: - point = point_four; - break; - case 5: - point = point_five; - break; - case 6: - point = point_six; - break; - default: - continue; - } - - if (point != nullptr) - { - if (i <= num) - { - // 如果是前 num 个点,则设置为激活颜色 - point->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); - } - else - { - // 其他点设置为默认颜色 - point->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); - } - } - } -#endif - /*ui刷新*/ - point_one->Invalidate(); - point_two->Invalidate(); - point_three->Invalidate(); - point_four->Invalidate(); - point_five->Invalidate(); - point_six->Invalidate(); + // 更新所有点的颜色 + for (int i = 1; i <= 6; ++i) { + UIImageView *point = nullptr; + switch (i) { + case 1: + point = point_one; + break; + case 2: + point = point_two; + break; + case 3: + point = point_three; + break; + case 4: + point = point_four; + break; + case 5: + point = point_five; + break; + case 6: + point = point_six; + break; + default: + continue; } - void CodedLockView::OnStart() - { - View::OnStart(); - - container_ = new UIScrollView(); - if (container_ == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail"); - return; - } - container_->SetScrollBlankSize(35); - container_->SetReboundSize(50); - container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - - container_->SetTouchable(false); - container_->SetDraggable(false); - container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); - container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - - InitButtonsView(); - InitImagesView(); - - SetContainerView(container_); + if (point != nullptr) { + if (i <= num) { + // 如果是前 num 个点,则设置为激活颜色 + point->SetStyle(STYLE_BACKGROUND_COLOR, activeColor); + } else { + // 其他点设置为默认颜色 + point->SetStyle(STYLE_BACKGROUND_COLOR, defaultColor); + } } + } +#endif + /*ui刷新*/ + point_one->Invalidate(); + point_two->Invalidate(); + point_three->Invalidate(); + point_four->Invalidate(); + point_five->Invalidate(); + point_six->Invalidate(); +} - void CodedLockView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } +void CodedLockView::OnStart() { + View::OnStart(); - void CodedLockView::OnTearDownView() - { - View::OnTearDownView(); - return; - } + container_ = new UIScrollView(); + if (container_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail"); + return; + } + container_->SetScrollBlankSize(35); + container_->SetReboundSize(50); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); - void CodedLockView::OnStop() - { - View::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - RootView::GetInstance()->RemoveAll(); - return; - } + container_->SetTouchable(false); + container_->SetDraggable(false); + container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); + container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + + InitButtonsView(); + InitImagesView(); + + SetContainerView(container_); +} + +void CodedLockView::OnSetUpView() { + View::OnSetUpView(); + Draw(); +} + +void CodedLockView::OnTearDownView() { + View::OnTearDownView(); + return; +} + +void CodedLockView::OnStop() { + View::OnStop(); + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->RemoveAll(); + return; } +} // namespace OHOS