nfc_scene_save_success.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <nfc/scenes/nfc_scene_save_success.h>
  2. #include <furi.h>
  3. #include "../nfc_i.h"
  4. #define SCENE_SAVE_SUCCESS_CUSTOM_EVENT (0UL)
  5. void nfc_scene_save_success_popup_callback(void* context) {
  6. Nfc* nfc = (Nfc*)context;
  7. view_dispatcher_send_custom_event(
  8. nfc->nfc_common.view_dispatcher, SCENE_SAVE_SUCCESS_CUSTOM_EVENT);
  9. }
  10. const void nfc_scene_save_success_on_enter(void* context) {
  11. Nfc* nfc = (Nfc*)context;
  12. // Setup view
  13. Popup* popup = nfc->popup;
  14. popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
  15. popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
  16. popup_set_timeout(popup, 1500);
  17. popup_set_context(popup, nfc);
  18. popup_set_callback(popup, nfc_scene_save_success_popup_callback);
  19. popup_enable_timeout(popup);
  20. view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewPopup);
  21. }
  22. const bool nfc_scene_save_success_on_event(void* context, uint32_t event) {
  23. Nfc* nfc = (Nfc*)context;
  24. if(event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
  25. view_dispatcher_send_back_search_scene_event(
  26. nfc->nfc_common.view_dispatcher, NfcSceneStart);
  27. return true;
  28. }
  29. return false;
  30. }
  31. const void nfc_scene_save_success_on_exit(void* context) {
  32. Nfc* nfc = (Nfc*)context;
  33. // Clear view
  34. Popup* popup = nfc->popup;
  35. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  36. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  37. popup_set_icon(popup, 0, 0, NULL);
  38. popup_set_callback(popup, NULL);
  39. popup_set_context(popup, NULL);
  40. popup_set_timeout(popup, 0);
  41. popup_disable_timeout(popup);
  42. }
  43. AppScene* nfc_scene_save_success_alloc() {
  44. AppScene* scene = furi_alloc(sizeof(AppScene));
  45. scene->id = NfcSceneSaveSuccess;
  46. scene->on_enter = nfc_scene_save_success_on_enter;
  47. scene->on_event = nfc_scene_save_success_on_event;
  48. scene->on_exit = nfc_scene_save_success_on_exit;
  49. return scene;
  50. }
  51. void nfc_scene_save_success_free(AppScene* scene) {
  52. free(scene);
  53. }