@hedia/recommendation-screen 2.0.2 → 2.1.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 (116) hide show
  1. package/coverage/clover.xml +700 -0
  2. package/coverage/coverage-final.json +28 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +79 -0
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +201 -0
  7. package/coverage/lcov-report/prettify.css +1 -0
  8. package/coverage/lcov-report/prettify.js +2 -0
  9. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  10. package/coverage/lcov-report/sorter.js +170 -0
  11. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
  12. package/coverage/lcov-report/src/__tests__/index.html +111 -0
  13. package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
  14. package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
  15. package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
  16. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
  17. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
  18. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
  19. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
  20. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
  21. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
  22. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
  23. package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
  24. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
  25. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
  26. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
  27. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
  28. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
  29. package/coverage/lcov-report/src/components/activity/index.html +141 -0
  30. package/coverage/lcov-report/src/components/index.html +276 -0
  31. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
  32. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
  33. package/coverage/lcov-report/src/components/mood/index.html +126 -0
  34. package/coverage/lcov-report/src/index.html +111 -0
  35. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
  36. package/coverage/lcov-report/src/locale/index.html +111 -0
  37. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
  38. package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
  39. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
  40. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
  41. package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
  42. package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
  43. package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
  44. package/coverage/lcov-report/src/utils/index.html +201 -0
  45. package/coverage/lcov.info +1581 -0
  46. package/jest.config.js +2 -1
  47. package/package.json +2 -2
  48. package/src/RecommendationScreen.d.ts +2 -3
  49. package/src/__tests__/components/Emotion.test.jsx +7 -8
  50. package/src/components/Icon.d.ts +13 -0
  51. package/src/components/Icon.jsx +42 -0
  52. package/src/components/LimitationMessage.d.ts +1 -2
  53. package/src/components/RecommendationModal.d.ts +2 -3
  54. package/src/components/RecommendationModal.jsx +2 -1
  55. package/src/components/activity/ActivityIntensity.jsx +4 -3
  56. package/src/utils/AttentionMessages.d.ts +16 -10
  57. package/src/utils/AttentionMessages.jsx +15 -10
  58. package/src/utils/RecommendationUtils.d.ts +2 -3
  59. package/src/utils/RecommendationUtils.js +10 -6
  60. package/src/utils/Utils.d.ts +1 -0
  61. package/src/utils/Utils.js +4 -0
  62. package/tsconfig.json +7 -5
  63. package/App.d.ts +0 -27
  64. package/App.jsx +0 -98
  65. package/App.tsx +0 -140
  66. package/app.json +0 -4
  67. package/index.ts +0 -6
  68. package/src/RecommendationScreen.tsx +0 -461
  69. package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
  70. package/src/__tests__/RecommendationUtils.test.ts +0 -332
  71. package/src/__tests__/Translate.test.tsx +0 -31
  72. package/src/__tests__/Utils.test.ts +0 -91
  73. package/src/__tests__/Validations.test.ts +0 -648
  74. package/src/__tests__/components/Activity.test.tsx +0 -163
  75. package/src/__tests__/components/Emotion.test.tsx +0 -110
  76. package/src/__tests__/components/Header.test.tsx +0 -44
  77. package/src/__tests__/components/InfoBars.test.tsx +0 -152
  78. package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
  79. package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
  80. package/src/__tests__/components/MoodIcon.test.tsx +0 -45
  81. package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
  82. package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
  83. package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
  84. package/src/__tests__/components/Remeasure.test.tsx +0 -97
  85. package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
  86. package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
  87. package/src/__tests__/utils.tsx +0 -144
  88. package/src/components/Header.tsx +0 -89
  89. package/src/components/Icon.js +0 -41
  90. package/src/components/InfoBars.tsx +0 -108
  91. package/src/components/InvisibleNumberInput.tsx +0 -98
  92. package/src/components/LimitationMessage.tsx +0 -38
  93. package/src/components/LineSeparator.tsx +0 -24
  94. package/src/components/RecentInsulin.tsx +0 -101
  95. package/src/components/RecommendationModal.tsx +0 -224
  96. package/src/components/RecommendedCarbs.tsx +0 -259
  97. package/src/components/RecommendedInsulin.tsx +0 -175
  98. package/src/components/Remeasure.tsx +0 -120
  99. package/src/components/TransferToLogbook.tsx +0 -100
  100. package/src/components/TwoOptionModal.tsx +0 -185
  101. package/src/components/activity/Activity.tsx +0 -77
  102. package/src/components/activity/ActivityIcon.tsx +0 -54
  103. package/src/components/activity/ActivityIntensity.tsx +0 -58
  104. package/src/components/mood/Emotion.tsx +0 -66
  105. package/src/components/mood/MoodIcon.tsx +0 -60
  106. package/src/locale/CleanLanguage.ts +0 -13
  107. package/src/locale/i18nUtils.ts +0 -27
  108. package/src/types/enum.ts +0 -108
  109. package/src/types/types.ts +0 -16
  110. package/src/utils/AttentionMessages.tsx +0 -75
  111. package/src/utils/Constants.ts +0 -32
  112. package/src/utils/RecommendationError.tsx +0 -140
  113. package/src/utils/RecommendationUtils.ts +0 -125
  114. package/src/utils/Translations.ts +0 -9
  115. package/src/utils/Utils.ts +0 -57
  116. package/src/utils/Validations.ts +0 -245
