@hedia/recommendation-screen 2.1.3-beta.6 → 2.1.3
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/coverage/clover.xml +29 -29
- package/coverage/coverage-final.json +27 -27
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1 -1
- package/coverage/lcov-report/src/__tests__/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/utils.tsx.html +1 -1
- package/coverage/lcov-report/src/components/Header.tsx.html +1 -1
- package/coverage/lcov-report/src/components/InfoBars.tsx.html +1 -1
- package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +1 -1
- package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +1 -1
- package/coverage/lcov-report/src/components/LineSeparator.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +1 -1
- package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +1 -1
- package/coverage/lcov-report/src/components/Remeasure.tsx.html +1 -1
- package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +1 -1
- package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/Activity.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +1 -1
- package/coverage/lcov-report/src/components/activity/index.html +1 -1
- package/coverage/lcov-report/src/components/index.html +1 -1
- package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +1 -1
- package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +1 -1
- package/coverage/lcov-report/src/components/mood/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/locale/i18nUtils.ts.html +1 -1
- package/coverage/lcov-report/src/locale/index.html +1 -1
- package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +1 -1
- package/coverage/lcov-report/src/utils/Constants.ts.html +1 -1
- package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +1 -1
- package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Translations.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Utils.ts.html +1 -1
- package/coverage/lcov-report/src/utils/Validations.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/index.js +5 -31
- package/package.json +1 -1
- package/src/RecommendationScreen.js +76 -101
- package/src/__tests__/RecommendationScreen.test.js +404 -409
- package/src/__tests__/RecommendationUtils.test.js +117 -119
- package/src/__tests__/Translate.test.js +14 -16
- package/src/__tests__/Utils.test.js +16 -18
- package/src/__tests__/Validations.test.js +30 -51
- package/src/__tests__/components/Activity.test.js +51 -56
- package/src/__tests__/components/Emotion.test.js +28 -33
- package/src/__tests__/components/Header.test.js +24 -29
- package/src/__tests__/components/InfoBars.test.js +59 -64
- package/src/__tests__/components/InvisibleNumberInput.test.js +22 -27
- package/src/__tests__/components/LimitationMessage.test.js +28 -33
- package/src/__tests__/components/MoodIcon.test.js +9 -14
- package/src/__tests__/components/RecommendationModal.test.js +56 -61
- package/src/__tests__/components/RecommendedCarbs.test.js +58 -63
- package/src/__tests__/components/RecommendedInsulin.test.js +60 -65
- package/src/__tests__/components/Remeasure.test.js +32 -37
- package/src/__tests__/components/TransferToLogbook.test.js +15 -20
- package/src/__tests__/components/TwoOptionModal.test.js +22 -27
- package/src/__tests__/utils.js +22 -38
- package/src/components/Header.js +34 -41
- package/src/components/Icon.js +2 -8
- package/src/components/InfoBars.js +36 -43
- package/src/components/InvisibleNumberInput.js +5 -11
- package/src/components/LimitationMessage.js +18 -40
- package/src/components/LineSeparator.js +7 -13
- package/src/components/RecentInsulin.js +33 -39
- package/src/components/RecommendationModal.js +59 -85
- package/src/components/RecommendedCarbs.js +93 -99
- package/src/components/RecommendedInsulin.js +46 -52
- package/src/components/Remeasure.js +36 -42
- package/src/components/TransferToLogbook.js +20 -26
- package/src/components/TwoOptionModal.js +39 -65
- package/src/components/activity/Activity.js +42 -48
- package/src/components/activity/ActivityIcon.js +15 -21
- package/src/components/activity/ActivityIntensity.js +19 -25
- package/src/components/mood/Emotion.js +17 -23
- package/src/components/mood/MoodIcon.js +11 -17
- package/src/locale/i18nUtils.js +17 -24
- package/src/types/enum.js +28 -31
- package/src/types/types.js +1 -2
- package/src/utils/AttentionMessages.js +24 -32
- package/src/utils/Constants.js +23 -26
- package/src/utils/RecommendationError.js +28 -54
- package/src/utils/RecommendationUtils.js +60 -72
- package/src/utils/Translations.js +6 -9
- package/src/utils/Utils.js +8 -12
- package/src/utils/Validations.js +77 -107
- package/tsconfig.json +3 -3
|
@@ -1,37 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.stylesModal = void 0;
|
|
26
|
-
const macro_1 = require("@lingui/macro");
|
|
27
|
-
const React = __importStar(require("react"));
|
|
28
|
-
const react_native_1 = require("react-native");
|
|
29
|
-
const react_native_modal_1 = __importDefault(require("react-native-modal"));
|
|
30
|
-
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
31
|
-
const enum_1 = require("../types/enum");
|
|
32
|
-
const Constants_1 = require("../utils/Constants");
|
|
33
|
-
const LimitationMessage_1 = __importDefault(require("./LimitationMessage"));
|
|
34
|
-
class RecommendationModal extends React.Component {
|
|
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 { RecommendationModalTestIds } from "../types/enum";
|
|
7
|
+
import { BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
8
|
+
import LimitationMessage from "./LimitationMessage";
|
|
9
|
+
export default class RecommendationModal extends React.Component {
|
|
35
10
|
constructor(props) {
|
|
36
11
|
super(props);
|
|
37
12
|
this.onPressNextButton = () => {
|
|
@@ -40,63 +15,63 @@ class RecommendationModal extends React.Component {
|
|
|
40
15
|
return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
|
|
41
16
|
};
|
|
42
17
|
this.recommendationButtons = () => {
|
|
43
|
-
return (<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
</
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
</
|
|
50
|
-
</
|
|
18
|
+
return (<View style={stylesModal.recommendationButtonsContainer}>
|
|
19
|
+
<TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} accessibilityLabel="yesButtonModal" style={stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
|
|
20
|
+
<Text style={stylesModal.affirmativeCarbsText}>{i18n._(t `OK`)}</Text>
|
|
21
|
+
</TouchableOpacity>
|
|
22
|
+
<TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} accessibilityLabel="noButtonModal" style={stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
|
|
23
|
+
<Text style={stylesModal.negativeCarbsText}>{i18n._(t `NO`)}</Text>
|
|
24
|
+
</TouchableOpacity>
|
|
25
|
+
</View>);
|
|
51
26
|
};
|
|
52
27
|
this.recommendCarbohydrates = (suggestedCarbohydrates) => {
|
|
53
28
|
const displayCarbs = Math.round(suggestedCarbohydrates);
|
|
54
29
|
return (<React.Fragment>
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
<
|
|
58
|
-
{
|
|
59
|
-
</
|
|
60
|
-
</
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
</
|
|
66
|
-
</
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
</
|
|
70
|
-
</
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
{
|
|
74
|
-
</
|
|
30
|
+
<View style={stylesModal.innerView}>
|
|
31
|
+
<View style={stylesModal.recommendationRow}>
|
|
32
|
+
<Text style={stylesModal.recommendEatingText}>
|
|
33
|
+
{i18n._(t `We recommend eating an additional:`)}
|
|
34
|
+
</Text>
|
|
35
|
+
</View>
|
|
36
|
+
<View style={stylesModal.suggestedContainer}>
|
|
37
|
+
<Text style={stylesModal.textCenter}>
|
|
38
|
+
<Text style={stylesModal.suggestedCarbs} testID={RecommendationModalTestIds.SuggestedCarbs}>{`${displayCarbs} `}</Text>
|
|
39
|
+
<Text style={stylesModal.carbohydrateText}>{i18n._(t `grams of carbohydrates`)}</Text>
|
|
40
|
+
</Text>
|
|
41
|
+
</View>
|
|
42
|
+
<View style={stylesModal.recommendationRow}>
|
|
43
|
+
<Text style={stylesModal.recommendEatingText}>{i18n._(t `Instead of taking insulin`)}</Text>
|
|
44
|
+
</View>
|
|
45
|
+
</View>
|
|
46
|
+
<View style={stylesModal.addToCalculationContainer}>
|
|
47
|
+
<Text style={stylesModal.addToCalculation}>
|
|
48
|
+
{i18n._(t `Would you like to add this to your current calculation?`)}
|
|
49
|
+
</Text>
|
|
75
50
|
{this.recommendationButtons()}
|
|
76
|
-
</
|
|
51
|
+
</View>
|
|
77
52
|
</React.Fragment>);
|
|
78
53
|
};
|
|
79
54
|
this.secondPage = () => {
|
|
80
55
|
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
81
56
|
const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
|
|
82
57
|
return (<React.Fragment>
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
</
|
|
87
|
-
<
|
|
58
|
+
<View style={stylesModal.container}>
|
|
59
|
+
<View style={stylesModal.titleContainer}>
|
|
60
|
+
<Text style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</Text>
|
|
61
|
+
</View>
|
|
62
|
+
<Text style={stylesModal.textMessage}>{attentionMessage}</Text>
|
|
88
63
|
{willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
|
|
89
|
-
</
|
|
90
|
-
{willRecommendCarbs ? null : (<
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
</
|
|
94
|
-
</
|
|
64
|
+
</View>
|
|
65
|
+
{willRecommendCarbs ? null : (<View style={stylesModal.containerAcceptButton}>
|
|
66
|
+
<TouchableOpacity testID={RecommendationModalTestIds.OkButton} accessibilityLabel="okayButtonModal" style={stylesModal.okButton} onPress={this.props.onClickOkButton}>
|
|
67
|
+
<Text style={stylesModal.buttonText}>{i18n._(t `OK`)}</Text>
|
|
68
|
+
</TouchableOpacity>
|
|
69
|
+
</View>)}
|
|
95
70
|
</React.Fragment>);
|
|
96
71
|
};
|
|
97
72
|
this.firstPage = () => {
|
|
98
73
|
const { limitationMessage } = this.props;
|
|
99
|
-
return <
|
|
74
|
+
return <LimitationMessage limitationMessage={limitationMessage} onPressNextButton={this.onPressNextButton}/>;
|
|
100
75
|
};
|
|
101
76
|
this.state = {
|
|
102
77
|
firstPageVisible: !!this.props.limitationMessage,
|
|
@@ -105,13 +80,12 @@ class RecommendationModal extends React.Component {
|
|
|
105
80
|
render() {
|
|
106
81
|
const { isVisible } = this.props;
|
|
107
82
|
const { firstPageVisible } = this.state;
|
|
108
|
-
return (<
|
|
83
|
+
return (<ReactNativeModal isVisible={isVisible} style={stylesModal.modalStyle}>
|
|
109
84
|
{firstPageVisible ? this.firstPage() : this.secondPage()}
|
|
110
|
-
</
|
|
85
|
+
</ReactNativeModal>);
|
|
111
86
|
}
|
|
112
87
|
}
|
|
113
|
-
|
|
114
|
-
const { height, width } = react_native_1.Dimensions.get(`screen`);
|
|
88
|
+
const { height, width } = Dimensions.get(`screen`);
|
|
115
89
|
const buttonHeight = height / 20;
|
|
116
90
|
const buttonWidth = width / 2.5;
|
|
117
91
|
const buttonFontSize = width / 22;
|
|
@@ -121,7 +95,7 @@ const sugestionFontSize = width / 19;
|
|
|
121
95
|
const recommendEatingFontSize = height / 45;
|
|
122
96
|
const textFontSize = width / 20;
|
|
123
97
|
const titleFontSize = width / 13;
|
|
124
|
-
|
|
98
|
+
export const stylesModal = StyleSheet.create({
|
|
125
99
|
modalStyle: { margin: 0 },
|
|
126
100
|
container: {
|
|
127
101
|
flex: 4,
|
|
@@ -138,7 +112,7 @@ exports.stylesModal = react_native_1.StyleSheet.create({
|
|
|
138
112
|
recommendationRow: { justifyContent: `center`, alignContent: `center`, marginBottom: `3%` },
|
|
139
113
|
textTittleMessage: { color: `white`, fontSize: titleFontSize, textAlign: `center` },
|
|
140
114
|
textMessage: { color: `white`, fontSize: textFontSize, textAlign: `center` },
|
|
141
|
-
buttonText: { color:
|
|
115
|
+
buttonText: { color: BORDER_COLOUR_TEAL, fontSize: buttonFontSize, textAlign: `center` },
|
|
142
116
|
addToCalculationContainer: { justifyContent: `flex-start`, marginVertical: `5%` },
|
|
143
117
|
innerView: {
|
|
144
118
|
alignContent: `center`,
|
|
@@ -147,7 +121,7 @@ exports.stylesModal = react_native_1.StyleSheet.create({
|
|
|
147
121
|
marginTop: `5%`,
|
|
148
122
|
borderRadius: height / 80,
|
|
149
123
|
borderWidth: height / 300,
|
|
150
|
-
borderColor:
|
|
124
|
+
borderColor: BORDER_COLOUR_TEAL,
|
|
151
125
|
},
|
|
152
126
|
suggestedContainer: { justifyContent: `center`, flexDirection: `row`, marginBottom: `3%` },
|
|
153
127
|
suggestedCarbs: { color: `white`, fontSize: sugestionFontSize, fontWeight: `bold` },
|
|
@@ -156,13 +130,13 @@ exports.stylesModal = react_native_1.StyleSheet.create({
|
|
|
156
130
|
carbohydrateText: { color: `white`, fontSize: sugestionFontSize },
|
|
157
131
|
addToCalculation: { color: `white`, fontSize: textFontSize, textAlign: `center` },
|
|
158
132
|
recommendationButtonsContainer: { justifyContent: `center`, flexDirection: `row`, margin: `3%` },
|
|
159
|
-
affirmativeCarbsText: { color:
|
|
133
|
+
affirmativeCarbsText: { color: BORDER_COLOUR_TEAL, fontSize: buttonFontSize, textAlign: `center` },
|
|
160
134
|
negativeCarbsText: { color: `white`, fontSize: buttonFontSize, textAlign: `center` },
|
|
161
135
|
affirmativeCarbsButton: {
|
|
162
136
|
marginTop: `2%`,
|
|
163
137
|
borderRadius: buttonBorderRadius,
|
|
164
138
|
borderWidth: buttonBorderWidth,
|
|
165
|
-
borderColor:
|
|
139
|
+
borderColor: BORDER_COLOUR_TEAL,
|
|
166
140
|
width: buttonWidth,
|
|
167
141
|
height: buttonHeight,
|
|
168
142
|
alignSelf: `center`,
|
|
@@ -184,7 +158,7 @@ exports.stylesModal = react_native_1.StyleSheet.create({
|
|
|
184
158
|
marginTop: `6%`,
|
|
185
159
|
borderRadius: buttonBorderRadius,
|
|
186
160
|
borderWidth: buttonBorderWidth,
|
|
187
|
-
borderColor:
|
|
161
|
+
borderColor: BORDER_COLOUR_TEAL,
|
|
188
162
|
width: buttonWidth,
|
|
189
163
|
height: buttonHeight,
|
|
190
164
|
alignSelf: `center`,
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const Icon_1 = __importDefault(require("./Icon"));
|
|
14
|
-
const InfoBars_1 = require("./InfoBars");
|
|
15
|
-
const InvisibleNumberInput_1 = __importDefault(require("./InvisibleNumberInput"));
|
|
16
|
-
const LineSeparator_1 = __importDefault(require("./LineSeparator"));
|
|
17
|
-
class RecommendedCarbs extends react_1.default.Component {
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Alert, Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
4
|
+
import { i18n } from "../locale/i18nUtils";
|
|
5
|
+
import { RecommendedCarbsTestIds } from "../types/enum";
|
|
6
|
+
import { BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
7
|
+
import { CarbohydrateLimitError } from "../utils/RecommendationError";
|
|
8
|
+
import Icon from "./Icon";
|
|
9
|
+
import { infoStyles } from "./InfoBars";
|
|
10
|
+
import InvisibleNumberInput from "./InvisibleNumberInput";
|
|
11
|
+
import LineSeparator from "./LineSeparator";
|
|
12
|
+
export default class RecommendedCarbs extends React.Component {
|
|
18
13
|
constructor() {
|
|
19
14
|
super(...arguments);
|
|
20
15
|
this.state = {
|
|
@@ -32,9 +27,9 @@ class RecommendedCarbs extends react_1.default.Component {
|
|
|
32
27
|
if (carbs >= 0) {
|
|
33
28
|
if (carbs > 300) {
|
|
34
29
|
this.setState({ partialInput: this.props.recommendedCarbs });
|
|
35
|
-
return
|
|
30
|
+
return Alert.alert(i18n._(t `Attention`), CarbohydrateLimitError().message, [
|
|
36
31
|
{
|
|
37
|
-
text:
|
|
32
|
+
text: i18n._(t `OK`),
|
|
38
33
|
},
|
|
39
34
|
]);
|
|
40
35
|
}
|
|
@@ -44,96 +39,95 @@ class RecommendedCarbs extends react_1.default.Component {
|
|
|
44
39
|
this.renderRecommendedCarbs = () => {
|
|
45
40
|
const shownCarbs = this.state.partialInput ?? Math.round(Number(this.props.recommendedCarbs));
|
|
46
41
|
const totalCarbs = Math.round(parseFloat(this.props.enteredCarbs) + Number(shownCarbs));
|
|
47
|
-
return (<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
</
|
|
54
|
-
<
|
|
55
|
-
</
|
|
56
|
-
</
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
</
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
42
|
+
return (<React.Fragment>
|
|
43
|
+
<LineSeparator color={BORDER_COLOUR_GREY}/>
|
|
44
|
+
<View style={calculationStyles.borderContainer}>
|
|
45
|
+
<View style={calculationStyles.recommendedContainer}>
|
|
46
|
+
<TouchableOpacity testID={RecommendedCarbsTestIds.RemoveRecommendation} accessibilityLabel="removeRecommendedCarbs" style={calculationStyles.removeRecommended} onPress={this.props.removeRecommendedCarbs}>
|
|
47
|
+
<Icon iconIdentifier={`Ionicons/ios-close-circle-outline`} style={calculationStyles.removeRecommendedIcon}/>
|
|
48
|
+
</TouchableOpacity>
|
|
49
|
+
<Text style={calculationStyles.recommendedLabel}>{i18n._(t `Recommended`)}</Text>
|
|
50
|
+
</View>
|
|
51
|
+
</View>
|
|
52
|
+
<View style={calculationStyles.borderContainer}>
|
|
53
|
+
<View style={calculationStyles.recommendedContainer}>
|
|
54
|
+
<Text style={calculationStyles.recommendedLabel}>{i18n._(t `Additional`)}</Text>
|
|
55
|
+
</View>
|
|
56
|
+
<View style={calculationStyles.valueUnitContainer}>
|
|
57
|
+
<TouchableOpacity testID={RecommendedCarbsTestIds.EditRecommendedCarbs} accessibilityLabel="editRecommendedCarbsButton" onPress={this.showTextInput} style={[calculationStyles.valueUnitContainer]}>
|
|
58
|
+
<View style={calculationStyles.valueContainer}>
|
|
59
|
+
<Text testID={RecommendedCarbsTestIds.RecommendedCarbs} style={[calculationStyles.value, { color: BORDER_COLOUR_TEAL }]}>
|
|
65
60
|
{shownCarbs}
|
|
66
|
-
</
|
|
67
|
-
</
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
</
|
|
72
|
-
<
|
|
73
|
-
{
|
|
74
|
-
</
|
|
75
|
-
</
|
|
76
|
-
</
|
|
77
|
-
</
|
|
78
|
-
</
|
|
79
|
-
<
|
|
61
|
+
</Text>
|
|
62
|
+
</View>
|
|
63
|
+
<View style={[calculationStyles.unitContainer]}>
|
|
64
|
+
<View style={calculationStyles.editIconContainer}>
|
|
65
|
+
<Icon style={calculationStyles.editIcon} iconIdentifier={`Feather/edit`}/>
|
|
66
|
+
</View>
|
|
67
|
+
<Text style={[calculationStyles.units, { color: BORDER_COLOUR_TEAL }]}>
|
|
68
|
+
{i18n._(t `grams`)}
|
|
69
|
+
</Text>
|
|
70
|
+
</View>
|
|
71
|
+
</TouchableOpacity>
|
|
72
|
+
</View>
|
|
73
|
+
</View>
|
|
74
|
+
<LineSeparator color={BORDER_COLOUR_TEAL}/>
|
|
80
75
|
{this.renderRow({
|
|
81
|
-
label:
|
|
76
|
+
label: i18n._(t `Total`),
|
|
82
77
|
value: totalCarbs.toString(),
|
|
83
|
-
units:
|
|
84
|
-
},
|
|
85
|
-
<
|
|
86
|
-
</
|
|
78
|
+
units: i18n._(t `grams`),
|
|
79
|
+
}, RecommendedCarbsTestIds.TotalCarbs)}
|
|
80
|
+
<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}/>
|
|
81
|
+
</React.Fragment>);
|
|
87
82
|
};
|
|
88
83
|
this.renderRow = (row, testID) => {
|
|
89
|
-
return (<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
</
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
84
|
+
return (<View style={[calculationStyles.borderContainer, { paddingVertical: `1%` }]}>
|
|
85
|
+
<View style={calculationStyles.rowContainer}>
|
|
86
|
+
<Text style={calculationStyles.rowLabel}>{row.label}</Text>
|
|
87
|
+
</View>
|
|
88
|
+
<View style={calculationStyles.valueUnitContainer}>
|
|
89
|
+
<View style={calculationStyles.valueContainer}>
|
|
90
|
+
<Text testID={testID} style={calculationStyles.value}>
|
|
96
91
|
{row.value}
|
|
97
|
-
</
|
|
98
|
-
</
|
|
99
|
-
<
|
|
100
|
-
<
|
|
101
|
-
</
|
|
102
|
-
</
|
|
103
|
-
</
|
|
92
|
+
</Text>
|
|
93
|
+
</View>
|
|
94
|
+
<View style={calculationStyles.unitContainer}>
|
|
95
|
+
<Text style={calculationStyles.units}>{row.units}</Text>
|
|
96
|
+
</View>
|
|
97
|
+
</View>
|
|
98
|
+
</View>);
|
|
104
99
|
};
|
|
105
100
|
}
|
|
106
101
|
render() {
|
|
107
102
|
const carbs = Number(this.props.recommendedCarbs);
|
|
108
|
-
return (<
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
<
|
|
112
|
-
</
|
|
103
|
+
return (<React.Fragment>
|
|
104
|
+
<View style={calculationStyles.foodTitleContainer}>
|
|
105
|
+
<Text style={infoStyles.label}>{i18n._(t `Food`)}</Text>
|
|
106
|
+
<Text style={calculationStyles.foodUnitsLabel}>{`(${i18n._(t `Carbohydrates`)})`}</Text>
|
|
107
|
+
</View>
|
|
113
108
|
{this.renderRow({
|
|
114
|
-
label:
|
|
109
|
+
label: i18n._(t `Entered`),
|
|
115
110
|
value: this.props.enteredCarbs,
|
|
116
|
-
units:
|
|
117
|
-
},
|
|
111
|
+
units: i18n._(t `grams`),
|
|
112
|
+
}, RecommendedCarbsTestIds.EnteredCarbs)}
|
|
118
113
|
{!isNaN(carbs) && carbs > 0 ? this.renderRecommendedCarbs() : null}
|
|
119
|
-
</
|
|
114
|
+
</React.Fragment>);
|
|
120
115
|
}
|
|
121
116
|
}
|
|
122
|
-
|
|
123
|
-
const calculationStyles = react_native_1.StyleSheet.create({
|
|
117
|
+
const calculationStyles = StyleSheet.create({
|
|
124
118
|
borderContainer: {
|
|
125
|
-
...
|
|
119
|
+
...infoStyles.borderContainer,
|
|
126
120
|
alignItems: `center`,
|
|
127
121
|
},
|
|
128
122
|
foodTitleContainer: {
|
|
129
|
-
flex:
|
|
130
|
-
flexDirection:
|
|
131
|
-
paddingHorizontal:
|
|
123
|
+
flex: infoStyles.borderContainer.flex,
|
|
124
|
+
flexDirection: infoStyles.borderContainer.flexDirection,
|
|
125
|
+
paddingHorizontal: infoStyles.borderContainer.paddingHorizontal,
|
|
132
126
|
alignItems: `center`,
|
|
133
127
|
paddingVertical: `2%`,
|
|
134
128
|
},
|
|
135
129
|
foodUnitsLabel: {
|
|
136
|
-
...
|
|
130
|
+
...infoStyles.units,
|
|
137
131
|
color: `rgba(160, 180, 240, 1)`,
|
|
138
132
|
paddingLeft: `1%`,
|
|
139
133
|
},
|
|
@@ -142,7 +136,7 @@ const calculationStyles = react_native_1.StyleSheet.create({
|
|
|
142
136
|
},
|
|
143
137
|
rowLabel: {
|
|
144
138
|
color: `white`,
|
|
145
|
-
fontSize:
|
|
139
|
+
fontSize: Dimensions.get(`screen`).width / 25,
|
|
146
140
|
fontWeight: `bold`,
|
|
147
141
|
},
|
|
148
142
|
enteredContainer: {
|
|
@@ -151,22 +145,22 @@ const calculationStyles = react_native_1.StyleSheet.create({
|
|
|
151
145
|
},
|
|
152
146
|
entered: {
|
|
153
147
|
color: `white`,
|
|
154
|
-
fontSize:
|
|
148
|
+
fontSize: Dimensions.get(`screen`).width / 23,
|
|
155
149
|
},
|
|
156
150
|
valueUnitContainer: {
|
|
157
|
-
...
|
|
151
|
+
...infoStyles.valueUnitContainer,
|
|
158
152
|
},
|
|
159
153
|
valueContainer: {
|
|
160
|
-
...
|
|
154
|
+
...infoStyles.valueContainer,
|
|
161
155
|
},
|
|
162
156
|
value: {
|
|
163
|
-
...
|
|
157
|
+
...infoStyles.value,
|
|
164
158
|
},
|
|
165
159
|
unitContainer: {
|
|
166
|
-
...
|
|
160
|
+
...infoStyles.unitContainer,
|
|
167
161
|
},
|
|
168
162
|
units: {
|
|
169
|
-
...
|
|
163
|
+
...infoStyles.units,
|
|
170
164
|
},
|
|
171
165
|
editIconContainer: {
|
|
172
166
|
justifyContent: `flex-end`,
|
|
@@ -174,16 +168,16 @@ const calculationStyles = react_native_1.StyleSheet.create({
|
|
|
174
168
|
flexDirection: `row`,
|
|
175
169
|
},
|
|
176
170
|
editIcon: {
|
|
177
|
-
color:
|
|
178
|
-
fontSize:
|
|
171
|
+
color: BORDER_COLOUR_TEAL,
|
|
172
|
+
fontSize: Dimensions.get(`screen`).width / 30,
|
|
179
173
|
},
|
|
180
174
|
recommendedContainer: {
|
|
181
175
|
flex: 7,
|
|
182
176
|
flexDirection: `row`,
|
|
183
177
|
},
|
|
184
178
|
recommendedLabel: {
|
|
185
|
-
color:
|
|
186
|
-
fontSize:
|
|
179
|
+
color: BORDER_COLOUR_TEAL,
|
|
180
|
+
fontSize: Dimensions.get(`screen`).width / 25,
|
|
187
181
|
alignSelf: `center`,
|
|
188
182
|
fontWeight: `bold`,
|
|
189
183
|
},
|
|
@@ -193,8 +187,8 @@ const calculationStyles = react_native_1.StyleSheet.create({
|
|
|
193
187
|
marginTop: `1%`,
|
|
194
188
|
},
|
|
195
189
|
removeRecommendedIcon: {
|
|
196
|
-
color:
|
|
197
|
-
fontSize:
|
|
190
|
+
color: BORDER_COLOUR_TEAL,
|
|
191
|
+
fontSize: Dimensions.get(`screen`).width / 20,
|
|
198
192
|
paddingBottom: `0.5%`,
|
|
199
193
|
},
|
|
200
194
|
});
|