@hedia/recommendation-screen 2.1.73 → 2.1.74-alpha.0

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 (408) hide show
  1. package/lib/commonjs/RecommendationScreen.js +768 -0
  2. package/lib/commonjs/RecommendationScreen.js.map +1 -0
  3. package/lib/commonjs/assets/IconsSVG/Close.js +20 -0
  4. package/lib/commonjs/assets/IconsSVG/Close.js.map +1 -0
  5. package/lib/commonjs/assets/IconsSVG/CloseOutlined.js +28 -0
  6. package/lib/commonjs/assets/IconsSVG/CloseOutlined.js.map +1 -0
  7. package/lib/commonjs/assets/IconsSVG/Edit.js +23 -0
  8. package/lib/commonjs/assets/IconsSVG/Edit.js.map +1 -0
  9. package/lib/commonjs/assets/IconsSVG/activity/Cycling.js +43 -0
  10. package/lib/commonjs/assets/IconsSVG/activity/Cycling.js.map +1 -0
  11. package/lib/commonjs/assets/IconsSVG/activity/Running.js +33 -0
  12. package/lib/commonjs/assets/IconsSVG/activity/Running.js.map +1 -0
  13. package/lib/commonjs/assets/IconsSVG/activity/Stretching.js +33 -0
  14. package/lib/commonjs/assets/IconsSVG/activity/Stretching.js.map +1 -0
  15. package/lib/commonjs/assets/IconsSVG/activity/Swimming.js +48 -0
  16. package/lib/commonjs/assets/IconsSVG/activity/Swimming.js.map +1 -0
  17. package/lib/commonjs/assets/IconsSVG/activity/Walking.js +38 -0
  18. package/lib/commonjs/assets/IconsSVG/activity/Walking.js.map +1 -0
  19. package/lib/commonjs/assets/IconsSVG/mood/Happy.js +34 -0
  20. package/lib/commonjs/assets/IconsSVG/mood/Happy.js.map +1 -0
  21. package/lib/commonjs/assets/IconsSVG/mood/Neutral.js +34 -0
  22. package/lib/commonjs/assets/IconsSVG/mood/Neutral.js.map +1 -0
  23. package/lib/commonjs/assets/IconsSVG/mood/Sad.js +34 -0
  24. package/lib/commonjs/assets/IconsSVG/mood/Sad.js.map +1 -0
  25. package/lib/commonjs/assets/IconsSVG/mood/SemiHappy.js +34 -0
  26. package/lib/commonjs/assets/IconsSVG/mood/SemiHappy.js.map +1 -0
  27. package/lib/commonjs/assets/IconsSVG/mood/SemiSad.js +34 -0
  28. package/lib/commonjs/assets/IconsSVG/mood/SemiSad.js.map +1 -0
  29. package/lib/commonjs/components/ExitModal.js +124 -0
  30. package/lib/commonjs/components/ExitModal.js.map +1 -0
  31. package/lib/commonjs/components/InfoBars.js +123 -0
  32. package/lib/commonjs/components/InfoBars.js.map +1 -0
  33. package/lib/commonjs/components/InvisibleNumberInput.js +150 -0
  34. package/lib/commonjs/components/InvisibleNumberInput.js.map +1 -0
  35. package/lib/commonjs/components/LineSeparator.js +27 -0
  36. package/lib/commonjs/components/LineSeparator.js.map +1 -0
  37. package/lib/commonjs/components/RecentInsulin.js +105 -0
  38. package/lib/commonjs/components/RecentInsulin.js.map +1 -0
  39. package/lib/commonjs/components/RecommendationModal.js +302 -0
  40. package/lib/commonjs/components/RecommendationModal.js.map +1 -0
  41. package/lib/commonjs/components/RecommendedCarbs.js +289 -0
  42. package/lib/commonjs/components/RecommendedCarbs.js.map +1 -0
  43. package/lib/commonjs/components/RecommendedInsulin.js +208 -0
  44. package/lib/commonjs/components/RecommendedInsulin.js.map +1 -0
  45. package/lib/commonjs/components/Remeasure.js +131 -0
  46. package/lib/commonjs/components/Remeasure.js.map +1 -0
  47. package/lib/commonjs/components/Text.js +25 -0
  48. package/lib/commonjs/components/Text.js.map +1 -0
  49. package/lib/commonjs/components/TimeoutModal.js +113 -0
  50. package/lib/commonjs/components/TimeoutModal.js.map +1 -0
  51. package/lib/commonjs/components/TransferToLogbook.js +83 -0
  52. package/lib/commonjs/components/TransferToLogbook.js.map +1 -0
  53. package/lib/commonjs/components/activity/Activity.js +112 -0
  54. package/lib/commonjs/components/activity/Activity.js.map +1 -0
  55. package/lib/commonjs/components/activity/ActivityIcon.js +86 -0
  56. package/lib/commonjs/components/activity/ActivityIcon.js.map +1 -0
  57. package/lib/commonjs/components/activity/ActivityIntensity.js +65 -0
  58. package/lib/commonjs/components/activity/ActivityIntensity.js.map +1 -0
  59. package/lib/commonjs/components/mood/Emotion.js +86 -0
  60. package/lib/commonjs/components/mood/Emotion.js.map +1 -0
  61. package/lib/commonjs/components/mood/MoodIcon.js +107 -0
  62. package/lib/commonjs/components/mood/MoodIcon.js.map +1 -0
  63. package/lib/commonjs/components/styles/fonts.js +154 -0
  64. package/lib/commonjs/components/styles/fonts.js.map +1 -0
  65. package/lib/commonjs/index.js +21 -0
  66. package/lib/commonjs/index.js.map +1 -0
  67. package/lib/commonjs/locales/da/translations.json +82 -0
  68. package/lib/commonjs/locales/de/translations.json +81 -0
  69. package/lib/commonjs/locales/en/translations.json +84 -0
  70. package/lib/commonjs/locales/es/translations.json +81 -0
  71. package/lib/commonjs/locales/fr/translations.json +81 -0
  72. package/lib/commonjs/locales/it/translations.json +81 -0
  73. package/lib/commonjs/locales/translate.js +63 -0
  74. package/lib/commonjs/locales/translate.js.map +1 -0
  75. package/lib/commonjs/types/enum.js +179 -0
  76. package/lib/commonjs/types/enum.js.map +1 -0
  77. package/lib/commonjs/types/types.js +6 -0
  78. package/lib/commonjs/types/types.js.map +1 -0
  79. package/lib/commonjs/utils/AttentionMessages.js +141 -0
  80. package/lib/commonjs/utils/AttentionMessages.js.map +1 -0
  81. package/lib/commonjs/utils/Constants.js +138 -0
  82. package/lib/commonjs/utils/Constants.js.map +1 -0
  83. package/lib/commonjs/utils/RecommendationError.js +116 -0
  84. package/lib/commonjs/utils/RecommendationError.js.map +1 -0
  85. package/lib/commonjs/utils/RecommendationUtils.js +212 -0
  86. package/lib/commonjs/utils/RecommendationUtils.js.map +1 -0
  87. package/lib/commonjs/utils/Translations.js +22 -0
  88. package/lib/commonjs/utils/Translations.js.map +1 -0
  89. package/lib/commonjs/utils/Utils.js +162 -0
  90. package/lib/commonjs/utils/Utils.js.map +1 -0
  91. package/lib/commonjs/utils/Validations.js +468 -0
  92. package/lib/commonjs/utils/Validations.js.map +1 -0
  93. package/lib/module/RecommendationScreen.js +758 -0
  94. package/lib/module/RecommendationScreen.js.map +1 -0
  95. package/lib/module/assets/IconsSVG/Close.js +11 -0
  96. package/lib/module/assets/IconsSVG/Close.js.map +1 -0
  97. package/lib/module/assets/IconsSVG/CloseOutlined.js +19 -0
  98. package/lib/module/assets/IconsSVG/CloseOutlined.js.map +1 -0
  99. package/lib/module/assets/IconsSVG/Edit.js +14 -0
  100. package/lib/module/assets/IconsSVG/Edit.js.map +1 -0
  101. package/lib/module/assets/IconsSVG/activity/Cycling.js +34 -0
  102. package/lib/module/assets/IconsSVG/activity/Cycling.js.map +1 -0
  103. package/lib/module/assets/IconsSVG/activity/Running.js +24 -0
  104. package/lib/module/assets/IconsSVG/activity/Running.js.map +1 -0
  105. package/lib/module/assets/IconsSVG/activity/Stretching.js +24 -0
  106. package/lib/module/assets/IconsSVG/activity/Stretching.js.map +1 -0
  107. package/lib/module/assets/IconsSVG/activity/Swimming.js +39 -0
  108. package/lib/module/assets/IconsSVG/activity/Swimming.js.map +1 -0
  109. package/lib/module/assets/IconsSVG/activity/Walking.js +29 -0
  110. package/lib/module/assets/IconsSVG/activity/Walking.js.map +1 -0
  111. package/lib/module/assets/IconsSVG/mood/Happy.js +25 -0
  112. package/lib/module/assets/IconsSVG/mood/Happy.js.map +1 -0
  113. package/lib/module/assets/IconsSVG/mood/Neutral.js +25 -0
  114. package/lib/module/assets/IconsSVG/mood/Neutral.js.map +1 -0
  115. package/lib/module/assets/IconsSVG/mood/Sad.js +25 -0
  116. package/lib/module/assets/IconsSVG/mood/Sad.js.map +1 -0
  117. package/lib/module/assets/IconsSVG/mood/SemiHappy.js +25 -0
  118. package/lib/module/assets/IconsSVG/mood/SemiHappy.js.map +1 -0
  119. package/lib/module/assets/IconsSVG/mood/SemiSad.js +25 -0
  120. package/lib/module/assets/IconsSVG/mood/SemiSad.js.map +1 -0
  121. package/lib/module/components/ExitModal.js +114 -0
  122. package/lib/module/components/ExitModal.js.map +1 -0
  123. package/lib/module/components/InfoBars.js +114 -0
  124. package/lib/module/components/InfoBars.js.map +1 -0
  125. package/lib/module/components/InvisibleNumberInput.js +142 -0
  126. package/lib/module/components/InvisibleNumberInput.js.map +1 -0
  127. package/lib/module/components/LineSeparator.js +19 -0
  128. package/lib/module/components/LineSeparator.js.map +1 -0
  129. package/lib/module/components/RecentInsulin.js +97 -0
  130. package/lib/module/components/RecentInsulin.js.map +1 -0
  131. package/lib/module/components/RecommendationModal.js +291 -0
  132. package/lib/module/components/RecommendationModal.js.map +1 -0
  133. package/lib/module/components/RecommendedCarbs.js +281 -0
  134. package/lib/module/components/RecommendedCarbs.js.map +1 -0
  135. package/lib/module/components/RecommendedInsulin.js +200 -0
  136. package/lib/module/components/RecommendedInsulin.js.map +1 -0
  137. package/lib/module/components/Remeasure.js +123 -0
  138. package/lib/module/components/Remeasure.js.map +1 -0
  139. package/lib/module/components/Text.js +16 -0
  140. package/lib/module/components/Text.js.map +1 -0
  141. package/lib/module/components/TimeoutModal.js +103 -0
  142. package/lib/module/components/TimeoutModal.js.map +1 -0
  143. package/lib/module/components/TransferToLogbook.js +75 -0
  144. package/lib/module/components/TransferToLogbook.js.map +1 -0
  145. package/lib/module/components/activity/Activity.js +104 -0
  146. package/lib/module/components/activity/Activity.js.map +1 -0
  147. package/lib/module/components/activity/ActivityIcon.js +78 -0
  148. package/lib/module/components/activity/ActivityIcon.js.map +1 -0
  149. package/lib/module/components/activity/ActivityIntensity.js +57 -0
  150. package/lib/module/components/activity/ActivityIntensity.js.map +1 -0
  151. package/lib/module/components/mood/Emotion.js +78 -0
  152. package/lib/module/components/mood/Emotion.js.map +1 -0
  153. package/lib/module/components/mood/MoodIcon.js +97 -0
  154. package/lib/module/components/mood/MoodIcon.js.map +1 -0
  155. package/lib/module/components/styles/fonts.js +145 -0
  156. package/lib/module/components/styles/fonts.js.map +1 -0
  157. package/lib/module/index.js +5 -0
  158. package/lib/module/index.js.map +1 -0
  159. package/lib/module/locales/da/translations.json +82 -0
  160. package/lib/module/locales/de/translations.json +81 -0
  161. package/lib/module/locales/en/translations.json +84 -0
  162. package/lib/module/locales/es/translations.json +81 -0
  163. package/lib/module/locales/fr/translations.json +81 -0
  164. package/lib/module/locales/it/translations.json +81 -0
  165. package/lib/module/locales/translate.js +55 -0
  166. package/lib/module/locales/translate.js.map +1 -0
  167. package/lib/module/types/enum.js +170 -0
  168. package/lib/module/types/enum.js.map +1 -0
  169. package/lib/module/types/types.js.map +1 -0
  170. package/lib/module/utils/AttentionMessages.js +131 -0
  171. package/lib/module/utils/AttentionMessages.js.map +1 -0
  172. package/{dist/src → lib/module}/utils/Constants.js +78 -35
  173. package/lib/module/utils/Constants.js.map +1 -0
  174. package/{dist/src → lib/module}/utils/RecommendationError.js +28 -6
  175. package/lib/module/utils/RecommendationError.js.map +1 -0
  176. package/{dist/src → lib/module}/utils/RecommendationUtils.js +89 -90
  177. package/lib/module/utils/RecommendationUtils.js.map +1 -0
  178. package/{dist/src → lib/module}/utils/Translations.js +5 -3
  179. package/lib/module/utils/Translations.js.map +1 -0
  180. package/lib/module/utils/Utils.js +155 -0
  181. package/lib/module/utils/Utils.js.map +1 -0
  182. package/{dist/src → lib/module}/utils/Validations.js +155 -128
  183. package/lib/module/utils/Validations.js.map +1 -0
  184. package/{dist/src → lib/typescript}/RecommendationScreen.d.ts +2 -1
  185. package/lib/typescript/RecommendationScreen.d.ts.map +1 -0
  186. package/{dist/src → lib/typescript}/assets/IconsSVG/Close.d.ts +1 -0
  187. package/lib/typescript/assets/IconsSVG/Close.d.ts.map +1 -0
  188. package/{dist/src → lib/typescript}/assets/IconsSVG/CloseOutlined.d.ts +1 -0
  189. package/lib/typescript/assets/IconsSVG/CloseOutlined.d.ts.map +1 -0
  190. package/{dist/src → lib/typescript}/assets/IconsSVG/Edit.d.ts +1 -0
  191. package/lib/typescript/assets/IconsSVG/Edit.d.ts.map +1 -0
  192. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Cycling.d.ts +1 -0
  193. package/lib/typescript/assets/IconsSVG/activity/Cycling.d.ts.map +1 -0
  194. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Running.d.ts +1 -0
  195. package/lib/typescript/assets/IconsSVG/activity/Running.d.ts.map +1 -0
  196. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Stretching.d.ts +1 -0
  197. package/lib/typescript/assets/IconsSVG/activity/Stretching.d.ts.map +1 -0
  198. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Swimming.d.ts +1 -0
  199. package/lib/typescript/assets/IconsSVG/activity/Swimming.d.ts.map +1 -0
  200. package/{dist/src → lib/typescript}/assets/IconsSVG/activity/Walking.d.ts +1 -0
  201. package/lib/typescript/assets/IconsSVG/activity/Walking.d.ts.map +1 -0
  202. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/Happy.d.ts +1 -0
  203. package/lib/typescript/assets/IconsSVG/mood/Happy.d.ts.map +1 -0
  204. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/Neutral.d.ts +1 -0
  205. package/lib/typescript/assets/IconsSVG/mood/Neutral.d.ts.map +1 -0
  206. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/Sad.d.ts +1 -0
  207. package/lib/typescript/assets/IconsSVG/mood/Sad.d.ts.map +1 -0
  208. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/SemiHappy.d.ts +1 -0
  209. package/lib/typescript/assets/IconsSVG/mood/SemiHappy.d.ts.map +1 -0
  210. package/{dist/src → lib/typescript}/assets/IconsSVG/mood/SemiSad.d.ts +1 -0
  211. package/lib/typescript/assets/IconsSVG/mood/SemiSad.d.ts.map +1 -0
  212. package/{dist/src → lib/typescript}/components/ExitModal.d.ts +1 -0
  213. package/lib/typescript/components/ExitModal.d.ts.map +1 -0
  214. package/{dist/src → lib/typescript}/components/InfoBars.d.ts +1 -0
  215. package/lib/typescript/components/InfoBars.d.ts.map +1 -0
  216. package/{dist/src → lib/typescript}/components/InvisibleNumberInput.d.ts +1 -0
  217. package/lib/typescript/components/InvisibleNumberInput.d.ts.map +1 -0
  218. package/{dist/src → lib/typescript}/components/LineSeparator.d.ts +1 -0
  219. package/lib/typescript/components/LineSeparator.d.ts.map +1 -0
  220. package/{dist/src → lib/typescript}/components/RecentInsulin.d.ts +1 -0
  221. package/lib/typescript/components/RecentInsulin.d.ts.map +1 -0
  222. package/{dist/src → lib/typescript}/components/RecommendationModal.d.ts +1 -0
  223. package/lib/typescript/components/RecommendationModal.d.ts.map +1 -0
  224. package/{dist/src → lib/typescript}/components/RecommendedCarbs.d.ts +1 -0
  225. package/lib/typescript/components/RecommendedCarbs.d.ts.map +1 -0
  226. package/{dist/src → lib/typescript}/components/RecommendedInsulin.d.ts +1 -0
  227. package/lib/typescript/components/RecommendedInsulin.d.ts.map +1 -0
  228. package/{dist/src → lib/typescript}/components/Remeasure.d.ts +1 -0
  229. package/lib/typescript/components/Remeasure.d.ts.map +1 -0
  230. package/{dist/src → lib/typescript}/components/Text.d.ts +1 -0
  231. package/lib/typescript/components/Text.d.ts.map +1 -0
  232. package/{dist/src → lib/typescript}/components/TimeoutModal.d.ts +1 -0
  233. package/lib/typescript/components/TimeoutModal.d.ts.map +1 -0
  234. package/{dist/src → lib/typescript}/components/TransferToLogbook.d.ts +1 -0
  235. package/lib/typescript/components/TransferToLogbook.d.ts.map +1 -0
  236. package/{dist/src → lib/typescript}/components/activity/Activity.d.ts +1 -0
  237. package/lib/typescript/components/activity/Activity.d.ts.map +1 -0
  238. package/{dist/src → lib/typescript}/components/activity/ActivityIcon.d.ts +1 -0
  239. package/lib/typescript/components/activity/ActivityIcon.d.ts.map +1 -0
  240. package/{dist/src → lib/typescript}/components/activity/ActivityIntensity.d.ts +1 -0
  241. package/lib/typescript/components/activity/ActivityIntensity.d.ts.map +1 -0
  242. package/{dist/src → lib/typescript}/components/mood/Emotion.d.ts +1 -0
  243. package/lib/typescript/components/mood/Emotion.d.ts.map +1 -0
  244. package/{dist/src → lib/typescript}/components/mood/MoodIcon.d.ts +1 -0
  245. package/lib/typescript/components/mood/MoodIcon.d.ts.map +1 -0
  246. package/{dist/src → lib/typescript}/components/styles/fonts.d.ts +1 -0
  247. package/lib/typescript/components/styles/fonts.d.ts.map +1 -0
  248. package/lib/typescript/index.d.ts +5 -0
  249. package/lib/typescript/index.d.ts.map +1 -0
  250. package/{dist/src → lib/typescript}/locales/translate.d.ts +1 -0
  251. package/lib/typescript/locales/translate.d.ts.map +1 -0
  252. package/{dist/src → lib/typescript}/types/enum.d.ts +1 -0
  253. package/lib/typescript/types/enum.d.ts.map +1 -0
  254. package/{dist/src → lib/typescript}/types/types.d.ts +1 -0
  255. package/lib/typescript/types/types.d.ts.map +1 -0
  256. package/{dist/src → lib/typescript}/utils/AttentionMessages.d.ts +1 -0
  257. package/lib/typescript/utils/AttentionMessages.d.ts.map +1 -0
  258. package/{dist/src → lib/typescript}/utils/Constants.d.ts +1 -0
  259. package/lib/typescript/utils/Constants.d.ts.map +1 -0
  260. package/{dist/src → lib/typescript}/utils/RecommendationError.d.ts +1 -0
  261. package/lib/typescript/utils/RecommendationError.d.ts.map +1 -0
  262. package/{dist/src → lib/typescript}/utils/RecommendationUtils.d.ts +1 -0
  263. package/lib/typescript/utils/RecommendationUtils.d.ts.map +1 -0
  264. package/{dist/src → lib/typescript}/utils/Translations.d.ts +1 -0
  265. package/lib/typescript/utils/Translations.d.ts.map +1 -0
  266. package/{dist/src → lib/typescript}/utils/Utils.d.ts +1 -0
  267. package/lib/typescript/utils/Utils.d.ts.map +1 -0
  268. package/{dist/src → lib/typescript}/utils/Validations.d.ts +1 -0
  269. package/lib/typescript/utils/Validations.d.ts.map +1 -0
  270. package/package.json +27 -7
  271. package/src/RecommendationScreen.tsx +854 -0
  272. package/src/assets/IconsSVG/Close.tsx +13 -0
  273. package/src/assets/IconsSVG/CloseOutlined.tsx +23 -0
  274. package/src/assets/IconsSVG/Edit.tsx +16 -0
  275. package/src/assets/IconsSVG/activity/Cycling.tsx +41 -0
  276. package/src/assets/IconsSVG/activity/Running.tsx +29 -0
  277. package/src/assets/IconsSVG/activity/Stretching.tsx +29 -0
  278. package/src/assets/IconsSVG/activity/Swimming.tsx +47 -0
  279. package/src/assets/IconsSVG/activity/Walking.tsx +35 -0
  280. package/src/assets/IconsSVG/mood/Happy.tsx +30 -0
  281. package/src/assets/IconsSVG/mood/Neutral.tsx +30 -0
  282. package/src/assets/IconsSVG/mood/Sad.tsx +30 -0
  283. package/src/assets/IconsSVG/mood/SemiHappy.tsx +30 -0
  284. package/src/assets/IconsSVG/mood/SemiSad.tsx +30 -0
  285. package/src/components/ExitModal.tsx +134 -0
  286. package/src/components/InfoBars.tsx +122 -0
  287. package/src/components/InvisibleNumberInput.tsx +170 -0
  288. package/src/components/LineSeparator.tsx +29 -0
  289. package/src/components/RecentInsulin.tsx +109 -0
  290. package/src/components/RecommendationModal.tsx +319 -0
  291. package/src/components/RecommendedCarbs.tsx +303 -0
  292. package/src/components/RecommendedInsulin.tsx +219 -0
  293. package/src/components/Remeasure.tsx +135 -0
  294. package/src/components/Text.tsx +27 -0
  295. package/src/components/TimeoutModal.tsx +121 -0
  296. package/src/components/TransferToLogbook.tsx +92 -0
  297. package/src/components/activity/Activity.tsx +107 -0
  298. package/src/components/activity/ActivityIcon.tsx +77 -0
  299. package/src/components/activity/ActivityIntensity.tsx +67 -0
  300. package/src/components/mood/Emotion.tsx +97 -0
  301. package/src/components/mood/MoodIcon.tsx +91 -0
  302. package/src/components/styles/fonts.ts +145 -0
  303. package/src/index.ts +5 -0
  304. package/src/locales/da/translations.json +82 -0
  305. package/src/locales/de/translations.json +81 -0
  306. package/src/locales/en/translations.json +84 -0
  307. package/src/locales/es/translations.json +81 -0
  308. package/src/locales/fr/translations.json +81 -0
  309. package/src/locales/it/translations.json +81 -0
  310. package/src/locales/translate.ts +62 -0
  311. package/src/types/enum.ts +164 -0
  312. package/src/types/types.ts +19 -0
  313. package/src/utils/AttentionMessages.ts +167 -0
  314. package/src/utils/Constants.ts +77 -0
  315. package/src/utils/RecommendationError.ts +182 -0
  316. package/src/utils/RecommendationUtils.ts +232 -0
  317. package/src/utils/Translations.ts +17 -0
  318. package/src/utils/Utils.ts +156 -0
  319. package/src/utils/Validations.ts +490 -0
  320. package/dist/index.d.ts +0 -5
  321. package/dist/index.js +0 -6
  322. package/dist/index.js.map +0 -1
  323. package/dist/src/RecommendationScreen.js +0 -537
  324. package/dist/src/RecommendationScreen.js.map +0 -1
  325. package/dist/src/assets/IconsSVG/Close.js +0 -7
  326. package/dist/src/assets/IconsSVG/Close.js.map +0 -1
  327. package/dist/src/assets/IconsSVG/CloseOutlined.js +0 -9
  328. package/dist/src/assets/IconsSVG/CloseOutlined.js.map +0 -1
  329. package/dist/src/assets/IconsSVG/Edit.js +0 -8
  330. package/dist/src/assets/IconsSVG/Edit.js.map +0 -1
  331. package/dist/src/assets/IconsSVG/activity/Cycling.js +0 -12
  332. package/dist/src/assets/IconsSVG/activity/Cycling.js.map +0 -1
  333. package/dist/src/assets/IconsSVG/activity/Running.js +0 -10
  334. package/dist/src/assets/IconsSVG/activity/Running.js.map +0 -1
  335. package/dist/src/assets/IconsSVG/activity/Stretching.js +0 -10
  336. package/dist/src/assets/IconsSVG/activity/Stretching.js.map +0 -1
  337. package/dist/src/assets/IconsSVG/activity/Swimming.js +0 -13
  338. package/dist/src/assets/IconsSVG/activity/Swimming.js.map +0 -1
  339. package/dist/src/assets/IconsSVG/activity/Walking.js +0 -11
  340. package/dist/src/assets/IconsSVG/activity/Walking.js.map +0 -1
  341. package/dist/src/assets/IconsSVG/mood/Happy.js +0 -11
  342. package/dist/src/assets/IconsSVG/mood/Happy.js.map +0 -1
  343. package/dist/src/assets/IconsSVG/mood/Neutral.js +0 -11
  344. package/dist/src/assets/IconsSVG/mood/Neutral.js.map +0 -1
  345. package/dist/src/assets/IconsSVG/mood/Sad.js +0 -11
  346. package/dist/src/assets/IconsSVG/mood/Sad.js.map +0 -1
  347. package/dist/src/assets/IconsSVG/mood/SemiHappy.js +0 -11
  348. package/dist/src/assets/IconsSVG/mood/SemiHappy.js.map +0 -1
  349. package/dist/src/assets/IconsSVG/mood/SemiSad.js +0 -11
  350. package/dist/src/assets/IconsSVG/mood/SemiSad.js.map +0 -1
  351. package/dist/src/components/ExitModal.js +0 -91
  352. package/dist/src/components/ExitModal.js.map +0 -1
  353. package/dist/src/components/InfoBars.js +0 -98
  354. package/dist/src/components/InfoBars.js.map +0 -1
  355. package/dist/src/components/InvisibleNumberInput.js +0 -123
  356. package/dist/src/components/InvisibleNumberInput.js.map +0 -1
  357. package/dist/src/components/LineSeparator.js +0 -17
  358. package/dist/src/components/LineSeparator.js.map +0 -1
  359. package/dist/src/components/RecentInsulin.js +0 -90
  360. package/dist/src/components/RecentInsulin.js.map +0 -1
  361. package/dist/src/components/RecommendationModal.js +0 -241
  362. package/dist/src/components/RecommendationModal.js.map +0 -1
  363. package/dist/src/components/RecommendedCarbs.js +0 -234
  364. package/dist/src/components/RecommendedCarbs.js.map +0 -1
  365. package/dist/src/components/RecommendedInsulin.js +0 -166
  366. package/dist/src/components/RecommendedInsulin.js.map +0 -1
  367. package/dist/src/components/Remeasure.js +0 -103
  368. package/dist/src/components/Remeasure.js.map +0 -1
  369. package/dist/src/components/Text.js +0 -14
  370. package/dist/src/components/Text.js.map +0 -1
  371. package/dist/src/components/TimeoutModal.js +0 -84
  372. package/dist/src/components/TimeoutModal.js.map +0 -1
  373. package/dist/src/components/TransferToLogbook.js +0 -68
  374. package/dist/src/components/TransferToLogbook.js.map +0 -1
  375. package/dist/src/components/activity/Activity.js +0 -93
  376. package/dist/src/components/activity/Activity.js.map +0 -1
  377. package/dist/src/components/activity/ActivityIcon.js +0 -66
  378. package/dist/src/components/activity/ActivityIcon.js.map +0 -1
  379. package/dist/src/components/activity/ActivityIntensity.js +0 -55
  380. package/dist/src/components/activity/ActivityIntensity.js.map +0 -1
  381. package/dist/src/components/mood/Emotion.js +0 -69
  382. package/dist/src/components/mood/Emotion.js.map +0 -1
  383. package/dist/src/components/mood/MoodIcon.js +0 -68
  384. package/dist/src/components/mood/MoodIcon.js.map +0 -1
  385. package/dist/src/components/styles/fonts.js +0 -145
  386. package/dist/src/components/styles/fonts.js.map +0 -1
  387. package/dist/src/locales/da/translations.json +0 -82
  388. package/dist/src/locales/de/translations.json +0 -81
  389. package/dist/src/locales/en/translations.json +0 -84
  390. package/dist/src/locales/es/translations.json +0 -81
  391. package/dist/src/locales/fr/translations.json +0 -81
  392. package/dist/src/locales/it/translations.json +0 -81
  393. package/dist/src/locales/translate.js +0 -53
  394. package/dist/src/locales/translate.js.map +0 -1
  395. package/dist/src/types/enum.js +0 -154
  396. package/dist/src/types/enum.js.map +0 -1
  397. package/dist/src/types/types.js.map +0 -1
  398. package/dist/src/utils/AttentionMessages.js +0 -123
  399. package/dist/src/utils/AttentionMessages.js.map +0 -1
  400. package/dist/src/utils/Constants.js.map +0 -1
  401. package/dist/src/utils/RecommendationError.js.map +0 -1
  402. package/dist/src/utils/RecommendationUtils.js.map +0 -1
  403. package/dist/src/utils/Translations.js.map +0 -1
  404. package/dist/src/utils/Utils.js +0 -142
  405. package/dist/src/utils/Utils.js.map +0 -1
  406. package/dist/src/utils/Validations.js.map +0 -1
  407. package/dist/tsconfig.tsbuildinfo +0 -1
  408. /package/{dist/src → lib/module}/types/types.js +0 -0
