@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.
Files changed (29) hide show
  1. package/dist/src/RecommendationScreen.js +337 -312
  2. package/dist/src/components/Header.js +4 -4
  3. package/dist/src/components/Icon.js +2 -0
  4. package/dist/src/components/InfoBars.d.ts +0 -2
  5. package/dist/src/components/InfoBars.js +39 -42
  6. package/dist/src/components/InvisibleNumberInput.js +70 -71
  7. package/dist/src/components/LimitationMessage.js +13 -14
  8. package/dist/src/components/RecentInsulin.js +19 -19
  9. package/dist/src/components/RecommendationModal.d.ts +0 -1
  10. package/dist/src/components/RecommendationModal.js +73 -65
  11. package/dist/src/components/RecommendedCarbs.js +101 -97
  12. package/dist/src/components/RecommendedInsulin.js +98 -95
  13. package/dist/src/components/Remeasure.js +34 -32
  14. package/dist/src/components/TransferToLogbook.js +23 -25
  15. package/dist/src/components/TwoOptionModal.d.ts +0 -10
  16. package/dist/src/components/TwoOptionModal.js +10 -18
  17. package/dist/src/components/activity/Activity.js +14 -12
  18. package/dist/src/components/activity/ActivityIcon.js +11 -11
  19. package/dist/src/components/activity/ActivityIntensity.js +16 -19
  20. package/dist/src/components/mood/Emotion.js +29 -32
  21. package/dist/src/components/mood/MoodIcon.js +23 -26
  22. package/dist/src/components/text/TextBold.d.ts +8 -0
  23. package/dist/src/components/text/TextBold.js +12 -0
  24. package/dist/src/components/text/TextRegular.d.ts +8 -0
  25. package/dist/src/components/text/TextRegular.js +12 -0
  26. package/dist/src/utils/AttentionMessages.js +36 -36
  27. package/dist/src/utils/RecommendationError.js +1 -0
  28. package/dist/src/utils/Utils.js +15 -15
  29. package/package.json +5 -5
@@ -1,7 +1,7 @@
1
1
  import { BolusCalculator } from "@hedia/types";
2
2
  import { t } from "@lingui/macro";
3
3
  import React from "react";
