lfrfid_app_scene_raw_success.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "lfrfid_app_scene_raw_success.h"
  2. #include "../view/elements/button_element.h"
  3. #include "../view/elements/icon_element.h"
  4. #include "../view/elements/string_element.h"
  5. void LfRfidAppSceneRawSuccess::on_enter(LfRfidApp* app, bool /* need_restore */) {
  6. string_init(string_info);
  7. string_printf(string_info, "RAW RFID read success!\r\n");
  8. string_cat_printf(string_info, "Now you can analyze files\r\n");
  9. string_cat_printf(string_info, "Or send them to developers");
  10. auto container = app->view_controller.get<ContainerVM>();
  11. auto line = container->add<StringElement>();
  12. line->set_text(string_get_cstr(string_info), 0, 1, 0, AlignLeft, AlignTop, FontSecondary);
  13. auto button = container->add<ButtonElement>();
  14. button->set_type(ButtonElement::Type::Center, "OK");
  15. button->set_callback(app, LfRfidAppSceneRawSuccess::ok_callback);
  16. app->view_controller.switch_to<ContainerVM>();
  17. }
  18. bool LfRfidAppSceneRawSuccess::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  19. bool consumed = false;
  20. if(event->type == LfRfidApp::EventType::Next) {
  21. app->scene_controller.search_and_switch_to_previous_scene(
  22. {LfRfidApp::SceneType::ExtraActions});
  23. consumed = true;
  24. }
  25. return consumed;
  26. }
  27. void LfRfidAppSceneRawSuccess::on_exit(LfRfidApp* app) {
  28. app->view_controller.get<ContainerVM>()->clean();
  29. string_clear(string_info);
  30. }
  31. void LfRfidAppSceneRawSuccess::ok_callback(void* context) {
  32. LfRfidApp* app = static_cast<LfRfidApp*>(context);
  33. LfRfidApp::Event event;
  34. event.type = LfRfidApp::EventType::Next;
  35. app->view_controller.send_event(&event);
  36. }