@hedia/recommendation-screen 2.1.33 → 2.1.34-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.
Files changed (101) hide show
  1. package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +2 -2
  2. package/ios/Podfile.lock +207 -207
  3. package/package.json +1 -1
  4. package/index.d.ts +0 -5
  5. package/index.js +0 -5
  6. package/src/RecommendationScreen.d.ts +0 -413
  7. package/src/RecommendationScreen.js +0 -493
  8. package/src/__tests__/RecommendationScreen.test.d.ts +0 -1
  9. package/src/__tests__/RecommendationScreen.test.js +0 -965
  10. package/src/__tests__/RecommendationUtils.test.d.ts +0 -1
  11. package/src/__tests__/RecommendationUtils.test.js +0 -216
  12. package/src/__tests__/Translate.test.d.ts +0 -1
  13. package/src/__tests__/Translate.test.js +0 -27
  14. package/src/__tests__/Utils.test.d.ts +0 -1
  15. package/src/__tests__/Utils.test.js +0 -66
  16. package/src/__tests__/Validations.test.d.ts +0 -1
  17. package/src/__tests__/Validations.test.js +0 -465
  18. package/src/__tests__/components/Activity.test.d.ts +0 -1
  19. package/src/__tests__/components/Activity.test.js +0 -86
  20. package/src/__tests__/components/Emotion.test.d.ts +0 -1
  21. package/src/__tests__/components/Emotion.test.js +0 -70
  22. package/src/__tests__/components/Header.test.d.ts +0 -1
  23. package/src/__tests__/components/Header.test.js +0 -36
  24. package/src/__tests__/components/InfoBars.test.d.ts +0 -1
  25. package/src/__tests__/components/InfoBars.test.js +0 -130
  26. package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -1
  27. package/src/__tests__/components/InvisibleNumberInput.test.js +0 -160
  28. package/src/__tests__/components/LimitationMessage.test.d.ts +0 -1
  29. package/src/__tests__/components/LimitationMessage.test.js +0 -47
  30. package/src/__tests__/components/MoodIcon.test.d.ts +0 -1
  31. package/src/__tests__/components/MoodIcon.test.js +0 -30
  32. package/src/__tests__/components/RecommendationModal.test.d.ts +0 -1
  33. package/src/__tests__/components/RecommendationModal.test.js +0 -98
  34. package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -1
  35. package/src/__tests__/components/RecommendedCarbs.test.js +0 -120
  36. package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -1
  37. package/src/__tests__/components/RecommendedInsulin.test.js +0 -154
  38. package/src/__tests__/components/Remeasure.test.d.ts +0 -1
  39. package/src/__tests__/components/Remeasure.test.js +0 -78
  40. package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -1
  41. package/src/__tests__/components/TransferToLogbook.test.js +0 -30
  42. package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -1
  43. package/src/__tests__/components/TwoOptionModal.test.js +0 -65
  44. package/src/__tests__/utils.d.ts +0 -16
  45. package/src/__tests__/utils.js +0 -126
  46. package/src/components/Header.d.ts +0 -10
  47. package/src/components/Header.js +0 -75
  48. package/src/components/Icon.d.ts +0 -20
  49. package/src/components/Icon.js +0 -41
  50. package/src/components/InfoBars.d.ts +0 -103
  51. package/src/components/InfoBars.js +0 -129
  52. package/src/components/InvisibleNumberInput.d.ts +0 -89
  53. package/src/components/InvisibleNumberInput.js +0 -122
  54. package/src/components/LimitationMessage.d.ts +0 -14
  55. package/src/components/LimitationMessage.js +0 -31
  56. package/src/components/LineSeparator.d.ts +0 -10
  57. package/src/components/LineSeparator.js +0 -18
  58. package/src/components/RecentInsulin.d.ts +0 -17
  59. package/src/components/RecentInsulin.js +0 -94
  60. package/src/components/RecommendationModal.d.ts +0 -207
  61. package/src/components/RecommendationModal.js +0 -213
  62. package/src/components/RecommendedCarbs.d.ts +0 -94
  63. package/src/components/RecommendedCarbs.js +0 -251
  64. package/src/components/RecommendedInsulin.d.ts +0 -84
  65. package/src/components/RecommendedInsulin.js +0 -170
  66. package/src/components/Remeasure.d.ts +0 -49
  67. package/src/components/Remeasure.js +0 -125
  68. package/src/components/TransferToLogbook.d.ts +0 -34
  69. package/src/components/TransferToLogbook.js +0 -94
  70. package/src/components/TwoOptionModal.d.ts +0 -145
  71. package/src/components/TwoOptionModal.js +0 -148
  72. package/src/components/activity/Activity.d.ts +0 -26
  73. package/src/components/activity/Activity.js +0 -80
  74. package/src/components/activity/ActivityIcon.d.ts +0 -22
  75. package/src/components/activity/ActivityIcon.js +0 -58
  76. package/src/components/activity/ActivityIntensity.d.ts +0 -16
  77. package/src/components/activity/ActivityIntensity.js +0 -59
  78. package/src/components/mood/Emotion.d.ts +0 -38
  79. package/src/components/mood/Emotion.js +0 -65
  80. package/src/components/mood/MoodIcon.d.ts +0 -40
  81. package/src/components/mood/MoodIcon.js +0 -66
  82. package/src/locale/i18nUtils.d.ts +0 -18
  83. package/src/locale/i18nUtils.js +0 -39
  84. package/src/types/enum.d.ts +0 -122
  85. package/src/types/enum.js +0 -138
  86. package/src/types/types.d.ts +0 -17
  87. package/src/types/types.js +0 -1
  88. package/src/utils/AttentionMessages.d.ts +0 -96
  89. package/src/utils/AttentionMessages.js +0 -118
  90. package/src/utils/Constants.d.ts +0 -47
  91. package/src/utils/Constants.js +0 -47
  92. package/src/utils/RecommendationError.d.ts +0 -56
  93. package/src/utils/RecommendationError.js +0 -62
  94. package/src/utils/RecommendationUtils.d.ts +0 -100
  95. package/src/utils/RecommendationUtils.js +0 -199
  96. package/src/utils/Translations.d.ts +0 -9
  97. package/src/utils/Translations.js +0 -14
  98. package/src/utils/Utils.d.ts +0 -105
  99. package/src/utils/Utils.js +0 -141
  100. package/src/utils/Validations.d.ts +0 -250
  101. package/src/utils/Validations.js +0 -409
