@hedia/recommendation-screen 2.2.0-alpha.44 → 2.2.0-alpha.5
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/index.js +0 -1
- package/dist/src/RecommendationScreen.d.ts +67 -64
- package/dist/src/RecommendationScreen.js +145 -157
- package/dist/src/assets/assets/activity/Cyclist.png +0 -0
- package/dist/src/assets/assets/activity/Other.png +0 -0
- package/dist/src/assets/assets/activity/Runner.png +0 -0
- package/dist/src/assets/assets/activity/Swimmer.png +0 -0
- package/dist/src/assets/assets/activity/Walk.png +0 -0
- package/dist/src/assets/assets/fonts/Poppins-Bold.ttf +0 -0
- package/dist/src/assets/assets/fonts/Poppins-SemiBold.ttf +0 -0
- package/dist/src/assets/assets/icons/Edit.tsx +22 -0
- package/dist/src/assets/assets/icons/X.tsx +14 -0
- package/dist/src/assets/assets/mood/happy.png +0 -0
- package/dist/src/assets/assets/mood/happy_active.png +0 -0
- package/dist/src/assets/assets/mood/neutral.png +0 -0
- package/dist/src/assets/assets/mood/neutral_active.png +0 -0
- package/dist/src/assets/assets/mood/sad.png +0 -0
- package/dist/src/assets/assets/mood/sad_active.png +0 -0
- package/dist/src/assets/assets/mood/semi_happy.png +0 -0
- package/dist/src/assets/assets/mood/semi_happy_active.png +0 -0
- package/dist/src/assets/assets/mood/semi_sad.png +0 -0
- package/dist/src/assets/assets/mood/semi_sad_active.png +0 -0
- package/dist/src/assets/icons/Edit.d.ts +4 -0
- package/dist/src/assets/icons/Edit.js +7 -0
- package/dist/src/assets/{IconsSVG/Edit.d.ts → icons/X.d.ts} +2 -2
- package/dist/src/assets/icons/X.js +6 -0
- package/dist/src/components/ForecastInfoBar.d.ts +109 -0
- package/dist/src/components/ForecastInfoBar.js +138 -0
- package/dist/src/components/Header.d.ts +8 -0
- package/dist/src/components/Header.js +54 -0
- package/dist/src/components/Icon.d.ts +20 -0
- package/dist/src/components/Icon.js +43 -0
- package/dist/src/components/InfoBars.d.ts +28 -13
- package/dist/src/components/InfoBars.js +63 -33
- package/dist/src/components/InvisibleNumberInput.d.ts +3 -8
- package/dist/src/components/InvisibleNumberInput.js +20 -22
- package/dist/src/components/LimitationMessage.d.ts +14 -0
- package/dist/src/components/LimitationMessage.js +30 -0
- package/dist/src/components/LineSeparator.d.ts +1 -5
- package/dist/src/components/LineSeparator.js +3 -2
- package/dist/src/components/RecentInsulin.d.ts +1 -2
- package/dist/src/components/RecentInsulin.js +40 -57
- package/dist/src/components/RecommendationModal.d.ts +63 -61
- package/dist/src/components/RecommendationModal.js +118 -133
- package/dist/src/components/RecommendedCarbs.d.ts +0 -2
- package/dist/src/components/RecommendedCarbs.js +99 -82
- package/dist/src/components/RecommendedInsulin.d.ts +1 -1
- package/dist/src/components/RecommendedInsulin.js +72 -56
- package/dist/src/components/Remeasure.d.ts +15 -5
- package/dist/src/components/Remeasure.js +77 -50
- package/dist/src/components/{TransferToLogbook.d.ts → SaveButton.d.ts} +2 -2
- package/dist/src/components/{TransferToLogbook.js → SaveButton.js} +30 -27
- package/dist/src/components/TwoOptionModal.d.ts +136 -0
- package/dist/src/components/TwoOptionModal.js +141 -0
- package/dist/src/components/activity/Activity.d.ts +2 -2
- package/dist/src/components/activity/Activity.js +49 -58
- package/dist/src/components/activity/ActivityIcon.d.ts +7 -7
- package/dist/src/components/activity/ActivityIcon.js +29 -37
- package/dist/src/components/activity/ActivityIntensity.d.ts +1 -1
- package/dist/src/components/activity/ActivityIntensity.js +23 -20
- package/dist/src/components/mood/Emotion.d.ts +1 -1
- package/dist/src/components/mood/Emotion.js +16 -21
- package/dist/src/components/mood/MoodIcon.d.ts +5 -4
- package/dist/src/components/mood/MoodIcon.js +23 -28
- 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/locale/da/messages.js +1 -0
- package/dist/src/locale/da/messages.po +353 -0
- package/dist/src/locale/de/messages.js +1 -0
- package/dist/src/locale/de/messages.po +353 -0
- package/dist/src/locale/en/messages.js +1 -0
- package/dist/src/locale/en/messages.po +353 -0
- package/dist/src/locale/es/messages.js +1 -0
- package/dist/src/locale/es/messages.po +353 -0
- package/dist/src/locale/fr/messages.js +1 -0
- package/dist/src/locale/fr/messages.po +353 -0
- package/dist/src/locale/i18nUtils.d.ts +18 -0
- package/dist/src/locale/i18nUtils.js +39 -0
- package/dist/src/locale/it/messages.js +1 -0
- package/dist/src/locale/it/messages.po +353 -0
- package/dist/src/types/enum.d.ts +15 -21
- package/dist/src/types/enum.js +18 -27
- package/dist/src/types/types.js +0 -1
- package/dist/src/utils/AttentionMessages.js +24 -29
- package/dist/src/utils/Constants.d.ts +3 -17
- package/dist/src/utils/Constants.js +1 -16
- package/dist/src/utils/RecommendationError.js +24 -26
- package/dist/src/utils/RecommendationUtils.js +2 -5
- package/dist/src/utils/Translations.js +5 -5
- package/dist/src/utils/Utils.d.ts +1 -1
- package/dist/src/utils/Utils.js +0 -1
- package/dist/src/utils/Validations.d.ts +1 -1
- package/dist/src/utils/Validations.js +2 -3
- package/package.json +99 -89
- package/dist/index.js.map +0 -1
- package/dist/src/RecommendationScreen.js.map +0 -1
- package/dist/src/assets/IconsSVG/Close.d.ts +0 -4
- package/dist/src/assets/IconsSVG/Close.js +0 -7
- package/dist/src/assets/IconsSVG/Close.js.map +0 -1
- package/dist/src/assets/IconsSVG/CloseOutlined.d.ts +0 -4
- package/dist/src/assets/IconsSVG/CloseOutlined.js +0 -9
- package/dist/src/assets/IconsSVG/CloseOutlined.js.map +0 -1
- package/dist/src/assets/IconsSVG/Edit.js +0 -8
- package/dist/src/assets/IconsSVG/Edit.js.map +0 -1
- package/dist/src/assets/IconsSVG/activity/Cycling.d.ts +0 -4
- package/dist/src/assets/IconsSVG/activity/Cycling.js +0 -12
- package/dist/src/assets/IconsSVG/activity/Cycling.js.map +0 -1
- package/dist/src/assets/IconsSVG/activity/Running.d.ts +0 -4
- package/dist/src/assets/IconsSVG/activity/Running.js +0 -10
- package/dist/src/assets/IconsSVG/activity/Running.js.map +0 -1
- package/dist/src/assets/IconsSVG/activity/Stretching.d.ts +0 -4
- package/dist/src/assets/IconsSVG/activity/Stretching.js +0 -10
- package/dist/src/assets/IconsSVG/activity/Stretching.js.map +0 -1
- package/dist/src/assets/IconsSVG/activity/Swimming.d.ts +0 -4
- package/dist/src/assets/IconsSVG/activity/Swimming.js +0 -13
- package/dist/src/assets/IconsSVG/activity/Swimming.js.map +0 -1
- package/dist/src/assets/IconsSVG/activity/Walking.d.ts +0 -4
- package/dist/src/assets/IconsSVG/activity/Walking.js +0 -11
- package/dist/src/assets/IconsSVG/activity/Walking.js.map +0 -1
- package/dist/src/assets/IconsSVG/mood/Happy.d.ts +0 -4
- package/dist/src/assets/IconsSVG/mood/Happy.js +0 -11
- package/dist/src/assets/IconsSVG/mood/Happy.js.map +0 -1
- package/dist/src/assets/IconsSVG/mood/Neutral.d.ts +0 -4
- package/dist/src/assets/IconsSVG/mood/Neutral.js +0 -11
- package/dist/src/assets/IconsSVG/mood/Neutral.js.map +0 -1
- package/dist/src/assets/IconsSVG/mood/Sad.d.ts +0 -4
- package/dist/src/assets/IconsSVG/mood/Sad.js +0 -11
- package/dist/src/assets/IconsSVG/mood/Sad.js.map +0 -1
- package/dist/src/assets/IconsSVG/mood/SemiHappy.d.ts +0 -4
- package/dist/src/assets/IconsSVG/mood/SemiHappy.js +0 -11
- package/dist/src/assets/IconsSVG/mood/SemiHappy.js.map +0 -1
- package/dist/src/assets/IconsSVG/mood/SemiSad.d.ts +0 -4
- package/dist/src/assets/IconsSVG/mood/SemiSad.js +0 -11
- package/dist/src/assets/IconsSVG/mood/SemiSad.js.map +0 -1
- package/dist/src/components/ExitModal.d.ts +0 -25
- package/dist/src/components/ExitModal.js +0 -91
- package/dist/src/components/ExitModal.js.map +0 -1
- package/dist/src/components/InfoBars.js.map +0 -1
- package/dist/src/components/InvisibleNumberInput.js.map +0 -1
- package/dist/src/components/LineSeparator.js.map +0 -1
- package/dist/src/components/RecentInsulin.js.map +0 -1
- package/dist/src/components/RecommendationModal.js.map +0 -1
- package/dist/src/components/RecommendedCarbs.js.map +0 -1
- package/dist/src/components/RecommendedInsulin.js.map +0 -1
- package/dist/src/components/Remeasure.js.map +0 -1
- package/dist/src/components/Text.d.ts +0 -13
- package/dist/src/components/Text.js +0 -14
- package/dist/src/components/Text.js.map +0 -1
- package/dist/src/components/TimeoutModal.d.ts +0 -24
- package/dist/src/components/TimeoutModal.js +0 -84
- package/dist/src/components/TimeoutModal.js.map +0 -1
- package/dist/src/components/TransferToLogbook.js.map +0 -1
- package/dist/src/components/activity/Activity.js.map +0 -1
- package/dist/src/components/activity/ActivityIcon.js.map +0 -1
- package/dist/src/components/activity/ActivityIntensity.js.map +0 -1
- package/dist/src/components/mood/Emotion.js.map +0 -1
- package/dist/src/components/mood/MoodIcon.js.map +0 -1
- package/dist/src/components/styles/fonts.d.ts +0 -143
- package/dist/src/components/styles/fonts.js +0 -145
- package/dist/src/components/styles/fonts.js.map +0 -1
- package/dist/src/locales/da/translations.json +0 -82
- package/dist/src/locales/de/translations.json +0 -81
- package/dist/src/locales/en/translations.json +0 -84
- package/dist/src/locales/es/translations.json +0 -81
- package/dist/src/locales/fr/translations.json +0 -81
- package/dist/src/locales/it/translations.json +0 -81
- package/dist/src/locales/translate.d.ts +0 -19
- package/dist/src/locales/translate.js +0 -53
- package/dist/src/locales/translate.js.map +0 -1
- package/dist/src/types/enum.js.map +0 -1
- package/dist/src/types/types.js.map +0 -1
- package/dist/src/utils/AttentionMessages.js.map +0 -1
- package/dist/src/utils/Constants.js.map +0 -1
- package/dist/src/utils/RecommendationError.js.map +0 -1
- package/dist/src/utils/RecommendationUtils.js.map +0 -1
- package/dist/src/utils/Translations.js.map +0 -1
- package/dist/src/utils/Utils.js.map +0 -1
- package/dist/src/utils/Validations.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
+
import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
4
|
import ReactNativeModal from "react-native-modal";
|
|
4
|
-
import {
|
|
5
|
+
import { i18n } from "../locale/i18nUtils";
|
|
5
6
|
import { Testing } from "../types/enum";
|
|
6
7
|
import { colors } from "../utils/Constants";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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.
|
|
@@ -28,15 +30,6 @@ export default class RecommendationModal extends React.Component {
|
|
|
28
30
|
firstPageVisible: !!this.props.limitationMessage,
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
/*
|
|
32
|
-
* Steps:
|
|
33
|
-
* 1. Set the firstPageVisible state variable true if the limitationMessage prop was updated.
|
|
34
|
-
*/
|
|
35
|
-
componentDidUpdate(prevProps) {
|
|
36
|
-
if (prevProps.limitationMessage !== this.props.limitationMessage) {
|
|
37
|
-
this.setState({ firstPageVisible: !!this.props.limitationMessage });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
33
|
/**
|
|
41
34
|
* Handle what happens when the “next” button is pressed.
|
|
42
35
|
*
|
|
@@ -47,8 +40,8 @@ export default class RecommendationModal extends React.Component {
|
|
|
47
40
|
*/
|
|
48
41
|
onPressNextButton = () => {
|
|
49
42
|
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
50
|
-
const
|
|
51
|
-
return
|
|
43
|
+
const isPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
|
|
44
|
+
return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
|
|
52
45
|
};
|
|
53
46
|
/**
|
|
54
47
|
* @returns Return an JSX element for composing two buttons: one for accepting a suggestion and one for rejecting it.
|
|
@@ -57,11 +50,11 @@ export default class RecommendationModal extends React.Component {
|
|
|
57
50
|
*/
|
|
58
51
|
recommendationButtons = () => {
|
|
59
52
|
return (<View style={stylesModal.recommendationButtonsContainer}>
|
|
60
|
-
<TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} style={
|
|
61
|
-
<
|
|
53
|
+
<TouchableOpacity testID={RecommendationModalTestIds.AcceptCarbs} style={stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
|
|
54
|
+
<TextRegular style={stylesModal.affirmativeCarbsText}>{i18n._(t `OK`)}</TextRegular>
|
|
62
55
|
</TouchableOpacity>
|
|
63
|
-
<TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} style={
|
|
64
|
-
<
|
|
56
|
+
<TouchableOpacity testID={RecommendationModalTestIds.DeclineCarbs} style={stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
|
|
57
|
+
<TextRegular style={stylesModal.negativeCarbsText}>{i18n._(t `NO`)}</TextRegular>
|
|
65
58
|
</TouchableOpacity>
|
|
66
59
|
</View>);
|
|
67
60
|
};
|
|
@@ -74,19 +67,33 @@ export default class RecommendationModal extends React.Component {
|
|
|
74
67
|
const displayCarbs = Math.round(suggestedCarbohydrates);
|
|
75
68
|
return (<React.Fragment>
|
|
76
69
|
<View style={stylesModal.innerView}>
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
<View style={stylesModal.recommendationRow}>
|
|
71
|
+
<TextRegular style={stylesModal.recommendEatingText}>
|
|
72
|
+
{i18n._(t `We recommend eating an additional:`)}
|
|
73
|
+
</TextRegular>
|
|
74
|
+
</View>
|
|
75
|
+
<View style={stylesModal.suggestedContainer}>
|
|
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>
|
|
84
|
+
</View>
|
|
85
|
+
<View style={stylesModal.recommendationRow}>
|
|
86
|
+
<TextRegular style={stylesModal.recommendEatingText}>
|
|
87
|
+
{i18n._(t `Instead of taking insulin`)}
|
|
88
|
+
</TextRegular>
|
|
89
|
+
</View>
|
|
90
|
+
</View>
|
|
91
|
+
<View style={stylesModal.addToCalculationContainer}>
|
|
92
|
+
<TextRegular style={stylesModal.addToCalculation}>
|
|
93
|
+
{i18n._(t `Would you like to add this to your current calculation?`)}
|
|
94
|
+
</TextRegular>
|
|
95
|
+
{this.recommendationButtons()}
|
|
85
96
|
</View>
|
|
86
|
-
<Text style={stylesModal.addToCalculation}>
|
|
87
|
-
{t(`Would you like to add this to your current calculation?`)}
|
|
88
|
-
</Text>
|
|
89
|
-
{this.recommendationButtons()}
|
|
90
97
|
</React.Fragment>);
|
|
91
98
|
};
|
|
92
99
|
/**
|
|
@@ -95,16 +102,20 @@ export default class RecommendationModal extends React.Component {
|
|
|
95
102
|
secondPage = () => {
|
|
96
103
|
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
97
104
|
const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
|
|
98
|
-
return (
|
|
105
|
+
return (<React.Fragment>
|
|
99
106
|
<View style={stylesModal.container}>
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
<View style={stylesModal.titleContainer}>
|
|
108
|
+
<TextBold style={stylesModal.textTittleMessage}>{i18n._(t `Attention`)}</TextBold>
|
|
109
|
+
</View>
|
|
110
|
+
<TextRegular style={stylesModal.textMessage}>{attentionMessage}</TextRegular>
|
|
111
|
+
{willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
|
|
103
112
|
</View>
|
|
104
|
-
{
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
{willRecommendCarbs ? null : (<View style={stylesModal.containerAcceptButton}>
|
|
114
|
+
<TouchableOpacity testID={RecommendationModalTestIds.OkButton} style={stylesModal.okButton} onPress={this.props.onClickOkButton}>
|
|
115
|
+
<TextRegular style={stylesModal.buttonText}>{i18n._(t `OK`)}</TextRegular>
|
|
116
|
+
</TouchableOpacity>
|
|
117
|
+
</View>)}
|
|
118
|
+
</React.Fragment>);
|
|
108
119
|
};
|
|
109
120
|
/**
|
|
110
121
|
* @returns JSX element for displaying the “first” page of the recommendation modal.
|
|
@@ -112,13 +123,7 @@ export default class RecommendationModal extends React.Component {
|
|
|
112
123
|
*/
|
|
113
124
|
firstPage = () => {
|
|
114
125
|
const { limitationMessage } = this.props;
|
|
115
|
-
return
|
|
116
|
-
<Text style={stylesModal.textTittleMessage}>{t(`Attention`)}</Text>
|
|
117
|
-
<Text style={stylesModal.textMessage}>{limitationMessage}</Text>
|
|
118
|
-
<TouchableOpacity testID={Testing.Id.RecommendationModalTestIds.LimitationOkButton} style={stylesModal.okButton} onPress={this.props.onlyShowLimitationMessage ? this.props.onClickOkButton : this.onPressNextButton}>
|
|
119
|
-
<Text style={stylesModal.buttonText}>{t(`OK`)}</Text>
|
|
120
|
-
</TouchableOpacity>
|
|
121
|
-
</React.Fragment>);
|
|
126
|
+
return <LimitationMessage limitationMessage={limitationMessage} onPressNextButton={this.onPressNextButton}/>;
|
|
122
127
|
};
|
|
123
128
|
/**
|
|
124
129
|
* @returns JSX element for rendering a modal that is visible if the isVisible prop is true.
|
|
@@ -128,114 +133,94 @@ export default class RecommendationModal extends React.Component {
|
|
|
128
133
|
render() {
|
|
129
134
|
const { isVisible } = this.props;
|
|
130
135
|
const { firstPageVisible } = this.state;
|
|
131
|
-
return (<ReactNativeModal isVisible={isVisible} style={stylesModal.modalStyle}
|
|
132
|
-
|
|
133
|
-
<SafeAreaView style={stylesModal.safe}>
|
|
134
|
-
<ScrollView contentContainerStyle={stylesModal.scrollViewContainer}>
|
|
135
|
-
{firstPageVisible ? this.firstPage() : this.secondPage()}
|
|
136
|
-
</ScrollView>
|
|
137
|
-
</SafeAreaView>
|
|
136
|
+
return (<ReactNativeModal isVisible={isVisible} style={stylesModal.modalStyle}>
|
|
137
|
+
{firstPageVisible ? this.firstPage() : this.secondPage()}
|
|
138
138
|
</ReactNativeModal>);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
const { height, width } = Dimensions.get(`screen`);
|
|
142
|
+
const buttonHeight = height / 20;
|
|
143
|
+
const buttonWidth = width / 2.5;
|
|
144
|
+
const buttonFontSize = width / 22;
|
|
145
|
+
const buttonBorderRadius = height / 30;
|
|
146
|
+
const buttonBorderWidth = height / 500;
|
|
147
|
+
const sugestionFontSize = width / 19;
|
|
148
|
+
const recommendEatingFontSize = height / 45;
|
|
149
|
+
const textFontSize = width / 20;
|
|
150
|
+
const titleFontSize = width / 13;
|
|
141
151
|
/** @internal */
|
|
142
152
|
export const stylesModal = StyleSheet.create({
|
|
143
|
-
safe: {
|
|
144
|
-
backgroundColor: colors.darkBlue,
|
|
145
|
-
},
|
|
146
153
|
modalStyle: {
|
|
147
154
|
margin: 0,
|
|
148
|
-
|
|
149
|
-
scrollViewContainer: {
|
|
150
|
-
flexGrow: 1,
|
|
151
|
-
justifyContent: `center`,
|
|
155
|
+
backgroundColor: colors.darkBlue,
|
|
152
156
|
},
|
|
153
157
|
container: {
|
|
158
|
+
flex: 4,
|
|
154
159
|
justifyContent: `center`,
|
|
160
|
+
paddingHorizontal: `4%`,
|
|
155
161
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
textAlign: `center`,
|
|
160
|
-
},
|
|
161
|
-
textMessage: {
|
|
162
|
-
...FONTS.Poppins.regular_Base,
|
|
163
|
-
color: colors.white,
|
|
164
|
-
textAlign: `center`,
|
|
165
|
-
marginHorizontal: 30,
|
|
166
|
-
marginTop: 8,
|
|
167
|
-
},
|
|
168
|
-
buttonText: {
|
|
169
|
-
...FONTS.Poppins.bold_Base,
|
|
170
|
-
color: colors.white,
|
|
171
|
-
textAlign: `center`,
|
|
172
|
-
paddingHorizontal: 16,
|
|
173
|
-
paddingVertical: 12,
|
|
162
|
+
containerAcceptButton: {
|
|
163
|
+
flex: 1,
|
|
164
|
+
justifyContent: `flex-start`,
|
|
174
165
|
},
|
|
166
|
+
titleContainer: { marginBottom: `5%` },
|
|
167
|
+
recommendationRow: { justifyContent: `center`, alignContent: `center`, marginBottom: `3%` },
|
|
168
|
+
textTittleMessage: { color: `white`, fontSize: titleFontSize, textAlign: `center` },
|
|
169
|
+
textMessage: { color: `white`, fontSize: textFontSize, textAlign: `center` },
|
|
170
|
+
buttonText: { color: colors.teal, fontSize: buttonFontSize, textAlign: `center` },
|
|
171
|
+
addToCalculationContainer: { justifyContent: `flex-start`, marginVertical: `5%` },
|
|
175
172
|
innerView: {
|
|
176
173
|
alignContent: `center`,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
textCenter: {
|
|
189
|
-
...FONTS.Poppins.regular_Base,
|
|
190
|
-
textAlign: `center`,
|
|
191
|
-
paddingHorizontal: 26.5,
|
|
192
|
-
},
|
|
174
|
+
paddingVertical: `5%`,
|
|
175
|
+
paddingHorizontal: `3%`,
|
|
176
|
+
marginTop: `5%`,
|
|
177
|
+
borderRadius: height / 80,
|
|
178
|
+
borderWidth: height / 300,
|
|
179
|
+
borderColor: colors.teal,
|
|
180
|
+
},
|
|
181
|
+
suggestedContainer: { justifyContent: `center`, flexDirection: `row`, marginBottom: `3%` },
|
|
182
|
+
suggestedCarbs: { color: `white`, fontSize: sugestionFontSize },
|
|
183
|
+
textCenter: { textAlign: `center` },
|
|
193
184
|
recommendEatingText: {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
textAlign: `center`,
|
|
197
|
-
paddingHorizontal: 15,
|
|
198
|
-
marginBottom: 8,
|
|
199
|
-
},
|
|
200
|
-
carbohydrateText: {
|
|
201
|
-
...FONTS.Poppins.bold_Base,
|
|
202
|
-
color: colors.white,
|
|
203
|
-
},
|
|
204
|
-
addToCalculation: {
|
|
205
|
-
...FONTS.Poppins.regular_Base,
|
|
206
|
-
color: colors.white,
|
|
185
|
+
color: colors.dustyBlue,
|
|
186
|
+
fontSize: recommendEatingFontSize,
|
|
207
187
|
textAlign: `center`,
|
|
208
|
-
marginBottom: 16,
|
|
209
|
-
marginHorizontal: 50,
|
|
210
188
|
},
|
|
211
|
-
|
|
189
|
+
carbohydrateText: { color: `white`, fontSize: sugestionFontSize },
|
|
190
|
+
addToCalculation: { color: `white`, fontSize: textFontSize, textAlign: `center` },
|
|
191
|
+
recommendationButtonsContainer: { justifyContent: `center`, flexDirection: `row`, margin: `3%` },
|
|
192
|
+
affirmativeCarbsText: { color: colors.teal, fontSize: buttonFontSize, textAlign: `center` },
|
|
193
|
+
negativeCarbsText: { color: `white`, fontSize: buttonFontSize, textAlign: `center` },
|
|
194
|
+
affirmativeCarbsButton: {
|
|
195
|
+
marginTop: `2%`,
|
|
196
|
+
borderRadius: buttonBorderRadius,
|
|
197
|
+
borderWidth: buttonBorderWidth,
|
|
198
|
+
borderColor: colors.teal,
|
|
199
|
+
width: buttonWidth,
|
|
200
|
+
height: buttonHeight,
|
|
201
|
+
alignSelf: `center`,
|
|
212
202
|
justifyContent: `center`,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
-
button: {
|
|
224
|
-
borderRadius: 50,
|
|
225
|
-
borderWidth: 1,
|
|
226
|
-
borderColor: colors.white,
|
|
203
|
+
marginRight: `2%`,
|
|
204
|
+
},
|
|
205
|
+
negativeCarbsButton: {
|
|
206
|
+
marginTop: `2%`,
|
|
207
|
+
borderRadius: buttonBorderRadius,
|
|
208
|
+
borderWidth: buttonBorderWidth,
|
|
209
|
+
borderColor: `white`,
|
|
210
|
+
width: buttonWidth,
|
|
211
|
+
height: buttonHeight,
|
|
227
212
|
alignSelf: `center`,
|
|
228
|
-
|
|
213
|
+
justifyContent: `center`,
|
|
214
|
+
marginLeft: `2%`,
|
|
229
215
|
},
|
|
230
216
|
okButton: {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
217
|
+
marginTop: `6%`,
|
|
218
|
+
borderRadius: buttonBorderRadius,
|
|
219
|
+
borderWidth: buttonBorderWidth,
|
|
220
|
+
borderColor: colors.teal,
|
|
221
|
+
width: buttonWidth,
|
|
222
|
+
height: buttonHeight,
|
|
237
223
|
alignSelf: `center`,
|
|
238
|
-
|
|
224
|
+
justifyContent: `center`,
|
|
239
225
|
},
|
|
240
226
|
});
|
|
241
|
-
//# sourceMappingURL=RecommendationModal.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Testing } from "../types/enum";
|
|
3
|
-
declare const RecommendedCarbsTestIds: typeof Testing.Id.RecommendedCarbsTestIds;
|
|
4
3
|
export interface ICalculationRow {
|
|
5
4
|
label: string;
|
|
6
5
|
value: string;
|
|
@@ -93,4 +92,3 @@ export default class RecommendedCarbs extends React.Component<IProps, IState> {
|
|
|
93
92
|
*/
|
|
94
93
|
render(): JSX.Element;
|
|
95
94
|
}
|
|
96
|
-
export {};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import { Alert, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { t } from "../locales/translate";
|
|
3
|
+
import { Alert, Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
4
|
+
import EditIcon from "../assets/icons/Edit";
|
|
5
|
+
import { i18n } from "../locale/i18nUtils";
|
|
6
6
|
import { Testing } from "../types/enum";
|
|
7
7
|
import { colors } from "../utils/Constants";
|
|
8
8
|
import { CarbohydrateLimitError } from "../utils/RecommendationError";
|
|
9
|
+
import Icon from "./Icon";
|
|
10
|
+
import { infoStyles } from "./InfoBars";
|
|
9
11
|
import InvisibleNumberInput from "./InvisibleNumberInput";
|
|
10
12
|
import LineSeparator from "./LineSeparator";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
+
import TextBold from "./text/TextBold";
|
|
14
|
+
import TextRegular from "./text/TextRegular";
|
|
13
15
|
const { RecommendedCarbsTestIds } = Testing.Id;
|
|
14
16
|
/**
|
|
15
17
|
* The contents of the RecommendedCarbs component may vary quite a bit depending on data that was entered by the user
|
|
@@ -63,7 +65,11 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
63
65
|
if (carbs >= 0) {
|
|
64
66
|
if (carbs > 300) {
|
|
65
67
|
this.setState({ partialInput: this.props.recommendedCarbs });
|
|
66
|
-
return Alert.alert(t
|
|
68
|
+
return Alert.alert(i18n._(t `Attention`), CarbohydrateLimitError().message, [
|
|
69
|
+
{
|
|
70
|
+
text: i18n._(t `OK`),
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
67
73
|
}
|
|
68
74
|
this.props.changedRecommendedCarbs(carbs);
|
|
69
75
|
}
|
|
@@ -84,38 +90,46 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
84
90
|
renderRecommendedCarbs = () => {
|
|
85
91
|
const shownCarbs = this.state.partialInput ?? Math.round(Number(this.props.recommendedCarbs));
|
|
86
92
|
const totalCarbs = Math.round(parseFloat(this.props.enteredCarbs) + Number(shownCarbs));
|
|
87
|
-
return (
|
|
88
|
-
<LineSeparator
|
|
89
|
-
<View style={
|
|
90
|
-
<View style={
|
|
91
|
-
<TouchableOpacity testID={RecommendedCarbsTestIds.RemoveRecommendation} style={
|
|
92
|
-
{
|
|
93
|
+
return (<>
|
|
94
|
+
<LineSeparator color={colors.fadeBlue}/>
|
|
95
|
+
<View style={calculationStyles.borderContainer}>
|
|
96
|
+
<View style={calculationStyles.recommendedContainer}>
|
|
97
|
+
<TouchableOpacity testID={RecommendedCarbsTestIds.RemoveRecommendation} style={calculationStyles.removeRecommended} onPress={this.props.removeRecommendedCarbs}>
|
|
98
|
+
<Icon iconIdentifier={`Ionicons/ios-close-circle-outline`} style={calculationStyles.removeRecommendedIcon}/>
|
|
93
99
|
</TouchableOpacity>
|
|
94
|
-
<
|
|
100
|
+
<TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Recommended`)}</TextBold>
|
|
95
101
|
</View>
|
|
96
102
|
</View>
|
|
97
|
-
<View style={
|
|
98
|
-
<View style={
|
|
99
|
-
<
|
|
103
|
+
<View style={calculationStyles.borderContainer}>
|
|
104
|
+
<View style={calculationStyles.recommendedContainer}>
|
|
105
|
+
<TextBold style={calculationStyles.recommendedLabel}>{i18n._(t `Additional`)}</TextBold>
|
|
100
106
|
</View>
|
|
101
|
-
<View style={
|
|
102
|
-
<TouchableOpacity testID={RecommendedCarbsTestIds.EditRecommendedCarbs} onPress={this.showTextInput} style={[
|
|
103
|
-
<
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
<View style={calculationStyles.valueUnitContainer}>
|
|
108
|
+
<TouchableOpacity testID={RecommendedCarbsTestIds.EditRecommendedCarbs} onPress={this.showTextInput} style={[calculationStyles.valueUnitContainer]}>
|
|
109
|
+
<View style={calculationStyles.valueContainer}>
|
|
110
|
+
<TextBold testID={RecommendedCarbsTestIds.RecommendedCarbs} style={{ ...calculationStyles.value, color: colors.teal }}>
|
|
111
|
+
{shownCarbs}
|
|
112
|
+
</TextBold>
|
|
113
|
+
</View>
|
|
114
|
+
<View style={[calculationStyles.unitContainer]}>
|
|
115
|
+
<View style={calculationStyles.editIconContainer}>
|
|
116
|
+
<EditIcon />
|
|
117
|
+
</View>
|
|
118
|
+
<TextRegular style={{ ...calculationStyles.units, color: colors.teal }}>
|
|
119
|
+
{i18n._(t `grams`)}
|
|
120
|
+
</TextRegular>
|
|
121
|
+
</View>
|
|
108
122
|
</TouchableOpacity>
|
|
109
123
|
</View>
|
|
110
124
|
</View>
|
|
111
|
-
<LineSeparator
|
|
125
|
+
<LineSeparator color={colors.fadeBlue}/>
|
|
112
126
|
{this.renderRow({
|
|
113
|
-
label: t
|
|
127
|
+
label: i18n._(t `Total`),
|
|
114
128
|
value: totalCarbs.toString(),
|
|
115
|
-
units: t
|
|
129
|
+
units: i18n._(t `grams`),
|
|
116
130
|
}, RecommendedCarbsTestIds.TotalCarbs)}
|
|
117
131
|
<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}/>
|
|
118
|
-
|
|
132
|
+
</>);
|
|
119
133
|
};
|
|
120
134
|
/**
|
|
121
135
|
* Display a row of information for the user. Specifically used to display the amount of carbohydrates that the user has entered.
|
|
@@ -124,15 +138,19 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
124
138
|
* @returns A JSX element to display 3 strings on the screen: label, value, and a unit.
|
|
125
139
|
*/
|
|
126
140
|
renderRow = (row, testID) => {
|
|
127
|
-
return (<View style={
|
|
128
|
-
<View style={
|
|
129
|
-
<
|
|
141
|
+
return (<View style={calculationStyles.borderContainer}>
|
|
142
|
+
<View style={calculationStyles.rowContainer}>
|
|
143
|
+
<TextBold style={calculationStyles.rowLabel}>{row.label}</TextBold>
|
|
130
144
|
</View>
|
|
131
|
-
<View style={
|
|
132
|
-
<
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
<View style={calculationStyles.valueUnitContainer}>
|
|
146
|
+
<View style={calculationStyles.valueContainer}>
|
|
147
|
+
<TextBold testID={testID} style={calculationStyles.value}>
|
|
148
|
+
{row.value}
|
|
149
|
+
</TextBold>
|
|
150
|
+
</View>
|
|
151
|
+
<View style={calculationStyles.unitContainer}>
|
|
152
|
+
<TextRegular style={calculationStyles.units}>{row.units}</TextRegular>
|
|
153
|
+
</View>
|
|
136
154
|
</View>
|
|
137
155
|
</View>);
|
|
138
156
|
};
|
|
@@ -144,91 +162,90 @@ export default class RecommendedCarbs extends React.Component {
|
|
|
144
162
|
*/
|
|
145
163
|
render() {
|
|
146
164
|
const carbs = Number(this.props.recommendedCarbs);
|
|
147
|
-
return (
|
|
148
|
-
<View style={
|
|
149
|
-
<
|
|
150
|
-
<
|
|
165
|
+
return (<>
|
|
166
|
+
<View style={calculationStyles.foodTitleContainer}>
|
|
167
|
+
<TextBold style={infoStyles.label}>{i18n._(t `Food`)}</TextBold>
|
|
168
|
+
<TextRegular style={calculationStyles.foodUnitsLabel}>
|
|
169
|
+
{`(${i18n._(t `Carbohydrates`)})`}
|
|
170
|
+
</TextRegular>
|
|
151
171
|
</View>
|
|
152
172
|
{this.renderRow({
|
|
153
|
-
label: t
|
|
173
|
+
label: i18n._(t `Entered`),
|
|
154
174
|
value: this.props.enteredCarbs,
|
|
155
|
-
units: t
|
|
175
|
+
units: i18n._(t `grams`),
|
|
156
176
|
}, RecommendedCarbsTestIds.EnteredCarbs)}
|
|
157
177
|
{!isNaN(carbs) && carbs > 0 ? this.renderRecommendedCarbs() : null}
|
|
158
|
-
|
|
178
|
+
</>);
|
|
159
179
|
}
|
|
160
180
|
}
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
181
|
+
const { width } = Dimensions.get(`screen`);
|
|
182
|
+
const calculationStyles = StyleSheet.create({
|
|
183
|
+
borderContainer: {
|
|
184
|
+
...infoStyles.borderContainer,
|
|
164
185
|
alignItems: `center`,
|
|
165
186
|
},
|
|
166
187
|
foodTitleContainer: {
|
|
167
|
-
|
|
188
|
+
flex: infoStyles.borderContainer.flex,
|
|
189
|
+
flexDirection: infoStyles.borderContainer.flexDirection,
|
|
190
|
+
paddingHorizontal: infoStyles.borderContainer.paddingHorizontal,
|
|
168
191
|
alignItems: `center`,
|
|
169
|
-
|
|
192
|
+
paddingVertical: `2%`,
|
|
170
193
|
},
|
|
171
194
|
foodUnitsLabel: {
|
|
172
|
-
...
|
|
173
|
-
|
|
174
|
-
paddingLeft:
|
|
175
|
-
color: colors.lightBlue,
|
|
195
|
+
...infoStyles.units,
|
|
196
|
+
color: colors.fadeBlue,
|
|
197
|
+
paddingLeft: `1%`,
|
|
176
198
|
},
|
|
177
199
|
rowContainer: {
|
|
178
200
|
flex: 7,
|
|
179
201
|
},
|
|
180
202
|
rowLabel: {
|
|
181
|
-
|
|
182
|
-
|
|
203
|
+
color: `white`,
|
|
204
|
+
fontSize: width / 25,
|
|
183
205
|
},
|
|
184
206
|
enteredContainer: {
|
|
185
207
|
flex: 3,
|
|
186
208
|
alignItems: `flex-end`,
|
|
187
209
|
},
|
|
210
|
+
entered: {
|
|
211
|
+
color: `white`,
|
|
212
|
+
fontSize: width / 23,
|
|
213
|
+
},
|
|
188
214
|
valueUnitContainer: {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
215
|
+
...infoStyles.valueUnitContainer,
|
|
216
|
+
},
|
|
217
|
+
valueContainer: {
|
|
218
|
+
...infoStyles.valueContainer,
|
|
193
219
|
},
|
|
194
220
|
value: {
|
|
195
|
-
...
|
|
196
|
-
|
|
197
|
-
|
|
221
|
+
...infoStyles.value,
|
|
222
|
+
},
|
|
223
|
+
unitContainer: {
|
|
224
|
+
...infoStyles.unitContainer,
|
|
198
225
|
},
|
|
199
226
|
units: {
|
|
200
|
-
...
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
paddingLeft:
|
|
227
|
+
...infoStyles.units,
|
|
228
|
+
},
|
|
229
|
+
editIconContainer: {
|
|
230
|
+
paddingLeft: `20%`,
|
|
204
231
|
},
|
|
205
232
|
recommendedContainer: {
|
|
206
233
|
flex: 7,
|
|
207
234
|
flexDirection: `row`,
|
|
208
235
|
},
|
|
209
236
|
recommendedLabel: {
|
|
210
|
-
...FONTS.Poppins.regular_Base,
|
|
211
237
|
color: colors.teal,
|
|
238
|
+
fontSize: width / 25,
|
|
239
|
+
alignSelf: `center`,
|
|
212
240
|
},
|
|
213
241
|
removeRecommended: {
|
|
214
242
|
justifyContent: `center`,
|
|
215
|
-
|
|
243
|
+
marginRight: `1%`,
|
|
244
|
+
marginTop: `1%`,
|
|
216
245
|
},
|
|
217
246
|
removeRecommendedIcon: {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
},
|
|
222
|
-
editIcon: {
|
|
223
|
-
height: 16,
|
|
224
|
-
width: 16,
|
|
225
|
-
right: 0,
|
|
226
|
-
top: -8,
|
|
227
|
-
position: `absolute`,
|
|
228
|
-
},
|
|
229
|
-
label: {
|
|
230
|
-
...FONTS.Poppins.regular_Base,
|
|
231
|
-
color: colors.white,
|
|
247
|
+
color: colors.teal,
|
|
248
|
+
fontSize: width / 20,
|
|
249
|
+
paddingBottom: `0.5%`,
|
|
232
250
|
},
|
|
233
251
|
});
|
|
234
|
-
//# sourceMappingURL=RecommendedCarbs.js.map
|