AboutScreen.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import {QS_BUTTONS} from "../utils/data";
  2. const APP_VERSION = "v2022-11-04";
  3. const AUTHORS = [
  4. ["melianmiko", "Developer"],
  5. ["Vanek905/zhenyok905", "BandBBS publisher"],
  6. ["天劍血狐", "zh-TW translation"],
  7. ["harrybin", "de-DE translation"]
  8. ];
  9. const COLORS = [
  10. [239, 83, 80],
  11. [171, 71, 188],
  12. [126, 87, 194],
  13. [92, 107, 192],
  14. [66, 165, 245],
  15. [66, 165, 245],
  16. [38, 198, 218],
  17. [38, 166, 154],
  18. [102, 187, 106],
  19. [102, 187, 106],
  20. [102, 187, 106],
  21. [255, 238, 88],
  22. [255, 202, 40],
  23. [255, 167, 38],
  24. [255, 112, 67],
  25. ];
  26. class AboutScreen {
  27. initAnimation() {
  28. let level = 0, currentColor = 0, currentIcon = 0;
  29. const names = Object.keys(QS_BUTTONS);
  30. const bg = hmUI.createWidget(hmUI.widget.FILL_RECT, {
  31. color: 0x0,
  32. x: 0,
  33. y: 0,
  34. w: 100,
  35. h: 100,
  36. radius: 12
  37. });
  38. const img = hmUI.createWidget(hmUI.widget.IMG, {
  39. x: (192-78)/2,
  40. y: 64,
  41. src: "qs/" + names[0] + ".png"
  42. });
  43. // Let's do some animation =)
  44. timer.createTimer(0, 100, () => {
  45. const cl = (100-level) / 100;
  46. const size = 78 + (40 * level / 100);
  47. let [r,g,b] = COLORS[currentColor];
  48. r = Math.floor(r * cl);
  49. g = Math.floor(g * cl);
  50. b = Math.floor(b * cl);
  51. bg.setProperty(hmUI.prop.MORE, {
  52. color: (r << 16) + (g << 8) + b,
  53. x: (192-size) / 2,
  54. y: 103 - (size/2),
  55. w: size,
  56. h: size
  57. })
  58. level += 10;
  59. if(level > 100) {
  60. // Switch color and icon
  61. level = 0;
  62. currentColor = (currentColor + 1) % COLORS.length;
  63. img.setProperty(hmUI.prop.MORE, {
  64. src: "qs/" + names[currentIcon] + ".png"
  65. });
  66. currentIcon = (currentIcon + 1) % names.length;
  67. }
  68. })
  69. }
  70. drawBasement() {
  71. hmUI.createWidget(hmUI.widget.TEXT, {
  72. x: 0,
  73. y: 148,
  74. w: 192,
  75. h: 48,
  76. text: "Toolbox",
  77. text_size: 28,
  78. color: 0xFFFFFF,
  79. align_h: hmUI.align.CENTER_H
  80. });
  81. hmUI.createWidget(hmUI.widget.TEXT, {
  82. x: 0,
  83. y: 184,
  84. w: 192,
  85. h: 32,
  86. text: APP_VERSION,
  87. text_size: 18,
  88. color: 0xAAAAAA,
  89. align_h: hmUI.align.CENTER_H
  90. });
  91. }
  92. drawAuthors() {
  93. let posY = 240;
  94. for(let [name, info] of AUTHORS) {
  95. hmUI.createWidget(hmUI.widget.TEXT, {
  96. x: 0,
  97. y: posY,
  98. w: 192,
  99. h: 22,
  100. text_size: 18,
  101. color: 0xFFFFFF,
  102. text: name,
  103. align_h: hmUI.align.CENTER_H
  104. });
  105. hmUI.createWidget(hmUI.widget.TEXT, {
  106. x: 0,
  107. y: posY + 24,
  108. w: 192,
  109. h: 22,
  110. text_size: 16,
  111. color: 0xAAAAAA,
  112. text: info,
  113. align_h: hmUI.align.CENTER_H
  114. });
  115. posY += 64;
  116. }
  117. }
  118. start() {
  119. hmSetting.setBrightScreen(60);
  120. this.initAnimation();
  121. this.drawBasement();
  122. this.drawAuthors();
  123. }
  124. finish() {
  125. hmSetting.setBrightScreenCancel();
  126. }
  127. }
  128. let __$$app$$__ = __$$hmAppManager$$__.currentApp;
  129. let __$$module$$__ = __$$app$$__.current;
  130. __$$module$$__.module = DeviceRuntimeCore.Page({
  131. onInit(p) {
  132. this.screen = new AboutScreen();
  133. this.screen.start();
  134. }
  135. });