@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,144 +0,0 @@
1
- import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
2
- import { I18nProvider } from "@lingui/react";
3
- import React from "react";
4
- import { RenderAPI } from "react-native-testing-library";
5
- import { ReactTestInstance } from "react-test-renderer";
6
- import { i18n } from "../locale/i18nUtils";
7
- import { IRecommendationProps } from "../RecommendationScreen";
8
- import { TestIdEnum } from "../types/enum";
9
- import { IActivityParams, IRecommendationParams, logbookEntry } from "../types/types";
10
-
11
- const ActivityEnum = Activity.Enums.ActivityEnum;
12
- const ActivityIntensity = Activity.Enums.ActivityIntensity;
13
- const InjectionMethod = UserSettings.Enums.InjectionMethod;
14
-
15
- const { Run } = ActivityEnum;
16
- const { moderate } = ActivityIntensity;
17
- const { PenHalf } = InjectionMethod;
18
-
19
- export function getRecommendationProps(partials?: Partial<IRecommendationProps>): IRecommendationProps {
20
- return {
21
- currentBKL: partials?.currentBKL ?? 0.1,
22
- bloodKetoneUnit: partials?.bloodKetoneUnit ?? BloodKetonesUnit.MMOL_L,
23
- bloodGlucoseUnit: partials?.bloodGlucoseUnit ?? BloodGlucoseUnit.MMOL_L,
24
- language: partials?.language ?? Languages.en,
25
- userReminder: partials?.userReminder ?? 1.5,
26
- latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours ?? generateDefaultLogbook(),
27
- calculatorParams: partials?.calculatorParams ?? generateDefaultCalculatorParams(),
28
- injectionMethod: partials?.injectionMethod ?? PenHalf,
29
- transferToLogbook: partials?.transferToLogbook ?? jest.fn(),
30
- onError: partials?.onError ?? jest.fn(),
31
- onRecentInsulinYes: partials?.onRecentInsulinYes ?? jest.fn(),
32
- exitCallback: partials?.exitCallback ?? jest.fn(),
33
- closeCalculationCallback: partials?.closeCalculationCallback ?? jest.fn(),
34
- carbRecommendationAnswer: partials?.carbRecommendationAnswer ?? jest.fn(),
35
- showBolusBar: partials?.showBolusBar ?? jest.fn(),
36
- restartCalculation: partials?.restartCalculation ?? jest.fn(),
37
- activityDisplayProps: partials?.activityDisplayProps ?? {
38
- activityTitle: `Activity Title Test`,
39
- activityType: Run,
40
- },
41
- };
42
- }
43
-
44
- export function generateDefaultCalculatorParams(): IRecommendationParams {
45
- return {
46
- carbohydrateRatio: 10,
47
- carbohydrates: 4,
48
- currentBGL: 5,
49
- insulinSensitivity: 4,
50
- targetBGL: 6,
51
- recentBoluses: [
52
- {
53
- insulinDose: 2,
54
- secondsPassed: 1000,
55
- },
56
- {
57
- insulinDose: 1.7,
58
- secondsPassed: 10000,
59
- },
60
- ],
61
- activity: null,
62
- };
63
- }
64
-
65
- export function generateActivityProps(): IActivityParams {
66
- return {
67
- activityDate: new Date(),
68
- activityDuration: 30,
69
- activityIntensity: moderate,
70
- activitySettings: generateDefaultActivitySettings(),
71
- };
72
- }
73
-
74
- export function generateDefaultActivitySettings(): IActivityParams["activitySettings"] {
75
- return {
76
- hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
77
- light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
78
- moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
79
- post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
80
- target: 9,
81
- };
82
- }
83
- export function generateDefaultLogbook(): logbookEntry {
84
- return {
85
- blood_glucose_millimolar: 6,
86
- carbohydrates_entered_grams: 25,
87
- carbohydrates_suggested_grams: 25,
88
- client_timestamp: `25`,
89
- client_version: `25`,
90
- entry_timestamp: `25`,
91
- event_uuid: null,
92
- insulin_entered_units: 25,
93
- insulin_suggested_units: 25,
94
- is_deleted: null,
95
- mood: 2,
96
- settings_uuid: `25`,
97
- uuid: `aaa`,
98
- device_and_os: `ios 12.1.2`,
99
- overwritten_by_id: null,
100
- server_timestamp: null,
101
- server_version: null,
102
- utc_timezone_offset: null,
103
- blood_ketones_millimolar: null,
104
- carbohydrates_modified_suggested_grams: null,
105
- };
106
- }
107
-
108
- export function expectTextExists(component: RenderAPI, text: string | RegExp): void {
109
- const element = component.queryByText(text);
110
- /*
111
- if (!element) {
112
- throw Error(`element with text: ${text} does not exist`);
113
- }
114
- */
115
- return expect(element).not.toBeNull();
116
- }
117
-
118
- export function queryTextFromComponent(wrapper: RenderAPI, testID: TestIdEnum): string {
119
- const component = wrapper.getByTestId(testID);
120
- const values = component.children;
121
- return values.join(``);
122
- }
123
-
124
- export function expectTextNotExists(component: RenderAPI, text: string | RegExp): void {
125
- const element = component.queryByText(text);
126
- /*
127
- if (element) {
128
- throw Error(`element with text: ${text} should not exist`);
129
- }
130
- */
131
- return expect(element).toBeNull();
132
- }
133
-
134
- export function i18nProvided(element: JSX.Element): JSX.Element {
135
- return (
136
- <I18nProvider language={i18n.language} i18n={i18n}>
137
- {element}
138
- </I18nProvider>
139
- );
140
- }
141
-
142
- export function getIcon(wrapper: RenderAPI, name: string, active: boolean): ReactTestInstance | null {
143
- return wrapper.queryByA11yLabel(`${name}_${active}`);
144
- }
@@ -1,89 +0,0 @@
1
- import { t } from "@lingui/macro";
2
- import React from "react";
3
- import { Dimensions, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
- import { i18n } from "../locale/i18nUtils";
5
- import { HeaderTestIds } from "../types/enum";
6
- import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY } from "../utils/Constants";
7
- import Icon from "./Icon";
8
-
9
- interface IProps {
10
- exitCallback(): void;
11
- }
12
-
13
- export default class Header extends React.Component<IProps> {
14
- public render(): JSX.Element {
15
- return (
16
- <React.Fragment>
17
- <SafeAreaView style={headerStyles.backgroundColour} />
18
- <View style={headerStyles.headerContainer}>
19
- <View style={headerStyles.margin}>
20
- <View style={headerStyles.exitButtonContainer}>
21
- <View style={headerStyles.exitButton}>
22
- <TouchableOpacity
23
- testID={HeaderTestIds.ExitCalculation}
24
- accessibilityLabel="exitButton"
25
- style={headerStyles.exitButton}
26
- onPress={this.props.exitCallback}
27
- >
28
- <Icon
29
- iconIdentifier={`Ionicons/ios-close-circle-outline`}
30
- style={headerStyles.iconStyle}
31
- />
32
- </TouchableOpacity>
33
- <View style={headerStyles.headerFiller} />
34
- </View>
35
- </View>
36
- <View style={headerStyles.headerTextContainer}>
37
- <Text style={headerStyles.headerText} testID="headerText">
38
- {i18n._(t`INSULIN${`\n`}RECOMMENDATION`)}
39
- </Text>
40
- </View>
41
- <View style={headerStyles.headerFiller} />
42
- </View>
43
- </View>
44
- </React.Fragment>
45
- );
46
- }
47
- }
48
-
49
- export const headerStyles = StyleSheet.create({
50
- backgroundColour: {
51
- backgroundColor: BACKGROUND_COLOUR_PURPLE,
52
- },
53
- margin: {
54
- margin: `1%`,
55
- marginBottom: `3%`,
56
- flexDirection: `row`,
57
- flex: 1,
58
- },
59
- headerContainer: {
60
- flexDirection: `row`,
61
- flex: 1,
62
- },
63
- exitButtonContainer: {
64
- alignItems: `center`,
65
- flex: 1,
66
- },
67
- exitButton: {
68
- flex: 1,
69
- },
70
- iconStyle: {
71
- fontSize: Dimensions.get(`screen`).width / 12,
72
- color: BORDER_COLOUR_GREY,
73
- },
74
- headerTextContainer: {
75
- flex: 6,
76
- justifyContent: `center`,
77
- alignItems: `center`,
78
- marginTop: `5%`,
79
- },
80
- headerText: {
81
- fontSize: Dimensions.get(`screen`).width / 18,
82
- fontWeight: `bold`,
83
- textAlign: `center`,
84
- color: `white`,
85
- },
86
- headerFiller: {
87
- flex: 1,
88
- },
89
- });
@@ -1,41 +0,0 @@
1
- import React from "react";
2
-
3
- const IconSets = {
4
- AntDesign: require(`react-native-vector-icons/AntDesign`),
5
- Feather: require(`react-native-vector-icons/Feather`),
6
- EvilIcons: require(`react-native-vector-icons/EvilIcons`),
7
- Ionicons: require(`react-native-vector-icons/Ionicons`),
8
- FontAwesome: require(`react-native-vector-icons/FontAwesome`),
9
- Entypo: require(`react-native-vector-icons/Entypo`),
10
- };
11
-
12
- export default class Icon extends React.Component {
13
- setNativeProps(nativeProps) {
14
- this._root.setNativeProps(nativeProps);
15
- }
16
-
17
- render() {
18
- const iconParts = this.props.iconIdentifier.split(`/`);
19
- let iconPackageName = iconParts[0];
20
- let iconName = iconParts[1];
21
- if (!IconSets[iconPackageName]) {
22
- iconPackageName = `FontAwesome`;
23
- iconName = `question`;
24
- }
25
- const IconClass = IconSets[iconPackageName].default;
26
- const clonedProps = { ...this.props, name: iconName };
27
- delete clonedProps.iconIdentifier;
28
-
29
- // Support FontAwesome5's solid/light/brand
30
- if (clonedProps.iconStyle) {
31
- clonedProps[clonedProps.iconStyle] = true;
32
- }
33
- delete clonedProps.iconStyle;
34
-
35
- return <IconClass {...clonedProps} ref={(component) => (this._root = component)} />;
36
- }
37
- }
38
-
39
- Icon.defaultProps = {
40
- iconIdentifier: `FontAwesome/question`,
41
- };
@@ -1,108 +0,0 @@
1
- import { BloodGlucoseUnit, BloodKetonesUnit } 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 { BORDER_COLOUR_GREY } from "../utils/Constants";
7
- import { Utils } from "../utils/Utils";
8
-
9
- export interface IProps {
10
- label: string;
11
- value: string | null;
12
- unit: string | BloodGlucoseUnit | BloodKetonesUnit;
13
- showNullAsDash: boolean;
14
- }
15
-
16
- export default class InfoBars extends React.Component<IProps> {
17
- public displayValue = (): string => {
18
- const { showNullAsDash, unit, value } = this.props;
19
- const noDecimal = unit === BloodGlucoseUnit.MG_DL || unit === BloodKetonesUnit.MG_DL;
20
- const nullPlaceholder = noDecimal ? `-` : `-.-`;
21
- return value ?? (showNullAsDash ? nullPlaceholder : `0`);
22
- };
23
-
24
- public displayUnit = (): string => {
25
- const { unit } = this.props;
26
- return unit === i18n._(t`units`) ? unit : Utils.formatUnit(unit as BloodGlucoseUnit | BloodKetonesUnit);
27
- };
28
-
29
- public render(): JSX.Element {
30
- return (
31
- <View style={infoStyles.container}>
32
- <View style={infoStyles.margin}>
33
- <View style={infoStyles.border}>
34
- <View style={infoStyles.borderContainer}>
35
- <View style={infoStyles.labelContainer}>
36
- <Text style={infoStyles.label}>{this.props.label}</Text>
37
- </View>
38
- <View style={infoStyles.valueUnitContainer}>
39
- <View style={infoStyles.valueContainer}>
40
- <Text style={infoStyles.value}>{this.displayValue()}</Text>
41
- </View>
42
- <View style={infoStyles.unitContainer}>
43
- <Text style={infoStyles.units}>{this.displayUnit()}</Text>
44
- </View>
45
- </View>
46
- </View>
47
- </View>
48
- </View>
49
- </View>
50
- );
51
- }
52
- }
53
-
54
- export const infoStyles = StyleSheet.create({
55
- container: { flex: 1 },
56
- margin: {
57
- flex: 1,
58
- margin: `3%`,
59
- marginBottom: 0,
60
- },
61
- border: {
62
- borderWidth: 2,
63
- borderColor: BORDER_COLOUR_GREY,
64
- borderRadius: 5,
65
- paddingVertical: `1%`,
66
- },
67
- borderContainer: {
68
- flex: 1,
69
- flexDirection: `row`,
70
- justifyContent: `space-between`,
71
- paddingHorizontal: `3%`,
72
- },
73
- labelContainer: {
74
- flex: 7,
75
- justifyContent: `center`,
76
- },
77
- label: {
78
- color: `white`,
79
- fontSize: Dimensions.get(`screen`).width / 22,
80
- fontWeight: `bold`,
81
- },
82
- valueUnitContainer: {
83
- flex: 6.5,
84
- justifyContent: `flex-end`,
85
- flexDirection: `row`,
86
- },
87
- valueContainer: {
88
- flex: 5,
89
- justifyContent: `flex-end`,
90
- },
91
- value: {
92
- color: `white`,
93
- fontSize: Dimensions.get(`screen`).width / 15,
94
- fontWeight: `bold`,
95
- textAlign: `right`,
96
- },
97
- unitContainer: {
98
- flex: 3,
99
- justifyContent: `flex-end`,
100
- paddingBottom: `3%`,
101
- },
102
- units: {
103
- color: `white`,
104
- fontSize: Dimensions.get(`screen`).width / 30,
105
- textAlign: `left`,
106
- paddingLeft: `5%`,
107
- },
108
- });
@@ -1,98 +0,0 @@
1
- import React from "react";
2
- import { StyleSheet, TextInput } from "react-native";
3
-
4
- interface IProps {
5
- startValue?: string;
6
- decimalPlaces: number;
7
- cleanPartialInput: boolean;
8
- negativeAllowed: boolean;
9
- maxLength?: number;
10
- testID: string;
11
- visible(toggle: () => void): void;
12
- onEnd?(value: number): void;
13
- partialInput?(value: string): void;
14
- }
15
-
16
- interface IState {
17
- value: string;
18
- }
19
-
20
- export default class InvisibleNumberInput extends React.Component<IProps, IState> {
21
- public textInput?: TextInput;
22
-
23
- public state: IState = {
24
- value: `0`,
25
- };
26
-
27
- public componentDidMount(): void {
28
- this.setState({
29
- value: this.props.startValue ?? `0`,
30
- });
31
- this.props.visible((): void => {
32
- this.setState({
33
- value: this.props.startValue ?? `0`,
34
- });
35
- return this.textInput?.focus();
36
- });
37
- }
38
-
39
- public cleanInput = (text: string): string => {
40
- const replaced = text.replace(/\,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
41
- const round = (value: string): string => {
42
- const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
43
- const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
44
- return rounded.toFixed(this.props.decimalPlaces);
45
- };
46
- if (!isNaN(Number(replaced))) {
47
- return round(replaced);
48
- }
49
- return `0`;
50
- };
51
-
52
- public handleOnChangeText = (text: string): void => {
53
- const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
54
- let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
55
- if (!this.props.negativeAllowed) {
56
- replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
57
- }
58
- this.setState({
59
- value: `${replacedSeparator}`,
60
- });
61
- this.props.partialInput?.(`${replacedSeparator}`);
62
- };
63
-
64
- public onEndEdit = (): void => {
65
- const cleaned = this.cleanInput(this.state.value);
66
- this.props.onEnd?.(Number(cleaned));
67
- };
68
-
69
- public render(): JSX.Element {
70
- const { testID } = this.props;
71
- return (
72
- <TextInput
73
- testID={testID}
74
- accessibilityLabel="InvisibleNumberInput"
75
- value={`${this.state.value}`}
76
- ref={(textInput): void => {
77
- if (textInput !== null) {
78
- this.textInput = textInput;
79
- }
80
- }}
81
- style={inputStyles.textInput}
82
- keyboardType="numeric"
83
- onChangeText={this.handleOnChangeText}
84
- onEndEditing={this.onEndEdit}
85
- maxLength={this.props.maxLength}
86
- selectTextOnFocus
87
- />
88
- );
89
- }
90
- }
91
-
92
- const inputStyles = StyleSheet.create({
93
- textInput: {
94
- width: 0,
95
- height: 0,
96
- padding: 0.2,
97
- },
98
- });
@@ -1,38 +0,0 @@
1
- import { t } from "@lingui/macro";
2
- import * as React from "react";
3
- import { Text, TouchableOpacity, View } from "react-native";
4
- import { i18n } from "../locale/i18nUtils";
5
- import { LimitationMessageTestIds } from "../types/enum";
6
- import { AttentionMessage } from "../utils/AttentionMessages";
7
- import { stylesModal } from "./RecommendationModal";
8
-
9
- export interface ILimitationMessageProps {
10
- limitationMessage: AttentionMessage | null;
11
- onPressNextButton(): void;
12
- }
13
-
14
- export default class LimitationMessage extends React.Component<ILimitationMessageProps> {
15
- public render = (): JSX.Element => {
16
- const { limitationMessage } = this.props;
17
- return (
18
- <React.Fragment>
19
- <View style={stylesModal.container}>
20
- <View style={stylesModal.titleContainer}>
21
- <Text style={stylesModal.textTittleMessage}>{i18n._(t`Attention`)}</Text>
22
- </View>
23
- <Text style={stylesModal.textMessage}>{limitationMessage}</Text>
24
- </View>
25
- <View style={stylesModal.containerAcceptButton}>
26
- <TouchableOpacity
27
- testID={LimitationMessageTestIds.OkButton}
28
- accessibilityLabel="nextButtonModal"
29
- style={stylesModal.okButton}
30
- onPress={this.props.onPressNextButton}
31
- >
32
- <Text style={stylesModal.buttonText}>{i18n._(t`OK`)}</Text>
33
- </TouchableOpacity>
34
- </View>
35
- </React.Fragment>
36
- );
37
- };
38
- }
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import { StyleSheet, View } from "react-native";
3
-
4
- interface IProps {
5
- color: string;
6
- }
7
-
8
- export default class LineSeparator extends React.Component<IProps> {
9
- public render(): JSX.Element {
10
- return (
11
- <React.Fragment>
12
- <View style={[lineSeparatorStyles.lineStyle, { borderBottomColor: this.props.color }]} />
13
- </React.Fragment>
14
- );
15
- }
16
- }
17
-
18
- const lineSeparatorStyles = StyleSheet.create({
19
- lineStyle: {
20
- marginHorizontal: `3%`,
21
- marginVertical: `2%`,
22
- borderBottomWidth: 1,
23
- },
24
- });
@@ -1,101 +0,0 @@
1
- import { t } from "@lingui/macro";
2
- import React from "react";
3
- import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
- import { i18n } from "../locale/i18nUtils";
5
- import { RecentInsulinTestIds } from "../types/enum";
6
- import { infoStyles } from "./InfoBars";
7
-
8
- interface IProps {
9
- onRecentInsulinYes(): void;
10
- onRecentInsulinNo(): void;
11
- }
12
-
13
- export default class RecentInsulin extends React.Component<IProps> {
14
- public render = (): JSX.Element => {
15
- return (
16
- <View style={recentInsulinStyles.container}>
17
- <View style={recentInsulinStyles.titleContainer}>
18
- <Text style={recentInsulinStyles.recommended}>{i18n._(t`Recommended amount of insulin`)}</Text>
19
- </View>
20
- <View style={recentInsulinStyles.takenInsulinContainer}>
21
- <Text style={recentInsulinStyles.takenInsulin}>
22
- {i18n._(t`Have you taken insulin within the last 4 hours?`)}
23
- </Text>
24
- </View>
25
- <View style={recentInsulinStyles.buttonContainer}>
26
- <View style={recentInsulinStyles.filler} />
27
- <TouchableOpacity
28
- testID={RecentInsulinTestIds.Yes}
29
- onPress={this.props.onRecentInsulinYes}
30
- style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}
31
- >
32
- <Text style={recentInsulinStyles.yesNoText}>{i18n._(t`Yes`)}</Text>
33
- </TouchableOpacity>
34
- <TouchableOpacity
35
- testID={RecentInsulinTestIds.No}
36
- onPress={this.props.onRecentInsulinNo}
37
- style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}
38
- >
39
- <Text style={recentInsulinStyles.yesNoText}>{i18n._(t`No`)}</Text>
40
- </TouchableOpacity>
41
- <View style={recentInsulinStyles.filler} />
42
- </View>
43
- </View>
44
- );
45
- };
46
- }
47
-
48
- const recentInsulinStyles = StyleSheet.create({
49
- container: {
50
- ...infoStyles.margin,
51
- backgroundColor: `rgba(118, 82, 255, 0.5)`,
52
- borderRadius: 5,
53
- },
54
- titleContainer: {
55
- flex: 1,
56
- justifyContent: `center`,
57
- alignItems: `center`,
58
- marginTop: `4%`,
59
- marginBottom: `4%`,
60
- },
61
- recommended: {
62
- ...infoStyles.label,
63
- },
64
- takenInsulinContainer: {
65
- flex: 1,
66
- justifyContent: `center`,
67
- alignItems: `center`,
68
- marginTop: `2%`,
69
- },
70
- takenInsulin: {
71
- ...infoStyles.label,
72
- fontSize: Dimensions.get(`screen`).width / 27,
73
- textAlign: `center`,
74
- },
75
- buttonContainer: {
76
- flex: 1,
77
- flexDirection: `row`,
78
- justifyContent: `space-evenly`,
79
- marginTop: `4%`,
80
- marginBottom: `5%`,
81
- },
82
- yesNoContainer: {
83
- flex: 1,
84
- borderColor: `white`,
85
- borderRadius: 100,
86
- borderWidth: 2,
87
- paddingHorizontal: `2%`,
88
- paddingVertical: `1%`,
89
- },
90
- yesNoText: {
91
- textAlign: `center`,
92
- paddingTop: `1%`,
93
- paddingBottom: `1%`,
94
- color: `white`,
95
- fontSize: Dimensions.get(`screen`).width / 25,
96
- fontWeight: `bold`,
97
- },
98
- filler: {
99
- flex: 1,
100
- },
101
- });