@hedia/recommendation-screen 2.0.2 → 2.1.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 (114) hide show
  1. package/App.d.ts +2 -2
  2. package/coverage/clover.xml +700 -0
  3. package/coverage/coverage-final.json +28 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +79 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +201 -0
  8. package/coverage/lcov-report/prettify.css +1 -0
  9. package/coverage/lcov-report/prettify.js +2 -0
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +170 -0
  12. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
  13. package/coverage/lcov-report/src/__tests__/index.html +111 -0
  14. package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
  15. package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
  16. package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
  17. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
  18. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
  19. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
  20. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
  21. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
  22. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
  23. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
  24. package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
  25. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
  26. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
  27. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
  28. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
  29. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
  30. package/coverage/lcov-report/src/components/activity/index.html +141 -0
  31. package/coverage/lcov-report/src/components/index.html +276 -0
  32. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
  33. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
  34. package/coverage/lcov-report/src/components/mood/index.html +126 -0
  35. package/coverage/lcov-report/src/index.html +111 -0
  36. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
  37. package/coverage/lcov-report/src/locale/index.html +111 -0
  38. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
  39. package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
  40. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
  41. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
  42. package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
  43. package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
  44. package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
  45. package/coverage/lcov-report/src/utils/index.html +201 -0
  46. package/coverage/lcov.info +1581 -0
  47. package/jest.config.js +2 -1
  48. package/package.json +2 -2
  49. package/src/RecommendationScreen.d.ts +2 -3
  50. package/src/__tests__/components/Emotion.test.jsx +7 -8
  51. package/src/components/Icon.d.ts +13 -0
  52. package/src/components/Icon.jsx +42 -0
  53. package/src/components/LimitationMessage.d.ts +1 -2
  54. package/src/components/RecommendationModal.d.ts +2 -3
  55. package/src/components/RecommendationModal.jsx +2 -1
  56. package/src/components/activity/ActivityIntensity.jsx +4 -3
  57. package/src/utils/AttentionMessages.d.ts +16 -10
  58. package/src/utils/AttentionMessages.jsx +15 -10
  59. package/src/utils/RecommendationUtils.d.ts +2 -3
  60. package/src/utils/RecommendationUtils.js +10 -6
  61. package/src/utils/Utils.d.ts +1 -0
  62. package/src/utils/Utils.js +4 -0
  63. package/tsconfig.json +7 -5
  64. package/App.tsx +0 -140
  65. package/index.ts +0 -6
  66. package/src/RecommendationScreen.tsx +0 -461
  67. package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
  68. package/src/__tests__/RecommendationUtils.test.ts +0 -332
  69. package/src/__tests__/Translate.test.tsx +0 -31
  70. package/src/__tests__/Utils.test.ts +0 -91
  71. package/src/__tests__/Validations.test.ts +0 -648
  72. package/src/__tests__/components/Activity.test.tsx +0 -163
  73. package/src/__tests__/components/Emotion.test.tsx +0 -110
  74. package/src/__tests__/components/Header.test.tsx +0 -44
  75. package/src/__tests__/components/InfoBars.test.tsx +0 -152
  76. package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
  77. package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
  78. package/src/__tests__/components/MoodIcon.test.tsx +0 -45
  79. package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
  80. package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
  81. package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
  82. package/src/__tests__/components/Remeasure.test.tsx +0 -97
  83. package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
  84. package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
  85. package/src/__tests__/utils.tsx +0 -144
  86. package/src/components/Header.tsx +0 -89
  87. package/src/components/Icon.js +0 -41
  88. package/src/components/InfoBars.tsx +0 -108
  89. package/src/components/InvisibleNumberInput.tsx +0 -98
  90. package/src/components/LimitationMessage.tsx +0 -38
  91. package/src/components/LineSeparator.tsx +0 -24
  92. package/src/components/RecentInsulin.tsx +0 -101
  93. package/src/components/RecommendationModal.tsx +0 -224
  94. package/src/components/RecommendedCarbs.tsx +0 -259
  95. package/src/components/RecommendedInsulin.tsx +0 -175
  96. package/src/components/Remeasure.tsx +0 -120
  97. package/src/components/TransferToLogbook.tsx +0 -100
  98. package/src/components/TwoOptionModal.tsx +0 -185
  99. package/src/components/activity/Activity.tsx +0 -77
  100. package/src/components/activity/ActivityIcon.tsx +0 -54
  101. package/src/components/activity/ActivityIntensity.tsx +0 -58
  102. package/src/components/mood/Emotion.tsx +0 -66
  103. package/src/components/mood/MoodIcon.tsx +0 -60
  104. package/src/locale/CleanLanguage.ts +0 -13
  105. package/src/locale/i18nUtils.ts +0 -27
  106. package/src/types/enum.ts +0 -108
  107. package/src/types/types.ts +0 -16
  108. package/src/utils/AttentionMessages.tsx +0 -75
  109. package/src/utils/Constants.ts +0 -32
  110. package/src/utils/RecommendationError.tsx +0 -140
  111. package/src/utils/RecommendationUtils.ts +0 -125
  112. package/src/utils/Translations.ts +0 -9
  113. package/src/utils/Utils.ts +0 -57
  114. package/src/utils/Validations.ts +0 -245
