gpio_scene_usb_uart_close_rpc.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../gpio_app_i.h"
  2. #include "../gpio_custom_event.h"
  3. static void gpio_scene_usb_uart_close_rpc_event_callback(
  4. GuiButtonType result,
  5. InputType type,
  6. void* context) {
  7. furi_assert(context);
  8. GpioApp* app = context;
  9. if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
  10. view_dispatcher_send_custom_event(app->view_dispatcher, GpioCustomEventErrorBack);
  11. }
  12. }
  13. void gpio_scene_usb_uart_close_rpc_on_enter(void* context) {
  14. GpioApp* app = context;
  15. widget_add_string_multiline_element(
  16. app->widget,
  17. 63,
  18. 10,
  19. AlignCenter,
  20. AlignTop,
  21. FontSecondary,
  22. "Disconnect from\ncompanion app\nto use this function");
  23. widget_add_button_element(
  24. app->widget, GuiButtonTypeLeft, "Back", gpio_scene_usb_uart_close_rpc_event_callback, app);
  25. view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewUsbUartCloseRpc);
  26. }
  27. bool gpio_scene_usb_uart_close_rpc_on_event(void* context, SceneManagerEvent event) {
  28. GpioApp* app = context;
  29. bool consumed = false;
  30. if(event.type == SceneManagerEventTypeCustom) {
  31. if(event.event == GpioCustomEventErrorBack) {
  32. if(!scene_manager_previous_scene(app->scene_manager)) {
  33. scene_manager_stop(app->scene_manager);
  34. view_dispatcher_stop(app->view_dispatcher);
  35. }
  36. consumed = true;
  37. }
  38. }
  39. return consumed;
  40. }
  41. void gpio_scene_usb_uart_close_rpc_on_exit(void* context) {
  42. GpioApp* app = context;
  43. widget_reset(app->widget);
  44. }