@hedia/recommendation-screen 2.2.0-alpha.13 → 2.2.0-alpha.15
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/src/RecommendationScreen.d.ts +11 -8
- package/dist/src/RecommendationScreen.js +3 -3
- package/dist/src/components/ForecastInfoBar.d.ts +5 -18
- package/dist/src/components/ForecastInfoBar.js +37 -40
- package/dist/src/components/RecommendedInsulin.d.ts +2 -1
- package/dist/src/components/RecommendedInsulin.js +5 -4
- package/package.json +1 -1
|
@@ -10,6 +10,15 @@ export interface IResult {
|
|
|
10
10
|
/** The actual amount (of insulin in units or carbohydrates in grams) */
|
|
11
11
|
entered: number | null;
|
|
12
12
|
}
|
|
13
|
+
/** Represents forecast data */
|
|
14
|
+
export interface IForecast {
|
|
15
|
+
/** The forecasted glucose value to display. */
|
|
16
|
+
forecastedGlucose: number | null;
|
|
17
|
+
/** Forecasted time value to display. */
|
|
18
|
+
forecastTime: string | null;
|
|
19
|
+
/** Latest CGM value to display. */
|
|
20
|
+
latestCGMReading: number | null;
|
|
21
|
+
}
|
|
13
22
|
export interface IRecommendationProps {
|
|
14
23
|
/** The blood glucose measurement unit that the user prefers. */
|
|
15
24
|
bloodGlucoseUnit: BloodGlucoseUnit;
|
|
@@ -29,14 +38,8 @@ export interface IRecommendationProps {
|
|
|
29
38
|
latestLogbookFrom6Hours: Logbook.Types.ILogbookEntry | null;
|
|
30
39
|
/** The properties of the entered activity that are not used for making the calculation itself, but will be used on the recommendation screen. */
|
|
31
40
|
activityDisplayProps: IActivityDisplayProps | null;
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/** Forecasted time value to display. */
|
|
35
|
-
forecastTime: string | null;
|
|
36
|
-
/** Latest CGM value to display. */
|
|
37
|
-
latestCGMReading: number | null;
|
|
38
|
-
/** Check if the forecasted glucose value is in very low range. */
|
|
39
|
-
isForecastedGlucoseVeryLow: boolean;
|
|
41
|
+
/** Forecast data received from the app */
|
|
42
|
+
forecast: IForecast | null;
|
|
40
43
|
/**
|
|
41
44
|
* Callback function taking a single boolean argument and returning nothing.
|
|
42
45
|
* To be called when the user decides on a presented carbohydrate recommendation.
|
|
@@ -460,7 +460,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
460
460
|
const carbRecommendation = carbRecommendationProp !== null ? Math.round(carbRecommendationProp) : null;
|
|
461
461
|
const recommendedCarbs = enteredCarbs ?? carbRecommendation;
|
|
462
462
|
const isModalOpen = showExitModal || showLimitationMessage || showTimeoutModal;
|
|
463
|
-
const { activityDisplayProps, bloodGlucoseUnit, bloodKetoneUnit, calculatorParams, currentBKL, injectionMethod, language, onRecentInsulinYes,
|
|
463
|
+
const { activityDisplayProps, bloodGlucoseUnit, bloodKetoneUnit, calculatorParams, currentBKL, injectionMethod, language, onRecentInsulinYes, forecast, } = this.props;
|
|
464
464
|
const { activity, currentBGL, carbohydrates: providedCarbs } = calculatorParams;
|
|
465
465
|
const displayedBGL = currentBGL ? Utils.displayedBGLValue(currentBGL, bloodGlucoseUnit) : null;
|
|
466
466
|
const displayedBKL = currentBKL !== null && bloodKetoneUnit ? Utils.displayedBKLValue(currentBKL, bloodKetoneUnit) : null;
|
|
@@ -474,7 +474,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
474
474
|
}}>
|
|
475
475
|
<Header exitCallback={this.onExit}/>
|
|
476
476
|
<InfoBars label={i18n._(t `Active Insulin`)} value={activeInsulin ? `${activeInsulin.toFixed(1)}` : null} unit={i18n._(t `units`)} showNullAsDash={false} testID={{ unitID: ActiveInsulinUnitTestID, valueID: ActiveInsulinValueTestID }}/>
|
|
477
|
-
{
|
|
477
|
+
{forecast ? (<ForecastInfoBar label={i18n._(t `Forecasted Glucose`)} forecast={forecast} unit={bloodGlucoseUnit} testID={{ unitID: FGUnitTestID, valueID: FGValueTestID }}/>) : (<InfoBars label={i18n._(t `Blood Glucose Level`)} value={displayedBGL} unit={bloodGlucoseUnit} showNullAsDash={true} testID={{ unitID: BGUnitTestID, valueID: BGValueTestID }}/>)}
|
|
478
478
|
<InfoBars label={i18n._(t `Blood Ketone Level`)} value={displayedBKL} unit={bloodKetoneUnit} showNullAsDash={true} testID={{ unitID: BKUnitTestID, valueID: BKValueTestID }}/>
|
|
479
479
|
<View style={containerStyles.calcContainer}>
|
|
480
480
|
<View style={containerStyles.calcMargin}>
|
|
@@ -485,7 +485,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
485
485
|
</View>
|
|
486
486
|
{activity && activityDisplayProps && (<Activity activity={activity} activityType={activityDisplayProps.activityType} activityTitle={activityDisplayProps.activityTitle} activityReduction={activityReduction}/>)}
|
|
487
487
|
<Remeasure onSliderChange={this.updateRemeasureTime} remeasureTime={remeasureTime}/>
|
|
488
|
-
{!isRecommendationDisplayed ? (<RecentInsulin onRecentInsulinYes={onRecentInsulinYes} onRecentInsulinNo={this.handleNoRecentInsulin}/>) : (<RecommendedInsulin injectionMethod={injectionMethod} insulinRecommendation={insulinRecommendation} enteredInsulin={enteredInsulin} activityReduction={activityReduction} updateRecommendedInsulin={this.updateInsulinRecommendation}
|
|
488
|
+
{!isRecommendationDisplayed ? (<RecentInsulin onRecentInsulinYes={onRecentInsulinYes} onRecentInsulinNo={this.handleNoRecentInsulin}/>) : (<RecommendedInsulin injectionMethod={injectionMethod} insulinRecommendation={insulinRecommendation} enteredInsulin={enteredInsulin} activityReduction={activityReduction} updateRecommendedInsulin={this.updateInsulinRecommendation} forecast={forecast}/>)}
|
|
489
489
|
<Emotion moodSelected={this.handleMoodSelected} currentMood={selectedMood}/>
|
|
490
490
|
<SaveButton visible={isRecommendationDisplayed} transfer={this.handleTransfer}/>
|
|
491
491
|
<RecommendationModal isVisible={recommendationModal} suggestedCarbohydrates={carbRecommendationProp} attentionMessage={this.getBGLevelAttentionMessage()} limitationMessage={this.getLimitationAttentionMessage()} onClickOkButton={this.hideAttentionModal} onAcceptCarbohydrates={this.acceptCarbRecommendation} onDeclineCarbohydrates={this.declineCarbRecommendation}/>
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { BloodGlucoseUnit } from "@hedia/types";
|
|
2
|
-
import
|
|
3
|
+
import { IForecast } from "../RecommendationScreen";
|
|
3
4
|
import { Testing } from "../types/enum";
|
|
4
5
|
export interface IProps {
|
|
5
6
|
/** The display label that describes the value to the user. */
|
|
6
7
|
label: string;
|
|
7
8
|
/** The value to display. */
|
|
8
|
-
|
|
9
|
+
forecast: IForecast;
|
|
9
10
|
/** Unit label to print after the value. */
|
|
10
11
|
unit: BloodGlucoseUnit;
|
|
11
|
-
/** Forecast time value to display. */
|
|
12
|
-
forecastTime: string | null;
|
|
13
|
-
/** Latest CGM value to display. */
|
|
14
|
-
latestCGMReading: number | null;
|
|
15
12
|
/** optional object that contains as properties a valueID and a unitID */
|
|
16
13
|
testID?: {
|
|
17
14
|
valueID: Testing.Id.InfoBarTestIds.Value;
|
|
@@ -19,18 +16,7 @@ export interface IProps {
|
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
/** A standard panel to display some data that the user entered. */
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Determine the unit string to be displayed in the infobar.
|
|
25
|
-
*
|
|
26
|
-
* @returns The string to display as the unit in the infobar
|
|
27
|
-
*/
|
|
28
|
-
displayUnit: () => string;
|
|
29
|
-
/**
|
|
30
|
-
* @returns JSX element to display a card with the entered value.
|
|
31
|
-
*/
|
|
32
|
-
render(): JSX.Element;
|
|
33
|
-
}
|
|
19
|
+
declare const ForecastInfoBar: (props: IProps) => JSX.Element;
|
|
34
20
|
/** @internal */
|
|
35
21
|
export declare const infoStyles: {
|
|
36
22
|
container: {
|
|
@@ -115,3 +101,4 @@ export declare const infoStyles: {
|
|
|
115
101
|
marginBottom: number;
|
|
116
102
|
};
|
|
117
103
|
};
|
|
104
|
+
export default ForecastInfoBar;
|
|
@@ -8,61 +8,57 @@ import { Utils } from "../utils/Utils";
|
|
|
8
8
|
import TextBold from "./text/TextBold";
|
|
9
9
|
import TextRegular from "./text/TextRegular";
|
|
10
10
|
/** A standard panel to display some data that the user entered. */
|
|
11
|
-
|
|
11
|
+
const ForecastInfoBar = (props) => {
|
|
12
|
+
const { testID, label, unit, forecast } = props;
|
|
12
13
|
/**
|
|
13
14
|
* Determine the unit string to be displayed in the infobar.
|
|
14
15
|
*
|
|
15
16
|
* @returns The string to display as the unit in the infobar
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
// tslint:disable-next-line: no-shadowed-variable
|
|
19
|
+
const displayUnit = (unit) => Utils.formatUnit(unit);
|
|
20
|
+
const { border, container, forecastDot, forecastSubtitle, forecastText, forecastTime, gradient, labelContainer, row, unitContainer, units, value, valueContainer, valueUnitContainer, } = infoStyles;
|
|
21
21
|
/**
|
|
22
22
|
* @returns JSX element to display a card with the entered value.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
return (<View style={container}>
|
|
25
|
+
<LinearGradient style={gradient} colors={[`#8B38F5`, `#D593E5`]} useAngle={true} angle={170}>
|
|
26
|
+
<View style={border}>
|
|
27
|
+
<View style={row}>
|
|
28
|
+
<View style={labelContainer}>
|
|
29
|
+
<TextBold style={infoStyles.label}>{label}</TextBold>
|
|
30
|
+
</View>
|
|
31
|
+
<View style={valueUnitContainer}>
|
|
32
|
+
<View style={valueContainer}>
|
|
33
|
+
<TextBold style={value} testID={testID?.valueID}>
|
|
34
|
+
{forecast.forecastedGlucose}
|
|
35
|
+
</TextBold>
|
|
33
36
|
</View>
|
|
34
|
-
<View style={
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</TextBold>
|
|
39
|
-
</View>
|
|
40
|
-
<View style={unitContainer}>
|
|
41
|
-
<TextRegular style={units} testID={testID?.unitID}>
|
|
42
|
-
{this.displayUnit()}
|
|
43
|
-
</TextRegular>
|
|
44
|
-
</View>
|
|
37
|
+
<View style={unitContainer}>
|
|
38
|
+
<TextRegular style={units} testID={testID?.unitID}>
|
|
39
|
+
{displayUnit(unit)}
|
|
40
|
+
</TextRegular>
|
|
45
41
|
</View>
|
|
46
42
|
</View>
|
|
43
|
+
</View>
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</View>
|
|
45
|
+
<View style={row}>
|
|
46
|
+
<View style={forecastSubtitle}>
|
|
47
|
+
<LinearGradient colors={[`#8B38F5`, `#D593E5`]} useAngle={true} angle={135} style={forecastDot}/>
|
|
48
|
+
<TextRegular style={forecastText}>{i18n._(t `Forecast time:`)}</TextRegular>
|
|
49
|
+
<TextRegular style={forecastTime}>{forecast.forecastTime}</TextRegular>
|
|
54
50
|
</View>
|
|
51
|
+
</View>
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
</View>
|
|
53
|
+
<View style={row}>
|
|
54
|
+
<TextRegular style={infoStyles.currentCGM}>
|
|
55
|
+
{i18n._(t `Current glucose: ${forecast.latestCGMReading} ${displayUnit(unit)}`)}
|
|
56
|
+
</TextRegular>
|
|
61
57
|
</View>
|
|
62
|
-
</
|
|
63
|
-
</
|
|
64
|
-
|
|
65
|
-
}
|
|
58
|
+
</View>
|
|
59
|
+
</LinearGradient>
|
|
60
|
+
</View>);
|
|
61
|
+
};
|
|
66
62
|
const { width } = Dimensions.get(`screen`);
|
|
67
63
|
/** @internal */
|
|
68
64
|
export const infoStyles = StyleSheet.create({
|
|
@@ -148,3 +144,4 @@ export const infoStyles = StyleSheet.create({
|
|
|
148
144
|
marginBottom: 5,
|
|
149
145
|
},
|
|
150
146
|
});
|
|
147
|
+
export default ForecastInfoBar;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UserSettings } from "@hedia/types";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { IForecast } from "../RecommendationScreen";
|
|
3
4
|
export interface IProps {
|
|
4
5
|
/** The amount of insulin in units to display to the user as a recommendation. */
|
|
5
6
|
insulinRecommendation: number;
|
|
@@ -14,7 +15,7 @@ export interface IProps {
|
|
|
14
15
|
/** Used to determine how the insulin amount should be rounded. */
|
|
15
16
|
injectionMethod: UserSettings.Enums.InjectionMethod;
|
|
16
17
|
/** Used to show different text depending on different insulin ranges. */
|
|
17
|
-
|
|
18
|
+
forecast: IForecast | null;
|
|
18
19
|
/**
|
|
19
20
|
* Callback function taking a number as argument and giving no return value.
|
|
20
21
|
* To be called with the new value every time the content of the insulin input field gets changed.
|
|
@@ -102,11 +102,12 @@ export default class RecommendedInsulin extends React.Component {
|
|
|
102
102
|
* and using an InvisibleNumberInput component to enable input when the insulin amount is tapped.
|
|
103
103
|
*/
|
|
104
104
|
render = () => {
|
|
105
|
-
const
|
|
105
|
+
const { forecast, insulinRecommendation } = this.props;
|
|
106
|
+
const shownInsulin = this.state.partialInput ?? insulinRecommendation ?? `0`;
|
|
106
107
|
const { container, editText, title, recommendedContainer, valueContainer, value, units, editButton } = styles;
|
|
107
|
-
const titleText =
|
|
108
|
-
? i18n._(t `Recommended amount of rapid-acting insulin for immidiate injection`)
|
|
109
|
-
: i18n._(t `Recommended amount of rapid-acting insulin for immidiate injection
|
|
108
|
+
const titleText = forecast
|
|
109
|
+
? i18n._(t `Recommended amount of rapid-acting insulin for immidiate injection based on forecasted glucose`)
|
|
110
|
+
: i18n._(t `Recommended amount of rapid-acting insulin for immidiate injection`);
|
|
110
111
|
return (<>
|
|
111
112
|
<TouchableOpacity testID={RecommendedInsulinTestIds.EditRecommendedInsulin} onPress={this.handleOnPress}>
|
|
112
113
|
<LinearGradient style={container} colors={[colors.purple, colors.blue]} useAngle={true} angle={315}>
|