@@ -0,0 +1,170 @@
1
+ import React from "react";
2
+ import { EmitterSubscription, Keyboard, StyleSheet, TextInput } from "react-native";
3
+
4
+ export interface IProps {
5
+ /** The initial value to put in the input field. */
6
+ startValue?: string;
7
+ /** The precision with which the content of the input field may be displayed */
8
+ decimalPlaces: number;
9
+ /** Whether or not the clean method should be used on the content every time it is changed */
10
+ cleanPartialInput: boolean;
11
+ /** Whether or not negative values can be entered. */
12
+ negativeAllowed: boolean;
13
+ /** Max length of the content in the input field. */
14
+ maxLength?: number;
15
+ /** Test id used for component testing */
16
+ testID: string;
17
+ /** Callback function taking a function as argument - For passing a reference for the input field’s to the parent component. */
18
+ visible(toggle: () => void): void;
19
+ /** Callback function taking a number argument - To be called when the user finishes editing the invisible text field with the final numerical value as argument. */
20
+ onEnd?(value: number): void;
21
+ /** Callback function taking a string as input and not returning anything - To be called every time the content in the input field changes. */
22
+ partialInput?(value: string): void;
23
+ }
24
+
25
+ export interface IState {
26
+ /** For storing the value of the text input so it is available for handling in onEndEdit() when editing the text input ends. */
27
+ value: string;
28
+ }
29
+
30
+ /**
31
+ * InvisibleNumberInput is used to enable numerical input by the user without displaying a traditional input field on the screen.
32
+ * Since the input field is made invisible and thus can’t be tapped directly by the user we need to be able to call
33
+ * its focus() method from the parent component in order to activate the input field and show the keyboard.
34
+ * We do this by defining a function that calls the input field’s focus() method inside the InvisibleNumberInput component when it has been mounted.
35
+ * This function is then passed to the parent by giving it as the argument for a callback function named visible.
36
+ */
37
+ export default class InvisibleNumberInput extends React.Component<IProps, IState> {
38
+ keyboardDidHideSubscription: EmitterSubscription | null = null;
39
+ inputRef: React.RefObject<TextInput> | null = null;
40
+ constructor(props: IProps) {
41
+ super(props);
42
+ this.inputRef = React.createRef<TextInput>();
43
+ }
44
+
45
+ /** Initialise the state value variable with `0` */
46
+ public state: IState = {
47
+ value: `0`,
48
+ };
49
+
50
+ /**
51
+ * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
52
+ * Perform various initialisation steps:
53
+ * 1. Set the value state of the component to the startValue prop (or to '0' if it is undefined)
54
+ * 2. Call the visible callback function using an anonymous function as argument. The anonymous function shall do the following:
55
+ * - Set the value state of the InvisibleNumberInput component to the startValue prop (or to '0' if it is undefined)
56
+ * - Return the value from calling the focus() method on the input field.
57
+ */
58
+ public componentDidMount(): void {
59
+ this.keyboardDidHideSubscription = Keyboard.addListener(`keyboardDidHide`, this.callOnTextInputsBlur);
60
+ this.setState({
61
+ value: this.props.startValue ?? `0`,
62
+ });
63
+ this.props.visible((): void => {
64
+ this.setState({
65
+ value: this.props.startValue ?? `0`,
66
+ });
67
+ return this.inputRef?.current?.focus();
68
+ });
69
+ }
70
+
71
+ /**
72
+ * Call the blur method on the TextInput component.
73
+ */
74
+ public callOnTextInputsBlur = (): void => {
75
+ this.inputRef?.current?.blur();
76
+ };
77
+
78
+ /**
79
+ * Sanitise a user-entered value by removing invalid characters
80
+ *
81
+ * Steps:
82
+ * 1. Use regular expressions to make the following manipulations to the text argument in the defined order and save the result to a local string variable named replaced.
83
+ * - Replace any commas with periods
84
+ * - Remove any characters that comes after two groups of zero or more digits separated by a period.
85
+ * 2. Define a function named round that rounds a given string that contains a number to have the amount of decimals given by the decimalPlaces prop. Return the result as a string.
86
+ * 3. If the value of the replaced variable from step 1 is not a NaN (not a number) when converted to a Number type then use the round function defined in step 2 on replaced and return the result
87
+ * 4. (If the NaN-check from step 2 didn’t fail) return the string '0'.
88
+
89
+ * @param text The string input to clean up
90
+ * @returns A string with the cleaned text.
91
+ */
92
+ public cleanInput = (text: string): string => {
93
+ const replaced = text.replace(/,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
94
+ const round = (value: string): string => {
95
+ const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
96
+ const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
97
+ return rounded.toFixed(this.props.decimalPlaces);
98
+ };
99
+ if (!isNaN(Number(replaced))) {
100
+ return round(replaced);
101
+ }
102
+ return `0`;
103
+ };
104
+
105
+ /**
106
+ * Handle what happens when the text in the input field is being changed.
107
+ * That includes cleaning the text a little and then saving the value and potentially calling a callback function.
108
+ *
109
+ * Steps:
110
+ * 1. If the cleanPartialInput prop is true, use the cleanInput() method to to clean the content of the text argument and save it to a variable named cleaned.
111
+ * Otherwise just replace any commas in the text argument with periods and save the result to the same variable.
112
+ * 2. Remove repeated periods from the text in the cleaned variable and save the the result in a new variable named replacedSeparator.
113
+ * 3. Set the value state of the component to replacedSeparator.
114
+ * 4. If the partialInput callback function prop is defined, call it with replacedSeparator as argument.
115
+ * @param text The updated text in the input field
116
+ */
117
+ public handleOnChangeText = (text: string): void => {
118
+ const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/,/g, `.`);
119
+ let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
120
+ if (!this.props.negativeAllowed) {
121
+ replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
122
+ }
123
+ this.setState({
124
+ value: `${replacedSeparator}`,
125
+ });
126
+ this.props.partialInput?.(`${replacedSeparator}`);
127
+ };
128
+
129
+ /**
130
+ * Handle what should happen when the user finish editing the input field.
131
+ *
132
+ * Steps:
133
+ * 1. Use the cleanInput() method on the value state and store the result in a variable named cleaned.
134
+ * 2. If the onEnd prop is not null, then convert the value of cleaned to a number and use it as an argument to call the onEnd prop function.
135
+ */
136
+ public onEndEdit = (): void => {
137
+ const cleaned = this.cleanInput(this.state.value);
138
+ this.props.onEnd?.(Number(cleaned));
139
+ };
140
+
141
+ /**
142
+ * @returns JSX element to display a TextInput field with the component’s value state as its value
143
+ * and the handleOnChangeText() and onEndEdit() methods as the textInput’s onChangeText and onEndEditing respectively.
144
+ */
145
+ public render(): JSX.Element {
146
+ const { testID } = this.props;
147
+ return (
148
+ <TextInput
149
+ testID={testID}
150
+ value={this.state.value}
151
+ ref={this.inputRef}
152
+ style={inputStyles.input}
153
+ keyboardType={`numeric`}
154
+ returnKeyType={`done`}
155
+ onChangeText={this.handleOnChangeText}
156
+ onEndEditing={this.onEndEdit}
157
+ maxLength={this.props.maxLength}
158
+ selectTextOnFocus
159
+ />
160
+ );
161
+ }
162
+ }
163
+
164
+ const inputStyles = StyleSheet.create({
165
+ input: {
166
+ width: 1,
167
+ height: 1,
168
+ opacity: 0,
169
+ },
170
+ });
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+
4
+ export interface IProps {
5
+ /** The color that the line should have. */
6
+ borderBottomColor: string;
7
+ /** The marginTop of the line. */
8
+ marginTop?: number;
9
+ /** The marginBottom of the line. */
10
+ marginBottom?: number;
11
+ }
12
+
13
+ /** Display a horizontal line for visually separating elements in the user interface. */
14
+ export default class LineSeparator extends React.Component<IProps> {
15
+ /** @return JSX element for displaying a thin horizontal line in the given color. */
16
+ public render(): JSX.Element {
17
+ return (
18
+ <React.Fragment>
19
+ <View style={[lineSeparatorStyles.lineStyle, { ...this.props }]} />
20
+ </React.Fragment>
21
+ );
22
+ }
23
+ }
24
+
25
+ const lineSeparatorStyles = StyleSheet.create({
26
+ lineStyle: {
27
+ borderBottomWidth: 1,
28
+ },
29
+ });
@@ -0,0 +1,109 @@
1
+ import React from "react";
2
+ import { StyleSheet, TouchableOpacity, View } from "react-native";
3
+
4
+ import { t } from "../locales/translate";
5
+ import { Testing } from "../types/enum";
6
+ import { colors } from "../utils/Constants";
7
+ import { FONTS } from "./styles/fonts";
8
+ import Text from "./Text";
9
+
10
+ export interface IProps {
11
+ /** Callback function taking no arguments and returning no value - To be called if the user presses the “Yes” button. */
12
+ onRecentInsulinYes(): void;
13
+ /** Callback function taking no arguments and returning no value - To be called if the user presses the “No” button. */
14
+ onRecentInsulinNo(): void;
15
+ }
16
+
17
+ /** Display a card that prompts the user to recall if they injected insulin recently. */
18
+ export default class RecentInsulin extends React.Component<IProps> {
19
+ /**
20
+ *
21
+ * @returns JSX element that displays a card with the question “Have you taken insulin within the last 4 hours?
22
+ * Along with two buttons labeled “Yes” and “No” respectively.
23
+ * If the user taps the “Yes” button, the onRecentInsulinYes prop callback function should be called.
24
+ * If the user taps the “No” button, the onRecentInsulinNo prop callback function should be called.
25
+ */
26
+ public render = (): JSX.Element => {
27
+ return (
28
+ <View style={recentInsulinStyles.container}>
29
+ <View style={recentInsulinStyles.textContainer}>
30
+ <Text style={recentInsulinStyles.recommended}>{t(`Recommended amount of insulin`)}</Text>
31
+ <Text style={recentInsulinStyles.takenInsulin}>
32
+ {t(`Have you taken insulin within the last 4 hours?`)}
33
+ </Text>
34
+ </View>
35
+ <View style={recentInsulinStyles.buttonContainer}>
36
+ <TouchableOpacity
37
+ testID={Testing.Id.RecentInsulinTestIds.Yes}
38
+ onPress={this.props.onRecentInsulinYes}
39
+ style={recentInsulinStyles.yesButton}
40
+ >
41
+ <Text style={recentInsulinStyles.yesNoText}>{t(`Yes`)}</Text>
42
+ </TouchableOpacity>
43
+ <TouchableOpacity
44
+ testID={Testing.Id.RecentInsulinTestIds.No}
45
+ onPress={this.props.onRecentInsulinNo}
46
+ style={recentInsulinStyles.noButton}
47
+ >
48
+ <Text style={recentInsulinStyles.yesNoText}>{t(`No`)}</Text>
49
+ </TouchableOpacity>
50
+ </View>
51
+ </View>
52
+ );
53
+ };
54
+ }
55
+
56
+ const recentInsulinStyles = StyleSheet.create({
57
+ container: {
58
+ minHeight: 220,
59
+ backgroundColor: colors.deepPurple,
60
+ borderRadius: 5,
61
+ marginBottom: 32,
62
+ paddingHorizontal: 16,
63
+ paddingTop: 16,
64
+ paddingBottom: 50,
65
+ },
66
+ textContainer: {
67
+ justifyContent: `center`,
68
+ alignItems: `center`,
69
+ marginBottom: 32,
70
+ },
71
+ recommended: {
72
+ ...FONTS.Poppins.medium_Base,
73
+ color: colors.white,
74
+ textAlign: `center`,
75
+ marginBottom: 2,
76
+ },
77
+ takenInsulin: {
78
+ ...FONTS.Poppins.regular_SM,
79
+ color: colors.white,
80
+ textAlign: `center`,
81
+ },
82
+ buttonContainer: {
83
+ flexDirection: `row`,
84
+ justifyContent: `center`,
85
+ },
86
+ yesButton: {
87
+ flex: 1,
88
+ borderRadius: 50,
89
+ minWidth: 127,
90
+ marginLeft: 30,
91
+ marginRight: 12,
92
+ backgroundColor: colors.teal,
93
+ },
94
+ noButton: {
95
+ flex: 1,
96
+ borderRadius: 50,
97
+ minWidth: 127,
98
+ marginRight: 30,
99
+ marginLeft: 12,
100
+ backgroundColor: colors.teal,
101
+ },
102
+ yesNoText: {
103
+ ...FONTS.Poppins.bold_Base,
104
+ textAlign: `center`,
105
+ paddingHorizontal: 16,
106
+ paddingVertical: 12,
107
+ color: colors.black,
108
+ },
109
+ });
@@ -0,0 +1,319 @@
1
+ import * as React from "react";
2
+ import { SafeAreaView, ScrollView, StatusBar, StyleSheet, TouchableOpacity, View } from "react-native";
3
+ import ReactNativeModal from "react-native-modal";
4
+
5
+ import { t } from "../locales/translate";
6
+ import { Testing } from "../types/enum";
7
+ import { colors } from "../utils/Constants";
8
+ import { FONTS } from "./styles/fonts";
9
+ import Text from "./Text";
10
+
11
+ const { RecommendationModalTestIds } = Testing.Id;
12
+
13
+ export interface IModalProps {
14
+ /** Whether or not the modal should currently be displayed on the screen */
15
+ isVisible: boolean;
16
+ /** The amount of additional carbohydrates that is being recommended for the user in grams. */
17
+ suggestedCarbohydrates: number | null;
18
+ /** A message to display to the user to inform them in natural language about special recommendations or warnings from HDA. */
19
+ attentionMessage: string | null;
20
+ /** A message to display to the user to inform them if their insulin recommendation was limited by the maximum threshold. */
21
+ limitationMessage: string | null;
22
+ /**
23
+ * If true then the modal will only display the limitation message and not the attention message.
24
+ */
25
+ onlyShowLimitationMessage: boolean;
26
+ /** Callback function taking no arguments and returning no value - Should be called if the user taps the “OK” button on the modal. */
27
+ onClickOkButton(): void;
28
+ /**
29
+ * Callback function taking no arguments and returning no value.
30
+ * Should be called if the user taps the “accept” button when they are recommended to eat additional carbohydrates.
31
+ */
32
+ onAcceptCarbohydrates(): void;
33
+ /**
34
+ * Callback function taking no arguments and returning no value.
35
+ * Should be called if the user taps the “decline” button when they are recommended to eat additional carbohydrates.
36
+ */
37
+ onDeclineCarbohydrates(): void;
38
+ }
39
+ export interface IModalState {
40
+ /** If true then the first page will be displayed, otherwise the second page will be displayed. */
41
+ firstPageVisible: boolean;
42
+ }
43
+
44
+ /**
45
+ * Popup modal for displaying information messages or warnings to the user if necessary.
46
+ * The modal has two “pages” with different content that it is able to display.
47
+ * The first page is for informing the user if their insulin recommendation was limited by the maximum insulin safety limit.
48
+ * This page will only be displayed if the recommendation was actually limited.
49
+ * The second page is for displaying a general attention message that may contain instructions for the user,
50
+ * and for letting the user know if they are being recommended eating additional carbohydrates.
51
+ */
52
+ export default class RecommendationModal extends React.Component<IModalProps, IModalState> {
53
+ /**
54
+ * Steps:
55
+ * 1. Call the super() method with the props.
56
+ * 2. Set the firstPageVisible state variable true if the limitationMessage prop is truthy.
57
+ * @param props The class props
58
+ */
59
+ constructor(props: IModalProps) {
60
+ super(props);
61
+ this.state = {
62
+ firstPageVisible: !!this.props.limitationMessage,
63
+ };
64
+ }
65
+
66
+ /*
67
+ * Steps:
68
+ * 1. Set the firstPageVisible state variable true if the limitationMessage prop was updated.
69
+ */
70
+ public componentDidUpdate(prevProps: Readonly<IModalProps>): void {
71
+ if (prevProps.limitationMessage !== this.props.limitationMessage) {
72
+ this.setState({ firstPageVisible: !!this.props.limitationMessage });
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Handle what happens when the “next” button is pressed.
78
+ *
79
+ * Steps:
80
+ * 1. Unpack attentionMessage and suggestedCarbohydrates from the props object.
81
+ * 2. Define isPageVisible to be true if either attentionMessage or suggestedCarbohydrates is truthy.
82
+ * 3. If isPageVisible is true then set the firstPageVisible state variable to false. Otherwise call the onClickOkButton prop callback function.
83
+ */
84
+ public onPressNextButton = (): void => {
85
+ const { attentionMessage, suggestedCarbohydrates } = this.props;
86
+ const isSecondPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
87
+ return isSecondPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
88
+ };
89
+
90
+ /**
91
+ * @returns Return an JSX element for composing two buttons: one for accepting a suggestion and one for rejecting it.
92
+ * If the accept button is pressed the onAcceptCarbohydrates prop callback function shall be called.
93
+ * If the accept button is pressed the onDeclineCarbohydrates prop callback function shall be called.
94
+ */
95
+ public recommendationButtons = (): JSX.Element => {
96
+ return (
97
+ <View style={stylesModal.recommendationButtonsContainer}>
98
+ <TouchableOpacity
99
+ testID={RecommendationModalTestIds.AcceptCarbs}
100
+ style={[stylesModal.button, { marginRight: 12 }]}
101
+ onPress={this.props.onAcceptCarbohydrates}
102
+ >
103
+ <Text style={stylesModal.carbsButtonText}>{t(`OK`)}</Text>
104
+ </TouchableOpacity>
105
+ <TouchableOpacity
106
+ testID={RecommendationModalTestIds.DeclineCarbs}
107
+ style={[stylesModal.button, { marginLeft: 12 }]}
108
+ onPress={this.props.onDeclineCarbohydrates}
109
+ >
110
+ <Text style={stylesModal.carbsButtonText}>{t(`NO`)}</Text>
111
+ </TouchableOpacity>
112
+ </View>
113
+ );
114
+ };
115
+
116
+ /**
117
+ * Compose a JSX element for displaying a recommendation of additional carbohydrates (the value of the suggestedCarbohydrates prop rounded to the nearest integer)
118
+ * to the user in a way that explains what to do with the suggestion.
119
+ * @param suggestedCarbohydrates the recommended additional carbohydrates
120
+ */
121
+ public recommendCarbohydrates = (suggestedCarbohydrates: number): JSX.Element => {
122
+ const displayCarbs = Math.round(suggestedCarbohydrates);
123
+
124
+ return (
125
+ <React.Fragment>
126
+ <View style={stylesModal.innerView}>
127
+ <Text style={stylesModal.recommendEatingText}>{t(`We recommend eating an additional:`)}</Text>
128
+ <Text style={stylesModal.textCenter}>
129
+ <Text style={stylesModal.suggestedCarbs} testID={RecommendationModalTestIds.SuggestedCarbs}>
130
+ {`${displayCarbs} `}
131
+ </Text>
132
+ <Text style={stylesModal.carbohydrateText}>{t(`grams of carbohydrates`)}</Text>
133
+ </Text>
134
+ <Text style={stylesModal.recommendEatingText}>{t(`Instead of taking insulin`)}</Text>
135
+ </View>
136
+ <Text style={stylesModal.addToCalculation}>
137
+ {t(`Would you like to add this to your current calculation?`)}
138
+ </Text>
139
+ {this.recommendationButtons()}
140
+ </React.Fragment>
141
+ );
142
+ };
143
+
144
+ /**
145
+ * @returns JSX element for displaying the “second” page of the recommendation modal. The second page displays the string from the attentionMessage prop.
146
+ */
147
+ public secondPage = (): JSX.Element => {
148
+ const { attentionMessage, suggestedCarbohydrates } = this.props;
149
+ const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
150
+
151
+ return (
152
+ <>
153
+ <View style={stylesModal.container}>
154
+ <Text style={stylesModal.textTittleMessage}>{t(`Attention`)}</Text>
155
+ {attentionMessage && <Text style={stylesModal.textMessage}>{attentionMessage}</Text>}
156
+ {willRecommendCarbs && this.recommendCarbohydrates(suggestedCarbohydrates)}
157
+ </View>
158
+ {!willRecommendCarbs && (
159
+ <TouchableOpacity
160
+ testID={RecommendationModalTestIds.OkButton}
161
+ style={stylesModal.okButton}
162
+ onPress={this.props.onClickOkButton}
163
+ >
164
+ <Text style={stylesModal.buttonText}>{t(`OK`)}</Text>
165
+ </TouchableOpacity>
166
+ )}
167
+ </>
168
+ );
169
+ };
170
+
171
+ /**
172
+ * @returns JSX element for displaying the “first” page of the recommendation modal.
173
+ * The first page consists of a limitation message rendered using a LimitationMessage component.
174
+ */
175
+ public firstPage = (): JSX.Element => {
176
+ const { limitationMessage } = this.props;
177
+ return (
178
+ <React.Fragment>
179
+ <Text style={stylesModal.textTittleMessage}>{t(`Attention`)}</Text>
180
+ <Text style={stylesModal.textMessage}>{limitationMessage}</Text>
181
+ <TouchableOpacity
182
+ testID={Testing.Id.RecommendationModalTestIds.LimitationOkButton}
183
+ style={stylesModal.okButton}
184
+ onPress={this.props.onlyShowLimitationMessage ? this.props.onClickOkButton : this.onPressNextButton}
185
+ >
186
+ <Text style={stylesModal.buttonText}>{t(`OK`)}</Text>
187
+ </TouchableOpacity>
188
+ </React.Fragment>
189
+ );
190
+ };
191
+
192
+ /**
193
+ * @returns JSX element for rendering a modal that is visible if the isVisible prop is true.
194
+ * If the firstPageVisible state variable is true then use firstPage() to render the first page.
195
+ * Otherwise use secondPage() to render the second page.
196
+ */
197
+ public render(): JSX.Element {
198
+ const { isVisible } = this.props;
199
+ const { firstPageVisible } = this.state;
200
+ return (
201
+ <ReactNativeModal
202
+ isVisible={isVisible}
203
+ style={stylesModal.modalStyle}
204
+ backdropColor={colors.darkBlue}
205
+ backdropOpacity={1}
206
+ animationIn={`fadeIn`}
207
+ animationOut={`fadeOut`}
208
+ >
209
+ <StatusBar backgroundColor={colors.darkBlue} />
210
+ <SafeAreaView style={stylesModal.safe}>
211
+ <ScrollView contentContainerStyle={stylesModal.scrollViewContainer}>
212
+ {firstPageVisible ? this.firstPage() : this.secondPage()}
213
+ </ScrollView>
214
+ </SafeAreaView>
215
+ </ReactNativeModal>
216
+ );
217
+ }
218
+ }
219
+
220
+ /** @internal */
221
+ export const stylesModal = StyleSheet.create({
222
+ safe: {
223
+ backgroundColor: colors.darkBlue,
224
+ },
225
+ modalStyle: {
226
+ margin: 0,
227
+ },
228
+ scrollViewContainer: {
229
+ flexGrow: 1,
230
+ justifyContent: `center`,
231
+ },
232
+ container: {
233
+ justifyContent: `center`,
234
+ },
235
+ textTittleMessage: {
236
+ ...FONTS.Poppins.bold_3XL,
237
+ color: colors.white,
238
+ textAlign: `center`,
239
+ },
240
+ textMessage: {
241
+ ...FONTS.Poppins.regular_Base,
242
+ color: colors.white,
243
+ textAlign: `center`,
244
+ marginHorizontal: 30,
245
+ marginTop: 8,
246
+ },
247
+ buttonText: {
248
+ ...FONTS.Poppins.bold_Base,
249
+ color: colors.white,
250
+ textAlign: `center`,
251
+ paddingHorizontal: 16,
252
+ paddingVertical: 12,
253
+ },
254
+ innerView: {
255
+ alignContent: `center`,
256
+ borderRadius: 8,
257
+ backgroundColor: colors.purple,
258
+ paddingVertical: 24,
259
+ marginHorizontal: 30,
260
+ marginTop: 24,
261
+ marginBottom: 36,
262
+ },
263
+ suggestedCarbs: {
264
+ ...FONTS.Poppins.bold_XL,
265
+ color: colors.white,
266
+ },
267
+ textCenter: {
268
+ ...FONTS.Poppins.regular_Base,
269
+ textAlign: `center`,
270
+ paddingHorizontal: 26.5,
271
+ },
272
+ recommendEatingText: {
273
+ ...FONTS.Poppins.regular_Base,
274
+ color: colors.white,
275
+ textAlign: `center`,
276
+ paddingHorizontal: 15,
277
+ marginBottom: 8,
278
+ },
279
+ carbohydrateText: {
280
+ ...FONTS.Poppins.bold_Base,
281
+ color: colors.white,
282
+ },
283
+ addToCalculation: {
284
+ ...FONTS.Poppins.regular_Base,
285
+ color: colors.white,
286
+ textAlign: `center`,
287
+ marginBottom: 16,
288
+ marginHorizontal: 50,
289
+ },
290
+ recommendationButtonsContainer: {
291
+ justifyContent: `center`,
292
+ flexDirection: `row`,
293
+ paddingHorizontal: 47,
294
+ },
295
+ carbsButtonText: {
296
+ ...FONTS.Poppins.bold_Base,
297
+ color: colors.white,
298
+ textAlign: `center`,
299
+ paddingHorizontal: 16,
300
+ paddingVertical: 12,
301
+ },
302
+ button: {
303
+ borderRadius: 50,
304
+ borderWidth: 1,
305
+ borderColor: colors.white,
306
+ alignSelf: `center`,
307
+ minWidth: 127,
308
+ },
309
+ okButton: {
310
+ backgroundColor: colors.darkBlue,
311
+ justifyContent: `flex-start`,
312
+ marginTop: 24,
313
+ borderRadius: 50,
314
+ borderWidth: 1,
315
+ borderColor: colors.white,
316
+ alignSelf: `center`,
317
+ minWidth: 127,
318
+ },
319
+ });