about_view.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "about_view.h"
  2. #include <furi.h>
  3. #include <gui/elements.h>
  4. #include <notification/notification.h>
  5. #include <notification/notification_messages.h>
  6. struct AboutView {
  7. View* view;
  8. };
  9. typedef struct {
  10. bool connected;
  11. } AboutViewModel;
  12. static void about_view_draw_callback(Canvas* canvas, void* context) {
  13. furi_assert(context);
  14. canvas_clear(canvas);
  15. canvas_set_color(canvas, ColorBlack);
  16. canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "IFTTT Virtual button");
  17. canvas_draw_str_aligned(canvas, 0, 15, AlignLeft, AlignTop, "Version 0.2");
  18. canvas_draw_str_aligned(canvas, 0, 50, AlignLeft, AlignTop, "press back");
  19. }
  20. AboutView* about_view_alloc() {
  21. AboutView* about_view = malloc(sizeof(AboutView));
  22. about_view->view = view_alloc();
  23. view_set_context(about_view->view, about_view);
  24. view_allocate_model(about_view->view, ViewModelTypeLocking, sizeof(AboutViewModel));
  25. view_set_draw_callback(about_view->view, about_view_draw_callback);
  26. return about_view;
  27. }
  28. void about_view_free(AboutView* about_view) {
  29. furi_assert(about_view);
  30. view_free(about_view->view);
  31. free(about_view);
  32. }
  33. View* about_view_get_view(AboutView* about_view) {
  34. furi_assert(about_view);
  35. return about_view->view;
  36. }
  37. void about_view_set_data(AboutView* about_view, bool connected) {
  38. furi_assert(about_view);
  39. with_view_model(
  40. about_view->view, AboutViewModel * model, { model->connected = connected; }, true);
  41. }