ibutton_scene_write_success.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../ibutton_i.h"
  2. static void ibutton_scene_write_success_popup_callback(void* context) {
  3. iButton* ibutton = context;
  4. view_dispatcher_send_custom_event(ibutton->view_dispatcher, iButtonCustomEventBack);
  5. ibutton_notification_message(ibutton, iButtonNotificationMessageGreenOff);
  6. }
  7. void ibutton_scene_write_success_on_enter(void* context) {
  8. iButton* ibutton = context;
  9. Popup* popup = ibutton->popup;
  10. popup_set_icon(popup, 0, 12, &I_iButtonDolphinVerySuccess_108x52);
  11. popup_set_text(popup, "Successfully written!", 40, 12, AlignLeft, AlignBottom);
  12. popup_set_callback(popup, ibutton_scene_write_success_popup_callback);
  13. popup_set_context(popup, ibutton);
  14. popup_set_timeout(popup, 1500);
  15. popup_enable_timeout(popup);
  16. view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
  17. ibutton_notification_message(ibutton, iButtonNotificationMessageSuccess);
  18. ibutton_notification_message(ibutton, iButtonNotificationMessageGreenOn);
  19. }
  20. bool ibutton_scene_write_success_on_event(void* context, SceneManagerEvent event) {
  21. iButton* ibutton = context;
  22. bool consumed = false;
  23. if(event.type == SceneManagerEventTypeCustom) {
  24. consumed = true;
  25. if(event.event == iButtonCustomEventBack) {
  26. const uint32_t possible_scenes[] = {iButtonSceneReadKeyMenu, iButtonSceneStart};
  27. scene_manager_search_and_switch_to_previous_scene_one_of(
  28. ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes));
  29. }
  30. }
  31. return consumed;
  32. }
  33. void ibutton_scene_write_success_on_exit(void* context) {
  34. iButton* ibutton = context;
  35. Popup* popup = ibutton->popup;
  36. popup_reset(popup);
  37. }