@hedia/recommendation-screen 2.2.0-alpha.39 → 2.2.0-alpha.4
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.
- package/dist/index.js +0 -1
- package/dist/src/RecommendationScreen.d.ts +3 -3
- package/dist/src/RecommendationScreen.js +38 -36
- package/dist/src/components/Header.js +3 -3
- package/dist/src/components/Icon.js +2 -1
- package/dist/src/components/InfoBars.d.ts +1 -1
- package/dist/src/components/InfoBars.js +4 -4
- package/dist/src/components/InvisibleNumberInput.js +2 -3
- package/dist/src/components/LimitationMessage.js +4 -4
- package/dist/src/components/LineSeparator.js +0 -1
- package/dist/src/components/RecentInsulin.js +6 -6
- package/dist/src/components/RecommendationModal.js +10 -10
- package/dist/src/components/RecommendedCarbs.d.ts +0 -2
- package/dist/src/components/RecommendedCarbs.js +17 -13
- package/dist/src/components/RecommendedInsulin.d.ts +1 -1
- package/dist/src/components/RecommendedInsulin.js +9 -7
- package/dist/src/components/Remeasure.d.ts +15 -5
- package/dist/src/components/Remeasure.js +27 -10
- package/dist/src/components/TransferToLogbook.js +4 -4
- package/dist/src/components/TwoOptionModal.js +0 -1
- package/dist/src/components/activity/Activity.d.ts +1 -1
- package/dist/src/components/activity/Activity.js +5 -5
- package/dist/src/components/activity/ActivityIcon.d.ts +1 -1
- package/dist/src/components/activity/ActivityIcon.js +4 -4
- package/dist/src/components/activity/ActivityIntensity.d.ts +1 -1
- package/dist/src/components/activity/ActivityIntensity.js +1 -2
- package/dist/src/components/mood/Emotion.d.ts +1 -1
- package/dist/src/components/mood/Emotion.js +4 -4
- package/dist/src/components/mood/MoodIcon.d.ts +1 -1
- package/dist/src/components/mood/MoodIcon.js +1 -2
- package/dist/src/components/text/TextBold.js +0 -1
- package/dist/src/components/text/TextRegular.js +0 -1
- package/dist/src/locale/da/messages.js +1 -0
- package/dist/src/locale/da/messages.po +349 -0
- package/dist/src/locale/de/messages.js +1 -0
- package/dist/src/locale/de/messages.po +349 -0
- package/dist/src/locale/en/messages.js +1 -0
- package/dist/src/locale/en/messages.po +349 -0
- package/dist/src/locale/es/messages.js +1 -0
- package/dist/src/locale/es/messages.po +349 -0
- package/dist/src/locale/fr/messages.js +1 -0
- package/dist/src/locale/fr/messages.po +349 -0
- package/dist/src/locale/i18nUtils.d.ts +18 -0
- package/dist/src/locale/i18nUtils.js +39 -0
- package/dist/src/locale/it/messages.js +1 -0
- package/dist/src/locale/it/messages.po +349 -0
- package/dist/src/types/enum.js +0 -2
- package/dist/src/types/types.js +0 -1
- package/dist/src/utils/AttentionMessages.js +24 -29
- package/dist/src/utils/Constants.d.ts +2 -2
- package/dist/src/utils/Constants.js +0 -1
- package/dist/src/utils/RecommendationError.js +24 -24
- package/dist/src/utils/RecommendationUtils.js +2 -5
- package/dist/src/utils/Translations.js +5 -5
- package/dist/src/utils/Utils.d.ts +1 -1
- package/dist/src/utils/Utils.js +0 -1
- package/dist/src/utils/Validations.d.ts +1 -1
- package/dist/src/utils/Validations.js +2 -3
- package/package.json +95 -88
- package/dist/index.js.map +0 -1
- package/dist/src/RecommendationScreen.js.map +0 -1
- package/dist/src/components/Header.js.map +0 -1
- package/dist/src/components/Icon.js.map +0 -1
- package/dist/src/components/InfoBars.js.map +0 -1
- package/dist/src/components/InvisibleNumberInput.js.map +0 -1
- package/dist/src/components/LimitationMessage.js.map +0 -1
- package/dist/src/components/LineSeparator.js.map +0 -1
- package/dist/src/components/RecentInsulin.js.map +0 -1
- package/dist/src/components/RecommendationModal.js.map +0 -1
- package/dist/src/components/RecommendedCarbs.js.map +0 -1
- package/dist/src/components/RecommendedInsulin.js.map +0 -1
- package/dist/src/components/Remeasure.js.map +0 -1
- package/dist/src/components/TransferToLogbook.js.map +0 -1
- package/dist/src/components/TwoOptionModal.js.map +0 -1
- package/dist/src/components/activity/Activity.js.map +0 -1
- package/dist/src/components/activity/ActivityIcon.js.map +0 -1
- package/dist/src/components/activity/ActivityIntensity.js.map +0 -1
- package/dist/src/components/mood/Emotion.js.map +0 -1
- package/dist/src/components/mood/MoodIcon.js.map +0 -1
- package/dist/src/components/text/TextBold.js.map +0 -1
- package/dist/src/components/text/TextRegular.js.map +0 -1
- package/dist/src/locales/da/messages.json +0 -80
- package/dist/src/locales/de/messages.json +0 -80
- package/dist/src/locales/en/messages.json +0 -83
- package/dist/src/locales/es/messages.json +0 -80
- package/dist/src/locales/fr/messages.json +0 -80
- package/dist/src/locales/it/messages.json +0 -80
- package/dist/src/locales/translate.d.ts +0 -18
- package/dist/src/locales/translate.js +0 -51
- package/dist/src/locales/translate.js.map +0 -1
- package/dist/src/types/enum.js.map +0 -1
- package/dist/src/types/types.js.map +0 -1
- package/dist/src/utils/AttentionMessages.js.map +0 -1
- package/dist/src/utils/Constants.js.map +0 -1
- package/dist/src/utils/RecommendationError.js.map +0 -1
- package/dist/src/utils/RecommendationUtils.js.map +0 -1
- package/dist/src/utils/Translations.js.map +0 -1
- package/dist/src/utils/Utils.js.map +0 -1
- package/dist/src/utils/Validations.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppStateStatus } from "react-native";
|
|
3
3
|
import { BloodGlucoseUnit, BloodKetonesUnit, BolusCalculator, Languages, Logbook, UserSettings } from "@hedia/types";
|
|
4
|
-
import { IActivityDisplayProps } from "./types/types";
|
|
5
4
|
import { RecommendationError } from "./utils/RecommendationError";
|
|
5
|
+
import { IActivityDisplayProps } from "./types/types";
|
|
6
6
|
/** Represents both a suggestion by HDA and an actual amount of either insulin or carbohydrates. */
|
|
7
7
|
export interface IResult {
|
|
8
8
|
/** The suggested amount (of insulin in units or carbohydrates in grams) */
|
|
@@ -14,7 +14,7 @@ export interface IRecommendationProps {
|
|
|
14
14
|
/** The blood glucose measurement unit that the user prefers. */
|
|
15
15
|
bloodGlucoseUnit: BloodGlucoseUnit;
|
|
16
16
|
/** The user’s preferred language. */
|
|
17
|
-
language:
|
|
17
|
+
language: Languages;
|
|
18
18
|
/** The user’s preferred default reminder time in hours when they enter carbohydrates or an activity. */
|
|
19
19
|
userReminder: number;
|
|
20
20
|
/** The values needed to make an insulin recommendation calculation. */
|
|
@@ -66,7 +66,7 @@ export interface IRecommendationProps {
|
|
|
66
66
|
* To be called in case a serious issue with the validity of input data is detected.
|
|
67
67
|
* @param error The detected error.
|
|
68
68
|
*/
|
|
69
|
-
onError(error: RecommendationError
|
|
69
|
+
onError(error: RecommendationError): void;
|
|
70
70
|
/**
|
|
71
71
|
* Callback function taking a single argument of type boolean.
|
|
72
72
|
* To be called to hide the bottom navigation bar while displaying modal dialogs.
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { AppState, BackHandler, LogBox, StyleSheet, View } from "react-native";
|
|
2
|
+
import { AppState, BackHandler, LogBox, ScrollView, StyleSheet, View, } from "react-native";
|
|
3
3
|
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
4
|
-
import
|
|
5
|
-
import { Milliseconds, } from "@hedia/types";
|
|
6
|
-
import Activity from "./components/activity/Activity";
|
|
4
|
+
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "./utils/Constants";
|
|
7
5
|
import Header from "./components/Header";
|
|
8
6
|
import InfoBars, { infoStyles } from "./components/InfoBars";
|
|
9
|
-
import LimitationMessage from "./components/LimitationMessage";
|
|
10
|
-
import Emotion from "./components/mood/Emotion";
|
|
11
7
|
import RecentInsulin from "./components/RecentInsulin";
|
|
12
|
-
import RecommendationModal from "./components/RecommendationModal";
|
|
13
8
|
import RecommendedCarbs from "./components/RecommendedCarbs";
|
|
14
9
|
import RecommendedInsulin from "./components/RecommendedInsulin";
|
|
15
10
|
import Remeasure from "./components/Remeasure";
|
|
11
|
+
import * as Calculator from "@hedia/recommendation-calculator";
|
|
12
|
+
import { Milliseconds, } from "@hedia/types";
|
|
13
|
+
import { I18nProvider } from "@lingui/react";
|
|
14
|
+
import Emotion from "./components/mood/Emotion";
|
|
16
15
|
import TransferToLogbook from "./components/TransferToLogbook";
|
|
16
|
+
import { t } from "@lingui/macro";
|
|
17
|
+
import Activity from "./components/activity/Activity";
|
|
18
|
+
import LimitationMessage from "./components/LimitationMessage";
|
|
19
|
+
import RecommendationModal from "./components/RecommendationModal";
|
|
17
20
|
import TwoOptionModal, { modalStyle } from "./components/TwoOptionModal";
|
|
18
|
-
import {
|
|
21
|
+
import { changeLanguage, i18n } from "./locale/i18nUtils";
|
|
19
22
|
import { Testing } from "./types/enum";
|
|
20
23
|
import { Messages } from "./utils/AttentionMessages";
|
|
21
|
-
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "./utils/Constants";
|
|
22
24
|
import { getAttentionMessage, getBGLevel, getLimitationMessage, getReminder } from "./utils/RecommendationUtils";
|
|
23
25
|
import { Utils } from "./utils/Utils";
|
|
24
26
|
import { validateParams } from "./utils/Validations";
|
|
@@ -91,8 +93,8 @@ export default class RecommendationScreen extends React.Component {
|
|
|
91
93
|
super(props);
|
|
92
94
|
try {
|
|
93
95
|
validateParams(props);
|
|
94
|
-
changeLocale(props.language);
|
|
95
96
|
this.recommendationDate = new Date(global.Date.now());
|
|
97
|
+
changeLanguage(props.language);
|
|
96
98
|
const { recentBoluses } = props.calculatorParams;
|
|
97
99
|
const { bolus, carbRecommendation, activityReduction, wasLimited, activeInsulin } = Calculator.calculateRecommendation(props.calculatorParams);
|
|
98
100
|
this.suggestedCarbs = carbRecommendation;
|
|
@@ -282,7 +284,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
282
284
|
handleNoRecentInsulin = () => {
|
|
283
285
|
this.setState({ isRecommendationDisplayed: true }, () => {
|
|
284
286
|
setTimeout(() => {
|
|
285
|
-
this.scrollView?.scrollToEnd(true);
|
|
287
|
+
this.scrollView?.scrollToEnd({ animated: true });
|
|
286
288
|
}, 0);
|
|
287
289
|
});
|
|
288
290
|
};
|
|
@@ -460,42 +462,43 @@ export default class RecommendationScreen extends React.Component {
|
|
|
460
462
|
const { currentBGL, carbohydrates: providedCarbs } = calculatorParams;
|
|
461
463
|
const displayedBGL = currentBGL ? Utils.displayedBGLValue(currentBGL, bloodGlucoseUnit) : null;
|
|
462
464
|
const displayedBKL = currentBKL !== null && bloodKetoneUnit ? Utils.displayedBKLValue(currentBKL, bloodKetoneUnit) : null;
|
|
463
|
-
return (
|
|
464
|
-
<KeyboardAwareScrollView testID={RecommendationScreenTestIds.RecommendationScrollView}
|
|
465
|
+
return (<I18nProvider language={this.props.language} i18n={i18n}>
|
|
466
|
+
<KeyboardAwareScrollView testID={RecommendationScreenTestIds.RecommendationScrollView}>
|
|
467
|
+
<ScrollView style={containerStyles.container} ref={(view) => {
|
|
465
468
|
if (view !== null) {
|
|
466
469
|
this.scrollView = view;
|
|
467
470
|
}
|
|
468
471
|
}}>
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
472
|
+
<Header exitCallback={this.onExit}/>
|
|
473
|
+
<InfoBars label={i18n._(t `Active Insulin`)} value={activeInsulin ? `${activeInsulin.toFixed(1)}` : null} unit={i18n._(t `units`)} showNullAsDash={false} testID={{ unitID: ActiveInsulinUnitTestID, valueID: ActiveInsulinValueTestID }}/>
|
|
474
|
+
<InfoBars label={i18n._(t `Blood Glucose Level`)} value={displayedBGL} unit={this.props.bloodGlucoseUnit} showNullAsDash={true} testID={{ unitID: BGUnitTestID, valueID: BGValueTestID }}/>
|
|
475
|
+
<InfoBars label={i18n._(t `Blood Ketone Level`)} value={displayedBKL} unit={this.props.bloodKetoneUnit} showNullAsDash={true} testID={{ unitID: BKUnitTestID, valueID: BKValueTestID }}/>
|
|
476
|
+
<View style={containerStyles.calcContainer}>
|
|
477
|
+
<View style={containerStyles.calcMargin}>
|
|
478
|
+
<View style={[
|
|
476
479
|
containerStyles.calcBorder,
|
|
477
480
|
{
|
|
478
481
|
borderColor: recommendedCarbs ? BORDER_COLOUR_TEAL : BORDER_COLOUR_GREY,
|
|
479
482
|
},
|
|
480
483
|
]}>
|
|
481
|
-
|
|
484
|
+
<RecommendedCarbs enteredCarbs={`${providedCarbs}`} changedRecommendedCarbs={this.updateCarbRecommendation} recommendedCarbs={`${recommendedCarbs}`} removeRecommendedCarbs={this.removeCarbRecommendation}/>
|
|
485
|
+
</View>
|
|
482
486
|
</View>
|
|
483
487
|
</View>
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
{this.props.calculatorParams.activity && this.props.activityDisplayProps ? (<Activity activity={this.props.calculatorParams.activity} activityType={this.props.activityDisplayProps.activityType} activityTitle={this.props.activityDisplayProps.activityTitle} activityReduction={this.state.activityReduction}/>) : null}
|
|
489
|
+
<Remeasure onSliderChange={this.updateRemeasureTime} remeasureTime={this.state.remeasureTime}/>
|
|
490
|
+
{!this.state.isRecommendationDisplayed ? (<RecentInsulin onRecentInsulinYes={this.props.onRecentInsulinYes} onRecentInsulinNo={this.handleNoRecentInsulin}/>) : (<RecommendedInsulin injectionMethod={this.props.injectionMethod} insulinRecommendation={insulinRecommendation} enteredInsulin={enteredInsulin} activityReduction={activityReduction} updateRecommendedInsulin={this.updateInsulinRecommendation}/>)}
|
|
491
|
+
<Emotion moodSelected={this.handleMoodSelected} currentMood={this.state.selectedMood}/>
|
|
492
|
+
<TransferToLogbook visible={isRecommendationDisplayed} transfer={this.handleTransfer}/>
|
|
493
|
+
<RecommendationModal isVisible={recommendationModal} suggestedCarbohydrates={carbRecommendationProp} attentionMessage={this.getBGLevelAttentionMessage()} limitationMessage={this.getLimitationAttentionMessage()} onClickOkButton={this.hideAttentionModal} onAcceptCarbohydrates={this.acceptCarbRecommendation} onDeclineCarbohydrates={this.declineCarbRecommendation}/>
|
|
494
|
+
</ScrollView>
|
|
495
|
+
{this.state.showExitModal ? (<TwoOptionModal title={i18n._(t `Save data before closing?`)} message={i18n._(t `Your saved data will be used for future calculations.`)} textFirstOption={i18n._(t `Save to logbook`)} textSecondOption={i18n._(t `Close calculation`)} isCancelable={true} rowAsButtonLayout={true} firstOption={this.handleTransfer} secondOption={this.closeCalculation} onClose={this.hideExitModal}/>) : null}
|
|
496
|
+
{this.state.showLimitationMessage ? (<View style={modalStyle.container}>
|
|
497
|
+
<LimitationMessage limitationMessage={this.getLimitationAttentionMessage()} onPressNextButton={this.hideLimitationMessage}/>
|
|
498
|
+
</View>) : null}
|
|
499
|
+
{this.state.showTimeoutModal ? (this.state.isRecommendationDisplayed ? (<TwoOptionModal title={Messages.TimeoutPrompTitle()} message={Messages.TimeoutRecommendationVisible(this.recommendationDate)} textFirstOption={i18n._(t `Yes, save to logbook`)} textSecondOption={i18n._(t `No, return to dashboard`)} rowAsButtonLayout={false} firstOption={this.handleTransfer} secondOption={this.closeCalculation}/>) : (<TwoOptionModal title={Messages.TimeoutPrompTitle()} message={Messages.TimeoutRecommendationNotVisible()} textFirstOption={i18n._(t `Start new calculation`)} textSecondOption={i18n._(t `Return to dashboard`)} rowAsButtonLayout={false} firstOption={this.restartCalculation} secondOption={this.closeCalculation}/>)) : null}
|
|
491
500
|
</KeyboardAwareScrollView>
|
|
492
|
-
|
|
493
|
-
{this.state.showLimitationMessage && (<View style={modalStyle.container}>
|
|
494
|
-
<LimitationMessage limitationMessage={this.getLimitationAttentionMessage()} onPressNextButton={this.hideLimitationMessage}/>
|
|
495
|
-
</View>)}
|
|
496
|
-
{this.state.showTimeoutModal &&
|
|
497
|
-
(this.state.isRecommendationDisplayed ? (<TwoOptionModal title={Messages.TimeoutPrompTitle()} message={Messages.TimeoutRecommendationVisible(this.recommendationDate)} textFirstOption={translate(`Yes, save to logbook`)} textSecondOption={translate(`No, return to dashboard`)} rowAsButtonLayout={false} firstOption={this.handleTransfer} secondOption={this.closeCalculation}/>) : (<TwoOptionModal title={Messages.TimeoutPrompTitle()} message={Messages.TimeoutRecommendationNotVisible()} textFirstOption={translate(`Start new calculation`)} textSecondOption={translate(`Return to dashboard`)} rowAsButtonLayout={false} firstOption={this.restartCalculation} secondOption={this.closeCalculation}/>))}
|
|
498
|
-
</>);
|
|
501
|
+
</I18nProvider>);
|
|
499
502
|
}
|
|
500
503
|
}
|
|
501
504
|
const containerStyles = StyleSheet.create({
|
|
@@ -516,4 +519,3 @@ const containerStyles = StyleSheet.create({
|
|
|
516
519
|
borderColor: BORDER_COLOUR_TEAL,
|
|
517
520
|
},
|
|
518
521
|
});
|
|
519
|
-
//# sourceMappingURL=RecommendationScreen.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { Dimensions, SafeAreaView, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
+
import { i18n } from "../locale/i18nUtils";
|
|
4
5
|
import { Testing } from "../types/enum";
|
|
5
6
|
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY } from "../utils/Constants";
|
|
6
7
|
import Icon from "./Icon";
|
|
@@ -23,7 +24,7 @@ export default class Header extends React.Component {
|
|
|
23
24
|
</View>
|
|
24
25
|
<View style={headerStyles.headerTextContainer}>
|
|
25
26
|
<TextBold style={headerStyles.headerText} testID={Testing.Id.HeaderTestIds.HeaderText}>
|
|
26
|
-
{
|
|
27
|
+
{i18n._(t `INSULIN${`\n`}RECOMMENDATION`)}
|
|
27
28
|
</TextBold>
|
|
28
29
|
</View>
|
|
29
30
|
<View style={headerStyles.headerFiller}/>
|
|
@@ -72,4 +73,3 @@ const headerStyles = StyleSheet.create({
|
|
|
72
73
|
flex: 1,
|
|
73
74
|
},
|
|
74
75
|
});
|
|
75
|
-
//# sourceMappingURL=Header.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* tslint:disable */
|
|
1
3
|
import React from "react";
|
|
2
4
|
/** Mapping from react-native-vector-icons identifier to corresponding icon resource. */
|
|
3
5
|
export const IconSets = {
|
|
@@ -39,4 +41,3 @@ export default class Icon extends React.Component {
|
|
|
39
41
|
Icon.defaultProps = {
|
|
40
42
|
iconIdentifier: `FontAwesome/question`,
|
|
41
43
|
};
|
|
42
|
-
//# sourceMappingURL=Icon.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
2
|
+
import { t } from "@lingui/macro";
|
|
1
3
|
import React from "react";
|
|
2
4
|
import { Dimensions, StyleSheet, View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import { translate } from "../locales/translate";
|
|
5
|
+
import { i18n } from "../locale/i18nUtils";
|
|
5
6
|
import { BORDER_COLOUR_GREY } from "../utils/Constants";
|
|
6
7
|
import { Utils } from "../utils/Utils";
|
|
7
8
|
import TextBold from "./text/TextBold";
|
|
@@ -37,7 +38,7 @@ export default class InfoBars extends React.Component {
|
|
|
37
38
|
if (!unit) {
|
|
38
39
|
return null;
|
|
39
40
|
}
|
|
40
|
-
return unit ===
|
|
41
|
+
return unit === i18n._(t `units`) ? unit : Utils.formatUnit(unit);
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* @returns JSX element to display a card with the entered value.
|
|
@@ -123,4 +124,3 @@ export const infoStyles = StyleSheet.create({
|
|
|
123
124
|
paddingLeft: `5%`,
|
|
124
125
|
},
|
|
125
126
|
});
|
|
126
|
-
//# sourceMappingURL=InfoBars.js.map
|
|
@@ -48,7 +48,7 @@ export default class InvisibleNumberInput extends React.Component {
|
|
|
48
48
|
* @returns A string with the cleaned text.
|
|
49
49
|
*/
|
|
50
50
|
cleanInput = (text) => {
|
|
51
|
-
const replaced = text.replace(
|
|
51
|
+
const replaced = text.replace(/\,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
52
52
|
const round = (value) => {
|
|
53
53
|
const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
|
|
54
54
|
const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
|
|
@@ -72,7 +72,7 @@ export default class InvisibleNumberInput extends React.Component {
|
|
|
72
72
|
* @param text The updated text in the input field
|
|
73
73
|
*/
|
|
74
74
|
handleOnChangeText = (text) => {
|
|
75
|
-
const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(
|
|
75
|
+
const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
|
|
76
76
|
let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
77
77
|
if (!this.props.negativeAllowed) {
|
|
78
78
|
replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
|
|
@@ -119,4 +119,3 @@ const inputStyles = StyleSheet.create({
|
|
|
119
119
|
}),
|
|
120
120
|
},
|
|
121
121
|
});
|
|
122
|
-
//# sourceMappingURL=InvisibleNumberInput.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { TouchableOpacity, View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
+
import { i18n } from "../locale/i18nUtils";
|
|
4
5
|
import { Testing } from "../types/enum";
|
|
5
6
|
import { stylesModal } from "./RecommendationModal";
|
|
6
7
|
import TextBold from "./text/TextBold";
|
|
@@ -15,16 +16,15 @@ export default class LimitationMessage extends React.Component {
|
|
|
15
16
|
return (<React.Fragment>
|
|
16
17
|
<View style={stylesModal.container}>
|
|
17
18
|
<View style={stylesModal.titleContainer}>
|
|
18
|
-
<TextBold style={stylesModal.textTittleMessage}>{
|
|
19
|
+
<TextBold style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</TextBold>
|
|
19
20
|
</View>
|
|
20
21
|
<TextRegular style={stylesModal.textMessage}>{limitationMessage}</TextRegular>
|
|
21
22
|
</View>
|
|
22
23
|
<View style={stylesModal.containerAcceptButton}>
|
|
23
24
|
<TouchableOpacity testID={Testing.Id.LimitationMessageTestIds.OkButton} style={stylesModal.okButton} onPress={this.props.onPressNextButton}>
|
|
24
|
-
<TextRegular style={stylesModal.buttonText}>{
|
|
25
|
+
<TextRegular style={stylesModal.buttonText}>{i18n._(t `OK`)}</TextRegular>
|
|
25
26
|
</TouchableOpacity>
|
|
26
27
|
</View>
|
|
27
28
|
</React.Fragment>);
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
//# sourceMappingURL=LimitationMessage.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
+
import { i18n } from "../locale/i18nUtils";
|
|
4
5
|
import { Testing } from "../types/enum";
|
|
5
6
|
import { infoStyles } from "./InfoBars";
|
|
6
7
|
import TextBold from "./text/TextBold";
|
|
@@ -16,21 +17,21 @@ export default class RecentInsulin extends React.Component {
|
|
|
16
17
|
return (<View style={recentInsulinStyles.container}>
|
|
17
18
|
<View style={recentInsulinStyles.titleContainer}>
|
|
18
19
|
<TextBold style={recentInsulinStyles.recommended}>
|
|
19
|
-
{
|
|
20
|
+
{i18n._(t `Recommended amount of insulin`)}
|
|
20
21
|
</TextBold>
|
|
21
22
|
</View>
|
|
22
23
|
<View style={recentInsulinStyles.takenInsulinContainer}>
|
|
23
24
|
<TextBold style={recentInsulinStyles.takenInsulin}>
|
|
24
|
-
{
|
|
25
|
+
{i18n._(t `Have you taken insulin within the last 4 hours?`)}
|
|
25
26
|
</TextBold>
|
|
26
27
|
</View>
|
|
27
28
|
<View style={recentInsulinStyles.buttonContainer}>
|
|
28
29
|
<View style={recentInsulinStyles.filler}/>
|
|
29
30
|
<TouchableOpacity testID={Testing.Id.RecentInsulinTestIds.Yes} onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
|
|
30
|
-
<TextBold style={recentInsulinStyles.yesNoText}>{
|
|
31
|
+
<TextBold style={recentInsulinStyles.yesNoText}>{i18n._(t `Yes`)}</TextBold>
|
|
31
32
|
</TouchableOpacity>
|
|
32
33
|
<TouchableOpacity testID={Testing.Id.RecentInsulinTestIds.No} onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
|
|
33
|
-
<TextBold style={recentInsulinStyles.yesNoText}>{
|
|
34
|
+
<TextBold style={recentInsulinStyles.yesNoText}>{i18n._(t `No`)}</TextBold>
|
|
34
35
|
</TouchableOpacity>
|
|
35
36
|
<View style={recentInsulinStyles.filler}/>
|
|
36
37
|
</View>
|
|
@@ -90,4 +91,3 @@ const recentInsulinStyles = StyleSheet.create({
|
|
|
90
91
|
flex: 1,
|
|
91
92
|
},
|
|
92
93
|
});
|
|
93
|
-
//# sourceMappingURL=RecentInsulin.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
4
|
import ReactNativeModal from "react-native-modal";
|
|
4
|
-
import {
|
|
5
|
+
import { i18n } from "../locale/i18nUtils";
|
|
5
6
|
import { Testing } from "../types/enum";
|
|
6
7
|
import { BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
7
8
|
import LimitationMessage from "./LimitationMessage";
|
|
@@ -50,10 +51,10 @@ export default class RecommendationModal extends React.Component {
|
|
|
50
51
|
recommendationButtons = () => {
|
|
51
52
|
return (<View style={stylesModal.recommendationButtonsContainer}>
|
|
52
53
|
<TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} style={stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
|
|
53
|
-
<TextRegular style={stylesModal.affirmativeCarbsText}>{
|
|
54
|
+
<TextRegular style={stylesModal.affirmativeCarbsText}>{i18n._(t `OK`)}</TextRegular>
|
|
54
55
|
</TouchableOpacity>
|
|
55
56
|
<TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} style={stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
|
|
56
|
-
<TextRegular style={stylesModal.negativeCarbsText}>{
|
|
57
|
+
<TextRegular style={stylesModal.negativeCarbsText}>{i18n._(t `NO`)}</TextRegular>
|
|
57
58
|
</TouchableOpacity>
|
|
58
59
|
</View>);
|
|
59
60
|
};
|
|
@@ -68,7 +69,7 @@ export default class RecommendationModal extends React.Component {
|
|
|
68
69
|
<View style={stylesModal.innerView}>
|
|
69
70
|
<View style={stylesModal.recommendationRow}>
|
|
70
71
|
<TextRegular style={stylesModal.recommendEatingText}>
|
|
71
|
-
{
|
|
72
|
+
{i18n._(t `We recommend eating an additional:`)}
|
|
72
73
|
</TextRegular>
|
|
73
74
|
</View>
|
|
74
75
|
<View style={stylesModal.suggestedContainer}>
|
|
@@ -77,19 +78,19 @@ export default class RecommendationModal extends React.Component {
|
|
|
77
78
|
{`${displayCarbs} `}
|
|
78
79
|
</TextBold>
|
|
79
80
|
<TextRegular style={stylesModal.carbohydrateText}>
|
|
80
|
-
{
|
|
81
|
+
{i18n._(t `grams of carbohydrates`)}
|
|
81
82
|
</TextRegular>
|
|
82
83
|
</TextRegular>
|
|
83
84
|
</View>
|
|
84
85
|
<View style={stylesModal.recommendationRow}>
|
|
85
86
|
<TextRegular style={stylesModal.recommendEatingText}>
|
|
86
|
-
{
|
|
87
|
+
{i18n._(t `Instead of taking insulin`)}
|
|
87
88
|
</TextRegular>
|
|
88
89
|
</View>
|
|
89
90
|
</View>
|
|
90
91
|
<View style={stylesModal.addToCalculationContainer}>
|
|
91
92
|
<TextRegular style={stylesModal.addToCalculation}>
|
|
92
|
-
{
|
|
93
|
+
{i18n._(t `Would you like to add this to your current calculation?`)}
|
|
93
94
|
</TextRegular>
|
|
94
95
|
{this.recommendationButtons()}
|
|
95
96
|
</View>
|
|
@@ -104,14 +105,14 @@ export default class RecommendationModal extends React.Component {
|
|
|
104
105
|
return (<React.Fragment>
|
|
105
106
|
<View style={stylesModal.container}>
|
|
106
107
|
<View style={stylesModal.titleContainer}>
|
|
107
|
-
<TextBold style={stylesModal.textTittleMessage}>{
|
|
108
|
+
<TextBold style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</TextBold>
|
|
108
109
|
</View>
|
|
109
110
|
<TextRegular style={stylesModal.textMessage}>{attentionMessage}</TextRegular>
|
|
110
111
|
{willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
|
|
111
112
|
</View>
|
|
112
113
|
{willRecommendCarbs ? null : (<View style={stylesModal.containerAcceptButton}>
|
|
113
114
|
<TouchableOpacity testID={RecommendationModalTestIds.OkButton} style={stylesModal.okButton} onPress={this.props.onClickOkButton}>
|
|
114
|
-
<TextRegular style={stylesModal.buttonText}>{
|
|
115
|
+
<TextRegular style={stylesModal.buttonText}>{i18n._(t `OK`)}</TextRegular>
|
|
115
116
|
</TouchableOpacity>
|
|
116
117
|
</View>)}
|
|
117
118
|
</React.Fragment>);
|
|
@@ -218,4 +219,3 @@ export const stylesModal = StyleSheet.create({
|
|
|
218
219
|
justifyContent: `center`,
|
|
219
220
|
},
|
|
220
221
|
});
|
|
221
|
-
//# sourceMappingURL=RecommendationModal.js.map
|
|
@@ -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,4 +92,3 @@ export default class RecommendedCarbs extends React.Component<IProps, IState> {
|
|
|
93
92
|
*/
|
|
94
93
|
render(): JSX.Element;
|
|
95
94
|
}
|
|
96
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { Alert, Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
+
import { i18n } from "../locale/i18nUtils";
|
|
4
5
|
import { Testing } from "../types/enum";
|
|
5
6
|
import { BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
6
7
|
import { CarbohydrateLimitError } from "../utils/RecommendationError";
|
|
@@ -63,8 +64,10 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
63
64
|
if (carbs >= 0) {
|
|
64
65
|
if (carbs > 300) {
|
|
65
66
|
this.setState({ partialInput: this.props.recommendedCarbs });
|
|
66
|
-
return Alert.alert(
|
|
67
|
-
{
|
|
67
|
+
return Alert.alert(i18n._(t `Attention`), CarbohydrateLimitError().message, [
|
|
68
|
+
{
|
|
69
|
+
text: i18n._(t `OK`),
|
|
70
|
+
},
|
|
68
71
|
]);
|
|
69
72
|
}
|
|
70
73
|
this.props.changedRecommendedCarbs(carbs);
|
|
@@ -93,12 +96,12 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
93
96
|
<TouchableOpacity testID={RecommendedCarbsTestIds.RemoveRecommendation} style={calculationStyles.removeRecommended} onPress={this.props.removeRecommendedCarbs}>
|
|
94
97
|
<Icon iconIdentifier={`Ionicons/ios-close-circle-outline`} style={calculationStyles.removeRecommendedIcon}/>
|
|
95
98
|
</TouchableOpacity>
|
|
96
|
-
<TextBold style={calculationStyles.recommendedLabel}>{
|
|
99
|
+
<TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Recommended`)}</TextBold>
|
|
97
100
|
</View>
|
|
98
101
|
</View>
|
|
99
102
|
<View style={calculationStyles.borderContainer}>
|
|
100
103
|
<View style={calculationStyles.recommendedContainer}>
|
|
101
|
-
<TextBold style={calculationStyles.recommendedLabel}>{
|
|
104
|
+
<TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Additional`)}</TextBold>
|
|
102
105
|
</View>
|
|
103
106
|
<View style={calculationStyles.valueUnitContainer}>
|
|
104
107
|
<TouchableOpacity testID={RecommendedCarbsTestIds.EditRecommendedCarbs} onPress={this.showTextInput} style={[calculationStyles.valueUnitContainer]}>
|
|
@@ -112,7 +115,7 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
112
115
|
<Icon style={calculationStyles.editIcon} iconIdentifier={`Feather/edit`}/>
|
|
113
116
|
</View>
|
|
114
117
|
<TextRegular style={{ ...calculationStyles.units, color: BORDER_COLOUR_TEAL }}>
|
|
115
|
-
{
|
|
118
|
+
{i18n._(t `grams`)}
|
|
116
119
|
</TextRegular>
|
|
117
120
|
</View>
|
|
118
121
|
</TouchableOpacity>
|
|
@@ -120,9 +123,9 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
120
123
|
</View>
|
|
121
124
|
<LineSeparator color={BORDER_COLOUR_TEAL}/>
|
|
122
125
|
{this.renderRow({
|
|
123
|
-
label:
|
|
126
|
+
label: i18n._(t `Total`),
|
|
124
127
|
value: totalCarbs.toString(),
|
|
125
|
-
units:
|
|
128
|
+
units: i18n._(t `grams`),
|
|
126
129
|
}, RecommendedCarbsTestIds.TotalCarbs)}
|
|
127
130
|
<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}/>
|
|
128
131
|
</React.Fragment>);
|
|
@@ -160,13 +163,15 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
160
163
|
const carbs = Number(this.props.recommendedCarbs);
|
|
161
164
|
return (<React.Fragment>
|
|
162
165
|
<View style={calculationStyles.foodTitleContainer}>
|
|
163
|
-
<TextBold style={infoStyles.label}>{
|
|
164
|
-
<TextRegular style={calculationStyles.foodUnitsLabel}>
|
|
166
|
+
<TextBold style={infoStyles.label}>{i18n._(t `Food`)}</TextBold>
|
|
167
|
+
<TextRegular style={calculationStyles.foodUnitsLabel}>
|
|
168
|
+
{`(${i18n._(t `Carbohydrates`)})`}
|
|
169
|
+
</TextRegular>
|
|
165
170
|
</View>
|
|
166
171
|
{this.renderRow({
|
|
167
|
-
label:
|
|
172
|
+
label: i18n._(t `Entered`),
|
|
168
173
|
value: this.props.enteredCarbs,
|
|
169
|
-
units:
|
|
174
|
+
units: i18n._(t `grams`),
|
|
170
175
|
}, RecommendedCarbsTestIds.EnteredCarbs)}
|
|
171
176
|
{!isNaN(carbs) && carbs > 0 ? this.renderRecommendedCarbs() : null}
|
|
172
177
|
</React.Fragment>);
|
|
@@ -248,4 +253,3 @@ const calculationStyles = StyleSheet.create({
|
|
|
248
253
|
paddingBottom: `0.5%`,
|
|
249
254
|
},
|
|
250
255
|
});
|
|
251
|
-
//# sourceMappingURL=RecommendedCarbs.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { BolusCalculator } from "@hedia/types";
|
|
2
|
+
import { t } from "@lingui/macro";
|
|
1
3
|
import React from "react";
|
|
2
4
|
import { Alert, Dimensions, Platform, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
5
|
import LinearGradient from "react-native-linear-gradient";
|
|
4
|
-
import {
|
|
5
|
-
import { translate } from "../locales/translate";
|
|
6
|
+
import { i18n } from "../locale/i18nUtils";
|
|
6
7
|
import { Testing } from "../types/enum";
|
|
7
8
|
import { Messages } from "../utils/AttentionMessages";
|
|
8
9
|
import { Utils } from "../utils/Utils";
|
|
@@ -87,8 +88,10 @@ export default class RecommendedInsulin extends React.Component {
|
|
|
87
88
|
if (rounded > limited) {
|
|
88
89
|
this.setState({ partialInput: this.props.insulinRecommendation?.toString() ?? null });
|
|
89
90
|
this.props.updateRecommendedInsulin(this.props.insulinRecommendation);
|
|
90
|
-
return Alert.alert(
|
|
91
|
-
{
|
|
91
|
+
return Alert.alert(i18n._(t `Attention`), Messages.InsulinInputWasLimited(this.props.activityReduction), [
|
|
92
|
+
{
|
|
93
|
+
text: i18n._(t `OK`),
|
|
94
|
+
},
|
|
92
95
|
]);
|
|
93
96
|
}
|
|
94
97
|
this.updatePartially(`${rounded}`);
|
|
@@ -106,7 +109,7 @@ export default class RecommendedInsulin extends React.Component {
|
|
|
106
109
|
<LinearGradient style={recommendedInsulinStyles.container} colors={[`#a200ff`, `#578aff`]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}>
|
|
107
110
|
<View style={recommendedInsulinStyles.recommendedTextContainer}>
|
|
108
111
|
<TextBold style={recommendedInsulinStyles.recommendedText}>
|
|
109
|
-
{
|
|
112
|
+
{i18n._(t `Recommended amount of insulin`)}
|
|
110
113
|
</TextBold>
|
|
111
114
|
</View>
|
|
112
115
|
<View style={[recommendedInsulinStyles.recommendedContainer, { paddingBottom }]}>
|
|
@@ -114,7 +117,7 @@ export default class RecommendedInsulin extends React.Component {
|
|
|
114
117
|
<TextBold style={recommendedInsulinStyles.value} testID={RecommendedInsulinTestIds.ShownInsulinText}>
|
|
115
118
|
{shownInsulin}
|
|
116
119
|
</TextBold>
|
|
117
|
-
<TextRegular style={recommendedInsulinStyles.units}>{
|
|
120
|
+
<TextRegular style={recommendedInsulinStyles.units}>{i18n._(t `Units`)}</TextRegular>
|
|
118
121
|
</View>
|
|
119
122
|
<Icon style={recommendedInsulinStyles.editIcon} iconIdentifier={`Feather/edit`} testID={RecommendedInsulinTestIds.EditRecommendedInsulinIcon}/>
|
|
120
123
|
</View>
|
|
@@ -168,4 +171,3 @@ const recommendedInsulinStyles = StyleSheet.create({
|
|
|
168
171
|
marginRight: `5%`,
|
|
169
172
|
},
|
|
170
173
|
});
|
|
171
|
-
//# sourceMappingURL=RecommendedInsulin.js.map
|
|
@@ -8,15 +8,25 @@ export interface IProps {
|
|
|
8
8
|
*/
|
|
9
9
|
onSliderChange(value: number): void;
|
|
10
10
|
}
|
|
11
|
-
export interface IState {
|
|
12
|
-
remeasureTime: number;
|
|
13
|
-
}
|
|
14
11
|
/**
|
|
15
12
|
* The Remeasure component has a slider child component that the user can drag to change
|
|
16
13
|
* when they will get a reminder notification about measuring their BGL again.
|
|
17
14
|
*/
|
|
18
|
-
export default class Remeasure extends React.Component<IProps
|
|
19
|
-
|
|
15
|
+
export default class Remeasure extends React.Component<IProps> {
|
|
16
|
+
/** For holding a reference to the slider component so its initial value can be set (only one time) when the Remeasure component has been mounted. */
|
|
17
|
+
private slider?;
|
|
18
|
+
/**
|
|
19
|
+
* Called immediately after a component is mounted. Setting state here will trigger re-rendering.
|
|
20
|
+
*
|
|
21
|
+
* If the value of a slider component in React Native is set to track an outside state,
|
|
22
|
+
* the slider indicator may jump back and forth while updates to the value are propagated through the affected objects and components.
|
|
23
|
+
* Since we don’t need to change the value of the slider from the outside after initialising it to the default value,
|
|
24
|
+
* we simply set the default value (using setNativeProp) upon initialisation instead of using the slider’s normal value prop to set it.
|
|
25
|
+
*
|
|
26
|
+
* Steps:
|
|
27
|
+
* 1. Call the setNativeProps() method on the slider to set its value to the remeasureTime prop.
|
|
28
|
+
*/
|
|
29
|
+
componentDidMount(): void;
|
|
20
30
|
/**
|
|
21
31
|
* Steps:
|
|
22
32
|
* 1. Use limitTime() to limit/clamp the value of remeasureTime in the range 0 to 6.
|