lfrfid_app_scene_write_success.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "lfrfid_app_scene_write_success.h"
  2. void LfRfidAppSceneWriteSuccess::on_enter(LfRfidApp* app, bool need_restore) {
  3. auto popup = app->view_controller.get<PopupVM>();
  4. popup->set_header("Successfully\nwritten!", 94, 3, AlignCenter, AlignTop);
  5. popup->set_icon(0, 6, &I_RFIDDolphinSuccess_108x57);
  6. popup->set_context(app);
  7. popup->set_callback(LfRfidAppSceneWriteSuccess::timeout_callback);
  8. popup->set_timeout(1500);
  9. popup->enable_timeout();
  10. app->view_controller.switch_to<PopupVM>();
  11. notification_message_block(app->notification, &sequence_set_green_255);
  12. }
  13. bool LfRfidAppSceneWriteSuccess::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  14. bool consumed = false;
  15. if(event->type == LfRfidApp::EventType::Back) {
  16. app->scene_controller.search_and_switch_to_previous_scene(
  17. {LfRfidApp::SceneType::ReadKeyMenu, LfRfidApp::SceneType::SelectKey});
  18. consumed = true;
  19. }
  20. return consumed;
  21. }
  22. void LfRfidAppSceneWriteSuccess::on_exit(LfRfidApp* app) {
  23. notification_message_block(app->notification, &sequence_reset_green);
  24. app->view_controller.get<PopupVM>()->clean();
  25. }
  26. void LfRfidAppSceneWriteSuccess::timeout_callback(void* context) {
  27. LfRfidApp* app = static_cast<LfRfidApp*>(context);
  28. LfRfidApp::Event event;
  29. event.type = LfRfidApp::EventType::Back;
  30. app->view_controller.send_event(&event);
  31. }