@@ -1,120 +0,0 @@
1
- import { t } from "@lingui/macro";
2
- import Slider from "@react-native-community/slider";
3
- import React from "react";
4
- import { Dimensions, Platform, StyleSheet, Text, View } from "react-native";
5
- import { i18n } from "../locale/i18nUtils";
6
- import { RemeasureTestIds } from "../types/enum";
7
- import { BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
8
- import { infoStyles } from "./InfoBars";
9
-
10
- interface IProps {
11
- remeasureTime: number;
12
- onSliderChange(value: number): void;
13
- }
14
-
15
- export default class Remeasure extends React.Component<IProps> {
16
- private slider?: Slider;
17
-
18
- public componentDidMount(): void {
19
- this.slider?.setNativeProps({
20
- value: this.props.remeasureTime,
21
- });
22
- }
23
-
24
- public handleSliderChange = (remeasureTime: number): void => {
25
- const limited = this.limitTime(remeasureTime);
26
- this.props.onSliderChange(limited);
27
- };
28
-
29
- public limitTime = (remeasureTime: number): number => {
30
- return Math.min(Math.max(0, remeasureTime), 6);
31
- };
32
-
33
- public render(): JSX.Element {
34
- const measure = this.props.remeasureTime > 0;
35
- const limited = this.limitTime(this.props.remeasureTime);
36
- const marginHorizontal = Platform.OS === `ios` ? `3%` : `0%`;
37
- const valueContainer = measure ? remeasureStyles.valueContainer : variantStyles.centeredValueContainer;
38
- return (
39
- <View style={remeasureStyles.container}>
40
- <View style={remeasureStyles.borderContainer}>
41
- <View style={remeasureStyles.remeasureContainer}>
42
- <Text style={remeasureStyles.remeasureLabel}>{i18n._(t`Remind me to remeasure in`)}</Text>
43
- </View>
44
- <View style={remeasureStyles.valueUnitContainer}>
45
- <View style={valueContainer}>
46
- <Text style={remeasureStyles.value}>{measure ? limited : i18n._(t`OFF`)}</Text>
47
- </View>
48
- {measure ? (
49
- <View style={remeasureStyles.unitContainer}>
50
- <Text style={remeasureStyles.units}>{i18n._(t`hours`)}</Text>
51
- </View>
52
- ) : null}
53
- </View>
54
- </View>
55
- <Slider
56
- ref={(slider): void => {
57
- if (slider !== null) {
58
- this.slider = slider;
59
- }
60
- }}
61
- testID={RemeasureTestIds.RemeasureSlider}
62
- accessibilityLabel="remeasureSlider"
63
- maximumTrackTintColor={BORDER_COLOUR_GREY}
64
- minimumTrackTintColor={BORDER_COLOUR_TEAL}
65
- thumbTintColor={BORDER_COLOUR_TEAL}
66
- maximumValue={6}
67
- minimumValue={0}
68
- step={0.5}
69
- style={[remeasureStyles.sliderStyle, { marginHorizontal }]}
70
- onValueChange={this.handleSliderChange}
71
- />
72
- </View>
73
- );
74
- }
75
- }
76
-
77
- const remeasureStyles = StyleSheet.create({
78
- container: {
79
- flexDirection: `column`,
80
- padding: `3%`,
81
- },
82
- borderContainer: {
83
- ...infoStyles.borderContainer,
84
- alignItems: `center`,
85
- },
86
- remeasureContainer: {
87
- flex: 7,
88
- },
89
- remeasureLabel: {
90
- color: `white`,
91
- fontSize: Dimensions.get(`screen`).width / 25,
92
- fontWeight: `bold`,
93
- },
94
- valueUnitContainer: {
95
- ...infoStyles.valueUnitContainer,
96
- },
97
- valueContainer: {
98
- ...infoStyles.valueContainer,
99
- },
100
- value: {
101
- ...infoStyles.value,
102
- },
103
- unitContainer: {
104
- ...infoStyles.unitContainer,
105
- },
106
- units: {
107
- ...infoStyles.units,
108
- },
109
- sliderStyle: {
110
- marginTop: `3%`,
111
- marginBottom: `2%`,
112
- },
113
- });
114
-
115
- const variantStyles = StyleSheet.create({
116
- centeredValueContainer: {
117
- ...remeasureStyles.valueContainer,
118
- alignItems: `center`,
119
- },
120
- });
@@ -1,100 +0,0 @@
1
- import React from "react";
2
- import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
3
-
4
- import { t } from "@lingui/macro";
5
- import { i18n } from "../locale/i18nUtils";
6
- import { TransferToLogbookTestIds } from "../types/enum";
7
- import Icon from "./Icon";
8
-
9
- interface IProps {
10
- visible: boolean;
11
- transfer(): void;
12
- }
13
-
14
- interface IState {
15
- pressed: boolean;
16
- }
17
-
18
- export default class TransferToLogbook extends React.Component<IProps, IState> {
19
- public state: IState = {
20
- pressed: false,
21
- };
22
-
23
- public handlePress = (): void => {
24
- this.setState({
25
- pressed: !this.state.pressed,
26
- });
27
- this.props.transfer();
28
- };
29
-
30
- public render(): JSX.Element {
31
- if (!this.props.visible) {
32
- return <View style={addToLogbookStyles.marginContainer} />;
33
- }
34
-
35
- return (
36
- <TouchableOpacity
37
- testID={TransferToLogbookTestIds.TransferButton}
38
- onPress={this.handlePress}
39
- disabled={this.state.pressed}
40
- style={addToLogbookStyles.container}
41
- accessibilityLabel="transferToLogbook"
42
- >
43
- {!this.state.pressed ? (
44
- <View style={addToLogbookStyles.textContainer}>
45
- <Text style={addToLogbookStyles.transferText}>{i18n._(t`Transfer to logbook`)}</Text>
46
- </View>
47
- ) : (
48
- <View style={addToLogbookStyles.textContainerActive}>
49
- <Icon style={addToLogbookStyles.icon} iconIdentifier={`Feather/check`} />
50
- <Text style={addToLogbookStyles.transferTextActive}>{i18n._(t`Transferred to logbook`)}</Text>
51
- </View>
52
- )}
53
- </TouchableOpacity>
54
- );
55
- }
56
- }
57
-
58
- const addToLogbookStyles = StyleSheet.create({
59
- marginContainer: {
60
- marginVertical: `3%`,
61
- },
62
- container: {
63
- flex: 1,
64
- margin: `5%`,
65
- },
66
- textContainer: {
67
- flexDirection: `row`,
68
- justifyContent: `center`,
69
- borderWidth: 1,
70
- borderRadius: 100,
71
- marginHorizontal: `4%`,
72
- paddingVertical: `4%`,
73
- borderColor: `#01FFFC`,
74
- },
75
- transferText: {
76
- color: `#01FFFC`,
77
- fontSize: Dimensions.get(`screen`).width / 22,
78
- fontWeight: `bold`,
79
- },
80
- textContainerActive: {
81
- flexDirection: `row`,
82
- backgroundColor: `#01FFFC`,
83
- justifyContent: `center`,
84
- borderWidth: 1,
85
- borderRadius: 100,
86
- marginHorizontal: `4%`,
87
- paddingVertical: `4%`,
88
- },
89
- icon: {
90
- paddingTop: `1.3%`,
91
- color: `#1B1F48`,
92
- fontSize: Dimensions.get(`screen`).width / 22,
93
- marginRight: `1%`,
94
- },
95
- transferTextActive: {
96
- color: `#1B1F48`,
97
- fontSize: Dimensions.get(`screen`).width / 22,
98
- fontWeight: `bold`,
99
- },
100
- });
@@ -1,185 +0,0 @@
1
- import * as React from "react";
2
- import { Dimensions, StatusBar, StyleSheet, Text, TouchableOpacity, View } from "react-native";
3
- import { TwoOptionModalTestIds } from "../types/enum";
4
- import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
5
- import Icon from "./Icon";
6
- import { stylesModal } from "./RecommendationModal";
7
-
8
- export interface ITwoOptionModalProps {
9
- title: string;
10
- message: string;
11
- textFirstOption: string;
12
- textSecondOption: string;
13
- isCancelable?: boolean;
14
- rowAsButtonLayout: boolean;
15
- firstOption(): void;
16
- secondOption(): void;
17
- onClose?(): void;
18
- }
19
-
20
- export default class TwoOptionModal extends React.Component<ITwoOptionModalProps> {
21
- constructor(props: ITwoOptionModalProps) {
22
- super(props);
23
- }
24
-
25
- public render(): JSX.Element {
26
- const { rowAsButtonLayout, isCancelable } = this.props;
27
- return (
28
- <View style={modalStyle.container}>
29
- <StatusBar backgroundColor={`rgba(0, 0, 0, 1)`} />
30
- <View style={modalStyle.modalContainer}>
31
- {isCancelable ? (
32
- <TouchableOpacity
33
- onPress={this.props.onClose}
34
- testID={TwoOptionModalTestIds.ExitButton}
35
- style={modalStyle.iconWrapper}
36
- >
37
- <Icon
38
- accessibilityLabel="ModalExitIcon"
39
- iconIdentifier={`Ionicons/ios-close-circle-outline`}
40
- style={modalStyle.icon}
41
- />
42
- </TouchableOpacity>
43
- ) : null}
44
-
45
- <View style={isCancelable ? modalStyle.textContainer : modalStyle.textContainerNotCancelable}>
46
- <Text style={rowAsButtonLayout ? modalStyle.titleRowLayout : modalStyle.titleColumnLayout}>
47
- {this.props.title}
48
- </Text>
49
- <Text style={modalStyle.message}>{this.props.message}</Text>
50
- </View>
51
- <View style={rowAsButtonLayout ? modalStyle.buttonContainerRow : modalStyle.buttonContainerColumn}>
52
- <TouchableOpacity
53
- testID={TwoOptionModalTestIds.FirstOption}
54
- accessibilityLabel="firstOptionButton"
55
- onPress={this.props.firstOption}
56
- style={rowAsButtonLayout ? modalStyle.buttonRow : modalStyle.firstButtonColumn}
57
- >
58
- <Text
59
- style={rowAsButtonLayout ? modalStyle.textButtonRow : modalStyle.textFirstButtonColumn}
60
- >
61
- {this.props.textFirstOption}
62
- </Text>
63
- </TouchableOpacity>
64
- <TouchableOpacity
65
- testID={TwoOptionModalTestIds.SecondOption}
66
- accessibilityLabel="secondOptionButton"
67
- onPress={this.props.secondOption}
68
- style={rowAsButtonLayout ? modalStyle.buttonRow : modalStyle.secondButtonColumn}
69
- >
70
- <Text
71
- style={rowAsButtonLayout ? modalStyle.textButtonRow : modalStyle.textSecondButtonColumn}
72
- >
73
- {this.props.textSecondOption}
74
- </Text>
75
- </TouchableOpacity>
76
- </View>
77
- </View>
78
- </View>
79
- );
80
- }
81
- }
82
- const { height, width } = Dimensions.get(`screen`);
83
- export const modalStyle = StyleSheet.create({
84
- container: {
85
- ...StyleSheet.absoluteFillObject,
86
- justifyContent: `center`,
87
- backgroundColor: `rgba(0, 0, 0, 0.9)`,
88
- },
89
- modalContainer: {
90
- margin: `4%`,
91
- backgroundColor: BACKGROUND_COLOUR_PURPLE,
92
- borderRadius: width / 25,
93
- },
94
- iconWrapper: {
95
- alignSelf: `flex-end`,
96
- marginRight: `4%`,
97
- marginTop: `3%`,
98
- },
99
- icon: {
100
- color: BORDER_COLOUR_GREY,
101
- fontSize: width / 12,
102
- },
103
- textContainer: {
104
- marginHorizontal: `4%`,
105
- marginBottom: `5%`,
106
- marginTop: `2%`,
107
- alignSelf: `flex-start`,
108
- },
109
- textContainerNotCancelable: {
110
- marginHorizontal: `4%`,
111
- marginVertical: `5%`,
112
- alignSelf: `flex-start`,
113
- },
114
- titleRowLayout: {
115
- fontFamily: `Roboto-Regular`,
116
- color: `rgba(139, 144, 196, 1)`,
117
- fontSize: width / 17,
118
- fontWeight: `bold`,
119
- textAlign: `center`,
120
- marginBottom: `10%`,
121
- },
122
- titleColumnLayout: {
123
- fontFamily: `Roboto-Regular`,
124
- color: `rgba(139, 144, 196, 1)`,
125
- fontSize: width / 17,
126
- fontWeight: `bold`,
127
- textAlign: `center`,
128
- marginBottom: `5%`,
129
- },
130
- message: {
131
- fontFamily: `Roboto-Regular`,
132
- color: `rgba(245, 242, 242, 1)`,
133
- fontSize: width / 22,
134
- textAlign: `center`,
135
- },
136
- buttonContainerRow: {
137
- flexDirection: `row`,
138
- justifyContent: `space-around`,
139
- marginHorizontal: `4%`,
140
- marginVertical: `6%`,
141
- },
142
- buttonContainerColumn: {
143
- flexDirection: `column`,
144
- justifyContent: `space-around`,
145
- margin: `4%`,
146
- },
147
- buttonRow: {
148
- ...stylesModal.okButton,
149
- height: height / 16,
150
- marginTop: 0,
151
- },
152
- firstButtonColumn: {
153
- ...stylesModal.okButton,
154
- height: height / 18,
155
- width: width / 1.5,
156
- marginTop: 0,
157
- backgroundColor: BORDER_COLOUR_TEAL,
158
- },
159
- secondButtonColumn: {
160
- alignSelf: `center`,
161
- justifyContent: `center`,
162
- height: height / 18,
163
- width: width / 1.5,
164
- marginTop: `2%`,
165
- },
166
- textButtonRow: {
167
- fontFamily: `Roboto-Regular`,
168
- textAlign: `center`,
169
- fontSize: width / 24,
170
- color: `white`,
171
- },
172
- textFirstButtonColumn: {
173
- fontFamily: `Roboto-Regular`,
174
- textAlign: `center`,
175
- fontSize: width / 22,
176
- paddingHorizontal: 15,
177
- },
178
- textSecondButtonColumn: {
179
- fontFamily: `Roboto-Regular`,
180
- textAlign: `center`,
181
- fontSize: width / 26,
182
- color: BORDER_COLOUR_TEAL,
183
- fontWeight: `bold`,
184
- },
185
- });
@@ -1,77 +0,0 @@
1
- import { t } from "@lingui/macro";
2
- import React from "react";
3
- import { Dimensions, StyleSheet, Text, View } from "react-native";
4
- import { i18n } from "../../locale/i18nUtils";
5
- import { ActivityTestIds } from "../../types/enum";
6
- import { IActivityDisplayProps, IActivityParams, ReductionType } from "../../types/types";
7
- import { infoStyles } from "../InfoBars";
8
- import ActivityIcon from "./ActivityIcon";
9
- import ActivityIntensity from "./ActivityIntensity";
10
-
11
- interface IProps extends IActivityDisplayProps {
12
- activity: IActivityParams;
13
- activityReduction: ReductionType;
14
- }
15
-
16
- export default class Activity extends React.Component<IProps> {
17
- public render(): JSX.Element {
18
- const { activity, activityType, activityReduction, activityTitle } = this.props;
19
- const reductionPercentage = ((activityReduction ?? 0) * 100).toFixed(0);
20
-
21
- return (
22
- <View style={[infoStyles.container, activityStyles.botMargin]}>
23
- <View style={infoStyles.margin}>
24
- <View style={infoStyles.border}>
25
- <View style={infoStyles.borderContainer}>
26
- <View style={infoStyles.labelContainer}>
27
- <Text style={infoStyles.label}>{i18n._(t`Activity`)}</Text>
28
- </View>
29
- <View style={infoStyles.valueUnitContainer}>
30
- <View style={infoStyles.valueContainer}>
31
- <Text style={infoStyles.value}>{activity.activityDuration}</Text>
32
- </View>
33
- <View style={infoStyles.unitContainer}>
34
- <Text style={infoStyles.units}>{i18n._(t`min`)}</Text>
35
- </View>
36
- </View>
37
- </View>
38
- <ActivityIcon activityType={activityType} activityTitle={activityTitle} />
39
- <ActivityIntensity activityIntensity={activity.activityIntensity} />
40
- <View style={[infoStyles.borderContainer, activityStyles.topMargin]}>
41
- <Text style={activityStyles.infoText}>
42
- {i18n._(t`Based on the selected activity your insulin recommendation is reduced by:`)}
43
- </Text>
44
- </View>
45
- <View style={[infoStyles.borderContainer, activityStyles.verticalMargin]}>
46
- <Text style={activityStyles.reductionPercentage} testID={ActivityTestIds.ActivityReduction}>
47
- {reductionPercentage}%
48
- </Text>
49
- </View>
50
- </View>
51
- </View>
52
- </View>
53
- );
54
- }
55
- }
56
-
57
- const activityStyles = StyleSheet.create({
58
- topMargin: {
59
- marginTop: `2%`,
60
- },
61
- botMargin: {
62
- marginBottom: `2%`,
63
- },
64
- verticalMargin: {
65
- marginBottom: `2%`,
66
- },
67
- infoText: {
68
- color: `rgba(160, 180, 240, 1)`,
69
- fontSize: Dimensions.get(`screen`).width / 24,
70
- },
71
- reductionPercentage: {
72
- color: `white`,
73
- marginTop: `2%`,
74
- fontSize: Dimensions.get(`screen`).width / 18,
75
- fontWeight: `bold`,
76
- },
77
- });
@@ -1,54 +0,0 @@
1
- import { Activity } from "@hedia/types";
2
- import { t } from "@lingui/macro";
3
- import React from "react";
4
- import { Dimensions, Image, ImageURISource, StyleSheet, Text, View } from "react-native";
5
- import { i18n } from "../../locale/i18nUtils";
6
- import { IActivityDisplayProps } from "../../types/types";
7
-
8
- const { Other } = Activity.Enums.ActivityEnum;
9
-
10
- const ACTIVITY_ICONS: Record<Activity.Enums.ActivityEnum, ImageURISource> = {
11
- Run: require(`../../assets/activity/Runner.png`),
12
- Walk: require(`../../assets/activity/Walk.png`),
13
- Cycling: require(`../../assets/activity/Cyclist.png`),
14
- Swim: require(`../../assets/activity/Swimmer.png`),
15
- Other: require(`../../assets/activity/Other.png`),
16
- };
17
-
18
- export default class ActivityIcon extends React.Component<IActivityDisplayProps> {
19
- public getActivityIcon = (): ImageURISource => {
20
- return ACTIVITY_ICONS[this.props.activityType ?? Other];
21
- };
22
-
23
- public render(): JSX.Element | null {
24
- const { activityType, activityTitle } = this.props;
25
- const label = `${Activity.Enums.ActivityEnum[activityType ?? Other]}_activity`;
26
- return (
27
- <View style={activityIconStyles.container}>
28
- <Image
29
- style={activityIconStyles.activityIcon}
30
- source={this.getActivityIcon()}
31
- accessibilityLabel={label}
32
- />
33
- <Text style={activityIconStyles.activityTitle}>{activityTitle || i18n._(t`Untitled Activity`)}</Text>
34
- </View>
35
- );
36
- }
37
- }
38
-
39
- const activityIconStyles = StyleSheet.create({
40
- container: {
41
- flex: 1,
42
- flexDirection: `row`,
43
- alignItems: `center`,
44
- marginTop: `1%`,
45
- },
46
- activityIcon: {
47
- resizeMode: `contain`,
48
- height: Dimensions.get(`screen`).width / 16,
49
- },
50
- activityTitle: {
51
- color: `white`,
52
- fontSize: Dimensions.get(`screen`).width / 25,
53
- },
54
- });
@@ -1,58 +0,0 @@
1
- import React from "react";
2
- import { Dimensions, StyleSheet, Text, View } from "react-native";
3
- import { IActivityParams } from "../../types/types";
4
- import { ActivityIntensityTranslations } from "../../utils/Translations";
5
- import { infoStyles } from "../InfoBars";
6
-
7
- interface IProps {
8
- activityIntensity: IActivityParams["activityIntensity"];
9
- }
10
-
11
- export default class ActivityIntensity extends React.Component<IProps> {
12
- public render = (): JSX.Element => {
13
- const intensity = this.props.activityIntensity;
14
- const style = activityIntensityStyles[intensity];
15
-
16
- return (
17
- <View style={[infoStyles.margin, activityIntensityStyles.row]}>
18
- <View style={activityIntensityStyles.intensityContainer}>
19
- <View style={[activityIntensityStyles.intensityTextContainer, style]}>
20
- <Text style={activityIntensityStyles.bold}>{ActivityIntensityTranslations[intensity]()}</Text>
21
- </View>
22
- </View>
23
- <View style={activityIntensityStyles.intensityContainerOffset} />
24
- </View>
25
- );
26
- };
27
- }
28
-
29
- const activityIntensityStyles = StyleSheet.create({
30
- row: {
31
- flexDirection: `row`,
32
- },
33
- intensityTextContainer: {
34
- alignItems: `center`,
35
- justifyContent: `center`,
36
- padding: `5%`,
37
- borderRadius: 5,
38
- },
39
- Light: {
40
- backgroundColor: `#A5D871`,
41
- },
42
- Moderate: {
43
- backgroundColor: `#F9BD5A`,
44
- },
45
- Hard: {
46
- backgroundColor: `#EC5466`,
47
- },
48
- intensityContainer: {
49
- flex: 5,
50
- },
51
- intensityContainerOffset: {
52
- flex: 16,
53
- },
54
- bold: {
55
- fontWeight: `bold`,
56
- fontSize: Dimensions.get(`screen`).width / 30,
57
- },
58
- });
@@ -1,66 +0,0 @@
1
- import { Logbook } from "@hedia/types";
2
- import { t } from "@lingui/macro";
3
- import React from "react";
4
- import { Dimensions, StyleSheet, Text, View } from "react-native";
5
- import { i18n } from "../../locale/i18nUtils";
6
- import MoodIcon from "./MoodIcon";
7
-
8
- const MoodEnum = Logbook.Enums.MoodEnum;
9
-
10
- interface IProps {
11
- currentMood: Logbook.Enums.MoodEnum | null;
12
- moodSelected(mood: Logbook.Enums.MoodEnum | null): void;
13
- }
14
-
15
- export default class Emotion extends React.Component<IProps> {
16
- public handleIconPress = (selected: Logbook.Enums.MoodEnum, toggle: boolean): void => {
17
- this.props.moodSelected(toggle ? selected : null);
18
- };
19
-
20
- public mappedMoods = (): Array<JSX.Element> => {
21
- const values = Object.values(MoodEnum).filter((val): boolean => isNaN(Number(val))) as Array<
22
- keyof typeof MoodEnum
23
- >;
24
-
25
- return values.map(
26
- (key): JSX.Element => {
27
- const moodValue = MoodEnum[key];
28
- return (
29
- <MoodIcon
30
- onPress={(toggle): void => this.handleIconPress(moodValue, toggle)}
31
- active={moodValue === this.props.currentMood}
32
- mood={moodValue}
33
- key={moodValue}
34
- />
35
- );
36
- },
37
- );
38
- };
39
-
40
- public render(): JSX.Element {
41
- return (
42
- <View style={emotionStyles.container}>
43
- <View style={emotionStyles.feelingContainer}>
44
- <Text style={emotionStyles.feelingText}>{i18n._(t`How are you feeling?`)}</Text>
45
- </View>
46
- <View style={emotionStyles.moodIconContainer}>{this.mappedMoods()}</View>
47
- </View>
48
- );
49
- }
50
- }
51
-
52
- const emotionStyles = StyleSheet.create({
53
- container: {
54
- flex: 1,
55
- },
56
- feelingContainer: {
57
- marginVertical: `3%`,
58
- },
59
- feelingText: {
60
- textAlign: `center`,
61
- color: `white`,
62
- fontWeight: `bold`,
63
- fontSize: Dimensions.get(`screen`).width / 26,
64
- },
65
- moodIconContainer: { flex: 1, flexDirection: `row`, justifyContent: `center` },
66
- });