@hedia/recommendation-screen 2.1.75 → 2.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +5 -0
  3. package/{lib/typescript → dist/src}/RecommendationScreen.d.ts +68 -82
  4. package/dist/src/RecommendationScreen.js +522 -0
  5. package/dist/src/assets/assets/activity/Cyclist.png +0 -0
  6. package/dist/src/assets/assets/activity/Other.png +0 -0
  7. package/dist/src/assets/assets/activity/Runner.png +0 -0
  8. package/dist/src/assets/assets/activity/Swimmer.png +0 -0
  9. package/dist/src/assets/assets/activity/Walk.png +0 -0
  10. package/dist/src/assets/assets/fonts/Poppins-Bold.ttf +0 -0
  11. package/dist/src/assets/assets/fonts/Poppins-SemiBold.ttf +0 -0
  12. package/dist/src/assets/assets/icons/Edit.tsx +22 -0
  13. package/dist/src/assets/assets/icons/X.tsx +14 -0
  14. package/dist/src/assets/assets/mood/happy.png +0 -0
  15. package/dist/src/assets/assets/mood/happy_active.png +0 -0
  16. package/dist/src/assets/assets/mood/neutral.png +0 -0
  17. package/dist/src/assets/assets/mood/neutral_active.png +0 -0
  18. package/dist/src/assets/assets/mood/sad.png +0 -0
  19. package/dist/src/assets/assets/mood/sad_active.png +0 -0
  20. package/dist/src/assets/assets/mood/semi_happy.png +0 -0
  21. package/dist/src/assets/assets/mood/semi_happy_active.png +0 -0
  22. package/dist/src/assets/assets/mood/semi_sad.png +0 -0
  23. package/dist/src/assets/assets/mood/semi_sad_active.png +0 -0
  24. package/dist/src/assets/icons/Edit.d.ts +4 -0
  25. package/dist/src/assets/icons/Edit.js +7 -0
  26. package/dist/src/assets/icons/X.d.ts +4 -0
  27. package/dist/src/assets/icons/X.js +6 -0
  28. package/dist/src/components/ForecastInfoBar.d.ts +109 -0
  29. package/dist/src/components/ForecastInfoBar.js +138 -0
  30. package/dist/src/components/Header.d.ts +8 -0
  31. package/dist/src/components/Header.js +54 -0
  32. package/dist/src/components/Icon.d.ts +20 -0
  33. package/dist/src/components/Icon.js +43 -0
  34. package/{lib/typescript → dist/src}/components/InfoBars.d.ts +28 -14
  35. package/dist/src/components/InfoBars.js +128 -0
  36. package/{lib/typescript → dist/src}/components/InvisibleNumberInput.d.ts +3 -9
  37. package/dist/src/components/InvisibleNumberInput.js +121 -0
  38. package/dist/src/components/LimitationMessage.d.ts +14 -0
  39. package/dist/src/components/LimitationMessage.js +30 -0
  40. package/{lib/typescript → dist/src}/components/LineSeparator.d.ts +1 -6
  41. package/dist/src/components/LineSeparator.js +18 -0
  42. package/{lib/typescript → dist/src}/components/RecentInsulin.d.ts +1 -3
  43. package/dist/src/components/RecentInsulin.js +73 -0
  44. package/{lib/typescript → dist/src}/components/RecommendationModal.d.ts +63 -63
  45. package/dist/src/components/RecommendationModal.js +226 -0
  46. package/{lib/typescript → dist/src}/components/RecommendedCarbs.d.ts +0 -3
  47. package/dist/src/components/RecommendedCarbs.js +251 -0
  48. package/{lib/typescript → dist/src}/components/RecommendedInsulin.d.ts +1 -2
  49. package/dist/src/components/RecommendedInsulin.js +180 -0
  50. package/{lib/typescript → dist/src}/components/Remeasure.d.ts +15 -6
  51. package/dist/src/components/Remeasure.js +130 -0
  52. package/{lib/typescript/components/TransferToLogbook.d.ts → dist/src/components/SaveButton.d.ts} +2 -3
  53. package/dist/src/components/SaveButton.js +71 -0
  54. package/dist/src/components/TwoOptionModal.d.ts +136 -0
  55. package/dist/src/components/TwoOptionModal.js +141 -0
  56. package/{lib/typescript → dist/src}/components/activity/Activity.d.ts +2 -3
  57. package/dist/src/components/activity/Activity.js +84 -0
  58. package/{lib/typescript → dist/src}/components/activity/ActivityIcon.d.ts +7 -8
  59. package/dist/src/components/activity/ActivityIcon.js +58 -0
  60. package/{lib/typescript → dist/src}/components/activity/ActivityIntensity.d.ts +1 -2
  61. package/dist/src/components/activity/ActivityIntensity.js +58 -0
  62. package/{lib/typescript → dist/src}/components/mood/Emotion.d.ts +1 -2
  63. package/dist/src/components/mood/Emotion.js +64 -0
  64. package/{lib/typescript → dist/src}/components/mood/MoodIcon.d.ts +5 -5
  65. package/dist/src/components/mood/MoodIcon.js +63 -0
  66. package/dist/src/components/text/TextBold.d.ts +8 -0
  67. package/dist/src/components/text/TextBold.js +12 -0
  68. package/dist/src/components/text/TextRegular.d.ts +8 -0
  69. package/dist/src/components/text/TextRegular.js +12 -0
  70. package/dist/src/locale/da/messages.js +1 -0
  71. package/dist/src/locale/da/messages.po +353 -0
  72. package/dist/src/locale/de/messages.js +1 -0
  73. package/dist/src/locale/de/messages.po +353 -0
  74. package/dist/src/locale/en/messages.js +1 -0
  75. package/dist/src/locale/en/messages.po +353 -0
  76. package/dist/src/locale/es/messages.js +1 -0
  77. package/dist/src/locale/es/messages.po +353 -0
  78. package/dist/src/locale/fr/messages.js +1 -0
  79. package/dist/src/locale/fr/messages.po +353 -0
  80. package/dist/src/locale/i18nUtils.d.ts +18 -0
  81. package/dist/src/locale/i18nUtils.js +39 -0
  82. package/dist/src/locale/it/messages.js +1 -0
  83. package/dist/src/locale/it/messages.po +353 -0
  84. package/{lib/typescript → dist/src}/types/enum.d.ts +15 -22
  85. package/dist/src/types/enum.js +145 -0
  86. package/{lib/typescript → dist/src}/types/types.d.ts +0 -1
  87. package/dist/src/types/types.js +1 -0
  88. package/{lib/typescript → dist/src}/utils/AttentionMessages.d.ts +0 -1
  89. package/dist/src/utils/AttentionMessages.js +118 -0
  90. package/{lib/typescript → dist/src}/utils/Constants.d.ts +3 -18
  91. package/{lib/module → dist/src}/utils/Constants.js +21 -79
  92. package/{lib/typescript → dist/src}/utils/RecommendationError.d.ts +0 -1
  93. package/dist/src/utils/RecommendationError.js +63 -0
  94. package/{lib/typescript → dist/src}/utils/RecommendationUtils.d.ts +0 -1
  95. package/{lib/module → dist/src}/utils/RecommendationUtils.js +88 -90
  96. package/{lib/typescript → dist/src}/utils/Translations.d.ts +0 -1
  97. package/{lib/module → dist/src}/utils/Translations.js +5 -7
  98. package/{lib/typescript → dist/src}/utils/Utils.d.ts +1 -2
  99. package/dist/src/utils/Utils.js +141 -0
  100. package/{lib/typescript → dist/src}/utils/Validations.d.ts +1 -2
  101. package/{lib/module → dist/src}/utils/Validations.js +128 -156
  102. package/package.json +96 -109
  103. package/lib/commonjs/RecommendationScreen.js +0 -778
  104. package/lib/commonjs/RecommendationScreen.js.map +0 -1
  105. package/lib/commonjs/assets/IconsSVG/Close.js +0 -20
  106. package/lib/commonjs/assets/IconsSVG/Close.js.map +0 -1
  107. package/lib/commonjs/assets/IconsSVG/CloseOutlined.js +0 -28
  108. package/lib/commonjs/assets/IconsSVG/CloseOutlined.js.map +0 -1
  109. package/lib/commonjs/assets/IconsSVG/Edit.js +0 -23
  110. package/lib/commonjs/assets/IconsSVG/Edit.js.map +0 -1
  111. package/lib/commonjs/assets/IconsSVG/activity/Cycling.js +0 -43
  112. package/lib/commonjs/assets/IconsSVG/activity/Cycling.js.map +0 -1
  113. package/lib/commonjs/assets/IconsSVG/activity/Running.js +0 -33
  114. package/lib/commonjs/assets/IconsSVG/activity/Running.js.map +0 -1
  115. package/lib/commonjs/assets/IconsSVG/activity/Stretching.js +0 -33
  116. package/lib/commonjs/assets/IconsSVG/activity/Stretching.js.map +0 -1
  117. package/lib/commonjs/assets/IconsSVG/activity/Swimming.js +0 -48
  118. package/lib/commonjs/assets/IconsSVG/activity/Swimming.js.map +0 -1
  119. package/lib/commonjs/assets/IconsSVG/activity/Walking.js +0 -38
  120. package/lib/commonjs/assets/IconsSVG/activity/Walking.js.map +0 -1
  121. package/lib/commonjs/assets/IconsSVG/mood/Happy.js +0 -34
  122. package/lib/commonjs/assets/IconsSVG/mood/Happy.js.map +0 -1
  123. package/lib/commonjs/assets/IconsSVG/mood/Neutral.js +0 -34
  124. package/lib/commonjs/assets/IconsSVG/mood/Neutral.js.map +0 -1
  125. package/lib/commonjs/assets/IconsSVG/mood/Sad.js +0 -34
  126. package/lib/commonjs/assets/IconsSVG/mood/Sad.js.map +0 -1
  127. package/lib/commonjs/assets/IconsSVG/mood/SemiHappy.js +0 -34
  128. package/lib/commonjs/assets/IconsSVG/mood/SemiHappy.js.map +0 -1
  129. package/lib/commonjs/assets/IconsSVG/mood/SemiSad.js +0 -34
  130. package/lib/commonjs/assets/IconsSVG/mood/SemiSad.js.map +0 -1
  131. package/lib/commonjs/components/ExitModal.js +0 -124
  132. package/lib/commonjs/components/ExitModal.js.map +0 -1
  133. package/lib/commonjs/components/InfoBars.js +0 -123
  134. package/lib/commonjs/components/InfoBars.js.map +0 -1
  135. package/lib/commonjs/components/InvisibleNumberInput.js +0 -150
  136. package/lib/commonjs/components/InvisibleNumberInput.js.map +0 -1
  137. package/lib/commonjs/components/LineSeparator.js +0 -27
  138. package/lib/commonjs/components/LineSeparator.js.map +0 -1
  139. package/lib/commonjs/components/RecentInsulin.js +0 -105
  140. package/lib/commonjs/components/RecentInsulin.js.map +0 -1
  141. package/lib/commonjs/components/RecommendationModal.js +0 -302
  142. package/lib/commonjs/components/RecommendationModal.js.map +0 -1
  143. package/lib/commonjs/components/RecommendedCarbs.js +0 -289
  144. package/lib/commonjs/components/RecommendedCarbs.js.map +0 -1
  145. package/lib/commonjs/components/RecommendedInsulin.js +0 -209
  146. package/lib/commonjs/components/RecommendedInsulin.js.map +0 -1
  147. package/lib/commonjs/components/Remeasure.js +0 -131
  148. package/lib/commonjs/components/Remeasure.js.map +0 -1
  149. package/lib/commonjs/components/Text.js +0 -25
  150. package/lib/commonjs/components/Text.js.map +0 -1
  151. package/lib/commonjs/components/TimeoutModal.js +0 -113
  152. package/lib/commonjs/components/TimeoutModal.js.map +0 -1
  153. package/lib/commonjs/components/TransferToLogbook.js +0 -83
  154. package/lib/commonjs/components/TransferToLogbook.js.map +0 -1
  155. package/lib/commonjs/components/activity/Activity.js +0 -112
  156. package/lib/commonjs/components/activity/Activity.js.map +0 -1
  157. package/lib/commonjs/components/activity/ActivityIcon.js +0 -86
  158. package/lib/commonjs/components/activity/ActivityIcon.js.map +0 -1
  159. package/lib/commonjs/components/activity/ActivityIntensity.js +0 -65
  160. package/lib/commonjs/components/activity/ActivityIntensity.js.map +0 -1
  161. package/lib/commonjs/components/mood/Emotion.js +0 -86
  162. package/lib/commonjs/components/mood/Emotion.js.map +0 -1
  163. package/lib/commonjs/components/mood/MoodIcon.js +0 -107
  164. package/lib/commonjs/components/mood/MoodIcon.js.map +0 -1
  165. package/lib/commonjs/components/styles/fonts.js +0 -160
  166. package/lib/commonjs/components/styles/fonts.js.map +0 -1
  167. package/lib/commonjs/index.js +0 -21
  168. package/lib/commonjs/index.js.map +0 -1
  169. package/lib/commonjs/locales/da/translations.json +0 -82
  170. package/lib/commonjs/locales/de/translations.json +0 -81
  171. package/lib/commonjs/locales/en/translations.json +0 -84
  172. package/lib/commonjs/locales/es/translations.json +0 -81
  173. package/lib/commonjs/locales/fr/translations.json +0 -81
  174. package/lib/commonjs/locales/it/translations.json +0 -81
  175. package/lib/commonjs/locales/translate.js +0 -63
  176. package/lib/commonjs/locales/translate.js.map +0 -1
  177. package/lib/commonjs/types/enum.js +0 -179
  178. package/lib/commonjs/types/enum.js.map +0 -1
  179. package/lib/commonjs/types/types.js +0 -6
  180. package/lib/commonjs/types/types.js.map +0 -1
  181. package/lib/commonjs/utils/AttentionMessages.js +0 -141
  182. package/lib/commonjs/utils/AttentionMessages.js.map +0 -1
  183. package/lib/commonjs/utils/Constants.js +0 -138
  184. package/lib/commonjs/utils/Constants.js.map +0 -1
  185. package/lib/commonjs/utils/RecommendationError.js +0 -116
  186. package/lib/commonjs/utils/RecommendationError.js.map +0 -1
  187. package/lib/commonjs/utils/RecommendationUtils.js +0 -212
  188. package/lib/commonjs/utils/RecommendationUtils.js.map +0 -1
  189. package/lib/commonjs/utils/Translations.js +0 -22
  190. package/lib/commonjs/utils/Translations.js.map +0 -1
  191. package/lib/commonjs/utils/Utils.js +0 -162
  192. package/lib/commonjs/utils/Utils.js.map +0 -1
  193. package/lib/commonjs/utils/Validations.js +0 -468
  194. package/lib/commonjs/utils/Validations.js.map +0 -1
  195. package/lib/module/RecommendationScreen.js +0 -768
  196. package/lib/module/RecommendationScreen.js.map +0 -1
  197. package/lib/module/assets/IconsSVG/Close.js +0 -11
  198. package/lib/module/assets/IconsSVG/Close.js.map +0 -1
  199. package/lib/module/assets/IconsSVG/CloseOutlined.js +0 -19
  200. package/lib/module/assets/IconsSVG/CloseOutlined.js.map +0 -1
  201. package/lib/module/assets/IconsSVG/Edit.js +0 -14
  202. package/lib/module/assets/IconsSVG/Edit.js.map +0 -1
  203. package/lib/module/assets/IconsSVG/activity/Cycling.js +0 -34
  204. package/lib/module/assets/IconsSVG/activity/Cycling.js.map +0 -1
  205. package/lib/module/assets/IconsSVG/activity/Running.js +0 -24
  206. package/lib/module/assets/IconsSVG/activity/Running.js.map +0 -1
  207. package/lib/module/assets/IconsSVG/activity/Stretching.js +0 -24
  208. package/lib/module/assets/IconsSVG/activity/Stretching.js.map +0 -1
  209. package/lib/module/assets/IconsSVG/activity/Swimming.js +0 -39
  210. package/lib/module/assets/IconsSVG/activity/Swimming.js.map +0 -1
  211. package/lib/module/assets/IconsSVG/activity/Walking.js +0 -29
  212. package/lib/module/assets/IconsSVG/activity/Walking.js.map +0 -1
  213. package/lib/module/assets/IconsSVG/mood/Happy.js +0 -25
  214. package/lib/module/assets/IconsSVG/mood/Happy.js.map +0 -1
  215. package/lib/module/assets/IconsSVG/mood/Neutral.js +0 -25
  216. package/lib/module/assets/IconsSVG/mood/Neutral.js.map +0 -1
  217. package/lib/module/assets/IconsSVG/mood/Sad.js +0 -25
  218. package/lib/module/assets/IconsSVG/mood/Sad.js.map +0 -1
  219. package/lib/module/assets/IconsSVG/mood/SemiHappy.js +0 -25
  220. package/lib/module/assets/IconsSVG/mood/SemiHappy.js.map +0 -1
  221. package/lib/module/assets/IconsSVG/mood/SemiSad.js +0 -25
  222. package/lib/module/assets/IconsSVG/mood/SemiSad.js.map +0 -1
  223. package/lib/module/components/ExitModal.js +0 -114
  224. package/lib/module/components/ExitModal.js.map +0 -1
  225. package/lib/module/components/InfoBars.js +0 -114
  226. package/lib/module/components/InfoBars.js.map +0 -1
  227. package/lib/module/components/InvisibleNumberInput.js +0 -142
  228. package/lib/module/components/InvisibleNumberInput.js.map +0 -1
  229. package/lib/module/components/LineSeparator.js +0 -19
  230. package/lib/module/components/LineSeparator.js.map +0 -1
  231. package/lib/module/components/RecentInsulin.js +0 -97
  232. package/lib/module/components/RecentInsulin.js.map +0 -1
  233. package/lib/module/components/RecommendationModal.js +0 -291
  234. package/lib/module/components/RecommendationModal.js.map +0 -1
  235. package/lib/module/components/RecommendedCarbs.js +0 -281
  236. package/lib/module/components/RecommendedCarbs.js.map +0 -1
  237. package/lib/module/components/RecommendedInsulin.js +0 -201
  238. package/lib/module/components/RecommendedInsulin.js.map +0 -1
  239. package/lib/module/components/Remeasure.js +0 -123
  240. package/lib/module/components/Remeasure.js.map +0 -1
  241. package/lib/module/components/Text.js +0 -16
  242. package/lib/module/components/Text.js.map +0 -1
  243. package/lib/module/components/TimeoutModal.js +0 -103
  244. package/lib/module/components/TimeoutModal.js.map +0 -1
  245. package/lib/module/components/TransferToLogbook.js +0 -75
  246. package/lib/module/components/TransferToLogbook.js.map +0 -1
  247. package/lib/module/components/activity/Activity.js +0 -104
  248. package/lib/module/components/activity/Activity.js.map +0 -1
  249. package/lib/module/components/activity/ActivityIcon.js +0 -78
  250. package/lib/module/components/activity/ActivityIcon.js.map +0 -1
  251. package/lib/module/components/activity/ActivityIntensity.js +0 -57
  252. package/lib/module/components/activity/ActivityIntensity.js.map +0 -1
  253. package/lib/module/components/mood/Emotion.js +0 -78
  254. package/lib/module/components/mood/Emotion.js.map +0 -1
  255. package/lib/module/components/mood/MoodIcon.js +0 -97
  256. package/lib/module/components/mood/MoodIcon.js.map +0 -1
  257. package/lib/module/components/styles/fonts.js +0 -152
  258. package/lib/module/components/styles/fonts.js.map +0 -1
  259. package/lib/module/index.js +0 -5
  260. package/lib/module/index.js.map +0 -1
  261. package/lib/module/locales/da/translations.json +0 -82
  262. package/lib/module/locales/de/translations.json +0 -81
  263. package/lib/module/locales/en/translations.json +0 -84
  264. package/lib/module/locales/es/translations.json +0 -81
  265. package/lib/module/locales/fr/translations.json +0 -81
  266. package/lib/module/locales/it/translations.json +0 -81
  267. package/lib/module/locales/translate.js +0 -55
  268. package/lib/module/locales/translate.js.map +0 -1
  269. package/lib/module/types/enum.js +0 -170
  270. package/lib/module/types/enum.js.map +0 -1
  271. package/lib/module/types/types.js +0 -2
  272. package/lib/module/types/types.js.map +0 -1
  273. package/lib/module/utils/AttentionMessages.js +0 -131
  274. package/lib/module/utils/AttentionMessages.js.map +0 -1
  275. package/lib/module/utils/Constants.js.map +0 -1
  276. package/lib/module/utils/RecommendationError.js +0 -87
  277. package/lib/module/utils/RecommendationError.js.map +0 -1
  278. package/lib/module/utils/RecommendationUtils.js.map +0 -1
  279. package/lib/module/utils/Translations.js.map +0 -1
  280. package/lib/module/utils/Utils.js +0 -155
  281. package/lib/module/utils/Utils.js.map +0 -1
  282. package/lib/module/utils/Validations.js.map +0 -1
  283. package/lib/typescript/RecommendationScreen.d.ts.map +0 -1
  284. package/lib/typescript/assets/IconsSVG/Close.d.ts +0 -5
  285. package/lib/typescript/assets/IconsSVG/Close.d.ts.map +0 -1
  286. package/lib/typescript/assets/IconsSVG/CloseOutlined.d.ts +0 -5
  287. package/lib/typescript/assets/IconsSVG/CloseOutlined.d.ts.map +0 -1
  288. package/lib/typescript/assets/IconsSVG/Edit.d.ts +0 -5
  289. package/lib/typescript/assets/IconsSVG/Edit.d.ts.map +0 -1
  290. package/lib/typescript/assets/IconsSVG/activity/Cycling.d.ts +0 -5
  291. package/lib/typescript/assets/IconsSVG/activity/Cycling.d.ts.map +0 -1
  292. package/lib/typescript/assets/IconsSVG/activity/Running.d.ts +0 -5
  293. package/lib/typescript/assets/IconsSVG/activity/Running.d.ts.map +0 -1
  294. package/lib/typescript/assets/IconsSVG/activity/Stretching.d.ts +0 -5
  295. package/lib/typescript/assets/IconsSVG/activity/Stretching.d.ts.map +0 -1
  296. package/lib/typescript/assets/IconsSVG/activity/Swimming.d.ts +0 -5
  297. package/lib/typescript/assets/IconsSVG/activity/Swimming.d.ts.map +0 -1
  298. package/lib/typescript/assets/IconsSVG/activity/Walking.d.ts +0 -5
  299. package/lib/typescript/assets/IconsSVG/activity/Walking.d.ts.map +0 -1
  300. package/lib/typescript/assets/IconsSVG/mood/Happy.d.ts +0 -5
  301. package/lib/typescript/assets/IconsSVG/mood/Happy.d.ts.map +0 -1
  302. package/lib/typescript/assets/IconsSVG/mood/Neutral.d.ts +0 -5
  303. package/lib/typescript/assets/IconsSVG/mood/Neutral.d.ts.map +0 -1
  304. package/lib/typescript/assets/IconsSVG/mood/Sad.d.ts +0 -5
  305. package/lib/typescript/assets/IconsSVG/mood/Sad.d.ts.map +0 -1
  306. package/lib/typescript/assets/IconsSVG/mood/SemiHappy.d.ts +0 -5
  307. package/lib/typescript/assets/IconsSVG/mood/SemiHappy.d.ts.map +0 -1
  308. package/lib/typescript/assets/IconsSVG/mood/SemiSad.d.ts +0 -5
  309. package/lib/typescript/assets/IconsSVG/mood/SemiSad.d.ts.map +0 -1
  310. package/lib/typescript/components/ExitModal.d.ts +0 -26
  311. package/lib/typescript/components/ExitModal.d.ts.map +0 -1
  312. package/lib/typescript/components/InfoBars.d.ts.map +0 -1
  313. package/lib/typescript/components/InvisibleNumberInput.d.ts.map +0 -1
  314. package/lib/typescript/components/LineSeparator.d.ts.map +0 -1
  315. package/lib/typescript/components/RecentInsulin.d.ts.map +0 -1
  316. package/lib/typescript/components/RecommendationModal.d.ts.map +0 -1
  317. package/lib/typescript/components/RecommendedCarbs.d.ts.map +0 -1
  318. package/lib/typescript/components/RecommendedInsulin.d.ts.map +0 -1
  319. package/lib/typescript/components/Remeasure.d.ts.map +0 -1
  320. package/lib/typescript/components/Text.d.ts +0 -14
  321. package/lib/typescript/components/Text.d.ts.map +0 -1
  322. package/lib/typescript/components/TimeoutModal.d.ts +0 -25
  323. package/lib/typescript/components/TimeoutModal.d.ts.map +0 -1
  324. package/lib/typescript/components/TransferToLogbook.d.ts.map +0 -1
  325. package/lib/typescript/components/activity/Activity.d.ts.map +0 -1
  326. package/lib/typescript/components/activity/ActivityIcon.d.ts.map +0 -1
  327. package/lib/typescript/components/activity/ActivityIntensity.d.ts.map +0 -1
  328. package/lib/typescript/components/mood/Emotion.d.ts.map +0 -1
  329. package/lib/typescript/components/mood/MoodIcon.d.ts.map +0 -1
  330. package/lib/typescript/components/styles/fonts.d.ts +0 -151
  331. package/lib/typescript/components/styles/fonts.d.ts.map +0 -1
  332. package/lib/typescript/index.d.ts +0 -5
  333. package/lib/typescript/index.d.ts.map +0 -1
  334. package/lib/typescript/locales/translate.d.ts +0 -20
  335. package/lib/typescript/locales/translate.d.ts.map +0 -1
  336. package/lib/typescript/types/enum.d.ts.map +0 -1
  337. package/lib/typescript/types/types.d.ts.map +0 -1
  338. package/lib/typescript/utils/AttentionMessages.d.ts.map +0 -1
  339. package/lib/typescript/utils/Constants.d.ts.map +0 -1
  340. package/lib/typescript/utils/RecommendationError.d.ts.map +0 -1
  341. package/lib/typescript/utils/RecommendationUtils.d.ts.map +0 -1
  342. package/lib/typescript/utils/Translations.d.ts.map +0 -1
  343. package/lib/typescript/utils/Utils.d.ts.map +0 -1
  344. package/lib/typescript/utils/Validations.d.ts.map +0 -1
  345. package/src/RecommendationScreen.tsx +0 -854
  346. package/src/assets/IconsSVG/Close.tsx +0 -13
  347. package/src/assets/IconsSVG/CloseOutlined.tsx +0 -23
  348. package/src/assets/IconsSVG/Edit.tsx +0 -16
  349. package/src/assets/IconsSVG/activity/Cycling.tsx +0 -41
  350. package/src/assets/IconsSVG/activity/Running.tsx +0 -29
  351. package/src/assets/IconsSVG/activity/Stretching.tsx +0 -29
  352. package/src/assets/IconsSVG/activity/Swimming.tsx +0 -47
  353. package/src/assets/IconsSVG/activity/Walking.tsx +0 -35
  354. package/src/assets/IconsSVG/mood/Happy.tsx +0 -30
  355. package/src/assets/IconsSVG/mood/Neutral.tsx +0 -30
  356. package/src/assets/IconsSVG/mood/Sad.tsx +0 -30
  357. package/src/assets/IconsSVG/mood/SemiHappy.tsx +0 -30
  358. package/src/assets/IconsSVG/mood/SemiSad.tsx +0 -30
  359. package/src/components/ExitModal.tsx +0 -134
  360. package/src/components/InfoBars.tsx +0 -122
  361. package/src/components/InvisibleNumberInput.tsx +0 -170
  362. package/src/components/LineSeparator.tsx +0 -29
  363. package/src/components/RecentInsulin.tsx +0 -109
  364. package/src/components/RecommendationModal.tsx +0 -319
  365. package/src/components/RecommendedCarbs.tsx +0 -303
  366. package/src/components/RecommendedInsulin.tsx +0 -220
  367. package/src/components/Remeasure.tsx +0 -135
  368. package/src/components/Text.tsx +0 -27
  369. package/src/components/TimeoutModal.tsx +0 -121
  370. package/src/components/TransferToLogbook.tsx +0 -92
  371. package/src/components/activity/Activity.tsx +0 -107
  372. package/src/components/activity/ActivityIcon.tsx +0 -77
  373. package/src/components/activity/ActivityIntensity.tsx +0 -67
  374. package/src/components/mood/Emotion.tsx +0 -97
  375. package/src/components/mood/MoodIcon.tsx +0 -91
  376. package/src/components/styles/fonts.ts +0 -151
  377. package/src/index.ts +0 -5
  378. package/src/locales/da/translations.json +0 -82
  379. package/src/locales/de/translations.json +0 -81
  380. package/src/locales/en/translations.json +0 -84
  381. package/src/locales/es/translations.json +0 -81
  382. package/src/locales/fr/translations.json +0 -81
  383. package/src/locales/it/translations.json +0 -81
  384. package/src/locales/translate.ts +0 -62
  385. package/src/types/enum.ts +0 -164
  386. package/src/types/types.ts +0 -19
  387. package/src/utils/AttentionMessages.ts +0 -167
  388. package/src/utils/Constants.ts +0 -77
  389. package/src/utils/RecommendationError.ts +0 -182
  390. package/src/utils/RecommendationUtils.ts +0 -232
  391. package/src/utils/Translations.ts +0 -17
  392. package/src/utils/Utils.ts +0 -156
  393. package/src/utils/Validations.ts +0 -490