@@ -1,461 +0,0 @@
1
- import React from "react";
2
- import { AppState, AppStateStatus, ScrollView, StyleSheet, View, YellowBox } from "react-native";
3
-
4
- import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "./utils/Constants";
5
-
6
- import Header from "./components/Header";
7
- import InfoBars, { infoStyles } from "./components/InfoBars";
8
- import RecentInsulin from "./components/RecentInsulin";
9
- import RecommendedCarbs from "./components/RecommendedCarbs";
10
- import RecommendedInsulin from "./components/RecommendedInsulin";
11
- import Remeasure from "./components/Remeasure";
12
-
13
- import * as Calculator from "@hedia/recommendation-calculator";
14
- import { BloodGlucoseUnit, BloodKetonesUnit, Languages, Logbook, Milliseconds, UserSettings } from "@hedia/types";
15
- import { I18nProvider } from "@lingui/react";
16
- import Emotion from "./components/mood/Emotion";
17
- import TransferToLogbook from "./components/TransferToLogbook";
18
- import { RecommendationError } from "./utils/RecommendationError";
19
-
20
- import { t } from "@lingui/macro";
21
-
22
- import Activity from "./components/activity/Activity";
23
- import LimitationMessage from "./components/LimitationMessage";
24
- import RecommendationModal from "./components/RecommendationModal";
25
- import TwoOptionModal, { modalStyle } from "./components/TwoOptionModal";
26
- import { changeLanguage, i18n } from "./locale/i18nUtils";
27
- import { IActivityDisplayProps, IRecommendationParams, logbookEntry } from "./types/types";
28
- import { AttentionMessage, Messages } from "./utils/AttentionMessages";
29
- import { getAttentionMessage, getBGLevel, getLimitationMessage, getReminder } from "./utils/RecommendationUtils";
30
- import { Utils } from "./utils/Utils";
31
- import { validateParams } from "./utils/Validations";
32
-
33
- // Ignoring long timer warnings
34
- // https://github.com/facebook/react-native/issues/12981#issuecomment-652745831
35
- YellowBox.ignoreWarnings([`Setting a timer`]);
36
-
37
- interface IResult {
38
- suggested: number;
39
- entered: number | null;
40
- }
41
-
42
- export interface IRecommendationProps {
43
- // Values
44
- bloodGlucoseUnit: BloodGlucoseUnit;
45
- language: Languages;
46
- userReminder: number;
47
- calculatorParams: IRecommendationParams;
48
- injectionMethod: UserSettings.Enums.InjectionMethod;
49
- currentBKL: number;
50
- bloodKetoneUnit: BloodKetonesUnit;
51
- latestLogbookFrom6Hours: logbookEntry | null;
52
- activityDisplayProps: IActivityDisplayProps | null;
53
-
54
- // Callbacks
55
- carbRecommendationAnswer(carbRecommendationAnswer: boolean): void;
56
- closeCalculationCallback(): void;
57
- exitCallback(): void;
58
- onRecentInsulinYes(): void;
59
- transferToLogbook(
60
- carbs: IResult,
61
- insulin: IResult,
62
- reminder: number,
63
- recommendationDate: Date,
64
- mood: Logbook.Enums.MoodEnum | null,
65
- ): void;
66
- onError(error: RecommendationError): void;
67
- showBolusBar(toggle: boolean): void;
68
- restartCalculation(): void;
69
- }
70
-
71
- interface IState {
72
- remeasureTime: number;
73
- isRecommendationDisplayed: boolean;
74
- insulinRecommendation: number;
75
- activityReduction: number | null;
76
- wasLimited: boolean;
77
- carbRecommendation: number | null;
78
- activeInsulin: number;
79
- selectedMood: Logbook.Enums.MoodEnum | null;
80
- enteredCarbs: number | null;
81
- enteredInsulin: number | null;
82
- recommendationModal: boolean;
83
- showExitModal: boolean;
84
- showLimitationMessage: boolean;
85
- showTimeoutModal: boolean;
86
- }
87
-
88
- export default class RecommendationScreen extends React.Component<IRecommendationProps, IState> {
89
- private readonly timer!: ReturnType<typeof setTimeout>;
90
- private readonly suggestedCarbs!: number;
91
- private readonly hasError: boolean = false;
92
- private readonly recommendationDate!: Date;
93
- private scrollView?: ScrollView;
94
-
95
- constructor(props: IRecommendationProps) {
96
- super(props);
97
- try {
98
- validateParams(props);
99
- this.recommendationDate = new Date(global.Date.now());
100
-
101
- changeLanguage(props.language);
102
- const { recentBoluses } = props.calculatorParams;
103
- const {
104
- bolus,
105
- carbRecommendation,
106
- activityReduction,
107
- wasLimited,
108
- activeInsulin,
109
- } = Calculator.calculateRecommendation(props.calculatorParams);
110
-
111
- this.suggestedCarbs = carbRecommendation;
112
-
113
- this.state = {
114
- remeasureTime: this.getBGLevelRemeasurementReminder(),
115
- isRecommendationDisplayed: recentBoluses?.length !== 0,
116
- insulinRecommendation: Utils.roundValue(bolus, props.injectionMethod),
117
- wasLimited,
118
- activityReduction,
119
- carbRecommendation,
120
- activeInsulin,
121
- enteredCarbs: null,
122
- enteredInsulin: null,
123
- selectedMood: null,
124
- recommendationModal:
125
- wasLimited || !!Math.round(carbRecommendation) || !!this.getBGLevelAttentionMessage(),
126
- showExitModal: false,
127
- showLimitationMessage: false,
128
- showTimeoutModal: false,
129
- };
130
-
131
- this.timer = setTimeout(this.showTimeoutModal, Milliseconds.Minute * 15);
132
- } catch (error) {
133
- this.hasError = true;
134
- props.onError(error);
135
- }
136
- }
137
-
138
- public componentDidMount(): void {
139
- AppState.addEventListener(`change`, this.handleAppStateChange);
140
- }
141
-
142
- public componentWillUnmount(): void {
143
- if (this.timer !== undefined) {
144
- clearTimeout(this.timer);
145
- }
146
- AppState.removeEventListener(`change`, this.handleAppStateChange);
147
- }
148
-
149
- public handleAppStateChange = (nextAppState: AppStateStatus): void => {
150
- const time = this.recommendationDate.getTime();
151
- const isOlderThan15Minutes = global.Date.now() - time > Milliseconds.Minute * 15;
152
- if (nextAppState === `active` && isOlderThan15Minutes) {
153
- this.showTimeoutModal();
154
- }
155
- };
156
-
157
- public showTimeoutModal = (): void => {
158
- this.setState({ showTimeoutModal: true }, (): void => this.props.showBolusBar(!this.state.showTimeoutModal));
159
- };
160
-
161
- public recalculateInsulin = (calculatorParams: IRecommendationParams): void => {
162
- const { bolus, wasLimited, activityReduction } = Calculator.calculateRecommendation(calculatorParams);
163
- this.setState({
164
- insulinRecommendation: Utils.roundValue(bolus, this.props.injectionMethod),
165
- enteredInsulin: null,
166
- wasLimited,
167
- activityReduction,
168
- showLimitationMessage: wasLimited,
169
- });
170
- };
171
-
172
- public onExit = (): void => {
173
- if (this.state.isRecommendationDisplayed) {
174
- this.setState({ showExitModal: true }, (): void => this.props.showBolusBar(!this.state.showExitModal));
175
- } else {
176
- this.props.exitCallback();
177
- }
178
- };
179
-
180
- public hideAttentionModal = (): void => {
181
- this.setState({ recommendationModal: false });
182
- };
183
-
184
- public hideLimitationMessage = (): void => {
185
- this.setState({ showLimitationMessage: false });
186
- };
187
-
188
- public hideExitModal = (): void => {
189
- this.setState({ showExitModal: false }, (): void => this.props.showBolusBar(!this.state.showExitModal));
190
- };
191
-
192
- public hideTimeoutModal = (): void => {
193
- this.setState({ showTimeoutModal: false }, (): void => this.props.showBolusBar(!this.state.showTimeoutModal));
194
- };
195
-
196
- public updateRemeasureTime = (remeasureTime: number): void => {
197
- this.setState({ remeasureTime });
198
- };
199
-
200
- public handleNoRecentInsulin = (): void => {
201
- this.setState({ isRecommendationDisplayed: true }, (): void => {
202
- setTimeout((): void => {
203
- this.scrollView?.scrollToEnd({ animated: true });
204
- }, 0);
205
- });
206
- };
207
-
208
- public updateCarbRecommendation = (enteredCarbs: number): void => {
209
- const providedCarbs = this.props.calculatorParams.carbohydrates;
210
- this.setState({ enteredCarbs }, (): void => {
211
- this.recalculateInsulin({ ...this.props.calculatorParams, carbohydrates: providedCarbs + enteredCarbs });
212
- });
213
- };
214
-
215
- public removeCarbRecommendation = (): void => {
216
- this.setState({ enteredCarbs: null, carbRecommendation: null }, (): void =>
217
- this.recalculateInsulin({ ...this.props.calculatorParams }),
218
- );
219
- };
220
-
221
- public declineCarbRecommendation = (): void => {
222
- this.hideAttentionModal();
223
- this.removeCarbRecommendation();
224
- this.props.carbRecommendationAnswer(false);
225
- };
226
-
227
- public acceptCarbRecommendation = (): void => {
228
- this.hideAttentionModal();
229
- this.props.carbRecommendationAnswer(true);
230
- };
231
-
232
- public closeCalculation = (): void => {
233
- this.state.showExitModal ? this.hideExitModal() : this.hideTimeoutModal();
234
- this.props.closeCalculationCallback();
235
- };
236
-
237
- public restartCalculation = (): void => {
238
- this.hideTimeoutModal();
239
- this.props.restartCalculation();
240
- };
241
-
242
- public handleMoodSelected = (selectedMood: IState["selectedMood"]): void => {
243
- this.setState({ selectedMood });
244
- };
245
-
246
- public updateInsulinRecommendation = (enteredInsulin: number): void => {
247
- this.setState({ enteredInsulin });
248
- };
249
-
250
- public handleTransfer = (): void => {
251
- const {
252
- enteredCarbs,
253
- enteredInsulin,
254
- insulinRecommendation,
255
- remeasureTime,
256
- showExitModal,
257
- selectedMood,
258
- } = this.state;
259
- const carbs: IResult = { suggested: this.suggestedCarbs, entered: enteredCarbs };
260
- const insulin: IResult = { suggested: insulinRecommendation, entered: enteredInsulin };
261
-
262
- showExitModal ? this.hideExitModal() : this.hideTimeoutModal();
263
- this.props.transferToLogbook(carbs, insulin, remeasureTime, this.recommendationDate, selectedMood);
264
- };
265
-
266
- public getBGLevelAttentionMessage = (): AttentionMessage | null => {
267
- const { calculatorParams, latestLogbookFrom6Hours } = this.props;
268
- const { currentBGL, activity } = calculatorParams;
269
- const bgLevel = getBGLevel(currentBGL, latestLogbookFrom6Hours);
270
-
271
- return getAttentionMessage(bgLevel, activity);
272
- };
273
-
274
- public getBGLevelRemeasurementReminder = (): number => {
275
- const { calculatorParams, userReminder, latestLogbookFrom6Hours } = this.props;
276
- const { currentBGL, activity, carbohydrates } = calculatorParams;
277
- const bgLevel = getBGLevel(currentBGL, latestLogbookFrom6Hours);
278
-
279
- return getReminder(bgLevel, carbohydrates, userReminder, activity);
280
- };
281
-
282
- public getLimitationAttentionMessage = (): AttentionMessage | null => {
283
- const { wasLimited, activityReduction } = this.state;
284
-
285
- return getLimitationMessage(wasLimited, activityReduction);
286
- };
287
-
288
- public render(): JSX.Element {
289
- if (this.hasError) {
290
- return <View style={containerStyles.container} />;
291
- }
292
-
293
- const {
294
- activeInsulin,
295
- recommendationModal,
296
- carbRecommendation: carbRecommendationProp,
297
- enteredCarbs,
298
- enteredInsulin,
299
- insulinRecommendation,
300
- activityReduction,
301
- isRecommendationDisplayed,
302
- } = this.state;
303
-
304
- const carbRecommendation = carbRecommendationProp !== null ? Math.round(carbRecommendationProp) : null;
305
- const recommendedCarbs = enteredCarbs ?? carbRecommendation;
306
-
307
- const { calculatorParams, bloodGlucoseUnit, currentBKL, bloodKetoneUnit } = this.props;
308
- const { currentBGL, carbohydrates: providedCarbs } = calculatorParams;
309
- const displayedBGL = Utils.displayedBGLValue(currentBGL, bloodGlucoseUnit);
310
- const displayedBKL = Utils.displayedBKLValue(currentBKL, bloodKetoneUnit);
311
-
312
- return (
313
- <I18nProvider language={this.props.language} i18n={i18n}>
314
- <ScrollView
315
- style={containerStyles.container}
316
- ref={(view): void => {
317
- if (view !== null) {
318
- this.scrollView = view;
319
- }
320
- }}
321
- >
322
- <Header exitCallback={this.onExit} />
323
- <InfoBars
324
- label={i18n._(t`Active Insulin`)}
325
- value={activeInsulin ? `${activeInsulin.toFixed(1)}` : null}
326
- unit={i18n._(t`units`)}
327
- showNullAsDash={false}
328
- />
329
- <InfoBars
330
- label={i18n._(t`Blood Glucose Level`)}
331
- value={currentBGL ? `${displayedBGL}` : null}
332
- unit={this.props.bloodGlucoseUnit}
333
- showNullAsDash={true}
334
- />
335
- <InfoBars
336
- label={i18n._(t`Blood Ketone Level`)}
337
- value={currentBKL !== null ? `${displayedBKL}` : null}
338
- unit={this.props.bloodKetoneUnit}
339
- showNullAsDash={true}
340
- />
341
- <View style={containerStyles.calcContainer}>
342
- <View style={containerStyles.calcMargin}>
343
- <View
344
- style={[
345
- containerStyles.calcBorder,
346
- {
347
- borderColor: recommendedCarbs ? BORDER_COLOUR_TEAL : BORDER_COLOUR_GREY,
348
- },
349
- ]}
350
- >
351
- <RecommendedCarbs
352
- enteredCarbs={`${providedCarbs}`}
353
- changedRecommendedCarbs={this.updateCarbRecommendation}
354
- recommendedCarbs={`${recommendedCarbs}`}
355
- removeRecommendedCarbs={this.removeCarbRecommendation}
356
- />
357
- </View>
358
- </View>
359
- </View>
360
- {this.props.calculatorParams.activity && this.props.activityDisplayProps ? (
361
- <Activity
362
- activity={this.props.calculatorParams.activity}
363
- activityType={this.props.activityDisplayProps.activityType}
364
- activityTitle={this.props.activityDisplayProps.activityTitle}
365
- activityReduction={this.state.activityReduction}
366
- />
367
- ) : null}
368
- <Remeasure onSliderChange={this.updateRemeasureTime} remeasureTime={this.state.remeasureTime} />
369
- {!this.state.isRecommendationDisplayed ? (
370
- <RecentInsulin
371
- onRecentInsulinYes={this.props.onRecentInsulinYes}
372
- onRecentInsulinNo={this.handleNoRecentInsulin}
373
- />
374
- ) : (
375
- <RecommendedInsulin
376
- injectionMethod={this.props.injectionMethod}
377
- insulinRecommendation={insulinRecommendation}
378
- enteredInsulin={enteredInsulin}
379
- activityReduction={activityReduction}
380
- updateRecommendedInsulin={this.updateInsulinRecommendation}
381
- />
382
- )}
383
- <Emotion moodSelected={this.handleMoodSelected} currentMood={this.state.selectedMood} />
384
- <TransferToLogbook visible={isRecommendationDisplayed} transfer={this.handleTransfer} />
385
- <RecommendationModal
386
- isVisible={recommendationModal}
387
- suggestedCarbohydrates={carbRecommendationProp}
388
- attentionMessage={this.getBGLevelAttentionMessage()}
389
- limitationMessage={this.getLimitationAttentionMessage()}
390
- onClickOkButton={this.hideAttentionModal}
391
- onAcceptCarbohydrates={this.acceptCarbRecommendation}
392
- onDeclineCarbohydrates={this.declineCarbRecommendation}
393
- />
394
- </ScrollView>
395
- {this.state.showExitModal ? (
396
- <TwoOptionModal
397
- title={i18n._(t`Save data before closing?`)}
398
- message={i18n._(t`Your saved data will be used for future calculations.`)}
399
- textFirstOption={i18n._(t`Save to logbook`)}
400
- textSecondOption={i18n._(t`Close calculation`)}
401
- isCancelable={true}
402
- rowAsButtonLayout={true}
403
- firstOption={this.handleTransfer}
404
- secondOption={this.closeCalculation}
405
- onClose={this.hideExitModal}
406
- />
407
- ) : null}
408
- {this.state.showLimitationMessage ? (
409
- <View style={modalStyle.container}>
410
- <LimitationMessage
411
- limitationMessage={this.getLimitationAttentionMessage()}
412
- onPressNextButton={this.hideLimitationMessage}
413
- />
414
- </View>
415
- ) : null}
416
- {this.state.showTimeoutModal ? (
417
- this.state.isRecommendationDisplayed ? (
418
- <TwoOptionModal
419
- title={Messages.TimeoutPrompTitle()}
420
- message={Messages.TimeoutRecommendationVisible(this.recommendationDate)}
421
- textFirstOption={i18n._(t`Yes, save to logbook`)}
422
- textSecondOption={i18n._(t`No, return to dashboard`)}
423
- rowAsButtonLayout={false}
424
- firstOption={this.handleTransfer}
425
- secondOption={this.closeCalculation}
426
- />
427
- ) : (
428
- <TwoOptionModal
429
- title={Messages.TimeoutPrompTitle()}
430
- message={Messages.TimeoutRecommendationNotVisible()}
431
- textFirstOption={i18n._(t`Start new calculation`)}
432
- textSecondOption={i18n._(t`Return to dashboard`)}
433
- rowAsButtonLayout={false}
434
- firstOption={this.restartCalculation}
435
- secondOption={this.closeCalculation}
436
- />
437
- )
438
- ) : null}
439
- </I18nProvider>
440
- );
441
- }
442
- }
443
-
444
- const containerStyles = StyleSheet.create({
445
- container: {
446
- flex: 1,
447
- backgroundColor: BACKGROUND_COLOUR_PURPLE,
448
- },
449
- calcContainer: {
450
- flex: 1,
451
- },
452
- calcMargin: {
453
- flex: 1,
454
- marginBottom: 0,
455
- margin: `3%`,
456
- },
457
- calcBorder: {
458
- ...infoStyles.border,
459
- borderColor: BORDER_COLOUR_TEAL,
460
- },
461
- });