flip_social_callback.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. #ifndef FLIP_SOCIAL_CALLBACK_H
  2. #define FLIP_SOCIAL_CALLBACK_H
  3. #include <flip_social.h>
  4. #include <messages/flip_social_messages.h>
  5. #include <friends/flip_social_friends.h>
  6. #include <explore/flip_social_explore.h>
  7. #include <feed/flip_social_feed.h>
  8. #include <draw/flip_social_draw.h>
  9. #include <flip_storage/flip_social_storage.h>
  10. void flip_social_request_error_draw(Canvas *canvas);
  11. /**
  12. * @brief Navigation callback to go back to the submenu Logged out.
  13. * @param context The context - unused
  14. * @return next view id (FlipSocialViewLoggedOutSubmenu)
  15. */
  16. uint32_t flip_social_callback_to_submenu_logged_out(void *context);
  17. /**
  18. * @brief Navigation callback to go back to the submenu Logged in.
  19. * @param context The context - unused
  20. * @return next view id (FlipSocialViewLoggedInSubmenu)
  21. */
  22. uint32_t flip_social_callback_to_submenu_logged_in(void *context);
  23. /**
  24. * @brief Navigation callback to bring the user back to the (Logged out) Login screen
  25. * @param context The context - unused
  26. * @return next view id (FlipSocialViewLoggedOutLogin)
  27. */
  28. uint32_t flip_social_callback_to_login_logged_out(void *context);
  29. /**
  30. * @brief Navigation callback to bring the user back to the (Logged out) Register screen
  31. * @param context The context - unused
  32. * @return next view id (FlipSocialViewLoggedOutRegister)
  33. */
  34. uint32_t flip_social_callback_to_register_logged_out(void *context);
  35. /**
  36. * @brief Navigation callback to bring the user back to the (Logged out) Wifi Settings screen
  37. * @param context The context - unused
  38. * @return next view id (FlipSocialViewLoggedOutWifiSettings)
  39. */
  40. uint32_t flip_social_callback_to_wifi_settings_logged_out(void *context);
  41. /**
  42. * @brief Navigation callback to bring the user back to the (Logged in) Wifi Settings screen
  43. * @param context The context - unused
  44. * @return next view id (FlipSocialViewLoggedInSettingsWifi)
  45. */
  46. uint32_t flip_social_callback_to_wifi_settings_logged_in(void *context);
  47. /**
  48. * @brief Navigation callback to bring the user back to the (Logged in) Settings screen
  49. * @param context The context - unused
  50. * @return next view id (FlipSocialViewLoggedInSettingsWifi)
  51. */
  52. uint32_t flip_social_callback_to_settings_logged_in(void *context);
  53. /**
  54. * @brief Navigation callback to bring the user back to the (Logged in) Compose screen
  55. * @param context The context - unused
  56. * @return next view id (FlipSocialViewLoggedInCompose)
  57. */
  58. uint32_t flip_social_callback_to_compose_logged_in(void *context);
  59. /**
  60. * @brief Navigation callback to bring the user back to the (Logged in) Profile screen
  61. * @param context The context - unused
  62. * @return next view id (FlipSocialViewLoggedInProfile)
  63. */
  64. uint32_t flip_social_callback_to_profile_logged_in(void *context);
  65. /**
  66. * @brief Navigation callback to bring the user back to the Explore submenu
  67. * @param context The context - unused
  68. * @return next view id (FlipSocialViewLoggedInExploreSubmenu)
  69. */
  70. uint32_t flip_social_callback_to_explore_logged_in(void *context);
  71. /**
  72. * @brief Navigation callback to bring the user back to the Friends submenu
  73. * @param context The context - unused
  74. * @return next view id (FlipSocialViewLoggedInFriendsSubmenu)
  75. */
  76. uint32_t flip_social_callback_to_friends_logged_in(void *context);
  77. /**
  78. * @brief Navigation callback to bring the user back to the Messages submenu
  79. * @param context The context - unused
  80. * @return next view id (FlipSocialViewLoggedInMessagesSubmenu)
  81. */
  82. uint32_t flip_social_callback_to_messages_logged_in(void *context);
  83. /**
  84. * @brief Navigation callback to bring the user back to the User Choices screen
  85. * @param context The context - unused
  86. * @return next view id (FlipSocialViewLoggedInMessagesUserChoices)
  87. */
  88. uint32_t flip_social_callback_to_messages_user_choices(void *context);
  89. /**
  90. * @brief Navigation callback for exiting the application
  91. * @param context The context - unused
  92. * @return next view id (VIEW_NONE to exit the app)
  93. */
  94. uint32_t flip_social_callback_exit_app(void *context);
  95. /**
  96. * @brief Handle ALL submenu item selections.
  97. * @param context The context - FlipSocialApp object.
  98. * @param index The FlipSocialSubmenuIndex item that was clicked.
  99. * @return void
  100. */
  101. void flip_social_callback_submenu_choices(void *context, uint32_t index);
  102. /**
  103. * @brief Text input callback for when the user finishes entering their SSID on the wifi settings (logged out) screen.
  104. * @param context The context - FlipSocialApp object.
  105. * @return void
  106. */
  107. void flip_social_logged_out_wifi_settings_ssid_updated(void *context);
  108. /**
  109. * @brief Text input callback for when the user finishes entering their password on the wifi settings (logged out) screen.
  110. * @param context The context - FlipSocialApp object.
  111. * @return void
  112. */
  113. void flip_social_logged_out_wifi_settings_password_updated(void *context);
  114. /**
  115. * @brief Callback when the user selects a menu item in the wifi settings (logged out) screen.
  116. * @param context The context - FlipSocialApp object.
  117. * @param index The index of the selected item.
  118. * @return void
  119. */
  120. void flip_social_text_input_logged_out_wifi_settings_item_selected(void *context, uint32_t index);
  121. /**
  122. * @brief Text input callback for when the user finishes entering their username on the login (logged out) screen.
  123. * @param context The context - FlipSocialApp object.
  124. * @return void
  125. */
  126. void flip_social_logged_out_login_username_updated(void *context);
  127. /**
  128. * @brief Text input callback for when the user finishes entering their password on the login (logged out) screen.
  129. * @param context The context - FlipSocialApp object.
  130. * @return void
  131. */
  132. void flip_social_logged_out_login_password_updated(void *context);
  133. /**
  134. * @brief Callback when the user selects a menu item in the login (logged out) screen.
  135. * @param context The context - FlipSocialApp object.
  136. * @param index The index of the selected item.
  137. * @return void
  138. */
  139. void flip_social_text_input_logged_out_login_item_selected(void *context, uint32_t index);
  140. /**
  141. * @brief Text input callback for when the user finishes entering their username on the register (logged out) screen.
  142. * @param context The context - FlipSocialApp object.
  143. * @return void
  144. */
  145. void flip_social_logged_out_register_username_updated(void *context);
  146. /**
  147. * @brief Text input callback for when the user finishes entering their password on the register (logged out) screen.
  148. * @param context The context - FlipSocialApp object.
  149. * @return void
  150. */
  151. void flip_social_logged_out_register_password_updated(void *context);
  152. /**
  153. * @brief Text input callback for when the user finishes entering their password 2 on the register (logged out) screen.
  154. * @param context The context - FlipSocialApp object.
  155. * @return void
  156. */
  157. void flip_social_logged_out_register_password_2_updated(void *context);
  158. /**
  159. * @brief Text input callback for when the user finishes entering their SSID on the wifi settings (logged in) screen.
  160. * @param context The context - FlipSocialApp object.
  161. * @return void
  162. */
  163. void flip_social_logged_in_wifi_settings_ssid_updated(void *context);
  164. /**
  165. * @brief Text input callback for when the user finishes entering their password on the wifi settings (logged in) screen.
  166. * @param context The context - FlipSocialApp object.
  167. * @return void
  168. */
  169. void flip_social_logged_in_wifi_settings_password_updated(void *context);
  170. /**
  171. * @brief Callback when the user selects a menu item in the wifi settings (logged in) screen.
  172. * @param context The context - FlipSocialApp object.
  173. * @param index The index of the selected item.
  174. * @return void
  175. */
  176. void flip_social_text_input_logged_in_wifi_settings_item_selected(void *context, uint32_t index);
  177. /**
  178. * @brief Text input callback for when the user finishes entering their message on the compose (logged in) screen for Add Text
  179. * @param context The context - FlipSocialApp object.
  180. * @return void
  181. */
  182. void flip_social_logged_in_compose_pre_save_updated(void *context);
  183. /**
  184. * @brief Text input callback for when the user finishes entering their message on the profile (logged in) screen for change password
  185. * @param context The context - FlipSocialApp object.
  186. * @return void
  187. */
  188. void flip_social_logged_in_profile_change_password_updated(void *context);
  189. /**
  190. * @brief Callback when a user selects a menu item in the profile (logged in) screen.
  191. * @param context The context - FlipSocialApp object.
  192. * @param index The index of the selected item.
  193. * @return void
  194. */
  195. void flip_social_text_input_logged_in_profile_item_selected(void *context, uint32_t index);
  196. /**
  197. * @brief Callback when a user selects a menu item in the settings (logged in) screen.
  198. * @param context The context - FlipSocialApp object.
  199. * @param index The index of the selected item.
  200. * @return void
  201. */
  202. void flip_social_text_input_logged_in_settings_item_selected(void *context, uint32_t index);
  203. /**
  204. * @brief Text input callback for when the user finishes entering their message to send to the selected user choice (user choice messages view)
  205. * @param context The context - FlipSocialApp object.
  206. * @return void
  207. */
  208. void flip_social_logged_in_messages_user_choice_message_updated(void *context);
  209. /**
  210. * @brief Text input callback for when the user finishes entering their message to the selected user (messages view)
  211. * @param context The context - FlipSocialApp object.
  212. * @return void
  213. */
  214. void flip_social_logged_in_messages_new_message_updated(void *context);
  215. /**
  216. * @brief Callback when the user selects a menu item in the register (logged out) screen.
  217. * @param context The context - FlipSocialApp object.
  218. * @param index The index of the selected item.
  219. * @return void
  220. */
  221. void flip_social_text_input_logged_out_register_item_selected(void *context, uint32_t index);
  222. // Add edits by Derek Jamison
  223. typedef enum DataState DataState;
  224. enum DataState
  225. {
  226. DataStateInitial,
  227. DataStateRequested,
  228. DataStateReceived,
  229. DataStateParsed,
  230. DataStateParseError,
  231. DataStateError,
  232. };
  233. typedef enum FlipSocialCustomEvent FlipSocialCustomEvent;
  234. enum FlipSocialCustomEvent
  235. {
  236. FlipSocialCustomEventProcess,
  237. };
  238. typedef struct DataLoaderModel DataLoaderModel;
  239. typedef bool (*DataLoaderFetch)(DataLoaderModel *model);
  240. typedef char *(*DataLoaderParser)(DataLoaderModel *model);
  241. struct DataLoaderModel
  242. {
  243. char *title;
  244. char *data_text;
  245. DataState data_state;
  246. DataLoaderFetch fetcher;
  247. DataLoaderParser parser;
  248. void *parser_context;
  249. size_t request_index;
  250. size_t request_count;
  251. ViewNavigationCallback back_callback;
  252. FuriTimer *timer;
  253. };
  254. void flip_social_generic_switch_to_view(FlipSocialApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id);
  255. void flip_social_loader_draw_callback(Canvas *canvas, void *model);
  256. void flip_social_loader_init(View *view);
  257. void flip_social_loader_free_model(View *view);
  258. bool flip_social_custom_event_callback(void *context, uint32_t index);
  259. bool messages_dialog_alloc(bool free_first);
  260. #endif