@@ -0,0 +1,226 @@
1
+ import { t } from "@lingui/macro";
2
+ import * as React from "react";
3
+ import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
4
+ import ReactNativeModal from "react-native-modal";
5
+ import { i18n } from "../locale/i18nUtils";
6
+ import { Testing } from "../types/enum";
7
+ import { colors } from "../utils/Constants";
8
+ import LimitationMessage from "./LimitationMessage";
9
+ import TextBold from "./text/TextBold";
10
+ import TextRegular from "./text/TextRegular";
11
+ const { RecommendationModalTestIds } = Testing.Id;
12
+ /**
13
+ * Popup modal for displaying information messages or warnings to the user if necessary.
14
+ * The modal has two “pages” with different content that it is able to display.
15
+ * The first page is for informing the user if their insulin recommendation was limited by the maximum insulin safety limit.
16
+ * This page will only be displayed if the recommendation was actually limited.
17
+ * The second page is for displaying a general attention message that may contain instructions for the user,
18
+ * and for letting the user know if they are being recommended eating additional carbohydrates.
19
+ */
20
+ export default class RecommendationModal extends React.Component {
21
+ /**
22
+ * Steps:
23
+ * 1. Call the super() method with the props.
24
+ * 2. Set the firstPageVisible state variable true if the limitationMessage prop is truthy.
25
+ * @param props The class props
26
+ */
27
+ constructor(props) {
28
+ super(props);
29
+ this.state = {
30
+ firstPageVisible: !!this.props.limitationMessage,
31
+ };
32
+ }
33
+ /**
34
+ * Handle what happens when the “next” button is pressed.
35
+ *
36
+ * Steps:
37
+ * 1. Unpack attentionMessage and suggestedCarbohydrates from the props object.
38
+ * 2. Define isPageVisible to be true if either attentionMessage or suggestedCarbohydrates is truthy.
39
+ * 3. If isPageVisible is true then set the firstPageVisible state variable to false. Otherwise call the onClickOkButton prop callback function.
40
+ */
41
+ onPressNextButton = () => {
42
+ const { attentionMessage, suggestedCarbohydrates } = this.props;
43
+ const isPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
44
+ return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
45
+ };
46
+ /**
47
+ * @returns Return an JSX element for composing two buttons: one for accepting a suggestion and one for rejecting it.
48
+ * If the accept button is pressed the onAcceptCarbohydrates prop callback function shall be called.
49
+ * If the accept button is pressed the onDeclineCarbohydrates prop callback function shall be called.
50
+ */
51
+ recommendationButtons = () => {
52
+ return (<View style={stylesModal.recommendationButtonsContainer}>
53
+ <TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} style={stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
54
+ <TextRegular style={stylesModal.affirmativeCarbsText}>{i18n._(t `OK`)}</TextRegular>
55
+ </TouchableOpacity>
56
+ <TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} style={stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
57
+ <TextRegular style={stylesModal.negativeCarbsText}>{i18n._(t `NO`)}</TextRegular>
58
+ </TouchableOpacity>
59
+ </View>);
60
+ };
61
+ /**
62
+ * Compose a JSX element for displaying a recommendation of additional carbohydrates (the value of the suggestedCarbohydrates prop rounded to the nearest integer)
63
+ * to the user in a way that explains what to do with the suggestion.
64
+ * @param suggestedCarbohydrates the recommended additional carbohydrates
65
+ */
66
+ recommendCarbohydrates = (suggestedCarbohydrates) => {
67
+ const displayCarbs = Math.round(suggestedCarbohydrates);
68
+ return (<React.Fragment>
69
+ <View style={stylesModal.innerView}>
70
+ <View style={stylesModal.recommendationRow}>
71
+ <TextRegular style={stylesModal.recommendEatingText}>
72
+ {i18n._(t `We recommend eating an additional:`)}
73
+ </TextRegular>
74
+ </View>
75
+ <View style={stylesModal.suggestedContainer}>
76
+ <TextRegular style={stylesModal.textCenter}>
77
+ <TextBold style={stylesModal.suggestedCarbs} testID={RecommendationModalTestIds.SuggestedCarbs}>
78
+ {`${displayCarbs} `}
79
+ </TextBold>
80
+ <TextRegular style={stylesModal.carbohydrateText}>
81
+ {i18n._(t `grams of carbohydrates`)}
82
+ </TextRegular>
83
+ </TextRegular>
84
+ </View>
85
+ <View style={stylesModal.recommendationRow}>
86
+ <TextRegular style={stylesModal.recommendEatingText}>
87
+ {i18n._(t `Instead of taking insulin`)}
88
+ </TextRegular>
89
+ </View>
90
+ </View>
91
+ <View style={stylesModal.addToCalculationContainer}>
92
+ <TextRegular style={stylesModal.addToCalculation}>
93
+ {i18n._(t `Would you like to add this to your current calculation?`)}
94
+ </TextRegular>
95
+ {this.recommendationButtons()}
96
+ </View>
97
+ </React.Fragment>);
98
+ };
99
+ /**
100
+ * @returns JSX element for displaying the “second” page of the recommendation modal. The second page displays the string from the attentionMessage prop.
101
+ */
102
+ secondPage = () => {
103
+ const { attentionMessage, suggestedCarbohydrates } = this.props;
104
+ const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
105
+ return (<React.Fragment>
106
+ <View style={stylesModal.container}>
107
+ <View style={stylesModal.titleContainer}>
108
+ <TextBold style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</TextBold>
109
+ </View>
110
+ <TextRegular style={stylesModal.textMessage}>{attentionMessage}</TextRegular>
111
+ {willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
112
+ </View>
113
+ {willRecommendCarbs ? null : (<View style={stylesModal.containerAcceptButton}>
114
+ <TouchableOpacity testID={RecommendationModalTestIds.OkButton} style={stylesModal.okButton} onPress={this.props.onClickOkButton}>
115
+ <TextRegular style={stylesModal.buttonText}>{i18n._(t `OK`)}</TextRegular>
116
+ </TouchableOpacity>
117
+ </View>)}
118
+ </React.Fragment>);
119
+ };
120
+ /**
121
+ * @returns JSX element for displaying the “first” page of the recommendation modal.
122
+ * The first page consists of a limitation message rendered using a LimitationMessage component.
123
+ */
124
+ firstPage = () => {
125
+ const { limitationMessage } = this.props;
126
+ return <LimitationMessage limitationMessage={limitationMessage} onPressNextButton={this.onPressNextButton}/>;
127
+ };
128
+ /**
129
+ * @returns JSX element for rendering a modal that is visible if the isVisible prop is true.
130
+ * If the firstPageVisible state variable is true then use firstPage() to render the first page.
131
+ * Otherwise use secondPage() to render the second page.
132
+ */
133
+ render() {
134
+ const { isVisible } = this.props;
135
+ const { firstPageVisible } = this.state;
136
+ return (<ReactNativeModal isVisible={isVisible} style={stylesModal.modalStyle}>
137
+ {firstPageVisible ? this.firstPage() : this.secondPage()}
138
+ </ReactNativeModal>);
139
+ }
140
+ }
141
+ const { height, width } = Dimensions.get(`screen`);
142
+ const buttonHeight = height / 20;
143
+ const buttonWidth = width / 2.5;
144
+ const buttonFontSize = width / 22;
145
+ const buttonBorderRadius = height / 30;
146
+ const buttonBorderWidth = height / 500;
147
+ const sugestionFontSize = width / 19;
148
+ const recommendEatingFontSize = height / 45;
149
+ const textFontSize = width / 20;
150
+ const titleFontSize = width / 13;
151
+ /** @internal */
152
+ export const stylesModal = StyleSheet.create({
153
+ modalStyle: {
154
+ margin: 0,
155
+ backgroundColor: colors.darkBlue,
156
+ },
157
+ container: {
158
+ flex: 4,
159
+ justifyContent: `center`,
160
+ paddingHorizontal: `4%`,
161
+ },
162
+ containerAcceptButton: {
163
+ flex: 1,
164
+ justifyContent: `flex-start`,
165
+ },
166
+ titleContainer: { marginBottom: `5%` },
167
+ recommendationRow: { justifyContent: `center`, alignContent: `center`, marginBottom: `3%` },
168
+ textTittleMessage: { color: `white`, fontSize: titleFontSize, textAlign: `center` },
169
+ textMessage: { color: `white`, fontSize: textFontSize, textAlign: `center` },
170
+ buttonText: { color: colors.teal, fontSize: buttonFontSize, textAlign: `center` },
171
+ addToCalculationContainer: { justifyContent: `flex-start`, marginVertical: `5%` },
172
+ innerView: {
173
+ alignContent: `center`,
174
+ paddingVertical: `5%`,
175
+ paddingHorizontal: `3%`,
176
+ marginTop: `5%`,
177
+ borderRadius: height / 80,
178
+ borderWidth: height / 300,
179
+ borderColor: colors.teal,
180
+ },
181
+ suggestedContainer: { justifyContent: `center`, flexDirection: `row`, marginBottom: `3%` },
182
+ suggestedCarbs: { color: `white`, fontSize: sugestionFontSize },
183
+ textCenter: { textAlign: `center` },
184
+ recommendEatingText: {
185
+ color: colors.dustyBlue,
186
+ fontSize: recommendEatingFontSize,
187
+ textAlign: `center`,
188
+ },
189
+ carbohydrateText: { color: `white`, fontSize: sugestionFontSize },
190
+ addToCalculation: { color: `white`, fontSize: textFontSize, textAlign: `center` },
191
+ recommendationButtonsContainer: { justifyContent: `center`, flexDirection: `row`, margin: `3%` },
192
+ affirmativeCarbsText: { color: colors.teal, fontSize: buttonFontSize, textAlign: `center` },
193
+ negativeCarbsText: { color: `white`, fontSize: buttonFontSize, textAlign: `center` },
194
+ affirmativeCarbsButton: {
195
+ marginTop: `2%`,
196
+ borderRadius: buttonBorderRadius,
197
+ borderWidth: buttonBorderWidth,
198
+ borderColor: colors.teal,
199
+ width: buttonWidth,
200
+ height: buttonHeight,
201
+ alignSelf: `center`,
202
+ justifyContent: `center`,
203
+ marginRight: `2%`,
204
+ },
205
+ negativeCarbsButton: {
206
+ marginTop: `2%`,
207
+ borderRadius: buttonBorderRadius,
208
+ borderWidth: buttonBorderWidth,
209
+ borderColor: `white`,
210
+ width: buttonWidth,
211
+ height: buttonHeight,
212
+ alignSelf: `center`,
213
+ justifyContent: `center`,
214
+ marginLeft: `2%`,
215
+ },
216
+ okButton: {
217
+ marginTop: `6%`,
218
+ borderRadius: buttonBorderRadius,
219
+ borderWidth: buttonBorderWidth,
220
+ borderColor: colors.teal,
221
+ width: buttonWidth,
222
+ height: buttonHeight,
223
+ alignSelf: `center`,
224
+ justifyContent: `center`,
225
+ },
226
+ });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { Testing } from "../types/enum";
3
- declare const RecommendedCarbsTestIds: typeof Testing.Id.RecommendedCarbsTestIds;
4
3
  export interface ICalculationRow {
5
4
  label: string;
6
5
  value: string;
@@ -93,5 +92,3 @@ export default class RecommendedCarbs extends React.Component<IProps, IState> {
93
92
  */
94
93
  render(): JSX.Element;
95
94
  }
96
- export {};
97
- //# sourceMappingURL=RecommendedCarbs.d.ts.map
@@ -0,0 +1,251 @@
1
+ import { t } from "@lingui/macro";
2
+ import React from "react";
3
+ import { Alert, Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
4
+ import EditIcon from "../assets/icons/Edit";
5
+ import { i18n } from "../locale/i18nUtils";
6
+ import { Testing } from "../types/enum";
7
+ import { colors } from "../utils/Constants";
8
+ import { CarbohydrateLimitError } from "../utils/RecommendationError";
9
+ import Icon from "./Icon";
10
+ import { infoStyles } from "./InfoBars";
11
+ import InvisibleNumberInput from "./InvisibleNumberInput";
12
+ import LineSeparator from "./LineSeparator";
13
+ import TextBold from "./text/TextBold";
14
+ import TextRegular from "./text/TextRegular";
15
+ const { RecommendedCarbsTestIds } = Testing.Id;
16
+ /**
17
+ * The contents of the RecommendedCarbs component may vary quite a bit depending on data that was entered by the user
18
+ * and on the result of the recommendation calculation.
19
+ * For instance the part of the component that displays any recommendation of eating additional carbohydrates
20
+ * (composed by the renderRecommendedCarbs() method) will only be visible if it is actually recommended that the user eats additional carbohydrates.
21
+ */
22
+ export default class RecommendedCarbs extends React.Component {
23
+ /** Initialise the state partialInput variable with undefined */
24
+ state = {
25
+ partialInput: undefined,
26
+ };
27
+ /**
28
+ * Function taking no arguments and returning no value.
29
+ * Will be bound to the function that activates input for InvisibleNumberInput when that component has been mounted.
30
+ */
31
+ callbackInput;
32
+ /**
33
+ * Handle what should happen when the additional carbohydrates amount has been pressed.
34
+ * Uses the InvisibleNumberInput child component to enable the user to input the amount of additional carbohydrates that they are taking.
35
+ */
36
+ showTextInput = () => {
37
+ this.callbackInput?.();
38
+ };
39
+ /**
40
+ * Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
41
+ *
42
+ * Steps:
43
+ * 1. Save partialInput argument to the partialInput state variable.
44
+ * @param partialInput The contents of the input field.
45
+ */
46
+ handlePartialInput = (partialInput) => {
47
+ this.setState({
48
+ partialInput,
49
+ });
50
+ };
51
+ /**
52
+ * Handle what happens when input in the InvisibleNumberInput child component is completed.
53
+ *
54
+ * Steps:
55
+ * 1. If the carbs argument is greater than or equal to 0:
56
+ * - If the carbs argument is greater than 300:
57
+ * - Set the partialInput state variable to the value of the recommemdedCarbs prop.
58
+ * - Return - An alert message with the message of CarbohydrateLimitError() and with an OK button for closing it.
59
+ * - Use carbs as argument to call the changedRecommendedCarbs prop callback function.
60
+
61
+ * @param carbs The numerical value of the input field at completion.
62
+ * @returns void
63
+ */
64
+ handleChangedCarbs = (carbs) => {
65
+ if (carbs >= 0) {
66
+ if (carbs > 300) {
67
+ this.setState({ partialInput: this.props.recommendedCarbs });
68
+ return Alert.alert(i18n._(t `Attention`), CarbohydrateLimitError().message, [
69
+ {
70
+ text: i18n._(t `OK`),
71
+ },
72
+ ]);
73
+ }
74
+ this.props.changedRecommendedCarbs(carbs);
75
+ }
76
+ };
77
+ /**
78
+ * Render the section of the component that displays the extra carbs that the user should eat
79
+ * and allows the user to change the contents to indicate how many extra carbs they are actually going to eat.
80
+ *
81
+ * Steps:
82
+ * 1. Set a variable named shownCarbs to the partialInput state if it is set, or to the recommendedCarbs prop rounded to the nearest integer otherwise.
83
+ * 2. Set a variable named totalCarbs to the sum of the enteredCarbs prop and shownCarbs rounded to the nearest integer.
84
+ * 3. Compose and return a JSX element consisting of the following sub-components
85
+ * - A cancel button to remove recommended carbs from the calculation - When tapped, call the removeRecommendedCarbs prop callback function.
86
+ * - The text from the shownCarbs variable from step 1 - When tapped, call the showTextInput() method.
87
+ * - Use renderRow() to display the value of totalCarbs.
88
+ * - InvisibleNumberInput for showing the keyboard to enable the user to enter a number.
89
+ */
90
+ renderRecommendedCarbs = () => {
91
+ const shownCarbs = this.state.partialInput ?? Math.round(Number(this.props.recommendedCarbs));
92
+ const totalCarbs = Math.round(parseFloat(this.props.enteredCarbs) + Number(shownCarbs));
93
+ return (<>
94
+ <LineSeparator color={colors.fadeBlue}/>
95
+ <View style={calculationStyles.borderContainer}>
96
+ <View style={calculationStyles.recommendedContainer}>
97
+ <TouchableOpacity testID={RecommendedCarbsTestIds.RemoveRecommendation} style={calculationStyles.removeRecommended} onPress={this.props.removeRecommendedCarbs}>
98
+ <Icon iconIdentifier={`Ionicons/ios-close-circle-outline`} style={calculationStyles.removeRecommendedIcon}/>
99
+ </TouchableOpacity>
100
+ <TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Recommended`)}</TextBold>
101
+ </View>
102
+ </View>
103
+ <View style={calculationStyles.borderContainer}>
104
+ <View style={calculationStyles.recommendedContainer}>
105
+ <TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Additional`)}</TextBold>
106
+ </View>
107
+ <View style={calculationStyles.valueUnitContainer}>
108
+ <TouchableOpacity testID={RecommendedCarbsTestIds.EditRecommendedCarbs} onPress={this.showTextInput} style={[calculationStyles.valueUnitContainer]}>
109
+ <View style={calculationStyles.valueContainer}>
110
+ <TextBold testID={RecommendedCarbsTestIds.RecommendedCarbs} style={{ ...calculationStyles.value, color: colors.teal }}>
111
+ {shownCarbs}
112
+ </TextBold>
113
+ </View>
114
+ <View style={[calculationStyles.unitContainer]}>
115
+ <View style={calculationStyles.editIconContainer}>
116
+ <EditIcon />
117
+ </View>
118
+ <TextRegular style={{ ...calculationStyles.units, color: colors.teal }}>
119
+ {i18n._(t `grams`)}
120
+ </TextRegular>
121
+ </View>
122
+ </TouchableOpacity>
123
+ </View>
124
+ </View>
125
+ <LineSeparator color={colors.fadeBlue}/>
126
+ {this.renderRow({
127
+ label: i18n._(t `Total`),
128
+ value: totalCarbs.toString(),
129
+ units: i18n._(t `grams`),
130
+ }, RecommendedCarbsTestIds.TotalCarbs)}
131
+ <InvisibleNumberInput testID={RecommendedCarbsTestIds.InvisibleCarbInput} negativeAllowed={false} cleanPartialInput={true} decimalPlaces={0} visible={(callback) => (this.callbackInput = callback)} partialInput={this.handlePartialInput} onEnd={this.handleChangedCarbs} startValue={this.props.recommendedCarbs} maxLength={3}/>
132
+ </>);
133
+ };
134
+ /**
135
+ * Display a row of information for the user. Specifically used to display the amount of carbohydrates that the user has entered.
136
+ * @param row The values to display
137
+ * @param testID Id used for component testing
138
+ * @returns A JSX element to display 3 strings on the screen: label, value, and a unit.
139
+ */
140
+ renderRow = (row, testID) => {
141
+ return (<View style={calculationStyles.borderContainer}>
142
+ <View style={calculationStyles.rowContainer}>
143
+ <TextBold style={calculationStyles.rowLabel}>{row.label}</TextBold>
144
+ </View>
145
+ <View style={calculationStyles.valueUnitContainer}>
146
+ <View style={calculationStyles.valueContainer}>
147
+ <TextBold testID={testID} style={calculationStyles.value}>
148
+ {row.value}
149
+ </TextBold>
150
+ </View>
151
+ <View style={calculationStyles.unitContainer}>
152
+ <TextRegular style={calculationStyles.units}>{row.units}</TextRegular>
153
+ </View>
154
+ </View>
155
+ </View>);
156
+ };
157
+ /**
158
+ * Steps:
159
+ * 1. Convert the recommendedCarbs prop to a number and save that as a variable named carbs.
160
+ * 2. Use renderRow() to display the user’s entered amount of carbohydrates
161
+ * 3. If carbs is not a NaN-value and it is positive, call renderRecommendedCarbs() to display the carbohydrate recommendation.
162
+ */
163
+ render() {
164
+ const carbs = Number(this.props.recommendedCarbs);
165
+ return (<>
166
+ <View style={calculationStyles.foodTitleContainer}>
167
+ <TextBold style={infoStyles.label}>{i18n._(t `Food`)}</TextBold>
168
+ <TextRegular style={calculationStyles.foodUnitsLabel}>
169
+ {`(${i18n._(t `Carbohydrates`)})`}
170
+ </TextRegular>
171
+ </View>
172
+ {this.renderRow({
173
+ label: i18n._(t `Entered`),
174
+ value: this.props.enteredCarbs,
175
+ units: i18n._(t `grams`),
176
+ }, RecommendedCarbsTestIds.EnteredCarbs)}
177
+ {!isNaN(carbs) && carbs > 0 ? this.renderRecommendedCarbs() : null}
178
+ </>);
179
+ }
180
+ }
181
+ const { width } = Dimensions.get(`screen`);
182
+ const calculationStyles = StyleSheet.create({
183
+ borderContainer: {
184
+ ...infoStyles.borderContainer,
185
+ alignItems: `center`,
186
+ },
187
+ foodTitleContainer: {
188
+ flex: infoStyles.borderContainer.flex,
189
+ flexDirection: infoStyles.borderContainer.flexDirection,
190
+ paddingHorizontal: infoStyles.borderContainer.paddingHorizontal,
191
+ alignItems: `center`,
192
+ paddingVertical: `2%`,
193
+ },
194
+ foodUnitsLabel: {
195
+ ...infoStyles.units,
196
+ color: colors.fadeBlue,
197
+ paddingLeft: `1%`,
198
+ },
199
+ rowContainer: {
200
+ flex: 7,
201
+ },
202
+ rowLabel: {
203
+ color: `white`,
204
+ fontSize: width / 25,
205
+ },
206
+ enteredContainer: {
207
+ flex: 3,
208
+ alignItems: `flex-end`,
209
+ },
210
+ entered: {
211
+ color: `white`,
212
+ fontSize: width / 23,
213
+ },
214
+ valueUnitContainer: {
215
+ ...infoStyles.valueUnitContainer,
216
+ },
217
+ valueContainer: {
218
+ ...infoStyles.valueContainer,
219
+ },
220
+ value: {
221
+ ...infoStyles.value,
222
+ },
223
+ unitContainer: {
224
+ ...infoStyles.unitContainer,
225
+ },
226
+ units: {
227
+ ...infoStyles.units,
228
+ },
229
+ editIconContainer: {
230
+ paddingLeft: `20%`,
231
+ },
232
+ recommendedContainer: {
233
+ flex: 7,
234
+ flexDirection: `row`,
235
+ },
236
+ recommendedLabel: {
237
+ color: colors.teal,
238
+ fontSize: width / 25,
239
+ alignSelf: `center`,
240
+ },
241
+ removeRecommended: {
242
+ justifyContent: `center`,
243
+ marginRight: `1%`,
244
+ marginTop: `1%`,
245
+ },
246
+ removeRecommendedIcon: {
247
+ color: colors.teal,
248
+ fontSize: width / 20,
249
+ paddingBottom: `0.5%`,
250
+ },
251
+ });
@@ -1,5 +1,5 @@
1
- import React from "react";
2
1
  import { UserSettings } from "@hedia/types";
2
+ import React from "react";
3
3
  export interface IProps {
4
4
  /** The amount of insulin in units to display to the user as a recommendation. */
5
5
  insulinRecommendation: number;
@@ -82,4 +82,3 @@ export default class RecommendedInsulin extends React.Component<IProps, IState>
82
82
  */
83
83
  render: () => JSX.Element;
84
84
  }
85
- //# sourceMappingURL=RecommendedInsulin.d.ts.map
@@ -0,0 +1,180 @@
1
+ import { BolusCalculator } from "@hedia/types";
2
+ import { t } from "@lingui/macro";
3
+ import React from "react";
4
+ import { Alert, Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
5
+ import LinearGradient from "react-native-linear-gradient";
6
+ import EditIcon from "../assets/icons/Edit";
7
+ import { i18n } from "../locale/i18nUtils";
8
+ import { Testing } from "../types/enum";
9
+ import { Messages } from "../utils/AttentionMessages";
10
+ import { colors } from "../utils/Constants";
11
+ import { Utils } from "../utils/Utils";
12
+ import InvisibleNumberInput from "./InvisibleNumberInput";
13
+ import TextBold from "./text/TextBold";
14
+ import TextRegular from "./text/TextRegular";
15
+ const { RecommendedInsulinTestIds } = Testing.Id;
16
+ const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
17
+ /** Input field for displaying the entered amount of insulin (which defaults to HDA’s recommendation) and allowing the user to edit it. */
18
+ export default class RecommendedInsulin extends React.Component {
19
+ /** Initialise the state partialInput variable with undefined */
20
+ state = {
21
+ partialInput: undefined,
22
+ };
23
+ /**
24
+ * Function taking no arguments and returning no value.
25
+ * Will be bound to the function that activates input for InvisibleNumberInput when that component has been mounted.
26
+ */
27
+ callbackInput;
28
+ /**
29
+ * Called immediately after updating occurs. Not called for the initial render.
30
+ * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
31
+ *
32
+ * Steps:
33
+ * 1. If the value of the enteredInsulin prop was changed, set the partialInput state variable to the new value.
34
+ * @param prevProps The previous component props
35
+ */
36
+ componentDidUpdate(prevProps) {
37
+ const { enteredInsulin } = this.props;
38
+ if (prevProps.enteredInsulin !== enteredInsulin) {
39
+ this.setState({ partialInput: enteredInsulin?.toString() });
40
+ }
41
+ }
42
+ /**
43
+ * Handle what should happen when the InsulinRecommendation component has been pressed.
44
+ * Uses the InvisibleNumberInput child component to enable the user to input the amount of insulin that hey are taking.
45
+ *
46
+ * Steps:
47
+ * 1. Call the callbackInput() member method.
48
+ */
49
+ handleOnPress = () => {
50
+ this.callbackInput?.();
51
+ };
52
+ /**
53
+ * Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
54
+ *
55
+ * Steps:
56
+ * 1. Assign a new local variable, replacedZero, with the value of the insulin argument string
57
+ * except for the first character if insulin is longer than 1 character and starts with a '0' but doesn’t start with ‘0.’.
58
+ * Otherwise set it to insulin. This would be better handled by converting it to a number: replacedZero = Number(insulin);
59
+ * 2. Save replacedZero to the partialInput state variable.
60
+ * 3. Return replacedZero
61
+ * @param insulin The contents of the input field.
62
+ * @returns The partially cleaned input.
63
+ */
64
+ updatePartially = (insulin) => {
65
+ const replacedZero = insulin.length > 1 && insulin.startsWith(`0`) && !insulin.startsWith(`0.`) ? insulin.substring(1) : insulin;
66
+ this.setState({
67
+ partialInput: replacedZero,
68
+ });
69
+ return replacedZero;
70
+ };
71
+ /**
72
+ * Handle what happens when input in the InvisibleNumberInput child component is completed.
73
+ *
74
+ * Steps:
75
+ * 1. Get the rounded insulin amount using the value argument and the injectionMethod prop as arguments for the Utils.roundValue() function.
76
+ * 2. Get the adjusted safety insulin limit (due to activity) by multiplying the activity reduction factor (which is 1 minus the activityReduction prop) with the SAFETY_INSULIN_LIMIT constant.
77
+ * 3. If the rounded value exceeds the adjusted safety threshold:
78
+ * - Call the updatePartially() method with the adjusted safety threshold to set the insulin amount to the capped value.
79
+ * - Return an Alert with a message about the insulin limit.
80
+ * 4. Call the updatePartially() method with the rounded value to set the entered insulin value.
81
+ * 5. Call the updateRecommendedInsulin callback function prop with rounded as the argument to report back the updated insulin amount to the parent RecommendationScreen component.
82
+ * @param value The numerical value of the input field at completion.
83
+ */
84
+ handleUpdatedInsulin = (value) => {
85
+ const rounded = Utils.roundValue(value, this.props.injectionMethod);
86
+ // https://hedia.atlassian.net/browse/HDA-795
87
+ const limited = (1 - (this.props.activityReduction ?? 0)) * SAFETY_INSULIN_LIMIT;
88
+ if (rounded > limited) {
89
+ this.setState({ partialInput: this.props.insulinRecommendation?.toString() ?? null });
90
+ this.props.updateRecommendedInsulin(this.props.insulinRecommendation);
91
+ return Alert.alert(i18n._(t `Attention`), Messages.InsulinInputWasLimited(this.props.activityReduction), [
92
+ {
93
+ text: i18n._(t `OK`),
94
+ },
95
+ ]);
96
+ }
97
+ this.updatePartially(`${rounded}`);
98
+ this.props.updateRecommendedInsulin(rounded);
99
+ };
100
+ /**
101
+ * Render a JSX element to display the insulin input field with the current insulin amount value
102
+ * and using an InvisibleNumberInput component to enable input when the insulin amount is tapped.
103
+ */
104
+ render = () => {
105
+ const shownInsulin = this.state.partialInput ?? this.props.insulinRecommendation ?? `0`;
106
+ const { container, editText, title, recommendedContainer, valueContainer, value, units, editButton } = styles;
107
+ return (<>
108
+ <TouchableOpacity testID={RecommendedInsulinTestIds.EditRecommendedInsulin} onPress={this.handleOnPress}>
109
+ <LinearGradient style={container} colors={[colors.purple, colors.blue]} useAngle={true} angle={315}>
110
+ <TextBold style={title}>{i18n._(t `Recommended amount of insulin`)}</TextBold>
111
+ <View style={recommendedContainer}>
112
+ <View style={valueContainer}>
113
+ <TextBold style={value} testID={RecommendedInsulinTestIds.ShownInsulinText}>
114
+ {shownInsulin}
115
+ </TextBold>
116
+ <TextRegular style={units}>{i18n._(t `Units`)}</TextRegular>
117
+ </View>
118
+ <View testID={RecommendedInsulinTestIds.EditRecommendedInsulinIcon} style={editButton}>
119
+ <EditIcon />
120
+ <TextRegular style={editText}>{i18n._(t `Edit`)}</TextRegular>
121
+ </View>
122
+ </View>
123
+ </LinearGradient>
124
+ </TouchableOpacity>
125
+
126
+ <InvisibleNumberInput testID={RecommendedInsulinTestIds.InvisibleInsulinInput} decimalPlaces={3} negativeAllowed={false} cleanPartialInput={false} partialInput={this.updatePartially} onEnd={this.handleUpdatedInsulin} visible={(visible) => (this.callbackInput = visible)} startValue={`${shownInsulin}`}/>
127
+ </>);
128
+ };
129
+ }
130
+ const { width } = Dimensions.get(`screen`);
131
+ const styles = StyleSheet.create({
132
+ container: {
133
+ marginHorizontal: width / 17,
134
+ marginTop: width / 35,
135
+ borderRadius: 5,
136
+ paddingTop: width / 30,
137
+ },
138
+ title: {
139
+ fontFamily: `Poppins-Bold`,
140
+ fontSize: width / 28,
141
+ lineHeight: width / 19,
142
+ color: `white`,
143
+ textAlign: `center`,
144
+ paddingHorizontal: width / 12,
145
+ },
146
+ recommendedContainer: {
147
+ marginHorizontal: width / 12,
148
+ alignContent: `center`,
149
+ },
150
+ valueContainer: {
151
+ flexDirection: `row`,
152
+ justifyContent: `center`,
153
+ },
154
+ value: {
155
+ fontFamily: `Poppins-Bold`,
156
+ color: `white`,
157
+ fontSize: width / 6,
158
+ lineHeight: width / 4,
159
+ marginLeft: width / 15,
160
+ },
161
+ units: {
162
+ alignSelf: `flex-end`,
163
+ color: `white`,
164
+ fontSize: width / 28,
165
+ paddingBottom: `8%`,
166
+ marginLeft: width / 100,
167
+ },
168
+ editButton: {
169
+ position: `absolute`,
170
+ flexDirection: `row`,
171
+ right: width / 20,
172
+ top: width / 16,
173
+ },
174
+ editText: {
175
+ fontSize: width / 28,
176
+ color: `white`,
177
+ opacity: 0.8,
178
+ marginLeft: width / 80,
179
+ },
180
+ });