xremote_about_view.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*!
  2. * @file flipper-xremote/views/xremote_about_view.c
  3. @license This project is released under the GNU GPLv3 License
  4. * @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  5. *
  6. * @brief View functionality for version and additional information.
  7. */
  8. #include "xremote_about_view.h"
  9. #include "../xremote.h"
  10. static void xremote_about_view_draw_vertical(Canvas* canvas, XRemoteViewModel* model)
  11. {
  12. UNUSED(model);
  13. char version[32];
  14. canvas_set_font(canvas, FontSecondary);
  15. xremote_get_version(version, sizeof(version));
  16. canvas_draw_str_aligned(canvas, 0, 30, AlignLeft, AlignTop, "Version:");
  17. canvas_draw_str_aligned(canvas, 35, 30, AlignLeft, AlignTop, version);
  18. canvas_draw_str_aligned(canvas, 0, 40, AlignLeft, AlignTop, "License: GPLv3");
  19. canvas_draw_str_aligned(canvas, 0, 50, AlignLeft, AlignTop, "Author: kala13x");
  20. elements_slightly_rounded_frame(canvas, 9, 78, 45, 33);
  21. canvas_draw_str_aligned(canvas, 0, 69, AlignLeft, AlignTop, "Contact:");
  22. canvas_draw_str_aligned(canvas, 13, 80, AlignLeft, AlignTop, "s.kalatoz");
  23. canvas_draw_str_aligned(canvas, 28, 91, AlignLeft, AlignTop, "@");
  24. canvas_draw_str_aligned(canvas, 11, 100, AlignLeft, AlignTop, "gmail.com");
  25. }
  26. static void xremote_about_view_draw_horizontal(Canvas* canvas, XRemoteViewModel* model)
  27. {
  28. UNUSED(model);
  29. char version[32];
  30. canvas_set_font(canvas, FontSecondary);
  31. xremote_get_version(version, sizeof(version));
  32. canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "Version:");
  33. canvas_draw_str_aligned(canvas, 35, 0, AlignLeft, AlignTop, version);
  34. canvas_draw_str_aligned(canvas, 0, 10, AlignLeft, AlignTop, "License: GPLv3");
  35. canvas_draw_str_aligned(canvas, 0, 20, AlignLeft, AlignTop, "Author: kala13x");
  36. elements_slightly_rounded_frame(canvas, 8, 30, 45, 33);
  37. canvas_draw_str_aligned(canvas, 0, 69, AlignLeft, AlignTop, "Contact:");
  38. canvas_draw_str_aligned(canvas, 12, 32, AlignLeft, AlignTop, "s.kalatoz");
  39. canvas_draw_str_aligned(canvas, 27, 43, AlignLeft, AlignTop, "@");
  40. canvas_draw_str_aligned(canvas, 10, 52, AlignLeft, AlignTop, "gmail.com");
  41. }
  42. static void xremote_about_view_draw_callback(Canvas* canvas, void* context)
  43. {
  44. furi_assert(context);
  45. XRemoteViewModel* model = context;
  46. XRemoteAppContext *app_ctx = model->context;
  47. XRemoteViewDrawFunction xremote_about_view_draw_body;
  48. ViewOrientation orientation = app_ctx->app_settings->orientation;
  49. xremote_about_view_draw_body = orientation == ViewOrientationVertical ?
  50. xremote_about_view_draw_vertical : xremote_about_view_draw_horizontal;
  51. xremote_canvas_draw_header(canvas, orientation, "About");
  52. xremote_about_view_draw_body(canvas, model);
  53. xremote_canvas_draw_exit_footer(canvas, orientation, "Press to exit");
  54. }
  55. XRemoteView* xremote_about_view_alloc(void* app_ctx)
  56. {
  57. XRemoteView *view = xremote_view_alloc(app_ctx,
  58. NULL, xremote_about_view_draw_callback);
  59. with_view_model(
  60. xremote_view_get_view(view),
  61. XRemoteViewModel* model,
  62. { model->context = app_ctx; },
  63. true
  64. );
  65. return view;
  66. }