scene_success.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "app_i.h"
  2. #include <furi.h>
  3. #include <notification/notification_messages.h>
  4. #include "custom_event.h"
  5. #include "video_game_module_tool_icons.h"
  6. static void
  7. scene_success_button_callback(GuiButtonType button_type, InputType input_type, void* context) {
  8. App* app = context;
  9. if(input_type == InputTypeShort && button_type == GuiButtonTypeCenter) {
  10. view_dispatcher_send_custom_event(app->view_dispatcher, CustomEventSuccessDismissed);
  11. }
  12. }
  13. void scene_success_on_enter(void* context) {
  14. App* app = context;
  15. widget_add_icon_element(app->widget, 11, 24, &I_Module_60x26);
  16. widget_add_icon_element(app->widget, 77, 10, &I_Checkmark_44x40);
  17. widget_add_button_element(
  18. app->widget, GuiButtonTypeCenter, "OK", scene_success_button_callback, app);
  19. widget_add_string_multiline_element(
  20. app->widget, 64, 0, AlignCenter, AlignTop, FontPrimary, "Video Game Module\nUpdated");
  21. view_dispatcher_switch_to_view(app->view_dispatcher, ViewIdWidget);
  22. notification_message(app->notification, &sequence_success);
  23. notification_message(app->notification, &sequence_set_green_255);
  24. }
  25. bool scene_success_on_event(void* context, SceneManagerEvent event) {
  26. App* app = context;
  27. bool consumed = false;
  28. if(event.type == SceneManagerEventTypeCustom) {
  29. if(event.event == CustomEventSuccessDismissed) {
  30. scene_manager_search_and_switch_to_previous_scene(app->scene_manager, SceneProbe);
  31. }
  32. consumed = true;
  33. } else if(event.type == SceneManagerEventTypeBack) {
  34. consumed = true;
  35. }
  36. return consumed;
  37. }
  38. void scene_success_on_exit(void* context) {
  39. App* app = context;
  40. widget_reset(app->widget);
  41. furi_string_reset(app->file_path);
  42. notification_message(app->notification, &sequence_reset_green);
  43. }