Popup_view.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Unitemp - Universal temperature reader
  3. Copyright (C) 2022-2023 Victor Nikitchuk (https://github.com/quen0n)
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #include "UnitempViews.h"
  16. #include <gui/modules/variable_item_list.h>
  17. #include <stdio.h>
  18. uint32_t _prev_view_id;
  19. #define VIEW_ID UnitempViewPopup
  20. static void _popup_callback(void* context) {
  21. UNUSED(context);
  22. view_dispatcher_switch_to_view(app->view_dispatcher, _prev_view_id);
  23. }
  24. void unitemp_popup(const Icon* icon, char* header, char* message, uint32_t prev_view_id) {
  25. _prev_view_id = prev_view_id;
  26. popup_reset(app->popup);
  27. popup_set_icon(app->popup, 0, 64 - icon_get_height(icon), icon);
  28. popup_set_header(app->popup, header, 64, 6, AlignCenter, AlignCenter);
  29. popup_set_text(
  30. app->popup,
  31. message,
  32. (128 - icon_get_width(icon)) / 2 + icon_get_width(icon),
  33. 32,
  34. AlignCenter,
  35. AlignCenter);
  36. popup_set_timeout(app->popup, 5000);
  37. popup_set_callback(app->popup, _popup_callback);
  38. popup_enable_timeout(app->popup);
  39. view_dispatcher_switch_to_view(app->view_dispatcher, VIEW_ID);
  40. }