nfc_magic_scene_success.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "../nfc_magic_app_i.h"
  2. void nfc_magic_scene_success_popup_callback(void* context) {
  3. NfcMagicApp* instance = context;
  4. view_dispatcher_send_custom_event(instance->view_dispatcher, NfcMagicAppCustomEventViewExit);
  5. }
  6. void nfc_magic_scene_success_on_enter(void* context) {
  7. NfcMagicApp* instance = context;
  8. notification_message(instance->notifications, &sequence_success);
  9. Popup* popup = instance->popup;
  10. popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
  11. popup_set_header(popup, "Success!", 10, 20, AlignLeft, AlignBottom);
  12. popup_set_timeout(popup, 1500);
  13. popup_set_context(popup, instance);
  14. popup_set_callback(popup, nfc_magic_scene_success_popup_callback);
  15. popup_enable_timeout(popup);
  16. view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewPopup);
  17. }
  18. bool nfc_magic_scene_success_on_event(void* context, SceneManagerEvent event) {
  19. NfcMagicApp* instance = context;
  20. bool consumed = false;
  21. if(event.type == SceneManagerEventTypeCustom) {
  22. if(event.event == NfcMagicAppCustomEventViewExit) {
  23. consumed = scene_manager_search_and_switch_to_previous_scene(
  24. instance->scene_manager, NfcMagicSceneStart);
  25. }
  26. }
  27. return consumed;
  28. }
  29. void nfc_magic_scene_success_on_exit(void* context) {
  30. NfcMagicApp* instance = context;
  31. // Clear view
  32. popup_reset(instance->popup);
  33. }