@hedia/recommendation-screen 2.1.59 → 2.1.60-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/RecommendationScreen.d.ts +9 -1
- package/dist/src/RecommendationScreen.js +9 -2
- package/dist/src/components/InfoBars.d.ts +2 -0
- package/dist/src/components/InfoBars.js +2 -0
- package/dist/src/components/InvisibleNumberInput.js +5 -11
- package/dist/src/components/activity/Activity.js +1 -0
- package/package.json +1 -1
|
@@ -54,6 +54,12 @@ export interface IRecommendationProps {
|
|
|
54
54
|
* Should allow the user to enter when they injected insulin and how much.
|
|
55
55
|
*/
|
|
56
56
|
onRecentInsulinYes(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Callback function without arguments or return values.
|
|
59
|
+
* To be called if the user taps “No” when asked if they have taken insulin recently, making the recommendation visible.
|
|
60
|
+
* Or if they have recently taken insulin and the recommendation is visible.
|
|
61
|
+
*/
|
|
62
|
+
onRecommendationDisplayed(): void;
|
|
57
63
|
/**
|
|
58
64
|
* To be called when the “Transfer to Logbook” button is pressed.
|
|
59
65
|
* @param carbs The suggested and entered amount of carbohydrates.
|
|
@@ -163,6 +169,7 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
|
|
|
163
169
|
* - Set the language by using the language prop as argument for calling changeLanguage()
|
|
164
170
|
* - Unpack recentBoluses from the calculatorParams prop.
|
|
165
171
|
* - Use the calculatorParams prop as argument for calling calculateRecommendation() and unpack all of the resulting values.
|
|
172
|
+
* - Call the onRecommendationDisplayed() callback prop if the recommendation is visible
|
|
166
173
|
* - Copy the carbRecommendation to the suggestedCarbs member variable.
|
|
167
174
|
* - Set the following state variables:
|
|
168
175
|
* - Set remeasureTime to the return value from calling the getBGLevelRemeasurementReminder() method.
|
|
@@ -287,7 +294,8 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
|
|
|
287
294
|
*
|
|
288
295
|
* Steps:
|
|
289
296
|
* 1. Set the isRecommendationDisplayed state variable to be true.
|
|
290
|
-
* 2.
|
|
297
|
+
* 2. Call the onRecommendationDisplayed prop callback function.
|
|
298
|
+
* 3. As a callback to the setState() method, define a new anonymous function that calls setTimeout() with a duration of 0 milliseconds.
|
|
291
299
|
* When the time expires, call the scrollToEnd() method of the scrollView member, with the animated argument set to true.
|
|
292
300
|
* This ensures that the scroll event happens after all other events that get queued to happen at the same time,
|
|
293
301
|
* so all relevant elements are visible on the screen and the scroll happens reliably.
|
|
@@ -75,6 +75,7 @@ export default class RecommendationScreen extends React.Component {
|
|
|
75
75
|
* - Set the language by using the language prop as argument for calling changeLanguage()
|
|
76
76
|
* - Unpack recentBoluses from the calculatorParams prop.
|
|
77
77
|
* - Use the calculatorParams prop as argument for calling calculateRecommendation() and unpack all of the resulting values.
|
|
78
|
+
* - Call the onRecommendationDisplayed() callback prop if the recommendation is visible
|
|
78
79
|
* - Copy the carbRecommendation to the suggestedCarbs member variable.
|
|
79
80
|
* - Set the following state variables:
|
|
80
81
|
* - Set remeasureTime to the return value from calling the getBGLevelRemeasurementReminder() method.
|
|
@@ -100,9 +101,13 @@ export default class RecommendationScreen extends React.Component {
|
|
|
100
101
|
const { recentBoluses } = props.calculatorParams;
|
|
101
102
|
const { bolus, carbRecommendation, activityReduction, wasLimited, activeInsulin } = Calculator.calculateRecommendation(props.calculatorParams);
|
|
102
103
|
this.suggestedCarbs = carbRecommendation;
|
|
104
|
+
const isRecommendationDisplayed = recentBoluses?.length !== 0;
|
|
105
|
+
if (isRecommendationDisplayed) {
|
|
106
|
+
this.props.onRecommendationDisplayed();
|
|
107
|
+
}
|
|
103
108
|
this.state = {
|
|
104
109
|
remeasureTime: this.getBGLevelRemeasurementReminder(),
|
|
105
|
-
isRecommendationDisplayed
|
|
110
|
+
isRecommendationDisplayed,
|
|
106
111
|
insulinRecommendation: Utils.roundValue(bolus, props.injectionMethod),
|
|
107
112
|
wasLimited,
|
|
108
113
|
activityReduction,
|
|
@@ -280,13 +285,15 @@ export default class RecommendationScreen extends React.Component {
|
|
|
280
285
|
*
|
|
281
286
|
* Steps:
|
|
282
287
|
* 1. Set the isRecommendationDisplayed state variable to be true.
|
|
283
|
-
* 2.
|
|
288
|
+
* 2. Call the onRecommendationDisplayed prop callback function.
|
|
289
|
+
* 3. As a callback to the setState() method, define a new anonymous function that calls setTimeout() with a duration of 0 milliseconds.
|
|
284
290
|
* When the time expires, call the scrollToEnd() method of the scrollView member, with the animated argument set to true.
|
|
285
291
|
* This ensures that the scroll event happens after all other events that get queued to happen at the same time,
|
|
286
292
|
* so all relevant elements are visible on the screen and the scroll happens reliably.
|
|
287
293
|
*/
|
|
288
294
|
handleNoRecentInsulin = () => {
|
|
289
295
|
this.setState({ isRecommendationDisplayed: true }, () => {
|
|
296
|
+
this.props.onRecommendationDisplayed();
|
|
290
297
|
setTimeout(() => {
|
|
291
298
|
this.scrollView?.scrollToEnd(true);
|
|
292
299
|
}, 0);
|
|
@@ -70,9 +70,11 @@ export const infoStyles = StyleSheet.create({
|
|
|
70
70
|
borderWidth: 1,
|
|
71
71
|
borderColor: colors.dustyDarkBlue,
|
|
72
72
|
borderRadius: 5,
|
|
73
|
+
alignItems: `center`,
|
|
73
74
|
},
|
|
74
75
|
labelContainer: {
|
|
75
76
|
flex: 7,
|
|
77
|
+
justifyContent: `flex-start`,
|
|
76
78
|
},
|
|
77
79
|
label: {
|
|
78
80
|
...FONTS.Poppins.regular_Base,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, TextInput } from "react-native";
|
|
3
3
|
/**
|
|
4
4
|
* InvisibleNumberInput is used to enable numerical input by the user without displaying a traditional input field on the screen.
|
|
5
5
|
* Since the input field is made invisible and thus can’t be tapped directly by the user we need to be able to call
|
|
@@ -99,7 +99,7 @@ export default class InvisibleNumberInput extends React.Component {
|
|
|
99
99
|
*/
|
|
100
100
|
render() {
|
|
101
101
|
const { testID } = this.props;
|
|
102
|
-
return (<TextInput testID={testID} value={
|
|
102
|
+
return (<TextInput testID={testID} value={this.state.value} ref={(textInput) => {
|
|
103
103
|
if (textInput !== null) {
|
|
104
104
|
this.textInput = textInput;
|
|
105
105
|
}
|
|
@@ -108,14 +108,8 @@ export default class InvisibleNumberInput extends React.Component {
|
|
|
108
108
|
}
|
|
109
109
|
const inputStyles = StyleSheet.create({
|
|
110
110
|
input: {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
height: 0,
|
|
115
|
-
},
|
|
116
|
-
android: {
|
|
117
|
-
opacity: 0,
|
|
118
|
-
},
|
|
119
|
-
}),
|
|
111
|
+
width: 0,
|
|
112
|
+
height: 0,
|
|
113
|
+
opacity: 0,
|
|
120
114
|
},
|
|
121
115
|
});
|