4
- import { Alert, Dimensions, Platform, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
+ import { Alert, Dimensions, Platform, StyleSheet, TouchableOpacity, View } from "react-native";
5
5
  import LinearGradient from "react-native-linear-gradient";
6
6
  import { i18n } from "../locale/i18nUtils";
7
7
  import { Testing } from "../types/enum";
@@ -10,95 +10,114 @@ import { Utils } from "../utils/Utils";
10
10
  import Icon from "./Icon";
11
11
  import { infoStyles } from "./InfoBars";
12
12
  import InvisibleNumberInput from "./InvisibleNumberInput";
13
+ import TextBold from "./text/TextBold";
14
+ import TextRegular from "./text/TextRegular";
13
15
  const { RecommendedInsulinTestIds } = Testing.Id;
14
16
  const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
15
17
  /** Input field for displaying the entered amount of insulin (which defaults to HDA’s recommendation) and allowing the user to edit it. */
16
18
  export default class RecommendedInsulin extends React.Component {
17
- constructor() {
18
- super(...arguments);
19
- /** Initialise the state partialInput variable with undefined */
20
- this.state = {
21
- partialInput: undefined,
22
- };
23
- /**
24
- * Handle what should happen when the InsulinRecommendation component has been pressed.
25
- * Uses the InvisibleNumberInput child component to enable the user to input the amount of insulin that hey are taking.
26
- *
27
- * Steps:
28
- * 1. Call the callbackInput() member method.
29
- */
30
- this.handleOnPress = () => {
31
- this.callbackInput?.();
32
- };
33
- /**
34
- * Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
35
- *
36
- * Steps:
37
- * 1. Assign a new local variable, replacedZero, with the value of the insulin argument string
38
- * except for the first character if insulin is longer than 1 character and starts with a '0' but doesn’t start with ‘0.’.
39
- * Otherwise set it to insulin. This would be better handled by converting it to a number: replacedZero = Number(insulin);
40
- * 2. Save replacedZero to the partialInput state variable.
41
- * 3. Return replacedZero
42
- * @param insulin The contents of the input field.
43
- * @returns The partially cleaned input.
44
- */
45
- this.updatePartially = (insulin) => {
46
- const replacedZero = insulin.length > 1 && insulin.startsWith(`0`) && !insulin.startsWith(`0.`) ? insulin.substring(1) : insulin;
47
- this.setState({
48
- partialInput: replacedZero,
49
- });
50
- return replacedZero;
51
- };
52
- /**
53
- * Handle what happens when input in the InvisibleNumberInput child component is completed.
54
- *
55
- * Steps:
56
- * 1. Get the rounded insulin amount using the value argument and the injectionMethod prop as arguments for the Utils.roundValue() function.
57
- * 2. Get the adjusted safety insulin limit (due to activity) by multiplying the activity reduction factor (which is 1 minus the activityReduction prop) with the SAFETY_INSULIN_LIMIT constant.
58
- * 3. If the rounded value exceeds the adjusted safety threshold:
59
- * - Call the updatePartially() method with the adjusted safety threshold to set the insulin amount to the capped value.
60
- * - Return an Alert with a message about the insulin limit.
61
- * 4. Call the updatePartially() method with the rounded value to set the entered insulin value.
62
- * 5. Call the updateRecommendedInsulin callback function prop with rounded as the argument to report back the updated insulin amount to the parent RecommendationScreen component.
63
- * @param value The numerical value of the input field at completion.
64
- */
65
- this.handleUpdatedInsulin = (value) => {
66
- const rounded = Utils.roundValue(value, this.props.injectionMethod);
67
- // https://hedia.atlassian.net/browse/HDA-795
68
- const limited = (1 - (this.props.activityReduction ?? 0)) * SAFETY_INSULIN_LIMIT;
69
- if (rounded > limited) {
70
- this.setState({ partialInput: this.props.insulinRecommendation?.toString() ?? null });
71
- this.props.updateRecommendedInsulin(this.props.insulinRecommendation);
72
- return Alert.alert(i18n._(t `Attention`), Messages.InsulinInputWasLimited(this.props.activityReduction), [
73
- {
74
- text: i18n._(t `OK`),
75
- },
76
- ]);
77
- }
78
- this.updatePartially(`${rounded}`);
79
- this.props.updateRecommendedInsulin(rounded);
80
- };
81
- /**
82
- * Render a JSX element to display the insulin input field with the current insulin amount value
83
- * and using an InvisibleNumberInput component to enable input when the insulin amount is tapped.
84
- */
85
- this.render = () => {
86
- const paddingBottom = Platform.OS === `ios` ? `3%` : `1%`;
87
- const shownInsulin = this.state.partialInput ?? this.props.insulinRecommendation ?? `0`;
88
- return (<React.Fragment>
19
+ /** Initialise the state partialInput variable with undefined */
20
+ state = {
21
+ partialInput: undefined,
22
+ };
23
+ /**
24
+ * Function taking no arguments and returning no value.
25
+ * Will be bound to the function that activates input for InvisibleNumberInput when that component has been mounted.
26
+ */
27
+ callbackInput;
28
+ /**
29
+ * Called immediately after updating occurs. Not called for the initial render.
30
+ * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
31
+ *
32
+ * Steps:
33
+ * 1. If the value of the enteredInsulin prop was changed, set the partialInput state variable to the new value.
34
+ * @param prevProps The previous component props
35
+ */
36
+ componentDidUpdate(prevProps) {
37
+ const { enteredInsulin } = this.props;
38
+ if (prevProps.enteredInsulin !== enteredInsulin) {
39
+ this.setState({ partialInput: enteredInsulin?.toString() });
40
+ }
41
+ }
42
+ /**
43
+ * Handle what should happen when the InsulinRecommendation component has been pressed.
44
+ * Uses the InvisibleNumberInput child component to enable the user to input the amount of insulin that hey are taking.
45
+ *
46
+ * Steps:
47
+ * 1. Call the callbackInput() member method.
48
+ */
49
+ handleOnPress = () => {
50
+ this.callbackInput?.();
51
+ };
52
+ /**
53
+ * Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
54
+ *
55
+ * Steps:
56
+ * 1. Assign a new local variable, replacedZero, with the value of the insulin argument string
57
+ * except for the first character if insulin is longer than 1 character and starts with a '0' but doesn’t start with ‘0.’.
58
+ * Otherwise set it to insulin. This would be better handled by converting it to a number: replacedZero = Number(insulin);
59
+ * 2. Save replacedZero to the partialInput state variable.
60
+ * 3. Return replacedZero
61
+ * @param insulin The contents of the input field.
62
+ * @returns The partially cleaned input.
63
+ */
64
+ updatePartially = (insulin) => {
65
+ const replacedZero = insulin.length > 1 && insulin.startsWith(`0`) && !insulin.startsWith(`0.`) ? insulin.substring(1) : insulin;
66
+ this.setState({
67
+ partialInput: replacedZero,
68
+ });
69
+ return replacedZero;
70
+ };
71
+ /**
72
+ * Handle what happens when input in the InvisibleNumberInput child component is completed.
73
+ *
74
+ * Steps:
75
+ * 1. Get the rounded insulin amount using the value argument and the injectionMethod prop as arguments for the Utils.roundValue() function.
76
+ * 2. Get the adjusted safety insulin limit (due to activity) by multiplying the activity reduction factor (which is 1 minus the activityReduction prop) with the SAFETY_INSULIN_LIMIT constant.
77
+ * 3. If the rounded value exceeds the adjusted safety threshold:
78
+ * - Call the updatePartially() method with the adjusted safety threshold to set the insulin amount to the capped value.
79
+ * - Return an Alert with a message about the insulin limit.
80
+ * 4. Call the updatePartially() method with the rounded value to set the entered insulin value.
81
+ * 5. Call the updateRecommendedInsulin callback function prop with rounded as the argument to report back the updated insulin amount to the parent RecommendationScreen component.
82
+ * @param value The numerical value of the input field at completion.
83
+ */
84
+ handleUpdatedInsulin = (value) => {
85
+ const rounded = Utils.roundValue(value, this.props.injectionMethod);
86
+ // https://hedia.atlassian.net/browse/HDA-795
87
+ const limited = (1 - (this.props.activityReduction ?? 0)) * SAFETY_INSULIN_LIMIT;
88
+ if (rounded > limited) {
89
+ this.setState({ partialInput: this.props.insulinRecommendation?.toString() ?? null });
90
+ this.props.updateRecommendedInsulin(this.props.insulinRecommendation);
91
+ return Alert.alert(i18n._(t `Attention`), Messages.InsulinInputWasLimited(this.props.activityReduction), [
92
+ {
93
+ text: i18n._(t `OK`),
94
+ },
95
+ ]);
96
+ }
97
+ this.updatePartially(`${rounded}`);
98
+ this.props.updateRecommendedInsulin(rounded);
99
+ };
100
+ /**
101
+ * Render a JSX element to display the insulin input field with the current insulin amount value
102
+ * and using an InvisibleNumberInput component to enable input when the insulin amount is tapped.
103
+ */
104
+ render = () => {
105
+ const paddingBottom = Platform.OS === `ios` ? `3%` : `1%`;
106
+ const shownInsulin = this.state.partialInput ?? this.props.insulinRecommendation ?? `0`;
107
+ return (<React.Fragment>
89
108
  <TouchableOpacity testID={RecommendedInsulinTestIds.EditRecommendedInsulin} onPress={this.handleOnPress}>
90
109
  <LinearGradient style={recommendedInsulinStyles.container} colors={[`#a200ff`, `#578aff`]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}>
91
110
  <View style={recommendedInsulinStyles.recommendedTextContainer}>
92
- <Text style={recommendedInsulinStyles.recommendedText}>
111
+ <TextRegular style={recommendedInsulinStyles.recommendedText}>
93
112
  {i18n._(t `Recommended amount of insulin`)}
94
- </Text>
113
+ </TextRegular>
95
114
  </View>
96
115
  <View style={[recommendedInsulinStyles.recommendedContainer, { paddingBottom }]}>
97
116
  <View style={recommendedInsulinStyles.valueContainer}>
98
- <Text style={recommendedInsulinStyles.value} testID={RecommendedInsulinTestIds.ShownInsulinText}>
117
+ <TextBold style={recommendedInsulinStyles.value} testID={RecommendedInsulinTestIds.ShownInsulinText}>
99
118
  {shownInsulin}
100
- </Text>
101
- <Text style={recommendedInsulinStyles.units}>{i18n._(t `Units`)}</Text>
119
+ </TextBold>
120
+ <TextRegular style={recommendedInsulinStyles.units}>{i18n._(t `Units`)}</TextRegular>
102
121
  </View>
103
122
  <Icon style={recommendedInsulinStyles.editIcon} iconIdentifier={`Feather/edit`} testID={RecommendedInsulinTestIds.EditRecommendedInsulinIcon}/>
104
123
  </View>
@@ -106,22 +125,7 @@ export default class RecommendedInsulin extends React.Component {
106
125
  </TouchableOpacity>
107
126
  <InvisibleNumberInput testID={RecommendedInsulinTestIds.InvisibleInsulinInput} decimalPlaces={3} negativeAllowed={false} cleanPartialInput={false} partialInput={this.updatePartially} onEnd={this.handleUpdatedInsulin} visible={(visible) => (this.callbackInput = visible)} startValue={`${shownInsulin}`}/>
108
127
  </React.Fragment>);
109
- };
110
- }
111
- /**
112
- * Called immediately after updating occurs. Not called for the initial render.
113
- * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
114
- *
115
- * Steps:
116
- * 1. If the value of the enteredInsulin prop was changed, set the partialInput state variable to the new value.
117
- * @param prevProps The previous component props
118
- */
119
- componentDidUpdate(prevProps) {
120
- const { enteredInsulin } = this.props;
121
- if (prevProps.enteredInsulin !== enteredInsulin) {
122
- this.setState({ partialInput: enteredInsulin?.toString() });
123
- }
124
- }
128
+ };
125
129
  }
126
130
  const recommendedInsulinStyles = StyleSheet.create({
127
131
  container: {
@@ -151,7 +155,6 @@ const recommendedInsulinStyles = StyleSheet.create({
151
155
  },
152
156
  value: {
153
157
  color: `white`,
154
- fontWeight: `bold`,
155
158
  fontSize: Dimensions.get(`screen`).width / 5,
156
159
  },
157
160
  units: {
@@ -1,38 +1,20 @@
1
1
  import { t } from "@lingui/macro";
2
2
  import Slider from "@react-native-community/slider";
3
3
  import React from "react";
4
- import { Dimensions, Platform, StyleSheet, Text, View } from "react-native";
4
+ import { Dimensions, Platform, StyleSheet, View } from "react-native";
5
5
  import { i18n } from "../locale/i18nUtils";
6
6
  import { Testing } from "../types/enum";
7
7
  import { BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
8
8
  import { infoStyles } from "./InfoBars";
9
+ import TextBold from "./text/TextBold";
10
+ import TextRegular from "./text/TextRegular";
9
11
  /**
10
12
  * The Remeasure component has a slider child component that the user can drag to change
11
13
  * when they will get a reminder notification about measuring their BGL again.
12
14
  */
13
15
  export default class Remeasure extends React.Component {
14
- constructor() {
15
- super(...arguments);
16
- /**
17
- * Steps:
18
- * 1. Use limitTime() to limit/clamp the value of remeasureTime in the range 0 to 6.
19
- * 2. Call the onSliderChange prop callback function with the limited value as argument.
20
- * @param remeasureTime The value of the remeasurement slider.
21
- */
22
- this.handleSliderChange = (remeasureTime) => {
23
- const limited = this.limitTime(remeasureTime);
24
- this.props.onSliderChange(limited);
25
- };
26
- /**
27
- * Steps:
28
- * 1.Use Math.min() and Math.max() to clamp remeasureTime in the range 0 to 6 and return the result.
29
- * @param remeasureTime The value of the remeasurement slider.
30
- * @returns The limited remeasurement time in hours
31
- */
32
- this.limitTime = (remeasureTime) => {
33
- return Math.min(Math.max(0, remeasureTime), 6);
34
- };
35
- }
16
+ /** For holding a reference to the slider component so its initial value can be set (only one time) when the Remeasure component has been mounted. */
17
+ slider;
36
18
  /**
37
19
  * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
38
20
  *
@@ -49,6 +31,25 @@ export default class Remeasure extends React.Component {
49
31
  value: this.props.remeasureTime,
50
32
  });
51
33
  }
34
+ /**
35
+ * Steps:
36
+ * 1. Use limitTime() to limit/clamp the value of remeasureTime in the range 0 to 6.
37
+ * 2. Call the onSliderChange prop callback function with the limited value as argument.
38
+ * @param remeasureTime The value of the remeasurement slider.
39
+ */
40
+ handleSliderChange = (remeasureTime) => {
41
+ const limited = this.limitTime(remeasureTime);
42
+ this.props.onSliderChange(limited);
43
+ };
44
+ /**
45
+ * Steps:
46
+ * 1.Use Math.min() and Math.max() to clamp remeasureTime in the range 0 to 6 and return the result.
47
+ * @param remeasureTime The value of the remeasurement slider.
48
+ * @returns The limited remeasurement time in hours
49
+ */
50
+ limitTime = (remeasureTime) => {
51
+ return Math.min(Math.max(0, remeasureTime), 6);
52
+ };
52
53
  /**
53
54
  * Compose a JSX element for displaying the currently selected remeasurement time along
54
55
  * with a horizontal slider for changing it in increments of 0.5 hours in the range 0 to 6.
@@ -61,24 +62,26 @@ export default class Remeasure extends React.Component {
61
62
  return (<View style={remeasureStyles.container}>
62
63
  <View style={remeasureStyles.borderContainer}>
63
64
  <View style={remeasureStyles.remeasureContainer}>
64
- <Text style={remeasureStyles.remeasureLabel}>{i18n._(t `Remind me to remeasure in`)}</Text>
65
+ <TextBold style={remeasureStyles.remeasureLabel}>
66
+ {i18n._(t `Remind me to remeasure in`)}
67
+ </TextBold>
65
68
  </View>
66
69
  <View style={remeasureStyles.valueUnitContainer}>
67
70
  <View style={valueContainer}>
68
- <Text style={remeasureStyles.value} testID={Testing.Id.RemeasureTestIds.RemeasureHours}>
71
+ <TextRegular style={remeasureStyles.value} testID={Testing.Id.RemeasureTestIds.RemeasureHours}>
69
72
  {measure ? limited : i18n._(t `OFF`)}
70
- </Text>
73
+ </TextRegular>
71
74
  </View>
72
75
  {measure ? (<View style={remeasureStyles.unitContainer}>
73
- <Text style={remeasureStyles.units}>{i18n._(t `hours`)}</Text>
76
+ <TextRegular style={remeasureStyles.units}>{i18n._(t `hours`)}</TextRegular>
74
77
  </View>) : null}
75
78
  </View>
76
79
  </View>
77
80
  <Slider ref={(slider) => {
78
- if (slider !== null) {
79
- this.slider = slider;
80
- }
81
- }} testID={Testing.Id.RemeasureTestIds.RemeasureSlider} maximumTrackTintColor={BORDER_COLOUR_GREY} minimumTrackTintColor={BORDER_COLOUR_TEAL} thumbTintColor={BORDER_COLOUR_TEAL} maximumValue={6} minimumValue={0} step={0.5} style={[remeasureStyles.sliderStyle, { marginHorizontal }]} onValueChange={this.handleSliderChange}/>
81
+ if (slider !== null) {
82
+ this.slider = slider;
83
+ }
84
+ }} testID={Testing.Id.RemeasureTestIds.RemeasureSlider} maximumTrackTintColor={BORDER_COLOUR_GREY} minimumTrackTintColor={BORDER_COLOUR_TEAL} thumbTintColor={BORDER_COLOUR_TEAL} maximumValue={6} minimumValue={0} step={0.5} style={[remeasureStyles.sliderStyle, { marginHorizontal }]} onValueChange={this.handleSliderChange}/>
82
85
  </View>);
83
86
  }
84
87
  }
@@ -97,7 +100,6 @@ const remeasureStyles = StyleSheet.create({
97
100
  remeasureLabel: {
98
101
  color: `white`,
99
102
  fontSize: Dimensions.get(`screen`).width / 25,
100
- fontWeight: `bold`,
101
103
  },
102
104
  valueUnitContainer: {
103
105
  ...infoStyles.valueUnitContainer,
@@ -1,34 +1,32 @@
1
1
  import React from "react";
2
- import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
2
+ import { Dimensions, StyleSheet, TouchableOpacity, View } from "react-native";
3
3
  import { t } from "@lingui/macro";
4
4
  import { i18n } from "../locale/i18nUtils";
5
5
  import { Testing } from "../types/enum";
6
6
  import Icon from "./Icon";
7
+ import TextBold from "./text/TextBold";
7
8
  /**
8
9
  * Render a button for transferring the recommendation to a logbook entry.
9
10
  * The button has a visually distinct pressed state to signal to the user that the button was actually activated before returning to the dashboard screen.
10
11
  */
11
12
  export default class TransferToLogbook extends React.Component {
12
- constructor() {
13
- super(...arguments);
14
- /** Initialise the state pressed variable with false */
15
- this.state = {
16
- pressed: false,
17
- };
18
- /**
19
- * Handle what happens when the button is pressed.
20
- *
21
- * Steps:
22
- * 1. Toggle the pressed state to the opposite of its current value.
23
- * 2. Call the transfer prop callback function.
24
- */
25
- this.handlePress = () => {
26
- this.setState({
27
- pressed: !this.state.pressed,
28
- });
29
- this.props.transfer();
30
- };
31
- }
13
+ /** Initialise the state pressed variable with false */
14
+ state = {
15
+ pressed: false,
16
+ };
17
+ /**
18
+ * Handle what happens when the button is pressed.
19
+ *
20
+ * Steps:
21
+ * 1. Toggle the pressed state to the opposite of its current value.
22
+ * 2. Call the transfer prop callback function.
23
+ */
24
+ handlePress = () => {
25
+ this.setState({
26
+ pressed: !this.state.pressed,
27
+ });
28
+ this.props.transfer();
29
+ };
32
30
  /**
33
31
  * Steps:
34
32
  * 1. If the visible prop is false, display an empty space to keep the correct margins in the screen.
@@ -41,10 +39,12 @@ export default class TransferToLogbook extends React.Component {
41
39
  }
42
40
  return (<TouchableOpacity testID={Testing.Id.TransferToLogbookTestIds.TransferButton} onPress={this.handlePress} disabled={this.state.pressed} style={addToLogbookStyles.container}>
43
41
  {!this.state.pressed ? (<View style={addToLogbookStyles.textContainer}>
44
- <Text style={addToLogbookStyles.transferText}>{i18n._(t `Transfer to logbook`)}</Text>
42
+ <TextBold style={addToLogbookStyles.transferText}>{i18n._(t `Transfer to logbook`)}</TextBold>
45
43
  </View>) : (<View style={addToLogbookStyles.textContainerActive}>
46
44
  <Icon style={addToLogbookStyles.icon} iconIdentifier={`Feather/check`}/>
47
- <Text style={addToLogbookStyles.transferTextActive}>{i18n._(t `Transferred to logbook`)}</Text>
45
+ <TextBold style={addToLogbookStyles.transferTextActive}>
46
+ {i18n._(t `Transferred to logbook`)}
47
+ </TextBold>
48
48
  </View>)}
49
49
  </TouchableOpacity>);
50
50
  }
@@ -69,7 +69,6 @@ const addToLogbookStyles = StyleSheet.create({
69
69
  transferText: {
70
70
  color: `#01FFFC`,
71
71
  fontSize: Dimensions.get(`screen`).width / 22,
72
- fontWeight: `bold`,
73
72
  },
74
73
  textContainerActive: {
75
74
  flexDirection: `row`,
@@ -89,6 +88,5 @@ const addToLogbookStyles = StyleSheet.create({
89
88
  transferTextActive: {
90
89
  color: `#1B1F48`,
91
90
  fontSize: Dimensions.get(`screen`).width / 22,
92
- fontWeight: `bold`,
93
91
  },
94
92
  });
@@ -61,23 +61,18 @@ export declare const modalStyle: {
61
61
  alignSelf: "flex-start";
62
62
  };
63
63
  titleRowLayout: {
64
- fontFamily: string;
65
64
  color: string;
66
65
  fontSize: number;
67
- fontWeight: "bold";
68
66
  textAlign: "center";
69
67
  marginBottom: string;
70
68
  };
71
69
  titleColumnLayout: {
72
- fontFamily: string;
73
70
  color: string;
74
71
  fontSize: number;
75
- fontWeight: "bold";
76
72
  textAlign: "center";
77
73
  marginBottom: string;
78
74
  };
79
75
  message: {
80
- fontFamily: string;
81
76
  color: string;
82
77
  fontSize: number;
83
78
  textAlign: "center";
@@ -122,24 +117,19 @@ export declare const modalStyle: {
122
117
  marginTop: string;
123
118
  };
124
119
  textButtonRow: {
125
- fontFamily: string;
126
120
  textAlign: "center";
127
121
  fontSize: number;
128
122
  color: string;
129
123
  };
130
124
  textFirstButtonColumn: {
131
- fontFamily: string;
132
125
  textAlign: "center";
133
126
  fontSize: number;
134
127
  paddingHorizontal: number;
135
128
  color: string;
136
- fontWeight: "700";
137
129
  };
138
130
  textSecondButtonColumn: {
139
- fontFamily: string;
140
131
  textAlign: "center";
141
132
  fontSize: number;
142
133
  color: string;
143
- fontWeight: "bold";
144
134
  };
145
135
  };
@@ -1,9 +1,11 @@
1
1
  import * as React from "react";
2
- import { Dimensions, StatusBar, StyleSheet, Text, TouchableOpacity, View } from "react-native";
2
+ import { Dimensions, StatusBar, StyleSheet, TouchableOpacity, View } from "react-native";
3
3
  import { Testing } from "../types/enum";
4
4
  import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
5
5
  import Icon from "./Icon";
6
6
  import { stylesModal } from "./RecommendationModal";
7
+ import TextBold from "./text/TextBold";
8
+ import TextRegular from "./text/TextRegular";
7
9
  const { TwoOptionModalTestIds } = Testing.Id;
8
10
  /** Display a modal with two buttons for the user to choose between. */
9
11
  export default class TwoOptionModal extends React.Component {
@@ -18,21 +20,21 @@ export default class TwoOptionModal extends React.Component {
18
20
  </TouchableOpacity>) : null}
19
21
 
20
22
  <View style={isCancelable ? modalStyle.textContainer : modalStyle.textContainerNotCancelable}>
21
- <Text style={rowAsButtonLayout ? modalStyle.titleRowLayout : modalStyle.titleColumnLayout}>
23
+ <TextBold style={rowAsButtonLayout ? modalStyle.titleRowLayout : modalStyle.titleColumnLayout}>
22
24
  {this.props.title}
23
- </Text>
24
- <Text style={modalStyle.message}>{this.props.message}</Text>
25
+ </TextBold>
26
+ <TextRegular style={modalStyle.message}>{this.props.message}</TextRegular>
25
27
  </View>
26
28
  <View style={rowAsButtonLayout ? modalStyle.buttonContainerRow : modalStyle.buttonContainerColumn}>
27
29
  <TouchableOpacity testID={TwoOptionModalTestIds.FirstOption} onPress={this.props.firstOption} style={rowAsButtonLayout ? modalStyle.buttonRow : modalStyle.firstButtonColumn}>
28
- <Text style={rowAsButtonLayout ? modalStyle.textButtonRow : modalStyle.textFirstButtonColumn}>
30
+ <TextBold style={rowAsButtonLayout ? modalStyle.textButtonRow : modalStyle.textFirstButtonColumn}>
29
31
  {this.props.textFirstOption}
30
- </Text>
32
+ </TextBold>
31
33
  </TouchableOpacity>
32
34
  <TouchableOpacity testID={TwoOptionModalTestIds.SecondOption} onPress={this.props.secondOption} style={rowAsButtonLayout ? modalStyle.buttonRow : modalStyle.secondButtonColumn}>
33
- <Text style={rowAsButtonLayout ? modalStyle.textButtonRow : modalStyle.textSecondButtonColumn}>
35
+ <TextBold style={rowAsButtonLayout ? modalStyle.textButtonRow : modalStyle.textSecondButtonColumn}>
34
36
  {this.props.textSecondOption}
35
- </Text>
37
+ </TextBold>
36
38
  </TouchableOpacity>
37
39
  </View>
38
40
  </View>
@@ -73,23 +75,18 @@ export const modalStyle = StyleSheet.create({
73
75
  alignSelf: `flex-start`,
74
76
  },
75
77
  titleRowLayout: {
76
- fontFamily: `Roboto-Regular`,
77
78
  color: `rgba(139, 144, 196, 1)`,
78
79
  fontSize: width / 17,
79
- fontWeight: `bold`,
80
80
  textAlign: `center`,
81
81
  marginBottom: `10%`,
82
82
  },
83
83
  titleColumnLayout: {
84
- fontFamily: `Roboto-Regular`,
85
84
  color: `rgba(139, 144, 196, 1)`,
86
85
  fontSize: width / 17,
87
- fontWeight: `bold`,
88
86
  textAlign: `center`,
89
87
  marginBottom: `5%`,
90
88
  },
91
89
  message: {
92
- fontFamily: `Roboto-Regular`,
93
90
  color: `rgba(245, 242, 242, 1)`,
94
91
  fontSize: width / 22,
95
92
  textAlign: `center`,
@@ -125,24 +122,19 @@ export const modalStyle = StyleSheet.create({
125
122
  marginTop: `2%`,
126
123
  },
127
124
  textButtonRow: {
128
- fontFamily: `Roboto-Regular`,
129
125
  textAlign: `center`,
130
126
  fontSize: width / 24,
131
127
  color: `white`,
132
128
  },
133
129
  textFirstButtonColumn: {
134
- fontFamily: `Roboto-Regular`,
135
130
  textAlign: `center`,
136
131
  fontSize: width / 22,
137
132
  paddingHorizontal: 15,
138
133
  color: `#1B1F48`,
139
- fontWeight: `700`,
140
134
  },
141
135
  textSecondButtonColumn: {
142
- fontFamily: `Roboto-Regular`,
143
136
  textAlign: `center`,
144
137
  fontSize: width / 26,
145
138
  color: BORDER_COLOUR_TEAL,
146
- fontWeight: `bold`,
147
139
  },
148
140
  });
@@ -1,9 +1,11 @@
1
1
  import { t } from "@lingui/macro";
2
2
  import React from "react";
3
- import { Dimensions, StyleSheet, Text, View } from "react-native";
3
+ import { Dimensions, StyleSheet, 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
  import ActivityIcon from "./ActivityIcon";
8
10
  import ActivityIntensity from "./ActivityIntensity";
9
11
  /**
@@ -29,36 +31,37 @@ export default class Activity extends React.Component {
29
31
  <View style={infoStyles.border}>
30
32
  <View style={infoStyles.borderContainer}>
31
33
  <View style={infoStyles.labelContainer}>
32
- <Text style={infoStyles.label}>{i18n._(t `Activity`)}</Text>
34
+ <TextRegular style={infoStyles.label}>{i18n._(t `Activity`)}</TextRegular>
33
35
  </View>
34
36
  <View style={infoStyles.valueUnitContainer}>
35
37
  <View style={infoStyles.valueContainer}>
36
- <Text style={infoStyles.value} testID={Testing.Id.ActivityTestIds.ActivityDuration}>
38
+ <TextRegular style={infoStyles.value} testID={Testing.Id.ActivityTestIds.ActivityDuration}>
37
39
  {activity.activityDuration}
38
- </Text>
40
+ </TextRegular>
39
41
  </View>
40
42
  <View style={infoStyles.unitContainer}>
41
- <Text style={infoStyles.units}>{i18n._(t `min`)}</Text>
43
+ <TextRegular style={infoStyles.units}>{i18n._(t `min`)}</TextRegular>
42
44
  </View>
43
45
  </View>
44
46
  </View>
45
47
  <ActivityIcon activityType={activityType} activityTitle={activityTitle}/>
46
48
  <ActivityIntensity activityIntensity={activity.activityIntensity}/>
47
49
  <View style={[infoStyles.borderContainer, activityStyles.topMargin]}>
48
- <Text style={activityStyles.infoText}>
50
+ <TextRegular style={activityStyles.infoText}>
49
51
  {i18n._(t `Based on the selected activity your insulin recommendation is reduced by:`)}
50
- </Text>
52
+ </TextRegular>
51
53
  </View>
52
54
  <View style={[infoStyles.borderContainer, activityStyles.verticalMargin]}>
53
- <Text style={activityStyles.reductionPercentage} testID={Testing.Id.ActivityTestIds.ActivityReduction}>
55
+ <TextBold style={activityStyles.reductionPercentage} testID={Testing.Id.ActivityTestIds.ActivityReduction}>
54
56
  {reductionPercentage}%
55
- </Text>
57
+ </TextBold>
56
58
  </View>
57
59
  </View>
58
60
  </View>
59
61
  </View>);
60
62
  }
61
63
  }
64
+ const { width } = Dimensions.get(`screen`);
62
65
  const activityStyles = StyleSheet.create({
63
66
  topMargin: {
64
67
  marginTop: `2%`,
@@ -71,12 +74,11 @@ const activityStyles = StyleSheet.create({
71
74
  },
72
75
  infoText: {
73
76
  color: `rgba(160, 180, 240, 1)`,
74
- fontSize: Dimensions.get(`screen`).width / 24,
77
+ fontSize: width / 24,
75
78
  },
76
79
  reductionPercentage: {
77
80
  color: `white`,
78
81
  marginTop: `2%`,
79
- fontSize: Dimensions.get(`screen`).width / 18,
80
- fontWeight: `bold`,
82
+ fontSize: width / 18,
81
83
  },
82
84
  });