@hedia/recommendation-screen 2.1.42 → 2.1.43-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.
- package/dist/src/RecommendationScreen.js +337 -312
- package/dist/src/components/Header.js +4 -4
- package/dist/src/components/Icon.js +2 -0
- package/dist/src/components/InfoBars.d.ts +0 -2
- package/dist/src/components/InfoBars.js +39 -42
- package/dist/src/components/InvisibleNumberInput.js +70 -71
- package/dist/src/components/LimitationMessage.js +13 -14
- package/dist/src/components/RecentInsulin.js +19 -19
- package/dist/src/components/RecommendationModal.d.ts +0 -1
- package/dist/src/components/RecommendationModal.js +73 -65
- package/dist/src/components/RecommendedCarbs.js +101 -97
- package/dist/src/components/RecommendedInsulin.js +98 -95
- package/dist/src/components/Remeasure.js +34 -32
- package/dist/src/components/TransferToLogbook.js +23 -25
- package/dist/src/components/TwoOptionModal.d.ts +0 -10
- package/dist/src/components/TwoOptionModal.js +10 -18
- package/dist/src/components/activity/Activity.js +14 -12
- package/dist/src/components/activity/ActivityIcon.js +11 -11
- package/dist/src/components/activity/ActivityIntensity.js +16 -19
- package/dist/src/components/mood/Emotion.js +29 -32
- package/dist/src/components/mood/MoodIcon.js +23 -26
- package/dist/src/components/text/TextBold.d.ts +8 -0
- package/dist/src/components/text/TextBold.js +12 -0
- package/dist/src/components/text/TextRegular.d.ts +8 -0
- package/dist/src/components/text/TextRegular.js +12 -0
- package/dist/src/utils/AttentionMessages.js +36 -36
- package/dist/src/utils/RecommendationError.js +1 -0
- package/dist/src/utils/Utils.js +15 -15
- package/package.json +5 -5
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { t } from "@lingui/macro";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Dimensions, StyleSheet,
|
|
3
|
+
import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import ReactNativeModal from "react-native-modal";
|
|
5
5
|
import { i18n } from "../locale/i18nUtils";
|
|
6
6
|
import { Testing } from "../types/enum";
|
|
7
7
|
import { BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
8
8
|
import LimitationMessage from "./LimitationMessage";
|
|
9
|
+
import TextBold from "./text/TextBold";
|
|
10
|
+
import TextRegular from "./text/TextRegular";
|
|
9
11
|
const { RecommendationModalTestIds } = Testing.Id;
|
|
10
12
|
/**
|
|
11
13
|
* Popup modal for displaying information messages or warnings to the user if necessary.
|
|
@@ -24,99 +26,105 @@ export default class RecommendationModal extends React.Component {
|
|
|
24
26
|
*/
|
|
25
27
|
constructor(props) {
|
|
26
28
|
super(props);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
* Steps:
|
|
31
|
-
* 1. Unpack attentionMessage and suggestedCarbohydrates from the props object.
|
|
32
|
-
* 2. Define isPageVisible to be true if either attentionMessage or suggestedCarbohydrates is truthy.
|
|
33
|
-
* 3. If isPageVisible is true then set the firstPageVisible state variable to false. Otherwise call the onClickOkButton prop callback function.
|
|
34
|
-
*/
|
|
35
|
-
this.onPressNextButton = () => {
|
|
36
|
-
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
37
|
-
const isPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
|
|
38
|
-
return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
|
|
29
|
+
this.state = {
|
|
30
|
+
firstPageVisible: !!this.props.limitationMessage,
|
|
39
31
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Handle what happens when the “next” button is pressed.
|
|
35
|
+
*
|
|
36
|
+
* Steps:
|
|
37
|
+
* 1. Unpack attentionMessage and suggestedCarbohydrates from the props object.
|
|
38
|
+
* 2. Define isPageVisible to be true if either attentionMessage or suggestedCarbohydrates is truthy.
|
|
39
|
+
* 3. If isPageVisible is true then set the firstPageVisible state variable to false. Otherwise call the onClickOkButton prop callback function.
|
|
40
|
+
*/
|
|
41
|
+
onPressNextButton = () => {
|
|
42
|
+
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
43
|
+
const isPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
|
|
44
|
+
return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* @returns Return an JSX element for composing two buttons: one for accepting a suggestion and one for rejecting it.
|
|
48
|
+
* If the accept button is pressed the onAcceptCarbohydrates prop callback function shall be called.
|
|
49
|
+
* If the accept button is pressed the onDeclineCarbohydrates prop callback function shall be called.
|
|
50
|
+
*/
|
|
51
|
+
recommendationButtons = () => {
|
|
52
|
+
return (<View style={stylesModal.recommendationButtonsContainer}>
|
|
47
53
|
<TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} style={stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
|
|
48
|
-
<
|
|
54
|
+
<TextRegular style={stylesModal.affirmativeCarbsText}>{i18n._(t `OK`)}</TextRegular>
|
|
49
55
|
</TouchableOpacity>
|
|
50
56
|
<TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} style={stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
|
|
51
|
-
<
|
|
57
|
+
<TextRegular style={stylesModal.negativeCarbsText}>{i18n._(t `NO`)}</TextRegular>
|
|
52
58
|
</TouchableOpacity>
|
|
53
59
|
</View>);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Compose a JSX element for displaying a recommendation of additional carbohydrates (the value of the suggestedCarbohydrates prop rounded to the nearest integer)
|
|
63
|
+
* to the user in a way that explains what to do with the suggestion.
|
|
64
|
+
* @param suggestedCarbohydrates the recommended additional carbohydrates
|
|
65
|
+
*/
|
|
66
|
+
recommendCarbohydrates = (suggestedCarbohydrates) => {
|
|
67
|
+
const displayCarbs = Math.round(suggestedCarbohydrates);
|
|
68
|
+
return (<React.Fragment>
|
|
63
69
|
<View style={stylesModal.innerView}>
|
|
64
70
|
<View style={stylesModal.recommendationRow}>
|
|
65
|
-
<
|
|
71
|
+
<TextRegular style={stylesModal.recommendEatingText}>
|
|
66
72
|
{i18n._(t `We recommend eating an additional:`)}
|
|
67
|
-
</
|
|
73
|
+
</TextRegular>
|
|
68
74
|
</View>
|
|
69
75
|
<View style={stylesModal.suggestedContainer}>
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
<TextRegular style={stylesModal.textCenter}>
|
|
77
|
+
<TextBold style={stylesModal.suggestedCarbs} testID={RecommendationModalTestIds.SuggestedCarbs}>
|
|
78
|
+
{`${displayCarbs} `}
|
|
79
|
+
</TextBold>
|
|
80
|
+
<TextRegular style={stylesModal.carbohydrateText}>
|
|
81
|
+
{i18n._(t `grams of carbohydrates`)}
|
|
82
|
+
</TextRegular>
|
|
83
|
+
</TextRegular>
|
|
74
84
|
</View>
|
|
75
85
|
<View style={stylesModal.recommendationRow}>
|
|
76
|
-
<
|
|
86
|
+
<TextRegular style={stylesModal.recommendEatingText}>
|
|
87
|
+
{i18n._(t `Instead of taking insulin`)}
|
|
88
|
+
</TextRegular>
|
|
77
89
|
</View>
|
|
78
90
|
</View>
|
|
79
91
|
<View style={stylesModal.addToCalculationContainer}>
|
|
80
|
-
<
|
|
92
|
+
<TextRegular style={stylesModal.addToCalculation}>
|
|
81
93
|
{i18n._(t `Would you like to add this to your current calculation?`)}
|
|
82
|
-
</
|
|
94
|
+
</TextRegular>
|
|
83
95
|
{this.recommendationButtons()}
|
|
84
96
|
</View>
|
|
85
97
|
</React.Fragment>);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @returns JSX element for displaying the “second” page of the recommendation modal. The second page displays the string from the attentionMessage prop.
|
|
101
|
+
*/
|
|
102
|
+
secondPage = () => {
|
|
103
|
+
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
104
|
+
const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
|
|
105
|
+
return (<React.Fragment>
|
|
94
106
|
<View style={stylesModal.container}>
|
|
95
107
|
<View style={stylesModal.titleContainer}>
|
|
96
|
-
<
|
|
108
|
+
<TextBold style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</TextBold>
|
|
97
109
|
</View>
|
|
98
|
-
<
|
|
110
|
+
<TextRegular style={stylesModal.textMessage}>{attentionMessage}</TextRegular>
|
|
99
111
|
{willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
|
|
100
112
|
</View>
|
|
101
113
|
{willRecommendCarbs ? null : (<View style={stylesModal.containerAcceptButton}>
|
|
102
114
|
<TouchableOpacity testID={RecommendationModalTestIds.OkButton} style={stylesModal.okButton} onPress={this.props.onClickOkButton}>
|
|
103
|
-
<
|
|
115
|
+
<TextRegular style={stylesModal.buttonText}>{i18n._(t `OK`)}</TextRegular>
|
|
104
116
|
</TouchableOpacity>
|
|
105
117
|
</View>)}
|
|
106
118
|
</React.Fragment>);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.state = {
|
|
117
|
-
firstPageVisible: !!this.props.limitationMessage,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* @returns JSX element for displaying the “first” page of the recommendation modal.
|
|
122
|
+
* The first page consists of a limitation message rendered using a LimitationMessage component.
|
|
123
|
+
*/
|
|
124
|
+
firstPage = () => {
|
|
125
|
+
const { limitationMessage } = this.props;
|
|
126
|
+
return <LimitationMessage limitationMessage={limitationMessage} onPressNextButton={this.onPressNextButton}/>;
|
|
127
|
+
};
|
|
120
128
|
/**
|
|
121
129
|
* @returns JSX element for rendering a modal that is visible if the isVisible prop is true.
|
|
122
130
|
* If the firstPageVisible state variable is true then use firstPage() to render the first page.
|
|
@@ -170,7 +178,7 @@ export const stylesModal = StyleSheet.create({
|
|
|
170
178
|
borderColor: BORDER_COLOUR_TEAL,
|
|
171
179
|
},
|
|
172
180
|
suggestedContainer: { justifyContent: `center`, flexDirection: `row`, marginBottom: `3%` },
|
|
173
|
-
suggestedCarbs: { color: `white`, fontSize: sugestionFontSize
|
|
181
|
+
suggestedCarbs: { color: `white`, fontSize: sugestionFontSize },
|
|
174
182
|
textCenter: { textAlign: `center` },
|
|
175
183
|
recommendEatingText: { color: `#C5D0E7`, fontSize: recommendEatingFontSize, textAlign: `center` },
|
|
176
184
|
carbohydrateText: { color: `white`, fontSize: sugestionFontSize },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t } from "@lingui/macro";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Alert, Dimensions, StyleSheet,
|
|
3
|
+
import { Alert, Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
5
|
import { Testing } from "../types/enum";
|
|
6
6
|
import { BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
@@ -9,6 +9,8 @@ import Icon from "./Icon";
|
|
|
9
9
|
import { infoStyles } from "./InfoBars";
|
|
10
10
|
import InvisibleNumberInput from "./InvisibleNumberInput";
|
|
11
11
|
import LineSeparator from "./LineSeparator";
|
|
12
|
+
import TextBold from "./text/TextBold";
|
|
13
|
+
import TextRegular from "./text/TextRegular";
|
|
12
14
|
const { RecommendedCarbsTestIds } = Testing.Id;
|
|
13
15
|
/**
|
|
14
16
|
* The contents of the RecommendedCarbs component may vary quite a bit depending on data that was entered by the user
|
|
@@ -17,101 +19,104 @@ const { RecommendedCarbsTestIds } = Testing.Id;
|
|
|
17
19
|
* (composed by the renderRecommendedCarbs() method) will only be visible if it is actually recommended that the user eats additional carbohydrates.
|
|
18
20
|
*/
|
|
19
21
|
export default class RecommendedCarbs extends React.Component {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
22
|
+
/** Initialise the state partialInput variable with undefined */
|
|
23
|
+
state = {
|
|
24
|
+
partialInput: undefined,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Function taking no arguments and returning no value.
|
|
28
|
+
* Will be bound to the function that activates input for InvisibleNumberInput when that component has been mounted.
|
|
29
|
+
*/
|
|
30
|
+
callbackInput;
|
|
31
|
+
/**
|
|
32
|
+
* Handle what should happen when the additional carbohydrates amount has been pressed.
|
|
33
|
+
* Uses the InvisibleNumberInput child component to enable the user to input the amount of additional carbohydrates that they are taking.
|
|
34
|
+
*/
|
|
35
|
+
showTextInput = () => {
|
|
36
|
+
this.callbackInput?.();
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
|
|
40
|
+
*
|
|
41
|
+
* Steps:
|
|
42
|
+
* 1. Save partialInput argument to the partialInput state variable.
|
|
43
|
+
* @param partialInput The contents of the input field.
|
|
44
|
+
*/
|
|
45
|
+
handlePartialInput = (partialInput) => {
|
|
46
|
+
this.setState({
|
|
47
|
+
partialInput,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Handle what happens when input in the InvisibleNumberInput child component is completed.
|
|
52
|
+
*
|
|
53
|
+
* Steps:
|
|
54
|
+
* 1. If the carbs argument is greater than or equal to 0:
|
|
55
|
+
* - If the carbs argument is greater than 300:
|
|
56
|
+
* - Set the partialInput state variable to the value of the recommemdedCarbs prop.
|
|
57
|
+
* - Return - An alert message with the message of CarbohydrateLimitError() and with an OK button for closing it.
|
|
58
|
+
* - Use carbs as argument to call the changedRecommendedCarbs prop callback function.
|
|
59
|
+
|
|
60
|
+
* @param carbs The numerical value of the input field at completion.
|
|
61
|
+
* @returns void
|
|
62
|
+
*/
|
|
63
|
+
handleChangedCarbs = (carbs) => {
|
|
64
|
+
if (carbs >= 0) {
|
|
65
|
+
if (carbs > 300) {
|
|
66
|
+
this.setState({ partialInput: this.props.recommendedCarbs });
|
|
67
|
+
return Alert.alert(i18n._(t `Attention`), CarbohydrateLimitError().message, [
|
|
68
|
+
{
|
|
69
|
+
text: i18n._(t `OK`),
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
69
72
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
this.props.changedRecommendedCarbs(carbs);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Render the section of the component that displays the extra carbs that the user should eat
|
|
78
|
+
* and allows the user to change the contents to indicate how many extra carbs they are actually going to eat.
|
|
79
|
+
*
|
|
80
|
+
* Steps:
|
|
81
|
+
* 1. Set a variable named shownCarbs to the partialInput state if it is set, or to the recommendedCarbs prop rounded to the nearest integer otherwise.
|
|
82
|
+
* 2. Set a variable named totalCarbs to the sum of the enteredCarbs prop and shownCarbs rounded to the nearest integer.
|
|
83
|
+
* 3. Compose and return a JSX element consisting of the following sub-components
|
|
84
|
+
* - A cancel button to remove recommended carbs from the calculation - When tapped, call the removeRecommendedCarbs prop callback function.
|
|
85
|
+
* - The text from the shownCarbs variable from step 1 - When tapped, call the showTextInput() method.
|
|
86
|
+
* - Use renderRow() to display the value of totalCarbs.
|
|
87
|
+
* - InvisibleNumberInput for showing the keyboard to enable the user to enter a number.
|
|
88
|
+
*/
|
|
89
|
+
renderRecommendedCarbs = () => {
|
|
90
|
+
const shownCarbs = this.state.partialInput ?? Math.round(Number(this.props.recommendedCarbs));
|
|
91
|
+
const totalCarbs = Math.round(parseFloat(this.props.enteredCarbs) + Number(shownCarbs));
|
|
92
|
+
return (<React.Fragment>
|
|
88
93
|
<LineSeparator color={BORDER_COLOUR_GREY}/>
|
|
89
94
|
<View style={calculationStyles.borderContainer}>
|
|
90
95
|
<View style={calculationStyles.recommendedContainer}>
|
|
91
96
|
<TouchableOpacity testID={RecommendedCarbsTestIds.RemoveRecommendation} style={calculationStyles.removeRecommended} onPress={this.props.removeRecommendedCarbs}>
|
|
92
97
|
<Icon iconIdentifier={`Ionicons/ios-close-circle-outline`} style={calculationStyles.removeRecommendedIcon}/>
|
|
93
98
|
</TouchableOpacity>
|
|
94
|
-
<
|
|
99
|
+
<TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Recommended`)}</TextBold>
|
|
95
100
|
</View>
|
|
96
101
|
</View>
|
|
97
102
|
<View style={calculationStyles.borderContainer}>
|
|
98
103
|
<View style={calculationStyles.recommendedContainer}>
|
|
99
|
-
<
|
|
104
|
+
<TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Additional`)}</TextBold>
|
|
100
105
|
</View>
|
|
101
106
|
<View style={calculationStyles.valueUnitContainer}>
|
|
102
107
|
<TouchableOpacity testID={RecommendedCarbsTestIds.EditRecommendedCarbs} onPress={this.showTextInput} style={[calculationStyles.valueUnitContainer]}>
|
|
103
108
|
<View style={calculationStyles.valueContainer}>
|
|
104
|
-
<
|
|
109
|
+
<TextRegular testID={RecommendedCarbsTestIds.RecommendedCarbs} style={{ ...calculationStyles.value, color: BORDER_COLOUR_TEAL }}>
|
|
105
110
|
{shownCarbs}
|
|
106
|
-
</
|
|
111
|
+
</TextRegular>
|
|
107
112
|
</View>
|
|
108
113
|
<View style={[calculationStyles.unitContainer]}>
|
|
109
114
|
<View style={calculationStyles.editIconContainer}>
|
|
110
115
|
<Icon style={calculationStyles.editIcon} iconIdentifier={`Feather/edit`}/>
|
|
111
116
|
</View>
|
|
112
|
-
<
|
|
117
|
+
<TextRegular style={{ ...calculationStyles.units, color: BORDER_COLOUR_TEAL }}>
|
|
113
118
|
{i18n._(t `grams`)}
|
|
114
|
-
</
|
|
119
|
+
</TextRegular>
|
|
115
120
|
</View>
|
|
116
121
|
</TouchableOpacity>
|
|
117
122
|
</View>
|
|
@@ -124,31 +129,30 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
124
129
|
}, RecommendedCarbsTestIds.TotalCarbs)}
|
|
125
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}/>
|
|
126
131
|
</React.Fragment>);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Display a row of information for the user. Specifically used to display the amount of carbohydrates that the user has entered.
|
|
135
|
+
* @param row The values to display
|
|
136
|
+
* @param testID Id used for component testing
|
|
137
|
+
* @returns A JSX element to display 3 strings on the screen: label, value, and a unit.
|
|
138
|
+
*/
|
|
139
|
+
renderRow = (row, testID) => {
|
|
140
|
+
return (<View style={[calculationStyles.borderContainer, { paddingVertical: `1%` }]}>
|
|
136
141
|
<View style={calculationStyles.rowContainer}>
|
|
137
|
-
<
|
|
142
|
+
<TextBold style={calculationStyles.rowLabel}>{row.label}</TextBold>
|
|
138
143
|
</View>
|
|
139
144
|
<View style={calculationStyles.valueUnitContainer}>
|
|
140
145
|
<View style={calculationStyles.valueContainer}>
|
|
141
|
-
<
|
|
146
|
+
<TextRegular testID={testID} style={calculationStyles.value}>
|
|
142
147
|
{row.value}
|
|
143
|
-
</
|
|
148
|
+
</TextRegular>
|
|
144
149
|
</View>
|
|
145
150
|
<View style={calculationStyles.unitContainer}>
|
|
146
|
-
<
|
|
151
|
+
<TextRegular style={calculationStyles.units}>{row.units}</TextRegular>
|
|
147
152
|
</View>
|
|
148
153
|
</View>
|
|
149
154
|
</View>);
|
|
150
|
-
|
|
151
|
-
}
|
|
155
|
+
};
|
|
152
156
|
/**
|
|
153
157
|
* Steps:
|
|
154
158
|
* 1. Convert the recommendedCarbs prop to a number and save that as a variable named carbs.
|
|
@@ -159,14 +163,16 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
159
163
|
const carbs = Number(this.props.recommendedCarbs);
|
|
160
164
|
return (<React.Fragment>
|
|
161
165
|
<View style={calculationStyles.foodTitleContainer}>
|
|
162
|
-
<
|
|
163
|
-
<
|
|
166
|
+
<TextRegular style={infoStyles.label}>{i18n._(t `Food`)}</TextRegular>
|
|
167
|
+
<TextRegular style={calculationStyles.foodUnitsLabel}>
|
|
168
|
+
{`(${i18n._(t `Carbohydrates`)})`}
|
|
169
|
+
</TextRegular>
|
|
164
170
|
</View>
|
|
165
171
|
{this.renderRow({
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
label: i18n._(t `Entered`),
|
|
173
|
+
value: this.props.enteredCarbs,
|
|
174
|
+
units: i18n._(t `grams`),
|
|
175
|
+
}, RecommendedCarbsTestIds.EnteredCarbs)}
|
|
170
176
|
{!isNaN(carbs) && carbs > 0 ? this.renderRecommendedCarbs() : null}
|
|
171
177
|
</React.Fragment>);
|
|
172
178
|
}
|
|
@@ -194,7 +200,6 @@ const calculationStyles = StyleSheet.create({
|
|
|
194
200
|
rowLabel: {
|
|
195
201
|
color: `white`,
|
|
196
202
|
fontSize: Dimensions.get(`screen`).width / 25,
|
|
197
|
-
fontWeight: `bold`,
|
|
198
203
|
},
|
|
199
204
|
enteredContainer: {
|
|
200
205
|
flex: 3,
|
|
@@ -236,7 +241,6 @@ const calculationStyles = StyleSheet.create({
|
|
|
236
241
|
color: BORDER_COLOUR_TEAL,
|
|
237
242
|
fontSize: Dimensions.get(`screen`).width / 25,
|
|
238
243
|
alignSelf: `center`,
|
|
239
|
-
fontWeight: `bold`,
|
|
240
244
|
},
|
|
241
245
|
removeRecommended: {
|
|
242
246
|
justifyContent: `center`,
|