Popup_view.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Unitemp - Universal temperature reader
  3. Copyright (C) 2022 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. #include <assets_icons.h>
  19. uint32_t _prev_view_id;
  20. #define VIEW_ID UnitempViewPopup
  21. static void _popup_callback(void* context) {
  22. UNUSED(context);
  23. view_dispatcher_switch_to_view(app->view_dispatcher, _prev_view_id);
  24. }
  25. void unitemp_popup(const Icon* icon, char* header, char* message, uint32_t prev_view_id) {
  26. _prev_view_id = prev_view_id;
  27. popup_reset(app->popup);
  28. popup_set_icon(app->popup, 0, 64 - icon_get_height(icon), icon);
  29. popup_set_header(app->popup, header, 64, 6, AlignCenter, AlignCenter);
  30. popup_set_text(
  31. app->popup,
  32. message,
  33. (128 - icon_get_width(icon)) / 2 + icon_get_width(icon),
  34. 32,
  35. AlignCenter,
  36. AlignCenter);
  37. popup_set_timeout(app->popup, 5000);
  38. popup_set_callback(app->popup, _popup_callback);
  39. popup_enable_timeout(app->popup);
  40. view_dispatcher_switch_to_view(app->view_dispatcher, VIEW_ID);
  41. }