@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,10 +1,11 @@
|
|
|
1
1
|
import { t } from "@lingui/macro";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Dimensions, SafeAreaView, StyleSheet,
|
|
3
|
+
import { Dimensions, SafeAreaView, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
5
|
import { Testing } from "../types/enum";
|
|
6
6
|
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY } from "../utils/Constants";
|
|
7
7
|
import Icon from "./Icon";
|
|
8
|
+
import TextBold from "./text/TextBold";
|
|
8
9
|
/** Component to display a header text along with a cancel-button that triggers a callback function. */
|
|
9
10
|
export default class Header extends React.Component {
|
|
10
11
|
/** JSX element to display the cancel button and header. When the cancel button in the header is tabbed, the exitCallback prop callback function should be called. */
|
|
@@ -22,9 +23,9 @@ export default class Header extends React.Component {
|
|
|
22
23
|
</View>
|
|
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}/>
|
|
30
31
|
</View>
|
|
@@ -65,7 +66,6 @@ const headerStyles = StyleSheet.create({
|
|
|
65
66
|
},
|
|
66
67
|
headerText: {
|
|
67
68
|
fontSize: Dimensions.get(`screen`).width / 18,
|
|
68
|
-
fontWeight: `bold`,
|
|
69
69
|
textAlign: `center`,
|
|
70
70
|
color: `white`,
|
|
71
71
|
},
|
|
@@ -12,6 +12,8 @@ export const IconSets = {
|
|
|
12
12
|
};
|
|
13
13
|
/** Component used to display a react-native-vector-icons */
|
|
14
14
|
export default class Icon extends React.Component {
|
|
15
|
+
static defaultProps;
|
|
16
|
+
_root;
|
|
15
17
|
setNativeProps(nativeProps) {
|
|
16
18
|
this._root.setNativeProps(nativeProps);
|
|
17
19
|
}
|
|
@@ -72,7 +72,6 @@ export declare const infoStyles: {
|
|
|
72
72
|
label: {
|
|
73
73
|
color: string;
|
|
74
74
|
fontSize: number;
|
|
75
|
-
fontWeight: "bold";
|
|
76
75
|
};
|
|
77
76
|
valueUnitContainer: {
|
|
78
77
|
flex: number;
|
|
@@ -86,7 +85,6 @@ export declare const infoStyles: {
|
|
|
86
85
|
value: {
|
|
87
86
|
color: string;
|
|
88
87
|
fontSize: number;
|
|
89
|
-
fontWeight: "bold";
|
|
90
88
|
textAlign: "right";
|
|
91
89
|
};
|
|
92
90
|
unitContainer: {
|
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
2
2
|
import { t } from "@lingui/macro";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { Dimensions, StyleSheet,
|
|
4
|
+
import { Dimensions, StyleSheet, View } from "react-native";
|
|
5
5
|
import { i18n } from "../locale/i18nUtils";
|
|
6
6
|
import { BORDER_COLOUR_GREY } from "../utils/Constants";
|
|
7
7
|
import { Utils } from "../utils/Utils";
|
|
8
|
+
import TextBold from "./text/TextBold";
|
|
9
|
+
import TextRegular from "./text/TextRegular";
|
|
8
10
|
/** A standard panel to display some data that the user entered. */
|
|
9
11
|
export default class InfoBars extends React.Component {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return unit === i18n._(t `units`) ? unit : Utils.formatUnit(unit);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
12
|
+
/**
|
|
13
|
+
* Determine the value to be displayed in the infobar.
|
|
14
|
+
*
|
|
15
|
+
* Steps:
|
|
16
|
+
* 1. Unpack showNullAsDash, unit, and value from props.
|
|
17
|
+
* 2. Set noDecimal to be true if unit is BloodGlucoseUnit.MG_DL or if unit is BloodKetonesUnit.MG_DL.
|
|
18
|
+
* 3. Set nullPlaceholder to be ‘-' if noDecimal is true and to '-.-’ otherwise.
|
|
19
|
+
* 4. Return value if it is not null or undefined. Otherwise, if showNullAsDash is true then return nullPlaceholder, otherwise return the string '0'.
|
|
20
|
+
* @returns The string to display as the value in the infobar.
|
|
21
|
+
*/
|
|
22
|
+
displayValue = () => {
|
|
23
|
+
const { showNullAsDash, unit, value } = this.props;
|
|
24
|
+
const noDecimal = unit === BloodGlucoseUnit.MG_DL || unit === BloodKetonesUnit.MG_DL;
|
|
25
|
+
const nullPlaceholder = noDecimal || !unit ? `-` : `-.-`;
|
|
26
|
+
return value ?? (showNullAsDash ? nullPlaceholder : `0`);
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Determine the unit string to be displayed in the infobar.
|
|
30
|
+
*
|
|
31
|
+
* Steps:
|
|
32
|
+
* 1. Unpack unit from props.
|
|
33
|
+
* 2. Return unit if unit is “units” or the result of calling formatUnit() with unit as argument otherwise.
|
|
34
|
+
* @returns The string to display as the unit in the infobar
|
|
35
|
+
*/
|
|
36
|
+
displayUnit = () => {
|
|
37
|
+
const { unit } = this.props;
|
|
38
|
+
if (!unit) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return unit === i18n._(t `units`) ? unit : Utils.formatUnit(unit);
|
|
42
|
+
};
|
|
44
43
|
/**
|
|
45
44
|
* @returns JSX element to display a card with the entered value.
|
|
46
45
|
*/
|
|
@@ -51,18 +50,18 @@ export default class InfoBars extends React.Component {
|
|
|
51
50
|
<View style={infoStyles.border}>
|
|
52
51
|
<View style={infoStyles.borderContainer}>
|
|
53
52
|
<View style={infoStyles.labelContainer}>
|
|
54
|
-
<
|
|
53
|
+
<TextBold style={infoStyles.label}>{this.props.label}</TextBold>
|
|
55
54
|
</View>
|
|
56
55
|
<View style={infoStyles.valueUnitContainer}>
|
|
57
56
|
<View style={infoStyles.valueContainer}>
|
|
58
|
-
<
|
|
57
|
+
<TextBold style={infoStyles.value} testID={testID?.valueID}>
|
|
59
58
|
{this.displayValue()}
|
|
60
|
-
</
|
|
59
|
+
</TextBold>
|
|
61
60
|
</View>
|
|
62
61
|
<View style={infoStyles.unitContainer}>
|
|
63
|
-
<
|
|
62
|
+
<TextRegular style={infoStyles.units} testID={testID?.unitID}>
|
|
64
63
|
{this.displayUnit()}
|
|
65
|
-
</
|
|
64
|
+
</TextRegular>
|
|
66
65
|
</View>
|
|
67
66
|
</View>
|
|
68
67
|
</View>
|
|
@@ -98,7 +97,6 @@ export const infoStyles = StyleSheet.create({
|
|
|
98
97
|
label: {
|
|
99
98
|
color: `white`,
|
|
100
99
|
fontSize: Dimensions.get(`screen`).width / 22,
|
|
101
|
-
fontWeight: `bold`,
|
|
102
100
|
},
|
|
103
101
|
valueUnitContainer: {
|
|
104
102
|
flex: 6.5,
|
|
@@ -112,7 +110,6 @@ export const infoStyles = StyleSheet.create({
|
|
|
112
110
|
value: {
|
|
113
111
|
color: `white`,
|
|
114
112
|
fontSize: Dimensions.get(`screen`).width / 15,
|
|
115
|
-
fontWeight: `bold`,
|
|
116
113
|
textAlign: `right`,
|
|
117
114
|
},
|
|
118
115
|
unitContainer: {
|
|
@@ -8,73 +8,12 @@ import { Platform, StyleSheet, TextInput } from "react-native";
|
|
|
8
8
|
* This function is then passed to the parent by giving it as the argument for a callback function named visible.
|
|
9
9
|
*/
|
|
10
10
|
export default class InvisibleNumberInput extends React.Component {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Sanitise a user-entered value by removing invalid characters
|
|
19
|
-
*
|
|
20
|
-
* Steps:
|
|
21
|
-
* 1. Use regular expressions to make the following manipulations to the text argument in the defined order and save the result to a local string variable named replaced.
|
|
22
|
-
* - Replace any commas with periods
|
|
23
|
-
* - Remove any characters that comes after two groups of zero or more digits separated by a period.
|
|
24
|
-
* 2. Define a function named round that rounds a given string that contains a number to have the amount of decimals given by the decimalPlaces prop. Return the result as a string.
|
|
25
|
-
* 3. If the value of the replaced variable from step 1 is not a NaN (not a number) when converted to a Number type then use the round function defined in step 2 on replaced and return the result
|
|
26
|
-
* 4. (If the NaN-check from step 2 didn’t fail) return the string '0'.
|
|
27
|
-
|
|
28
|
-
* @param text The string input to clean up
|
|
29
|
-
* @returns A string with the cleaned text.
|
|
30
|
-
*/
|
|
31
|
-
this.cleanInput = (text) => {
|
|
32
|
-
const replaced = text.replace(/\,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
33
|
-
const round = (value) => {
|
|
34
|
-
const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
|
|
35
|
-
const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
|
|
36
|
-
return rounded.toFixed(this.props.decimalPlaces);
|
|
37
|
-
};
|
|
38
|
-
if (!isNaN(Number(replaced))) {
|
|
39
|
-
return round(replaced);
|
|
40
|
-
}
|
|
41
|
-
return `0`;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Handle what happens when the text in the input field is being changed.
|
|
45
|
-
* That includes cleaning the text a little and then saving the value and potentially calling a callback function.
|
|
46
|
-
*
|
|
47
|
-
* Steps:
|
|
48
|
-
* 1. If the cleanPartialInput prop is true, use the cleanInput() method to to clean the content of the text argument and save it to a variable named cleaned.
|
|
49
|
-
* Otherwise just replace any commas in the text argument with periods and save the result to the same variable.
|
|
50
|
-
* 2. Remove repeated periods from the text in the cleaned variable and save the the result in a new variable named replacedSeparator.
|
|
51
|
-
* 3. Set the value state of the component to replacedSeparator.
|
|
52
|
-
* 4. If the partialInput callback function prop is defined, call it with replacedSeparator as argument.
|
|
53
|
-
* @param text The updated text in the input field
|
|
54
|
-
*/
|
|
55
|
-
this.handleOnChangeText = (text) => {
|
|
56
|
-
const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
|
|
57
|
-
let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
58
|
-
if (!this.props.negativeAllowed) {
|
|
59
|
-
replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
|
|
60
|
-
}
|
|
61
|
-
this.setState({
|
|
62
|
-
value: `${replacedSeparator}`,
|
|
63
|
-
});
|
|
64
|
-
this.props.partialInput?.(`${replacedSeparator}`);
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Handle what should happen when the user finish editing the input field.
|
|
68
|
-
*
|
|
69
|
-
* Steps:
|
|
70
|
-
* 1. Use the cleanInput() method on the value state and store the result in a variable named cleaned.
|
|
71
|
-
* 2. If the onEnd prop is not null, then convert the value of cleaned to a number and use it as an argument to call the onEnd prop function.
|
|
72
|
-
*/
|
|
73
|
-
this.onEndEdit = () => {
|
|
74
|
-
const cleaned = this.cleanInput(this.state.value);
|
|
75
|
-
this.props.onEnd?.(Number(cleaned));
|
|
76
|
-
};
|
|
77
|
-
}
|
|
11
|
+
/** For holding a reference to the TextInput component so it can be focused when the InvisibleNumberInput component has been mounted. */
|
|
12
|
+
textInput;
|
|
13
|
+
/** Initialise the state value variable with `0` */
|
|
14
|
+
state = {
|
|
15
|
+
value: `0`,
|
|
16
|
+
};
|
|
78
17
|
/**
|
|
79
18
|
* Called immediately after a component is mounted. Setting state here will trigger re-rendering.
|
|
80
19
|
* Perform various initialisation steps:
|
|
@@ -94,6 +33,66 @@ export default class InvisibleNumberInput extends React.Component {
|
|
|
94
33
|
return this.textInput?.focus();
|
|
95
34
|
});
|
|
96
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Sanitise a user-entered value by removing invalid characters
|
|
38
|
+
*
|
|
39
|
+
* Steps:
|
|
40
|
+
* 1. Use regular expressions to make the following manipulations to the text argument in the defined order and save the result to a local string variable named replaced.
|
|
41
|
+
* - Replace any commas with periods
|
|
42
|
+
* - Remove any characters that comes after two groups of zero or more digits separated by a period.
|
|
43
|
+
* 2. Define a function named round that rounds a given string that contains a number to have the amount of decimals given by the decimalPlaces prop. Return the result as a string.
|
|
44
|
+
* 3. If the value of the replaced variable from step 1 is not a NaN (not a number) when converted to a Number type then use the round function defined in step 2 on replaced and return the result
|
|
45
|
+
* 4. (If the NaN-check from step 2 didn’t fail) return the string '0'.
|
|
46
|
+
|
|
47
|
+
* @param text The string input to clean up
|
|
48
|
+
* @returns A string with the cleaned text.
|
|
49
|
+
*/
|
|
50
|
+
cleanInput = (text) => {
|
|
51
|
+
const replaced = text.replace(/\,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
52
|
+
const round = (value) => {
|
|
53
|
+
const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
|
|
54
|
+
const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
|
|
55
|
+
return rounded.toFixed(this.props.decimalPlaces);
|
|
56
|
+
};
|
|
57
|
+
if (!isNaN(Number(replaced))) {
|
|
58
|
+
return round(replaced);
|
|
59
|
+
}
|
|
60
|
+
return `0`;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Handle what happens when the text in the input field is being changed.
|
|
64
|
+
* That includes cleaning the text a little and then saving the value and potentially calling a callback function.
|
|
65
|
+
*
|
|
66
|
+
* Steps:
|
|
67
|
+
* 1. If the cleanPartialInput prop is true, use the cleanInput() method to to clean the content of the text argument and save it to a variable named cleaned.
|
|
68
|
+
* Otherwise just replace any commas in the text argument with periods and save the result to the same variable.
|
|
69
|
+
* 2. Remove repeated periods from the text in the cleaned variable and save the the result in a new variable named replacedSeparator.
|
|
70
|
+
* 3. Set the value state of the component to replacedSeparator.
|
|
71
|
+
* 4. If the partialInput callback function prop is defined, call it with replacedSeparator as argument.
|
|
72
|
+
* @param text The updated text in the input field
|
|
73
|
+
*/
|
|
74
|
+
handleOnChangeText = (text) => {
|
|
75
|
+
const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
|
|
76
|
+
let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
77
|
+
if (!this.props.negativeAllowed) {
|
|
78
|
+
replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
|
|
79
|
+
}
|
|
80
|
+
this.setState({
|
|
81
|
+
value: `${replacedSeparator}`,
|
|
82
|
+
});
|
|
83
|
+
this.props.partialInput?.(`${replacedSeparator}`);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Handle what should happen when the user finish editing the input field.
|
|
87
|
+
*
|
|
88
|
+
* Steps:
|
|
89
|
+
* 1. Use the cleanInput() method on the value state and store the result in a variable named cleaned.
|
|
90
|
+
* 2. If the onEnd prop is not null, then convert the value of cleaned to a number and use it as an argument to call the onEnd prop function.
|
|
91
|
+
*/
|
|
92
|
+
onEndEdit = () => {
|
|
93
|
+
const cleaned = this.cleanInput(this.state.value);
|
|
94
|
+
this.props.onEnd?.(Number(cleaned));
|
|
95
|
+
};
|
|
97
96
|
/**
|
|
98
97
|
* @returns JSX element to display a TextInput field with the component’s value state as its value
|
|
99
98
|
* and the handleOnChangeText() and onEndEdit() methods as the textInput’s onChangeText and onEndEditing respectively.
|
|
@@ -101,10 +100,10 @@ export default class InvisibleNumberInput extends React.Component {
|
|
|
101
100
|
render() {
|
|
102
101
|
const { testID } = this.props;
|
|
103
102
|
return (<TextInput testID={testID} value={`${this.state.value}`} ref={(textInput) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
if (textInput !== null) {
|
|
104
|
+
this.textInput = textInput;
|
|
105
|
+
}
|
|
106
|
+
}} style={inputStyles.input} keyboardType={`numeric`} returnKeyType={`done`} onChangeText={this.handleOnChangeText} onEndEditing={this.onEndEdit} maxLength={this.props.maxLength} selectTextOnFocus/>);
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
const inputStyles = StyleSheet.create({
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { t } from "@lingui/macro";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
5
|
import { Testing } from "../types/enum";
|
|
6
6
|
import { stylesModal } from "./RecommendationModal";
|
|
7
|
+
import TextBold from "./text/TextBold";
|
|
8
|
+
import TextRegular from "./text/TextRegular";
|
|
7
9
|
/** Display a message on the screen to inform the user that their insulin recommendation was limited. */
|
|
8
10
|
export default class LimitationMessage extends React.Component {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const { limitationMessage } = this.props;
|
|
16
|
-
return (<React.Fragment>
|
|
11
|
+
/**
|
|
12
|
+
* @returns JSX element for displaying a dialog with the limitationMessage and an “OK” button that calls the onPressNextButton prop callback when tapped.
|
|
13
|
+
*/
|
|
14
|
+
render = () => {
|
|
15
|
+
const { limitationMessage } = this.props;
|
|
16
|
+
return (<React.Fragment>
|
|
17
17
|
<View style={stylesModal.container}>
|
|
18
18
|
<View style={stylesModal.titleContainer}>
|
|
19
|
-
<
|
|
19
|
+
<TextBold style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</TextBold>
|
|
20
20
|
</View>
|
|
21
|
-
<
|
|
21
|
+
<TextRegular style={stylesModal.textMessage}>{limitationMessage}</TextRegular>
|
|
22
22
|
</View>
|
|
23
23
|
<View style={stylesModal.containerAcceptButton}>
|
|
24
24
|
<TouchableOpacity testID={Testing.Id.LimitationMessageTestIds.OkButton} style={stylesModal.okButton} onPress={this.props.onPressNextButton}>
|
|
25
|
-
<
|
|
25
|
+
<TextRegular style={stylesModal.buttonText}>{i18n._(t `OK`)}</TextRegular>
|
|
26
26
|
</TouchableOpacity>
|
|
27
27
|
</View>
|
|
28
28
|
</React.Fragment>);
|
|
29
|
-
|
|
30
|
-
}
|
|
29
|
+
};
|
|
31
30
|
}
|
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
import { t } from "@lingui/macro";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Dimensions, StyleSheet,
|
|
3
|
+
import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
5
|
import { Testing } from "../types/enum";
|
|
6
6
|
import { infoStyles } from "./InfoBars";
|
|
7
|
+
import TextBold from "./text/TextBold";
|
|
8
|
+
import TextRegular from "./text/TextRegular";
|
|
7
9
|
/** Display a card that prompts the user to recall if they injected insulin recently. */
|
|
8
10
|
export default class RecentInsulin extends React.Component {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.render = () => {
|
|
18
|
-
return (<View style={recentInsulinStyles.container}>
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @returns JSX element that displays a card with the question “Have you taken insulin within the last 4 hours? Along with two buttons labeled “Yes” and “No” respectively.
|
|
14
|
+
* If the user taps the “Yes” button, the onRecentInsulinYes prop callback function should be called.
|
|
15
|
+
* If the user taps the “No” button, the onRecentInsulinNo prop callback function should be called.
|
|
16
|
+
*/
|
|
17
|
+
render = () => {
|
|
18
|
+
return (<View style={recentInsulinStyles.container}>
|
|
19
19
|
<View style={recentInsulinStyles.titleContainer}>
|
|
20
|
-
<
|
|
20
|
+
<TextRegular style={recentInsulinStyles.recommended}>
|
|
21
|
+
{i18n._(t `Recommended amount of insulin`)}
|
|
22
|
+
</TextRegular>
|
|
21
23
|
</View>
|
|
22
24
|
<View style={recentInsulinStyles.takenInsulinContainer}>
|
|
23
|
-
<
|
|
25
|
+
<TextRegular style={recentInsulinStyles.takenInsulin}>
|
|
24
26
|
{i18n._(t `Have you taken insulin within the last 4 hours?`)}
|
|
25
|
-
</
|
|
27
|
+
</TextRegular>
|
|
26
28
|
</View>
|
|
27
29
|
<View style={recentInsulinStyles.buttonContainer}>
|
|
28
30
|
<View style={recentInsulinStyles.filler}/>
|
|
29
31
|
<TouchableOpacity testID={Testing.Id.RecentInsulinTestIds.Yes} onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
|
|
30
|
-
<
|
|
32
|
+
<TextBold style={recentInsulinStyles.yesNoText}>{i18n._(t `Yes`)}</TextBold>
|
|
31
33
|
</TouchableOpacity>
|
|
32
34
|
<TouchableOpacity testID={Testing.Id.RecentInsulinTestIds.No} onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
|
|
33
|
-
<
|
|
35
|
+
<TextBold style={recentInsulinStyles.yesNoText}>{i18n._(t `No`)}</TextBold>
|
|
34
36
|
</TouchableOpacity>
|
|
35
37
|
<View style={recentInsulinStyles.filler}/>
|
|
36
38
|
</View>
|
|
37
39
|
</View>);
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
+
};
|
|
40
41
|
}
|
|
41
42
|
const recentInsulinStyles = StyleSheet.create({
|
|
42
43
|
container: {
|
|
@@ -86,7 +87,6 @@ const recentInsulinStyles = StyleSheet.create({
|
|
|
86
87
|
paddingBottom: `1%`,
|
|
87
88
|
color: `white`,
|
|
88
89
|
fontSize: Dimensions.get(`screen`).width / 25,
|
|
89
|
-
fontWeight: `bold`,
|
|
90
90
|
},
|
|
91
91
|
filler: {
|
|
92
92
|
flex: 1,
|