nfc_scene_dict_not_found.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "../nfc_i.h"
  2. void nfc_scene_dict_not_found_popup_callback(void* context) {
  3. Nfc* nfc = context;
  4. view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
  5. }
  6. void nfc_scene_dict_not_found_on_enter(void* context) {
  7. Nfc* nfc = context;
  8. // Setup view
  9. Popup* popup = nfc->popup;
  10. popup_set_text(
  11. popup,
  12. "Function requires\nan SD card with\nfresh databases.",
  13. 82,
  14. 24,
  15. AlignCenter,
  16. AlignCenter);
  17. popup_set_icon(popup, 6, 10, &I_SDQuestion_35x43);
  18. popup_set_timeout(popup, 2500);
  19. popup_set_context(popup, nfc);
  20. popup_set_callback(popup, nfc_scene_dict_not_found_popup_callback);
  21. popup_enable_timeout(popup);
  22. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  23. }
  24. bool nfc_scene_dict_not_found_on_event(void* context, SceneManagerEvent event) {
  25. Nfc* nfc = context;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. if(event.event == NfcCustomEventViewExit) {
  29. if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneScriptsMenu)) {
  30. consumed = scene_manager_search_and_switch_to_previous_scene(
  31. nfc->scene_manager, NfcSceneScriptsMenu);
  32. } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneCardMenu)) {
  33. consumed = scene_manager_search_and_switch_to_previous_scene(
  34. nfc->scene_manager, NfcSceneCardMenu);
  35. } else {
  36. consumed = scene_manager_search_and_switch_to_previous_scene(
  37. nfc->scene_manager, NfcSceneStart);
  38. }
  39. }
  40. }
  41. return consumed;
  42. }
  43. void nfc_scene_dict_not_found_on_exit(void* context) {
  44. Nfc* nfc = context;
  45. popup_reset(nfc->popup);
  46. }