@@ -1,207 +0,0 @@
1
- import * as React from "react";
2
- export interface IModalProps {
3
- /** Whether or not the modal should currently be displayed on the screen */
4
- isVisible: boolean;
5
- /** The amount of additional carbohydrates that is being recommended for the user in grams. */
6
- suggestedCarbohydrates: number | null;
7
- /** A message to display to the user to inform them in natural language about special recommendations or warnings from HDA. */
8
- attentionMessage: string | null;
9
- /** A message to display to the user to inform them if their insulin recommendation was limited by the maximum threshold. */
10
- limitationMessage: string | null;
11
- /** Callback function taking no arguments and returning no value - Should be called if the user taps the “OK” button on the modal. */
12
- onClickOkButton(): void;
13
- /**
14
- * Callback function taking no arguments and returning no value.
15
- * Should be called if the user taps the “accept” button when they are recommended to eat additional carbohydrates.
16
- */
17
- onAcceptCarbohydrates(): void;
18
- /**
19
- * Callback function taking no arguments and returning no value.
20
- * Should be called if the user taps the “decline” button when they are recommended to eat additional carbohydrates.
21
- */
22
- onDeclineCarbohydrates(): void;
23
- }
24
- export interface IModalState {
25
- /** If true then the first page will be displayed, otherwise the second page will be displayed. */
26
- firstPageVisible: boolean;
27
- }
28
- /**
29
- * Popup modal for displaying information messages or warnings to the user if necessary.
30
- * The modal has two “pages” with different content that it is able to display.
31
- * The first page is for informing the user if their insulin recommendation was limited by the maximum insulin safety limit.
32
- * This page will only be displayed if the recommendation was actually limited.
33
- * The second page is for displaying a general attention message that may contain instructions for the user,
34
- * and for letting the user know if they are being recommended eating additional carbohydrates.
35
- */
36
- export default class RecommendationModal extends React.Component<IModalProps, IModalState> {
37
- /**
38
- * Steps:
39
- * 1. Call the super() method with the props.
40
- * 2. Set the firstPageVisible state variable true if the limitationMessage prop is truthy.
41
- * @param props The class props
42
- */
43
- constructor(props: IModalProps);
44
- /**
45
- * Handle what happens when the “next” button is pressed.
46
- *
47
- * Steps:
48
- * 1. Unpack attentionMessage and suggestedCarbohydrates from the props object.
49
- * 2. Define isPageVisible to be true if either attentionMessage or suggestedCarbohydrates is truthy.
50
- * 3. If isPageVisible is true then set the firstPageVisible state variable to false. Otherwise call the onClickOkButton prop callback function.
51
- */
52
- onPressNextButton: () => void;
53
- /**
54
- * @returns Return an JSX element for composing two buttons: one for accepting a suggestion and one for rejecting it.
55
- * If the accept button is pressed the onAcceptCarbohydrates prop callback function shall be called.
56
- * If the accept button is pressed the onDeclineCarbohydrates prop callback function shall be called.
57
- */
58
- recommendationButtons: () => JSX.Element;
59
- /**
60
- * Compose a JSX element for displaying a recommendation of additional carbohydrates (the value of the suggestedCarbohydrates prop rounded to the nearest integer)
61
- * to the user in a way that explains what to do with the suggestion.
62
- * @param suggestedCarbohydrates the recommended additional carbohydrates
63
- */
64
- recommendCarbohydrates: (suggestedCarbohydrates: number) => JSX.Element;
65
- /**
66
- * @returns JSX element for displaying the “second” page of the recommendation modal. The second page displays the string from the attentionMessage prop.
67
- */
68
- secondPage: () => JSX.Element;
69
- /**
70
- * @returns JSX element for displaying the “first” page of the recommendation modal.
71
- * The first page consists of a limitation message rendered using a LimitationMessage component.
72
- */
73
- firstPage: () => JSX.Element;
74
- /**
75
- * @returns JSX element for rendering a modal that is visible if the isVisible prop is true.
76
- * If the firstPageVisible state variable is true then use firstPage() to render the first page.
77
- * Otherwise use secondPage() to render the second page.
78
- */
79
- render(): JSX.Element;
80
- }
81
- /** @internal */
82
- export declare const stylesModal: {
83
- modalStyle: {
84
- margin: number;
85
- };
86
- container: {
87
- flex: number;
88
- backgroundColor: string;
89
- justifyContent: "center";
90
- paddingHorizontal: string;
91
- };
92
- containerAcceptButton: {
93
- flex: number;
94
- backgroundColor: string;
95
- justifyContent: "flex-start";
96
- };
97
- titleContainer: {
98
- marginBottom: string;
99
- };
100
- recommendationRow: {
101
- justifyContent: "center";
102
- alignContent: "center";
103
- marginBottom: string;
104
- };
105
- textTittleMessage: {
106
- color: string;
107
- fontSize: number;
108
- textAlign: "center";
109
- };
110
- textMessage: {
111
- color: string;
112
- fontSize: number;
113
- textAlign: "center";
114
- };
115
- buttonText: {
116
- color: string;
117
- fontSize: number;
118
- textAlign: "center";
119
- };
120
- addToCalculationContainer: {
121
- justifyContent: "flex-start";
122
- marginVertical: string;
123
- };
124
- innerView: {
125
- alignContent: "center";
126
- paddingVertical: string;
127
- paddingHorizontal: string;
128
- marginTop: string;
129
- borderRadius: number;
130
- borderWidth: number;
131
- borderColor: string;
132
- };
133
- suggestedContainer: {
134
- justifyContent: "center";
135
- flexDirection: "row";
136
- marginBottom: string;
137
- };
138
- suggestedCarbs: {
139
- color: string;
140
- fontSize: number;
141
- fontWeight: "bold";
142
- };
143
- textCenter: {
144
- textAlign: "center";
145
- };
146
- recommendEatingText: {
147
- color: string;
148
- fontSize: number;
149
- textAlign: "center";
150
- };
151
- carbohydrateText: {
152
- color: string;
153
- fontSize: number;
154
- };
155
- addToCalculation: {
156
- color: string;
157
- fontSize: number;
158
- textAlign: "center";
159
- };
160
- recommendationButtonsContainer: {
161
- justifyContent: "center";
162
- flexDirection: "row";
163
- margin: string;
164
- };
165
- affirmativeCarbsText: {
166
- color: string;
167
- fontSize: number;
168
- textAlign: "center";
169
- };
170
- negativeCarbsText: {
171
- color: string;
172
- fontSize: number;
173
- textAlign: "center";
174
- };
175
- affirmativeCarbsButton: {
176
- marginTop: string;
177
- borderRadius: number;
178
- borderWidth: number;
179
- borderColor: string;
180
- width: number;
181
- height: number;
182
- alignSelf: "center";
183
- justifyContent: "center";
184
- marginRight: string;
185
- };
186
- negativeCarbsButton: {
187
- marginTop: string;
188
- borderRadius: number;
189
- borderWidth: number;
190
- borderColor: string;
191
- width: number;
192
- height: number;
193
- alignSelf: "center";
194
- justifyContent: "center";
195
- marginLeft: string;
196
- };
197
- okButton: {
198
- marginTop: string;
199
- borderRadius: number;
200
- borderWidth: number;
201
- borderColor: string;
202
- width: number;
203
- height: number;
204
- alignSelf: "center";
205
- justifyContent: "center";
206
- };
207
- };
@@ -1,213 +0,0 @@
1
- import { t } from "@lingui/macro";
2
- import * as React from "react";
3
- import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
- import ReactNativeModal from "react-native-modal";
5
- import { i18n } from "../locale/i18nUtils";
6
- import { Testing } from "../types/enum";
7
- import { BORDER_COLOUR_TEAL } from "../utils/Constants";
8
- import LimitationMessage from "./LimitationMessage";
9
- const { RecommendationModalTestIds } = Testing.Id;
10
- /**
11
- * Popup modal for displaying information messages or warnings to the user if necessary.
12
- * The modal has two “pages” with different content that it is able to display.
13
- * The first page is for informing the user if their insulin recommendation was limited by the maximum insulin safety limit.
14
- * This page will only be displayed if the recommendation was actually limited.
15
- * The second page is for displaying a general attention message that may contain instructions for the user,
16
- * and for letting the user know if they are being recommended eating additional carbohydrates.
17
- */
18
- export default class RecommendationModal extends React.Component {
19
- /**
20
- * Steps:
21
- * 1. Call the super() method with the props.
22
- * 2. Set the firstPageVisible state variable true if the limitationMessage prop is truthy.
23
- * @param props The class props
24
- */
25
- constructor(props) {
26
- super(props);
27
- /**
28
- * Handle what happens when the “next” button is pressed.
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();
39
- };
40
- /**
41
- * @returns Return an JSX element for composing two buttons: one for accepting a suggestion and one for rejecting it.
42
- * If the accept button is pressed the onAcceptCarbohydrates prop callback function shall be called.
43
- * If the accept button is pressed the onDeclineCarbohydrates prop callback function shall be called.
44
- */
45
- this.recommendationButtons = () => {
46
- return (<View style={stylesModal.recommendationButtonsContainer}>
47
- <TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} accessibilityLabel="yesButtonModal" style={stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
48
- <Text style={stylesModal.affirmativeCarbsText}>{i18n._(t `OK`)}</Text>
49
- </TouchableOpacity>
50
- <TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} accessibilityLabel="noButtonModal" style={stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
51
- <Text style={stylesModal.negativeCarbsText}>{i18n._(t `NO`)}</Text>
52
- </TouchableOpacity>
53
- </View>);
54
- };
55
- /**
56
- * Compose a JSX element for displaying a recommendation of additional carbohydrates (the value of the suggestedCarbohydrates prop rounded to the nearest integer)
57
- * to the user in a way that explains what to do with the suggestion.
58
- * @param suggestedCarbohydrates the recommended additional carbohydrates
59
- */
60
- this.recommendCarbohydrates = (suggestedCarbohydrates) => {
61
- const displayCarbs = Math.round(suggestedCarbohydrates);
62
- return (<React.Fragment>
63
- <View style={stylesModal.innerView}>
64
- <View style={stylesModal.recommendationRow}>
65
- <Text style={stylesModal.recommendEatingText}>
66
- {i18n._(t `We recommend eating an additional:`)}
67
- </Text>
68
- </View>
69
- <View style={stylesModal.suggestedContainer}>
70
- <Text style={stylesModal.textCenter}>
71
- <Text style={stylesModal.suggestedCarbs} testID={RecommendationModalTestIds.SuggestedCarbs}>{`${displayCarbs} `}</Text>
72
- <Text style={stylesModal.carbohydrateText}>{i18n._(t `grams of carbohydrates`)}</Text>
73
- </Text>
74
- </View>
75
- <View style={stylesModal.recommendationRow}>
76
- <Text style={stylesModal.recommendEatingText}>{i18n._(t `Instead of taking insulin`)}</Text>
77
- </View>
78
- </View>
79
- <View style={stylesModal.addToCalculationContainer}>
80
- <Text style={stylesModal.addToCalculation}>
81
- {i18n._(t `Would you like to add this to your current calculation?`)}
82
- </Text>
83
- {this.recommendationButtons()}
84
- </View>
85
- </React.Fragment>);
86
- };
87
- /**
88
- * @returns JSX element for displaying the “second” page of the recommendation modal. The second page displays the string from the attentionMessage prop.
89
- */
90
- this.secondPage = () => {
91
- const { attentionMessage, suggestedCarbohydrates } = this.props;
92
- const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
93
- return (<React.Fragment>
94
- <View style={stylesModal.container}>
95
- <View style={stylesModal.titleContainer}>
96
- <Text style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</Text>
97
- </View>
98
- <Text style={stylesModal.textMessage}>{attentionMessage}</Text>
99
- {willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
100
- </View>
101
- {willRecommendCarbs ? null : (<View style={stylesModal.containerAcceptButton}>
102
- <TouchableOpacity testID={RecommendationModalTestIds.OkButton} accessibilityLabel="okayButtonModal" style={stylesModal.okButton} onPress={this.props.onClickOkButton}>
103
- <Text style={stylesModal.buttonText}>{i18n._(t `OK`)}</Text>
104
- </TouchableOpacity>
105
- </View>)}
106
- </React.Fragment>);
107
- };
108
- /**
109
- * @returns JSX element for displaying the “first” page of the recommendation modal.
110
- * The first page consists of a limitation message rendered using a LimitationMessage component.
111
- */
112
- this.firstPage = () => {
113
- const { limitationMessage } = this.props;
114
- return <LimitationMessage limitationMessage={limitationMessage} onPressNextButton={this.onPressNextButton}/>;
115
- };
116
- this.state = {
117
- firstPageVisible: !!this.props.limitationMessage,
118
- };
119
- }
120
- /**
121
- * @returns JSX element for rendering a modal that is visible if the isVisible prop is true.
122
- * If the firstPageVisible state variable is true then use firstPage() to render the first page.
123
- * Otherwise use secondPage() to render the second page.
124
- */
125
- render() {
126
- const { isVisible } = this.props;
127
- const { firstPageVisible } = this.state;
128
- return (<ReactNativeModal isVisible={isVisible} style={stylesModal.modalStyle}>
129
- {firstPageVisible ? this.firstPage() : this.secondPage()}
130
- </ReactNativeModal>);
131
- }
132
- }
133
- const { height, width } = Dimensions.get(`screen`);
134
- const buttonHeight = height / 20;
135
- const buttonWidth = width / 2.5;
136
- const buttonFontSize = width / 22;
137
- const buttonBorderRadius = height / 30;
138
- const buttonBorderWidth = height / 500;
139
- const sugestionFontSize = width / 19;
140
- const recommendEatingFontSize = height / 45;
141
- const textFontSize = width / 20;
142
- const titleFontSize = width / 13;
143
- /** @internal */
144
- export const stylesModal = StyleSheet.create({
145
- modalStyle: { margin: 0 },
146
- container: {
147
- flex: 4,
148
- backgroundColor: `rgba(30, 35, 87, 0.9)`,
149
- justifyContent: `center`,
150
- paddingHorizontal: `4%`,
151
- },
152
- containerAcceptButton: {
153
- flex: 1,
154
- backgroundColor: `rgba(30, 35, 87, 0.9)`,
155
- justifyContent: `flex-start`,
156
- },
157
- titleContainer: { marginBottom: `5%` },
158
- recommendationRow: { justifyContent: `center`, alignContent: `center`, marginBottom: `3%` },
159
- textTittleMessage: { color: `white`, fontSize: titleFontSize, textAlign: `center` },
160
- textMessage: { color: `white`, fontSize: textFontSize, textAlign: `center` },
161
- buttonText: { color: BORDER_COLOUR_TEAL, fontSize: buttonFontSize, textAlign: `center` },
162
- addToCalculationContainer: { justifyContent: `flex-start`, marginVertical: `5%` },
163
- innerView: {
164
- alignContent: `center`,
165
- paddingVertical: `5%`,
166
- paddingHorizontal: `3%`,
167
- marginTop: `5%`,
168
- borderRadius: height / 80,
169
- borderWidth: height / 300,
170
- borderColor: BORDER_COLOUR_TEAL,
171
- },
172
- suggestedContainer: { justifyContent: `center`, flexDirection: `row`, marginBottom: `3%` },
173
- suggestedCarbs: { color: `white`, fontSize: sugestionFontSize, fontWeight: `bold` },
174
- textCenter: { textAlign: `center` },
175
- recommendEatingText: { color: `#C5D0E7`, fontSize: recommendEatingFontSize, textAlign: `center` },
176
- carbohydrateText: { color: `white`, fontSize: sugestionFontSize },
177
- addToCalculation: { color: `white`, fontSize: textFontSize, textAlign: `center` },
178
- recommendationButtonsContainer: { justifyContent: `center`, flexDirection: `row`, margin: `3%` },
179
- affirmativeCarbsText: { color: BORDER_COLOUR_TEAL, fontSize: buttonFontSize, textAlign: `center` },
180
- negativeCarbsText: { color: `white`, fontSize: buttonFontSize, textAlign: `center` },
181
- affirmativeCarbsButton: {
182
- marginTop: `2%`,
183
- borderRadius: buttonBorderRadius,
184
- borderWidth: buttonBorderWidth,
185
- borderColor: BORDER_COLOUR_TEAL,
186
- width: buttonWidth,
187
- height: buttonHeight,
188
- alignSelf: `center`,
189
- justifyContent: `center`,
190
- marginRight: `2%`,
191
- },
192
- negativeCarbsButton: {
193
- marginTop: `2%`,
194
- borderRadius: buttonBorderRadius,
195
- borderWidth: buttonBorderWidth,
196
- borderColor: `white`,
197
- width: buttonWidth,
198
- height: buttonHeight,
199
- alignSelf: `center`,
200
- justifyContent: `center`,
201
- marginLeft: `2%`,
202
- },
203
- okButton: {
204
- marginTop: `6%`,
205
- borderRadius: buttonBorderRadius,
206
- borderWidth: buttonBorderWidth,
207
- borderColor: BORDER_COLOUR_TEAL,
208
- width: buttonWidth,
209
- height: buttonHeight,
210
- alignSelf: `center`,
211
- justifyContent: `center`,
212
- },
213
- });
@@ -1,94 +0,0 @@
1
- import React from "react";
2
- import { Testing } from "../types/enum";
3
- export interface ICalculationRow {
4
- label: string;
5
- value: string;
6
- units: string;
7
- }
8
- export interface IProps {
9
- /** The amount of carbs in grams that was recommended to and accepted by the user. */
10
- recommendedCarbs?: string;
11
- /** The amount of carbs in grams that the user entered on the food screen. */
12
- enteredCarbs: string;
13
- /** Callback function that doesn’t accept any arguments and doesn’t return anything - To be called every time the “remove additional carbs” button has been pressed. */
14
- removeRecommendedCarbs(): void;
15
- /**
16
- * Callback function that takes a single number as argument and doesn’t return anything.
17
- * Function to be called when the entered carbohydrate value is changed by the user. The new value should be given as argument
18
- */
19
- changedRecommendedCarbs(value: number): void;
20
- }
21
- export interface IState {
22
- /** The internal value of the input field. */
23
- partialInput?: string;
24
- }
25
- /**
26
- * The contents of the RecommendedCarbs component may vary quite a bit depending on data that was entered by the user
27
- * and on the result of the recommendation calculation.
28
- * For instance the part of the component that displays any recommendation of eating additional carbohydrates
29
- * (composed by the renderRecommendedCarbs() method) will only be visible if it is actually recommended that the user eats additional carbohydrates.
30
- */
31
- export default class RecommendedCarbs extends React.Component<IProps, IState> {
32
- /** Initialise the state partialInput variable with undefined */
33
- state: IState;
34
- /**
35
- * Function taking no arguments and returning no value.
36
- * Will be bound to the function that activates input for InvisibleNumberInput when that component has been mounted.
37
- */
38
- callbackInput?: () => void;
39
- /**
40
- * Handle what should happen when the additional carbohydrates amount has been pressed.
41
- * Uses the InvisibleNumberInput child component to enable the user to input the amount of additional carbohydrates that they are taking.
42
- */
43
- showTextInput: () => void;
44
- /**
45
- * Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
46
- *
47
- * Steps:
48
- * 1. Save partialInput argument to the partialInput state variable.
49
- * @param partialInput The contents of the input field.
50
- */
51
- handlePartialInput: (partialInput: string) => void;
52
- /**
53
- * Handle what happens when input in the InvisibleNumberInput child component is completed.
54
- *
55
- * Steps:
56
- * 1. If the carbs argument is greater than or equal to 0:
57
- * - If the carbs argument is greater than 300:
58
- * - Set the partialInput state variable to the value of the recommemdedCarbs prop.
59
- * - Return - An alert message with the message of CarbohydrateLimitError() and with an OK button for closing it.
60
- * - Use carbs as argument to call the changedRecommendedCarbs prop callback function.
61
-
62
- * @param carbs The numerical value of the input field at completion.
63
- * @returns void
64
- */
65
- handleChangedCarbs: (carbs: number) => void;
66
- /**
67
- * Render the section of the component that displays the extra carbs that the user should eat
68
- * and allows the user to change the contents to indicate how many extra carbs they are actually going to eat.
69
- *
70
- * Steps:
71
- * 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.
72
- * 2. Set a variable named totalCarbs to the sum of the enteredCarbs prop and shownCarbs rounded to the nearest integer.
73
- * 3. Compose and return a JSX element consisting of the following sub-components
74
- * - A cancel button to remove recommended carbs from the calculation - When tapped, call the removeRecommendedCarbs prop callback function.
75
- * - The text from the shownCarbs variable from step 1 - When tapped, call the showTextInput() method.
76
- * - Use renderRow() to display the value of totalCarbs.
77
- * - InvisibleNumberInput for showing the keyboard to enable the user to enter a number.
78
- */
79
- renderRecommendedCarbs: () => JSX.Element;
80
- /**
81
- * Display a row of information for the user. Specifically used to display the amount of carbohydrates that the user has entered.
82
- * @param row The values to display
83
- * @param testID Id used for component testing
84
- * @returns A JSX element to display 3 strings on the screen: label, value, and a unit.
85
- */
86
- renderRow: (row: ICalculationRow, testID: Testing.Id.RecommendedCarbsTestIds) => JSX.Element;
87
- /**
88
- * Steps:
89
- * 1. Convert the recommendedCarbs prop to a number and save that as a variable named carbs.
90
- * 2. Use renderRow() to display the user’s entered amount of carbohydrates
91
- * 3. If carbs is not a NaN-value and it is positive, call renderRecommendedCarbs() to display the carbohydrate recommendation.
92
- */
93
- render(): JSX.Element;
94
- }