xremote_app.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*!
  2. * @file flipper-xremote/xremote_app.h
  3. @license This project is released under the GNU GPLv3 License
  4. * @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  5. *
  6. * @brief Shared functionality and data types between the apps.
  7. */
  8. #pragma once
  9. #include <furi.h>
  10. #include <gui/gui.h>
  11. #include <gui/view.h>
  12. #include <gui/view_dispatcher.h>
  13. #include <gui/modules/submenu.h>
  14. #include <gui/modules/dialog_ex.h>
  15. #include <notification/notification.h>
  16. #include <notification/notification_messages.h>
  17. #include <storage/storage.h>
  18. #include <dialogs/dialogs.h>
  19. #include "views/xremote_common_view.h"
  20. #include "xc_icons.h"
  21. #define xremote_app_assert_void(cond) if (!cond) return
  22. #define xremote_app_assert(cond, var) if (!cond) return var
  23. typedef struct {
  24. NotificationApp* notifications;
  25. ViewDispatcher* view_dispatcher;
  26. Gui* gui;
  27. void* arg;
  28. } XRemoteAppContext;
  29. XRemoteAppContext* xremote_app_context_alloc(void* arg);
  30. void xremote_app_context_free(XRemoteAppContext* ctx);
  31. typedef XRemoteView* (*XRemoteViewAllocator)(NotificationApp* notifications);
  32. typedef void (*XRemoteAppClearCallback)(void *context);
  33. typedef struct {
  34. XRemoteAppClearCallback on_clear;
  35. XRemoteAppContext* app_ctx;
  36. XRemoteViewID submenu_id;
  37. XRemoteViewID view_id;
  38. XRemoteView* view_ctx;
  39. Submenu* submenu;
  40. void *context;
  41. } XRemoteApp;
  42. void xremote_app_submenu_add(XRemoteApp* app, const char *name, uint32_t index, SubmenuItemCallback callback);
  43. void xremote_app_submenu_alloc(XRemoteApp* app, uint32_t index, ViewNavigationCallback prev_cb);
  44. void xremote_app_submenu_free(XRemoteApp *app);
  45. void xremote_app_view_alloc(XRemoteApp *app, uint32_t view_id, XRemoteViewAllocator allocator);
  46. void xremote_app_view_free(XRemoteApp* app);
  47. void xremote_app_view_set_previous_callback(XRemoteApp* app, ViewNavigationCallback callback);
  48. void xremote_app_set_view_context(XRemoteApp* app, void *context, XRemoteViewClearCallback on_clear);
  49. void xremote_app_set_user_context(XRemoteApp* app, void *context, XRemoteAppClearCallback on_clear);
  50. void xremote_app_user_context_free(XRemoteApp* app);
  51. bool xremote_app_has_view(XRemoteApp *app, uint32_t view_id);
  52. void xremote_app_switch_to_view(XRemoteApp *app, uint32_t view_id);
  53. void xremote_app_switch_to_submenu(XRemoteApp *app);
  54. XRemoteApp* xremote_app_alloc(XRemoteAppContext *ctx);
  55. void xremote_app_free(XRemoteApp* app);