@hedia/recommendation-screen 1.1.0 → 1.1.1
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/App.jsx +91 -0
- package/index.d.ts +5 -0
- package/index.js +32 -0
- package/package.json +1 -1
- package/src/RecommendationScreen.d.ts +57 -0
- package/src/RecommendationScreen.jsx +194 -0
- package/src/components/Header.d.ts +48 -0
- package/src/components/Header.jsx +77 -0
- package/src/components/HediaRecommendationModal.d.ts +26 -0
- package/src/components/HediaRecommendationModal.jsx +207 -0
- package/src/components/InfoBars.d.ts +67 -0
- package/src/components/InfoBars.jsx +90 -0
- package/src/components/InvisibleNumberInput.d.ts +24 -0
- package/src/components/InvisibleNumberInput.jsx +64 -0
- package/src/components/RecentInsulin.d.ts +9 -0
- package/src/components/RecentInsulin.jsx +91 -0
- package/src/components/RecommendedCarbs.d.ts +30 -0
- package/src/components/RecommendedCarbs.jsx +193 -0
- package/src/components/RecommendedInsulin.d.ts +22 -0
- package/src/components/RecommendedInsulin.jsx +112 -0
- package/src/components/Remeasure.d.ts +13 -0
- package/src/components/Remeasure.jsx +90 -0
- package/src/components/TransferToLogbook.d.ts +14 -0
- package/src/components/TransferToLogbook.jsx +81 -0
- package/src/components/activity/Activity.d.ts +11 -0
- package/src/components/activity/Activity.jsx +68 -0
- package/src/components/activity/ActivityIcon.d.ts +7 -0
- package/src/components/activity/ActivityIcon.jsx +50 -0
- package/src/components/activity/ActivityIntensity.d.ts +5 -0
- package/src/components/activity/ActivityIntensity.jsx +67 -0
- package/src/components/mood/Emotion.d.ts +12 -0
- package/src/components/mood/Emotion.jsx +50 -0
- package/src/components/mood/MoodIcon.d.ts +14 -0
- package/src/components/mood/MoodIcon.jsx +53 -0
- package/src/locale/i18nUtils.d.ts +5 -0
- package/src/locale/i18nUtils.js +22 -0
- package/src/types/enum.d.ts +76 -0
- package/src/types/enum.js +89 -0
- package/src/types/types.d.ts +38 -0
- package/src/types/types.js +2 -0
- package/src/utils/AttentionMessages.d.ts +21 -0
- package/src/utils/AttentionMessages.js +62 -0
- package/src/utils/Constants.d.ts +18 -0
- package/src/utils/Constants.js +20 -0
- package/src/utils/RecommendationError.d.ts +23 -0
- package/src/utils/RecommendationError.js +34 -0
- package/src/utils/RecommendationUtils.d.ts +12 -0
- package/src/utils/RecommendationUtils.js +118 -0
- package/src/utils/Utils.d.ts +7 -0
- package/src/utils/Utils.js +30 -0
- package/src/utils/Validations.d.ts +22 -0
- package/src/utils/Validations.js +175 -0
package/App.jsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const RecommendationCalculator_1 = require("@hedia/recommendation-calculator/src/RecommendationCalculator");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const RecommendationScreen_1 = __importDefault(require("./src/RecommendationScreen"));
|
|
9
|
+
const enum_1 = require("./src/types/enum");
|
|
10
|
+
class App extends react_1.default.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.exitCallback = () => {
|
|
14
|
+
console.log(`Exiting...`);
|
|
15
|
+
};
|
|
16
|
+
this.removeCarbs = () => {
|
|
17
|
+
this.setState({
|
|
18
|
+
carbs: null,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
this.changeCarbs = (carbs) => {
|
|
22
|
+
this.setState({
|
|
23
|
+
carbs,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.onYes = () => {
|
|
27
|
+
console.log(`Navigate to recent bolus screen`);
|
|
28
|
+
};
|
|
29
|
+
this.updatedRecommendedInsulin = (val) => {
|
|
30
|
+
console.log(`Updated recommended insulin: `, val);
|
|
31
|
+
};
|
|
32
|
+
this.transferToLogbook = (...params) => {
|
|
33
|
+
console.log(`Transfered:`, params);
|
|
34
|
+
};
|
|
35
|
+
this.updateRemeasureTime = (remeasureTime) => {
|
|
36
|
+
console.log(`updateRemeasureTime:`, remeasureTime);
|
|
37
|
+
};
|
|
38
|
+
this.handleError = (error) => {
|
|
39
|
+
console.log(JSON.stringify(error));
|
|
40
|
+
switch (error.type) {
|
|
41
|
+
default:
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const params = {
|
|
46
|
+
currentBGL: 3,
|
|
47
|
+
carbohydrates: 120,
|
|
48
|
+
carbohydrateRatio: 22,
|
|
49
|
+
insulinSensitivity: 0.3,
|
|
50
|
+
targetBGL: 7,
|
|
51
|
+
recentBoluses: [],
|
|
52
|
+
activity: {
|
|
53
|
+
activityDate: new Date(Date.now() - enum_1.Milliseconds.Minute * 2),
|
|
54
|
+
activityDuration: 5,
|
|
55
|
+
activityIntensity: RecommendationCalculator_1.ActivityIntensity.Moderate,
|
|
56
|
+
activitySettings: {
|
|
57
|
+
hard: { fromZero: 0.25, fromThirty: 0.55, fromFortysix: 0 },
|
|
58
|
+
light: { fromZero: 0.25, fromThirty: 0.55, fromFortysix: 0.25 },
|
|
59
|
+
post: { fromZero: 1, fromThirty: 0, fromFortysix: 0.25 },
|
|
60
|
+
moderate: { fromZero: 0.25, fromThirty: 0.5, fromFortysix: 0.75 },
|
|
61
|
+
target: 8.3,
|
|
62
|
+
},
|
|
63
|
+
activityTitle: `Moderate Activity Test Title`,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
this.state = {
|
|
67
|
+
params,
|
|
68
|
+
carbs: 25,
|
|
69
|
+
injectionMethod: enum_1.InjectionMethod.Pump,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
const logbook1 = {
|
|
74
|
+
blood_glucose_millimolar: 15,
|
|
75
|
+
carbohydrates_entered_grams: 25,
|
|
76
|
+
carbohydrates_suggested_grams: 25,
|
|
77
|
+
client_timestamp: `25`,
|
|
78
|
+
client_version: 25,
|
|
79
|
+
entry_timestamp: `25`,
|
|
80
|
+
event_uuid: null,
|
|
81
|
+
insulin_entered_units: 25,
|
|
82
|
+
insulin_suggested_units: 25,
|
|
83
|
+
is_deleted: null,
|
|
84
|
+
mood: 2,
|
|
85
|
+
settings_uuid: `25`,
|
|
86
|
+
uuid: `aaa`,
|
|
87
|
+
};
|
|
88
|
+
return (<RecommendationScreen_1.default latestLogbookFrom6Hours={logbook1} language={enum_1.Languages.en} injectionMethod={this.state.injectionMethod} calculatorParams={this.state.params} userReminder={5} units={enum_1.BGUnit.MMOL_L} exitCallback={this.exitCallback} onRecentInsulinYes={this.onYes} transferToLogbook={this.transferToLogbook} onError={this.handleError} activityType={enum_1.ActivityEnum.Walking}/>);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.default = App;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import RecommendationScreen from "./src/RecommendationScreen";
|
|
2
|
+
import { ActivityEnum, RecommendationErrorEnum } from "./src/types/enum";
|
|
3
|
+
import * as Errors from "./src/utils/RecommendationError";
|
|
4
|
+
export default RecommendationScreen;
|
|
5
|
+
export { ActivityEnum, Errors, RecommendationErrorEnum };
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.RecommendationErrorEnum = exports.Errors = exports.ActivityEnum = void 0;
|
|
26
|
+
const RecommendationScreen_1 = __importDefault(require("./src/RecommendationScreen"));
|
|
27
|
+
const enum_1 = require("./src/types/enum");
|
|
28
|
+
Object.defineProperty(exports, "ActivityEnum", { enumerable: true, get: function () { return enum_1.ActivityEnum; } });
|
|
29
|
+
Object.defineProperty(exports, "RecommendationErrorEnum", { enumerable: true, get: function () { return enum_1.RecommendationErrorEnum; } });
|
|
30
|
+
const Errors = __importStar(require("./src/utils/RecommendationError"));
|
|
31
|
+
exports.Errors = Errors;
|
|
32
|
+
exports.default = RecommendationScreen_1.default;
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ActivityEnum, BGUnit, InjectionMethod, Languages, MoodEnum } from "./types/enum";
|
|
3
|
+
import * as Calculator from "@hedia/recommendation-calculator";
|
|
4
|
+
import { RecommendationError } from "./utils/RecommendationError";
|
|
5
|
+
import { IActivity, logbookEntry } from "./types/types";
|
|
6
|
+
import { AttentionMessage } from "./utils/AttentionMessages";
|
|
7
|
+
interface IResult {
|
|
8
|
+
suggested: number;
|
|
9
|
+
entered?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface IRecommendationProps {
|
|
12
|
+
units: BGUnit;
|
|
13
|
+
language: Languages;
|
|
14
|
+
userReminder: number;
|
|
15
|
+
calculatorParams: Calculator.IRecommendationParams & IActivity;
|
|
16
|
+
activityType: ActivityEnum;
|
|
17
|
+
injectionMethod: InjectionMethod;
|
|
18
|
+
latestLogbookFrom6Hours: logbookEntry;
|
|
19
|
+
exitCallback(): void;
|
|
20
|
+
onRecentInsulinYes(): void;
|
|
21
|
+
transferToLogbook(carbs: IResult, insulin: IResult, reminder: number): void;
|
|
22
|
+
onError(error: RecommendationError): void;
|
|
23
|
+
}
|
|
24
|
+
interface IState {
|
|
25
|
+
remeasureTime: number;
|
|
26
|
+
showRecentInsulin: boolean;
|
|
27
|
+
insulinRecommendation: number;
|
|
28
|
+
activityReduction?: number;
|
|
29
|
+
wasLimited: boolean;
|
|
30
|
+
carbRecommendation: number;
|
|
31
|
+
bolus: number;
|
|
32
|
+
activeInsulin: number;
|
|
33
|
+
selectedMood?: MoodEnum;
|
|
34
|
+
enteredCarbs?: number;
|
|
35
|
+
enteredInsulin?: number;
|
|
36
|
+
recommendationModal: boolean;
|
|
37
|
+
}
|
|
38
|
+
export default class RecommendationScreen extends React.Component<IRecommendationProps, IState> {
|
|
39
|
+
private readonly timer;
|
|
40
|
+
private readonly suggestedCarbs;
|
|
41
|
+
private scrollView;
|
|
42
|
+
constructor(props: IRecommendationProps);
|
|
43
|
+
updateRemeasureTime: (remeasureTime: number) => void;
|
|
44
|
+
handleNoRecentInsulin: () => void;
|
|
45
|
+
updateCarbRecommendation: (enteredCarbs: number) => void;
|
|
46
|
+
removeCarbRecommendation: () => void;
|
|
47
|
+
declineCarbRecommendation: () => void;
|
|
48
|
+
hideAttentionModal: () => void;
|
|
49
|
+
handleMoodSelected: (selectedMood: IState["selectedMood"]) => void;
|
|
50
|
+
updateInsulinRecommendation: (enteredInsulin: number) => void;
|
|
51
|
+
handleTransfer: () => void;
|
|
52
|
+
getBGLevelAttentionMessage: () => AttentionMessage;
|
|
53
|
+
getBGLevelRemeasurementReminder: () => number;
|
|
54
|
+
getLimitationAttentionMessage: () => AttentionMessage;
|
|
55
|
+
render(): JSX.Element;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const react_1 = __importDefault(require("react"));
|
|
26
|
+
const react_native_1 = require("react-native");
|
|
27
|
+
const enum_1 = require("./types/enum");
|
|
28
|
+
const Constants_1 = require("./utils/Constants");
|
|
29
|
+
const Header_1 = __importStar(require("./components/Header"));
|
|
30
|
+
const InfoBars_1 = __importStar(require("./components/InfoBars"));
|
|
31
|
+
const RecentInsulin_1 = __importDefault(require("./components/RecentInsulin"));
|
|
32
|
+
const RecommendedCarbs_1 = __importDefault(require("./components/RecommendedCarbs"));
|
|
33
|
+
const RecommendedInsulin_1 = __importDefault(require("./components/RecommendedInsulin"));
|
|
34
|
+
const Remeasure_1 = __importDefault(require("./components/Remeasure"));
|
|
35
|
+
const Calculator = __importStar(require("@hedia/recommendation-calculator"));
|
|
36
|
+
const react_2 = require("@lingui/react");
|
|
37
|
+
const Emotion_1 = __importDefault(require("./components/mood/Emotion"));
|
|
38
|
+
const TransferToLogbook_1 = __importDefault(require("./components/TransferToLogbook"));
|
|
39
|
+
const RecommendationError_1 = require("./utils/RecommendationError");
|
|
40
|
+
const macro_1 = require("@lingui/macro");
|
|
41
|
+
const Activity_1 = __importDefault(require("./components/activity/Activity"));
|
|
42
|
+
const HediaRecommendationModal_1 = __importDefault(require("./components/HediaRecommendationModal"));
|
|
43
|
+
const i18nUtils_1 = require("./locale/i18nUtils");
|
|
44
|
+
const RecommendationUtils_1 = require("./utils/RecommendationUtils");
|
|
45
|
+
const Utils_1 = require("./utils/Utils");
|
|
46
|
+
const Validations_1 = require("./utils/Validations");
|
|
47
|
+
// Ignoring long timer warnings
|
|
48
|
+
// https://github.com/facebook/react-native/issues/12981#issuecomment-652745831
|
|
49
|
+
react_native_1.YellowBox.ignoreWarnings([`Setting a timer`]);
|
|
50
|
+
class RecommendationScreen extends react_1.default.Component {
|
|
51
|
+
constructor(props) {
|
|
52
|
+
super(props);
|
|
53
|
+
this.updateRemeasureTime = (remeasureTime) => {
|
|
54
|
+
this.setState({ remeasureTime });
|
|
55
|
+
};
|
|
56
|
+
this.handleNoRecentInsulin = () => {
|
|
57
|
+
this.setState({
|
|
58
|
+
showRecentInsulin: false,
|
|
59
|
+
}, () => {
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
this.scrollView?.scrollToEnd({
|
|
62
|
+
animated: true,
|
|
63
|
+
});
|
|
64
|
+
}, 0);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
this.updateCarbRecommendation = (enteredCarbs) => {
|
|
68
|
+
this.setState({ enteredCarbs });
|
|
69
|
+
};
|
|
70
|
+
this.removeCarbRecommendation = () => {
|
|
71
|
+
this.setState({
|
|
72
|
+
enteredCarbs: null,
|
|
73
|
+
carbRecommendation: null,
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
this.declineCarbRecommendation = () => {
|
|
77
|
+
this.removeCarbRecommendation();
|
|
78
|
+
this.hideAttentionModal();
|
|
79
|
+
};
|
|
80
|
+
this.hideAttentionModal = () => {
|
|
81
|
+
this.setState({ recommendationModal: false });
|
|
82
|
+
};
|
|
83
|
+
this.handleMoodSelected = (selectedMood) => {
|
|
84
|
+
this.setState({
|
|
85
|
+
selectedMood,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
this.updateInsulinRecommendation = (enteredInsulin) => {
|
|
89
|
+
this.setState({
|
|
90
|
+
enteredInsulin,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
this.handleTransfer = () => {
|
|
94
|
+
this.props.transferToLogbook({
|
|
95
|
+
suggested: this.suggestedCarbs,
|
|
96
|
+
entered: this.state.enteredCarbs,
|
|
97
|
+
}, {
|
|
98
|
+
suggested: this.state.insulinRecommendation,
|
|
99
|
+
entered: this.state.enteredInsulin,
|
|
100
|
+
}, this.state.remeasureTime);
|
|
101
|
+
clearTimeout(this.timer);
|
|
102
|
+
};
|
|
103
|
+
this.getBGLevelAttentionMessage = () => {
|
|
104
|
+
const { calculatorParams, latestLogbookFrom6Hours } = this.props;
|
|
105
|
+
const { currentBGL, activity } = calculatorParams;
|
|
106
|
+
const bgLevel = RecommendationUtils_1.getBGLevel(currentBGL, latestLogbookFrom6Hours);
|
|
107
|
+
return RecommendationUtils_1.getAttentionMessage(bgLevel, activity);
|
|
108
|
+
};
|
|
109
|
+
this.getBGLevelRemeasurementReminder = () => {
|
|
110
|
+
const { calculatorParams, userReminder, latestLogbookFrom6Hours } = this.props;
|
|
111
|
+
const { currentBGL, activity, carbohydrates } = calculatorParams;
|
|
112
|
+
const bgLevel = RecommendationUtils_1.getBGLevel(currentBGL, latestLogbookFrom6Hours);
|
|
113
|
+
return RecommendationUtils_1.getReminder(bgLevel, carbohydrates, userReminder, activity);
|
|
114
|
+
};
|
|
115
|
+
this.getLimitationAttentionMessage = () => {
|
|
116
|
+
const { wasLimited, activityReduction } = this.state;
|
|
117
|
+
return RecommendationUtils_1.getLimitationMessage(wasLimited, activityReduction);
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
Validations_1.validateParams(props);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
props.onError(error);
|
|
124
|
+
}
|
|
125
|
+
i18nUtils_1.changeLanguage(props.language);
|
|
126
|
+
const { recentBoluses } = props?.calculatorParams;
|
|
127
|
+
const { bolus, carbRecommendation, activityReduction, wasLimited } = Calculator.calculateRecommendation(RecommendationUtils_1.getParams(this.props));
|
|
128
|
+
this.suggestedCarbs = carbRecommendation;
|
|
129
|
+
const activeInsulin = Calculator.calculateActiveInsulin(recentBoluses ?? []);
|
|
130
|
+
this.state = {
|
|
131
|
+
remeasureTime: this.getBGLevelRemeasurementReminder(),
|
|
132
|
+
showRecentInsulin: recentBoluses?.length === 0,
|
|
133
|
+
insulinRecommendation: Utils_1.Utils.roundValue(bolus, props.injectionMethod),
|
|
134
|
+
wasLimited,
|
|
135
|
+
activityReduction,
|
|
136
|
+
bolus,
|
|
137
|
+
carbRecommendation,
|
|
138
|
+
activeInsulin,
|
|
139
|
+
selectedMood: null,
|
|
140
|
+
recommendationModal: wasLimited || !!carbRecommendation || !!this.getBGLevelAttentionMessage(),
|
|
141
|
+
};
|
|
142
|
+
this.timer = setTimeout(() => {
|
|
143
|
+
props.onError(RecommendationError_1.TimeoutLimitError());
|
|
144
|
+
}, enum_1.Milliseconds.Minute * 15);
|
|
145
|
+
}
|
|
146
|
+
render() {
|
|
147
|
+
const { activeInsulin, recommendationModal, carbRecommendation, enteredCarbs } = this.state;
|
|
148
|
+
const { calculatorParams } = this.props;
|
|
149
|
+
const { currentBGL, carbohydrates } = calculatorParams;
|
|
150
|
+
return (<react_2.I18nProvider language={this.props.language} i18n={i18nUtils_1.i18n}>
|
|
151
|
+
<react_native_1.ScrollView style={containerStyles.container} ref={(view) => (this.scrollView = view)}>
|
|
152
|
+
<Header_1.default exitCallback={this.props.exitCallback}/>
|
|
153
|
+
<InfoBars_1.default label={i18nUtils_1.i18n._(macro_1.t `Active Insulin`)} value={activeInsulin ? `${activeInsulin.toFixed(1)}` : null} units={i18nUtils_1.i18n._(macro_1.t `units`)} showZeroAsDash={false}/>
|
|
154
|
+
<InfoBars_1.default label={i18nUtils_1.i18n._(macro_1.t `Blood Glucose Level`)} value={currentBGL ? `${currentBGL}` : null} units={this.props.units} showZeroAsDash={true}/>
|
|
155
|
+
<react_native_1.View style={containerStyles.calcContainer}>
|
|
156
|
+
<react_native_1.View style={containerStyles.calcMargin}>
|
|
157
|
+
<react_native_1.View style={[
|
|
158
|
+
containerStyles.calcBorder,
|
|
159
|
+
{
|
|
160
|
+
borderColor: carbRecommendation ? Constants_1.BORDER_COLOUR_TEAL : Constants_1.BORDER_COLOUR_GREY,
|
|
161
|
+
},
|
|
162
|
+
]}>
|
|
163
|
+
<RecommendedCarbs_1.default enteredCarbs={`${carbohydrates}`} changedRecommendedCarbs={this.updateCarbRecommendation} recommendedCarbs={`${enteredCarbs ?? carbRecommendation}`} removeRecommendedCarbs={this.removeCarbRecommendation} onError={this.props.onError}/>
|
|
164
|
+
<Remeasure_1.default onSliderChange={this.updateRemeasureTime} remeasureTime={this.state.remeasureTime}/>
|
|
165
|
+
</react_native_1.View>
|
|
166
|
+
</react_native_1.View>
|
|
167
|
+
</react_native_1.View>
|
|
168
|
+
{this.props.calculatorParams.activity && this.props.activityType !== null ? (<Activity_1.default activity={this.props.calculatorParams.activity} activityType={this.props.activityType} activityReduction={this.state.activityReduction}/>) : null}
|
|
169
|
+
{this.state.showRecentInsulin ? (<RecentInsulin_1.default onRecentInsulinYes={this.props.onRecentInsulinYes} onRecentInsulinNo={this.handleNoRecentInsulin}/>) : (<RecommendedInsulin_1.default injectionMethod={this.props.injectionMethod} insulinRecommendation={this.state.enteredInsulin ?? this.state.insulinRecommendation} activityReduction={this.state.activityReduction} updateRecommendedInsulin={this.updateInsulinRecommendation} onError={this.props.onError}/>)}
|
|
170
|
+
<Emotion_1.default moodSelected={this.handleMoodSelected} currentMood={this.state.selectedMood}/>
|
|
171
|
+
<TransferToLogbook_1.default visible={!this.state.showRecentInsulin} transfer={this.handleTransfer}/>
|
|
172
|
+
<HediaRecommendationModal_1.default isVisible={recommendationModal} suggestedCarbohydrates={carbRecommendation} attentionMessage={this.getBGLevelAttentionMessage()} limitationMessage={this.getLimitationAttentionMessage()} onClickOkButton={this.hideAttentionModal} onAcceptCarbohydrates={this.hideAttentionModal} onDeclineCarbohydrates={this.declineCarbRecommendation}/>
|
|
173
|
+
</react_native_1.ScrollView>
|
|
174
|
+
</react_2.I18nProvider>);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.default = RecommendationScreen;
|
|
178
|
+
const containerStyles = react_native_1.StyleSheet.create({
|
|
179
|
+
container: {
|
|
180
|
+
flex: 1,
|
|
181
|
+
backgroundColor: Constants_1.BACKGROUND_COLOUR_PURPLE,
|
|
182
|
+
},
|
|
183
|
+
calcContainer: {
|
|
184
|
+
flex: 1,
|
|
185
|
+
},
|
|
186
|
+
calcMargin: {
|
|
187
|
+
flex: 1,
|
|
188
|
+
margin: Header_1.headerStyles.margin.margin,
|
|
189
|
+
},
|
|
190
|
+
calcBorder: {
|
|
191
|
+
...InfoBars_1.infoStyles.border,
|
|
192
|
+
borderColor: Constants_1.BORDER_COLOUR_TEAL,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IRecommendationProps } from "../RecommendationScreen";
|
|
3
|
+
interface IProps {
|
|
4
|
+
exitCallback: IRecommendationProps["exitCallback"];
|
|
5
|
+
}
|
|
6
|
+
export default class Header extends React.Component<IProps> {
|
|
7
|
+
render(): JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
export declare const headerStyles: {
|
|
10
|
+
backgroundColour: {
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
};
|
|
13
|
+
margin: {
|
|
14
|
+
margin: string;
|
|
15
|
+
flexDirection: "row";
|
|
16
|
+
flex: number;
|
|
17
|
+
};
|
|
18
|
+
headerContainer: {
|
|
19
|
+
flexDirection: "row";
|
|
20
|
+
flex: number;
|
|
21
|
+
};
|
|
22
|
+
exitButtonContainer: {
|
|
23
|
+
flex: number;
|
|
24
|
+
};
|
|
25
|
+
exitButton: {
|
|
26
|
+
flex: number;
|
|
27
|
+
};
|
|
28
|
+
iconStyle: {
|
|
29
|
+
fontSize: number;
|
|
30
|
+
color: string;
|
|
31
|
+
};
|
|
32
|
+
headerTextContainer: {
|
|
33
|
+
flex: number;
|
|
34
|
+
justifyContent: "center";
|
|
35
|
+
alignItems: "center";
|
|
36
|
+
marginTop: string;
|
|
37
|
+
};
|
|
38
|
+
headerText: {
|
|
39
|
+
fontSize: number;
|
|
40
|
+
fontWeight: "bold";
|
|
41
|
+
textAlign: "center";
|
|
42
|
+
color: string;
|
|
43
|
+
};
|
|
44
|
+
headerFiller: {
|
|
45
|
+
flex: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.headerStyles = void 0;
|
|
7
|
+
const macro_1 = require("@lingui/macro");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_native_1 = require("react-native");
|
|
10
|
+
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
11
|
+
const Constants_1 = require("../utils/Constants");
|
|
12
|
+
const Icon_1 = __importDefault(require("./Icon"));
|
|
13
|
+
class Header extends react_1.default.Component {
|
|
14
|
+
render() {
|
|
15
|
+
return (<react_1.default.Fragment>
|
|
16
|
+
<react_native_1.SafeAreaView style={exports.headerStyles.backgroundColour}/>
|
|
17
|
+
<react_native_1.View style={exports.headerStyles.headerContainer}>
|
|
18
|
+
<react_native_1.View style={exports.headerStyles.margin}>
|
|
19
|
+
<react_native_1.View style={exports.headerStyles.exitButtonContainer}>
|
|
20
|
+
<react_native_1.View style={exports.headerStyles.exitButton}>
|
|
21
|
+
<react_native_1.TouchableOpacity accessibilityLabel="exitButton" style={exports.headerStyles.exitButton} onPress={this.props.exitCallback}>
|
|
22
|
+
<Icon_1.default iconIdentifier={`Ionicons/ios-close-circle-outline`} style={exports.headerStyles.iconStyle}/>
|
|
23
|
+
</react_native_1.TouchableOpacity>
|
|
24
|
+
<react_native_1.View style={exports.headerStyles.headerFiller}/>
|
|
25
|
+
</react_native_1.View>
|
|
26
|
+
</react_native_1.View>
|
|
27
|
+
<react_native_1.View style={exports.headerStyles.headerTextContainer}>
|
|
28
|
+
<react_native_1.Text style={exports.headerStyles.headerText} testID="headerText">
|
|
29
|
+
{i18nUtils_1.i18n._(macro_1.t `INSULIN${`\n`}RECOMMENDATION`)}
|
|
30
|
+
</react_native_1.Text>
|
|
31
|
+
</react_native_1.View>
|
|
32
|
+
<react_native_1.View style={exports.headerStyles.headerFiller}/>
|
|
33
|
+
</react_native_1.View>
|
|
34
|
+
</react_native_1.View>
|
|
35
|
+
</react_1.default.Fragment>);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = Header;
|
|
39
|
+
exports.headerStyles = react_native_1.StyleSheet.create({
|
|
40
|
+
backgroundColour: {
|
|
41
|
+
backgroundColor: Constants_1.BACKGROUND_COLOUR_PURPLE,
|
|
42
|
+
},
|
|
43
|
+
margin: {
|
|
44
|
+
margin: `3%`,
|
|
45
|
+
flexDirection: `row`,
|
|
46
|
+
flex: 1,
|
|
47
|
+
},
|
|
48
|
+
headerContainer: {
|
|
49
|
+
flexDirection: `row`,
|
|
50
|
+
flex: 1,
|
|
51
|
+
},
|
|
52
|
+
exitButtonContainer: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
},
|
|
55
|
+
exitButton: {
|
|
56
|
+
flex: 1,
|
|
57
|
+
},
|
|
58
|
+
iconStyle: {
|
|
59
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 10,
|
|
60
|
+
color: Constants_1.BORDER_COLOUR_GREY,
|
|
61
|
+
},
|
|
62
|
+
headerTextContainer: {
|
|
63
|
+
flex: 6,
|
|
64
|
+
justifyContent: `center`,
|
|
65
|
+
alignItems: `center`,
|
|
66
|
+
marginTop: `5%`,
|
|
67
|
+
},
|
|
68
|
+
headerText: {
|
|
69
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 14,
|
|
70
|
+
fontWeight: `bold`,
|
|
71
|
+
textAlign: `center`,
|
|
72
|
+
color: `white`,
|
|
73
|
+
},
|
|
74
|
+
headerFiller: {
|
|
75
|
+
flex: 1,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
3
|
+
interface IModalProps {
|
|
4
|
+
isVisible: boolean;
|
|
5
|
+
suggestedCarbohydrates?: number;
|
|
6
|
+
attentionMessage: AttentionMessage;
|
|
7
|
+
limitationMessage: AttentionMessage;
|
|
8
|
+
onClickOkButton(): void;
|
|
9
|
+
onAcceptCarbohydrates(): void;
|
|
10
|
+
onDeclineCarbohydrates(): void;
|
|
11
|
+
}
|
|
12
|
+
interface IModalState {
|
|
13
|
+
firstPageVisible: boolean;
|
|
14
|
+
}
|
|
15
|
+
export default class HediaRecommendationModal extends React.Component<IModalProps, IModalState> {
|
|
16
|
+
constructor(props: IModalProps);
|
|
17
|
+
okayButton(): JSX.Element;
|
|
18
|
+
nextButton(): JSX.Element;
|
|
19
|
+
onPressNextButton: () => void;
|
|
20
|
+
recommendationButtons: () => JSX.Element;
|
|
21
|
+
recommendCarbohydrates: () => JSX.Element;
|
|
22
|
+
secondPage: () => JSX.Element;
|
|
23
|
+
firstPage: () => JSX.Element;
|
|
24
|
+
render(): JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
export {};
|