flip_social_e.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. // flip_social_e.h
  2. #ifndef FLIP_SOCIAL_E
  3. #define FLIP_SOCIAL_E
  4. #include <furi.h>
  5. #include <furi_hal.h>
  6. #include <gui/gui.h>
  7. #include <gui/icon_i.h>
  8. #include <gui/view.h>
  9. #include <gui/view_dispatcher.h>
  10. #include <gui/modules/submenu.h>
  11. #include <gui/modules/widget.h>
  12. #include <gui/modules/text_input.h>
  13. #include <gui/modules/text_box.h>
  14. #include <gui/modules/variable_item_list.h>
  15. #include <malloc.h>
  16. #include <dialogs/dialogs.h>
  17. #include <storage/storage.h>
  18. #include <flipper_http.h>
  19. #include <input/input.h>
  20. #include <flip_social_icons.h> // add <(YOUR-APP)_icons.h> so the compiler treats the .pngs are icons
  21. #define TAG "FlipSocial"
  22. #define MAX_PRE_SAVED_MESSAGES 25 // Maximum number of pre-saved messages
  23. #define MAX_MESSAGE_LENGTH 100 // Maximum length of a message in the feed
  24. // Define the submenu items for our Hello World application
  25. typedef enum
  26. {
  27. FlipSocialSubmenuLoggedOutIndexLogin, // click to go to the login screen
  28. FlipSocialSubmenuLoggedOutIndexRegister, // click to go to the register screen
  29. FlipSocialSubmenuLoggedOutIndexAbout, // click to go to the about screen
  30. FlipSocialSubmenuLoggedOutIndexWifiSettings, // click to go to the wifi settings screen
  31. //
  32. FlipSocialSubmenuLoggedInIndexProfile, // click to go to the profile screen
  33. FlipSocialSubmenuLoggedInIndexFeed, // click to go to the feed screen
  34. FlipSocialSubmenuLoggedInIndexCompose, // click to go to the compose screen
  35. FlipSocialSubmenuLoggedInIndexSettings, // click to go to the settings screen
  36. FlipSocialSubmenuLoggedInSignOutButton, // click to sign out
  37. //
  38. FlipSocialSubmenuComposeIndexAddPreSave, // click to add a pre-saved message
  39. FlipSocialSubemnuComposeIndexStartIndex = 99, // starting index for the first pre saved message
  40. } FlipSocialSubmenuIndex;
  41. typedef enum
  42. {
  43. ActionNone,
  44. ActionBack,
  45. ActionNext,
  46. ActionPrev,
  47. ActionFlip,
  48. } Action;
  49. Action action = ActionNone;
  50. // Define the ScriptPlaylist structure
  51. typedef struct
  52. {
  53. char *messages[MAX_PRE_SAVED_MESSAGES];
  54. size_t count;
  55. } PreSavedPlaylist;
  56. // Define views for our Hello World application
  57. typedef enum
  58. {
  59. FlipSocialViewLoggedOutSubmenu, // The menu if the user is not logged in
  60. FlipSocialViewLoggedOutLogin, // The login screen
  61. FlipSocialViewLoggedOutRegister, // The register screen
  62. FlipSocialViewLoggedOutAbout, // The about screen
  63. FlipSocialViewLoggedOutWifiSettings, // The wifi settings screen
  64. //
  65. FlipSocialViewLoggedOutLoginUsernameInput, // Text input screen for username input on login screen
  66. FlipSocialViewLoggedOutLoginPasswordInput, // Text input screen for password input on login screen
  67. FlipSocialViewLoggedOutRegisterUsernameInput, // Text input screen for username input on register screen
  68. FlipSocialViewLoggedOutRegisterPasswordInput, // Text input screen for password input on register screen
  69. FlipSocialViewLoggedOutRegisterPassword2Input, // Text input screen for password 2 input on register screen
  70. FlipSocialViewLoggedOutWifiSettingsSSIDInput, // Text input screen for SSID input on wifi screen
  71. FlipSocialViewLoggedOutWifiSettingsPasswordInput, // Text input screen for Password input on wifi screen
  72. FlipSocialViewLoggedOutProcessLogin, // The screen displayed after clicking login
  73. FlipSocialViewLoggedOutProcessRegister, // The screen displayed after clicking register
  74. //
  75. FlipSocialViewLoggedInSubmenu, // The menu if the user is logged in
  76. FlipSocialViewLoggedInProfile, // The profile screen
  77. FlipSocialViewLoggedInFeed, // The feed screen
  78. FlipSocialViewLoggedInCompose, // The compose screen
  79. FlipSocialViewLoggedInSettings, // The settings screen
  80. //
  81. FlipSocialViewLoggedInChangePasswordInput, // Text input screen for password input on change password screen
  82. FlipSocialViewLoggedInComposeAddPreSaveInput, // Text input screen for add text input on compose screen
  83. FlipSocialViewLoggedInMessagesNewMessageInput, // Text input screen for new message input on messages screen
  84. FlipSocialViewLoggedInSettingsAbout, // The about screen
  85. FlipSocialViewLoggedInSettingsWifi, // The wifi settings screen
  86. FlipSocialViewLoggedInWifiSettingsSSIDInput, // Text input screen for SSID input on wifi screen
  87. FlipSocialViewLoggedInWifiSettingsPasswordInput, // Text input screen for Password input on wifi screen
  88. FlipSocialViewLoggedInProcessCompose, // The dialog view to delete or send the clicked pre-saved text
  89. //
  90. FlipSocialViewLoggedInSignOut, // The view after clicking the sign out button
  91. } FlipSocialView;
  92. // Define the application structure
  93. typedef struct
  94. {
  95. ViewDispatcher *view_dispatcher; // Switches between our views
  96. Submenu *submenu_logged_out; // The application submenu (logged out)
  97. Submenu *submenu_logged_in; // The application submenu (logged in)
  98. Submenu *submenu_compose; // The application submenu (compose)
  99. Widget *widget_logged_out_about; // The about screen (logged out)
  100. Widget *widget_logged_in_about; // The about screen (logged in)
  101. View *view_process_login; // The screen displayed after clicking login
  102. View *view_process_register; // The screen displayed after clicking register
  103. View *view_process_feed; // Dialog for the feed screen
  104. View *view_process_compose; // Dialog for the compose screen (delete or send)
  105. VariableItemList *variable_item_list_logged_out_wifi_settings; // The wifi settings menu
  106. VariableItemList *variable_item_list_logged_out_login; // The login menu
  107. VariableItemList *variable_item_list_logged_out_register; // The register menu
  108. //
  109. VariableItemList *variable_item_list_logged_in_profile; // The profile menu
  110. VariableItemList *variable_item_list_logged_in_settings; // The settings menu
  111. VariableItemList *variable_item_list_logged_in_settings_wifi; // The wifi settings menu
  112. UART_TextInput *text_input_logged_out_wifi_settings_ssid; // Text input for ssid input on wifi settings screen
  113. UART_TextInput *text_input_logged_out_wifi_settings_password; // Text input for password input on wifi settings screen
  114. UART_TextInput *text_input_logged_out_login_username; // Text input for username input on login screen
  115. UART_TextInput *text_input_logged_out_login_password; // Text input for password input on login screen
  116. UART_TextInput *text_input_logged_out_register_username; // Text input for username input on register screen
  117. UART_TextInput *text_input_logged_out_register_password; // Text input for password input on register screen
  118. UART_TextInput *text_input_logged_out_register_password_2; // Text input for password 2 input on register screen
  119. //
  120. UART_TextInput *text_input_logged_in_change_password; // Text input for password input on change password screen
  121. UART_TextInput *text_input_logged_in_compose_pre_save_input; // Text input for pre save input on compose screen
  122. UART_TextInput *text_input_logged_in_wifi_settings_ssid; // Text input for ssid input on wifi settings screen
  123. UART_TextInput *text_input_logged_in_wifi_settings_password; // Text input for password input on wifi settings screen
  124. VariableItem *variable_item_logged_out_wifi_settings_ssid; // Reference to the ssid configuration item
  125. VariableItem *variable_item_logged_out_wifi_settings_password; // Reference to the password configuration item
  126. VariableItem *variable_item_logged_out_login_username; // Reference to the username configuration item
  127. VariableItem *variable_item_logged_out_login_password; // Reference to the password configuration item
  128. VariableItem *variable_item_logged_out_login_button; // Reference to the login button configuration item
  129. VariableItem *variable_item_logged_out_register_username; // Reference to the username configuration item
  130. VariableItem *variable_item_logged_out_register_password; // Reference to the password configuration item
  131. VariableItem *variable_item_logged_out_register_password_2; // Reference to the password 2 configuration item
  132. VariableItem *variable_item_logged_out_register_button; // Reference to the register button configuration item
  133. //
  134. VariableItem *variable_item_logged_in_profile_username; // Reference to the username configuration item
  135. VariableItem *variable_item_logged_in_profile_change_password; // Reference to the change password configuration item
  136. VariableItem *variable_item_logged_in_settings_about; // Reference to the about configuration item
  137. VariableItem *variable_item_logged_in_settings_wifi; // Reference to the wifi settings configuration item
  138. VariableItem *variable_item_logged_in_wifi_settings_ssid; // Reference to the ssid configuration item
  139. VariableItem *variable_item_logged_in_wifi_settings_password; // Reference to the password configuration item
  140. //
  141. FuriPubSub *input_event_queue;
  142. FuriPubSubSubscription *input_event;
  143. char *is_logged_in; // Store the login status
  144. uint32_t is_logged_in_size; // Size of the login status buffer
  145. char *login_username_logged_in; // Store the entered login username
  146. char *login_username_logged_in_temp_buffer; // Temporary buffer for login username text input
  147. uint32_t login_username_logged_in_temp_buffer_size; // Size of the login username temporary buffer
  148. PreSavedPlaylist pre_saved_messages; // Pre-saved messages for the feed screen
  149. char *wifi_ssid_logged_out; // Store the entered wifi ssid
  150. char *wifi_ssid_logged_out_temp_buffer; // Temporary buffer for wifi ssid text input
  151. uint32_t wifi_ssid_logged_out_temp_buffer_size; // Size of the wifi ssid temporary buffer
  152. char *wifi_password_logged_out; // Store the entered wifi password
  153. char *wifi_password_logged_out_temp_buffer; // Temporary buffer for wifi_password text input
  154. uint32_t wifi_password_logged_out_temp_buffer_size; // Size of the wifi_password temporary buffer
  155. char *login_username_logged_out; // Store the entered login username
  156. char *login_username_logged_out_temp_buffer; // Temporary buffer for login username text input
  157. uint32_t login_username_logged_out_temp_buffer_size; // Size of the login username temporary buffer
  158. char *login_password_logged_out; // Store the entered login password
  159. char *login_password_logged_out_temp_buffer; // Temporary buffer for login password text input
  160. uint32_t login_password_logged_out_temp_buffer_size; // Size of the login password temporary buffer
  161. char *register_username_logged_out; // Store the entered register username
  162. char *register_username_logged_out_temp_buffer; // Temporary buffer for register username text input
  163. uint32_t register_username_logged_out_temp_buffer_size; // Size of the register username temporary buffer
  164. char *register_password_logged_out; // Store the entered register password
  165. char *register_password_logged_out_temp_buffer; // Temporary buffer for register password text input
  166. uint32_t register_password_logged_out_temp_buffer_size; // Size of the register password temporary buffer
  167. char *register_password_2_logged_out; // Store the entered register password 2
  168. char *register_password_2_logged_out_temp_buffer; // Temporary buffer for register password 2 text input
  169. uint32_t register_password_2_logged_out_temp_buffer_size; // Size of the register password 2 temporary buffer
  170. //
  171. char *change_password_logged_in; // Store the entered change password
  172. char *change_password_logged_in_temp_buffer; // Temporary buffer for change password text input
  173. uint32_t change_password_logged_in_temp_buffer_size; // Size of the change password temporary buffer
  174. char *compose_pre_save_logged_in; // Store the entered add text
  175. char *compose_pre_save_logged_in_temp_buffer; // Temporary buffer for add text text input
  176. uint32_t compose_pre_save_logged_in_temp_buffer_size; // Size of the add text temporary buffer
  177. char *wifi_ssid_logged_in; // Store the entered wifi ssid
  178. char *wifi_ssid_logged_in_temp_buffer; // Temporary buffer for wifi ssid text input
  179. uint32_t wifi_ssid_logged_in_temp_buffer_size; // Size of the wifi ssid temporary buffer
  180. char *wifi_password_logged_in; // Store the entered wifi password
  181. char *wifi_password_logged_in_temp_buffer; // Temporary buffer for wifi_password text input
  182. uint32_t wifi_password_logged_in_temp_buffer_size; // Size of the wifi_password temporary buffer
  183. } FlipSocialApp;
  184. #endif