@hedia/recommendation-screen 1.0.7 → 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 +36 -15
- package/android/app/src/main/res/values/color.xml +3 -0
- package/android/app/src/main/res/values/styles.xml +3 -0
- package/index.d.ts +3 -3
- package/index.js +23 -7
- package/index.ts +3 -16
- package/ios/HediaRecommendationScreen/Info.plist +80 -57
- package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +1085 -807
- package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Podfile +106 -104
- package/ios/Podfile.lock +474 -0
- package/jest.mock.js +1 -0
- package/package.json +9 -2
- package/src/RecommendationScreen.d.ts +19 -5
- package/src/RecommendationScreen.jsx +69 -33
- package/src/RecommendationScreen.tsx +130 -60
- package/src/assets/activity/Cyclist.png +0 -0
- package/src/assets/activity/Other.png +0 -0
- package/src/assets/activity/Runner.png +0 -0
- package/src/assets/activity/Swimmer.png +0 -0
- package/src/assets/activity/Walk.png +0 -0
- package/src/components/Header.d.ts +1 -5
- package/src/components/Header.jsx +4 -9
- package/src/components/Header.tsx +7 -14
- package/src/components/HediaRecommendationModal.d.ts +26 -0
- package/src/components/HediaRecommendationModal.jsx +207 -0
- package/src/components/HediaRecommendationModal.tsx +231 -0
- package/src/components/InfoBars.jsx +1 -1
- package/src/components/InfoBars.tsx +3 -3
- package/src/components/InvisibleNumberInput.tsx +7 -7
- package/src/components/RecentInsulin.jsx +5 -4
- package/src/components/RecentInsulin.tsx +6 -5
- package/src/components/RecommendedCarbs.jsx +17 -17
- package/src/components/RecommendedCarbs.tsx +24 -24
- package/src/components/RecommendedInsulin.jsx +12 -9
- package/src/components/RecommendedInsulin.tsx +18 -15
- package/src/components/Remeasure.jsx +7 -5
- package/src/components/Remeasure.tsx +15 -13
- package/src/components/TransferToLogbook.jsx +4 -3
- package/src/components/TransferToLogbook.tsx +6 -4
- package/src/components/activity/Activity.d.ts +11 -0
- package/src/components/activity/Activity.jsx +68 -0
- package/src/components/activity/Activity.tsx +74 -0
- package/src/components/activity/ActivityIcon.d.ts +7 -0
- package/src/components/activity/ActivityIcon.jsx +50 -0
- package/src/components/activity/ActivityIcon.tsx +52 -0
- package/src/components/activity/ActivityIntensity.d.ts +5 -0
- package/src/components/activity/ActivityIntensity.jsx +67 -0
- package/src/components/activity/ActivityIntensity.tsx +66 -0
- package/src/components/mood/Emotion.d.ts +12 -0
- package/src/components/{Emotion.jsx → mood/Emotion.jsx} +12 -16
- package/src/components/mood/Emotion.tsx +64 -0
- package/src/components/{MoodIcon.d.ts → mood/MoodIcon.d.ts} +1 -1
- package/src/components/{MoodIcon.jsx → mood/MoodIcon.jsx} +15 -15
- package/src/components/{MoodIcon.tsx → mood/MoodIcon.tsx} +17 -17
- package/src/locale/da/messages.js +1 -1
- package/src/locale/da/messages.po +191 -49
- package/src/locale/en/messages.js +1 -1
- package/src/locale/en/messages.po +193 -51
- package/src/types/enum.d.ts +48 -6
- package/src/types/enum.js +53 -7
- package/src/types/enum.ts +48 -3
- package/src/types/types.d.ts +18 -1
- package/src/types/types.ts +21 -1
- package/src/utils/AttentionMessages.d.ts +21 -0
- package/src/utils/AttentionMessages.js +62 -0
- package/src/utils/AttentionMessages.ts +59 -0
- package/src/utils/Constants.d.ts +16 -1
- package/src/utils/Constants.js +16 -2
- package/src/utils/Constants.ts +20 -1
- package/src/utils/RecommendationError.d.ts +18 -6
- package/src/utils/RecommendationError.js +23 -7
- package/src/utils/RecommendationError.ts +114 -28
- package/src/utils/RecommendationUtils.d.ts +12 -0
- package/src/utils/RecommendationUtils.js +118 -0
- package/src/utils/RecommendationUtils.ts +128 -0
- package/src/utils/Utils.d.ts +3 -1
- package/src/utils/Utils.js +6 -0
- package/src/utils/Utils.ts +13 -5
- package/src/utils/Validations.d.ts +22 -0
- package/src/utils/Validations.js +175 -0
- package/src/utils/Validations.ts +210 -0
- package/src/components/Emotion.d.ts +0 -14
- package/src/components/Emotion.tsx +0 -70
- /package/src/assets/{happy.png → mood/happy.png} +0 -0
- /package/src/assets/{happy_active.png → mood/happy_active.png} +0 -0
- /package/src/assets/{neutral.png → mood/neutral.png} +0 -0
- /package/src/assets/{neutral_active.png → mood/neutral_active.png} +0 -0
- /package/src/assets/{sad.png → mood/sad.png} +0 -0
- /package/src/assets/{sad_active.png → mood/sad_active.png} +0 -0
- /package/src/assets/{semi_happy.png → mood/semi_happy.png} +0 -0
- /package/src/assets/{semi_happy_active.png → mood/semi_happy_active.png} +0 -0
- /package/src/assets/{semi_sad.png → mood/semi_sad.png} +0 -0
- /package/src/assets/{semi_sad_active.png → mood/semi_sad_active.png} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 macro_1 = require("@lingui/macro");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
10
|
+
const InfoBars_1 = require("../InfoBars");
|
|
11
|
+
const ActivityIcon_1 = __importDefault(require("./ActivityIcon"));
|
|
12
|
+
const ActivityIntensity_1 = __importDefault(require("./ActivityIntensity"));
|
|
13
|
+
class Activity extends react_1.default.Component {
|
|
14
|
+
render() {
|
|
15
|
+
const { activity, activityType, activityReduction } = this.props;
|
|
16
|
+
const reductionPercentage = (activityReduction * 100).toFixed(0);
|
|
17
|
+
return (<react_native_1.View style={[InfoBars_1.infoStyles.container, activityStyles.botMargin]}>
|
|
18
|
+
<react_native_1.View style={InfoBars_1.infoStyles.margin}>
|
|
19
|
+
<react_native_1.View style={InfoBars_1.infoStyles.border}>
|
|
20
|
+
<react_native_1.View style={InfoBars_1.infoStyles.borderContainer}>
|
|
21
|
+
<react_native_1.View style={InfoBars_1.infoStyles.labelContainer}>
|
|
22
|
+
<react_native_1.Text style={InfoBars_1.infoStyles.label}>{i18nUtils_1.i18n._(macro_1.t `Activity`)}</react_native_1.Text>
|
|
23
|
+
</react_native_1.View>
|
|
24
|
+
<react_native_1.View style={InfoBars_1.infoStyles.valueUnitContainer}>
|
|
25
|
+
<react_native_1.View style={InfoBars_1.infoStyles.valueContainer}>
|
|
26
|
+
<react_native_1.Text style={InfoBars_1.infoStyles.value}>{activity.activityDuration}</react_native_1.Text>
|
|
27
|
+
</react_native_1.View>
|
|
28
|
+
<react_native_1.View style={InfoBars_1.infoStyles.unitContainer}>
|
|
29
|
+
<react_native_1.Text style={InfoBars_1.infoStyles.units}>{i18nUtils_1.i18n._(macro_1.t `min`)}</react_native_1.Text>
|
|
30
|
+
</react_native_1.View>
|
|
31
|
+
</react_native_1.View>
|
|
32
|
+
</react_native_1.View>
|
|
33
|
+
<ActivityIcon_1.default activityType={activityType} activityTitle={activity.activityTitle}/>
|
|
34
|
+
<ActivityIntensity_1.default activityIntensity={activity.activityIntensity}/>
|
|
35
|
+
<react_native_1.View style={[InfoBars_1.infoStyles.borderContainer, activityStyles.topMargin]}>
|
|
36
|
+
<react_native_1.Text style={activityStyles.infoText}>
|
|
37
|
+
{i18nUtils_1.i18n._(macro_1.t `Based on the selected activity your insulin recommendation is reduced by:`)}
|
|
38
|
+
</react_native_1.Text>
|
|
39
|
+
</react_native_1.View>
|
|
40
|
+
<react_native_1.View style={[InfoBars_1.infoStyles.borderContainer, activityStyles.verticalMargin]}>
|
|
41
|
+
<react_native_1.Text style={activityStyles.reductionPercentage}>{reductionPercentage}%</react_native_1.Text>
|
|
42
|
+
</react_native_1.View>
|
|
43
|
+
</react_native_1.View>
|
|
44
|
+
</react_native_1.View>
|
|
45
|
+
</react_native_1.View>);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = Activity;
|
|
49
|
+
const activityStyles = react_native_1.StyleSheet.create({
|
|
50
|
+
topMargin: {
|
|
51
|
+
marginTop: `2%`,
|
|
52
|
+
},
|
|
53
|
+
botMargin: {
|
|
54
|
+
marginBottom: `2%`,
|
|
55
|
+
},
|
|
56
|
+
verticalMargin: {
|
|
57
|
+
marginBottom: `2%`,
|
|
58
|
+
},
|
|
59
|
+
infoText: {
|
|
60
|
+
color: `rgba(160, 180, 240, 1)`,
|
|
61
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 24,
|
|
62
|
+
},
|
|
63
|
+
reductionPercentage: {
|
|
64
|
+
color: `white`,
|
|
65
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 18,
|
|
66
|
+
fontWeight: `bold`,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IRecommendationParams } from "@hedia/recommendation-calculator";
|
|
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 { IActivityTitle, IActivityType } from "../../types/types";
|
|
7
|
+
import { infoStyles } from "../InfoBars";
|
|
8
|
+
import ActivityIcon from "./ActivityIcon";
|
|
9
|
+
import ActivityIntensity from "./ActivityIntensity";
|
|
10
|
+
|
|
11
|
+
interface IProps extends IActivityType {
|
|
12
|
+
activity: IRecommendationParams["activity"] & IActivityTitle;
|
|
13
|
+
activityReduction: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default class Activity extends React.Component<IProps> {
|
|
17
|
+
public render(): JSX.Element {
|
|
18
|
+
const { activity, activityType, activityReduction } = this.props;
|
|
19
|
+
const reductionPercentage = (activityReduction * 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={activity.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}>{reductionPercentage}%</Text>
|
|
47
|
+
</View>
|
|
48
|
+
</View>
|
|
49
|
+
</View>
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const activityStyles = StyleSheet.create({
|
|
56
|
+
topMargin: {
|
|
57
|
+
marginTop: `2%`,
|
|
58
|
+
},
|
|
59
|
+
botMargin: {
|
|
60
|
+
marginBottom: `2%`,
|
|
61
|
+
},
|
|
62
|
+
verticalMargin: {
|
|
63
|
+
marginBottom: `2%`,
|
|
64
|
+
},
|
|
65
|
+
infoText: {
|
|
66
|
+
color: `rgba(160, 180, 240, 1)`,
|
|
67
|
+
fontSize: Dimensions.get(`screen`).width / 24,
|
|
68
|
+
},
|
|
69
|
+
reductionPercentage: {
|
|
70
|
+
color: `white`,
|
|
71
|
+
fontSize: Dimensions.get(`screen`).width / 18,
|
|
72
|
+
fontWeight: `bold`,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ImageURISource } from "react-native";
|
|
3
|
+
import { IActivityTitle, IActivityType } from "../../types/types";
|
|
4
|
+
export default class ActivityIcon extends React.Component<IActivityType & IActivityTitle> {
|
|
5
|
+
getActivityIcon: () => ImageURISource;
|
|
6
|
+
render(): JSX.Element;
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 macro_1 = require("@lingui/macro");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
10
|
+
const enum_1 = require("../../types/enum");
|
|
11
|
+
const ACTIVITY_ICONS = {
|
|
12
|
+
0: require(`../../assets/activity/Runner.png`),
|
|
13
|
+
1: require(`../../assets/activity/Walk.png`),
|
|
14
|
+
2: require(`../../assets/activity/Cyclist.png`),
|
|
15
|
+
3: require(`../../assets/activity/Swimmer.png`),
|
|
16
|
+
4: require(`../../assets/activity/Other.png`),
|
|
17
|
+
};
|
|
18
|
+
class ActivityIcon extends react_1.default.Component {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.getActivityIcon = () => {
|
|
22
|
+
return ACTIVITY_ICONS[this.props.activityType];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const { activityType, activityTitle } = this.props;
|
|
27
|
+
const label = `${enum_1.ActivityEnum[activityType]}_activity`;
|
|
28
|
+
return (<react_native_1.View style={activityIconStyles.container}>
|
|
29
|
+
<react_native_1.Image style={activityIconStyles.activityIcon} source={this.getActivityIcon()} accessibilityLabel={label}/>
|
|
30
|
+
<react_native_1.Text style={activityIconStyles.activityTitle}>{activityTitle ?? i18nUtils_1.i18n._(macro_1.t `Untitled Activity`)}</react_native_1.Text>
|
|
31
|
+
</react_native_1.View>);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = ActivityIcon;
|
|
35
|
+
const activityIconStyles = react_native_1.StyleSheet.create({
|
|
36
|
+
container: {
|
|
37
|
+
flex: 1,
|
|
38
|
+
flexDirection: `row`,
|
|
39
|
+
alignItems: `center`,
|
|
40
|
+
marginTop: `1%`,
|
|
41
|
+
},
|
|
42
|
+
activityIcon: {
|
|
43
|
+
resizeMode: `contain`,
|
|
44
|
+
height: react_native_1.Dimensions.get(`screen`).width / 16,
|
|
45
|
+
},
|
|
46
|
+
activityTitle: {
|
|
47
|
+
color: `white`,
|
|
48
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 25,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { t } from "@lingui/macro";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Dimensions, Image, ImageURISource, StyleSheet, Text, View } from "react-native";
|
|
4
|
+
import { i18n } from "../../locale/i18nUtils";
|
|
5
|
+
import { ActivityEnum } from "../../types/enum";
|
|
6
|
+
import { IActivityTitle, IActivityType } from "../../types/types";
|
|
7
|
+
|
|
8
|
+
const ACTIVITY_ICONS: Record<ActivityEnum, ImageURISource> = {
|
|
9
|
+
0: require(`../../assets/activity/Runner.png`),
|
|
10
|
+
1: require(`../../assets/activity/Walk.png`),
|
|
11
|
+
2: require(`../../assets/activity/Cyclist.png`),
|
|
12
|
+
3: require(`../../assets/activity/Swimmer.png`),
|
|
13
|
+
4: require(`../../assets/activity/Other.png`),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default class ActivityIcon extends React.Component<IActivityType & IActivityTitle> {
|
|
17
|
+
public getActivityIcon = (): ImageURISource => {
|
|
18
|
+
return ACTIVITY_ICONS[this.props.activityType];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
public render(): JSX.Element {
|
|
22
|
+
const { activityType, activityTitle } = this.props;
|
|
23
|
+
const label = `${ActivityEnum[activityType]}_activity`;
|
|
24
|
+
return (
|
|
25
|
+
<View style={activityIconStyles.container}>
|
|
26
|
+
<Image
|
|
27
|
+
style={activityIconStyles.activityIcon}
|
|
28
|
+
source={this.getActivityIcon()}
|
|
29
|
+
accessibilityLabel={label}
|
|
30
|
+
/>
|
|
31
|
+
<Text style={activityIconStyles.activityTitle}>{activityTitle ?? i18n._(t`Untitled Activity`)}</Text>
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const activityIconStyles = StyleSheet.create({
|
|
38
|
+
container: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
flexDirection: `row`,
|
|
41
|
+
alignItems: `center`,
|
|
42
|
+
marginTop: `1%`,
|
|
43
|
+
},
|
|
44
|
+
activityIcon: {
|
|
45
|
+
resizeMode: `contain`,
|
|
46
|
+
height: Dimensions.get(`screen`).width / 16,
|
|
47
|
+
},
|
|
48
|
+
activityTitle: {
|
|
49
|
+
color: `white`,
|
|
50
|
+
fontSize: Dimensions.get(`screen`).width / 25,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
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 macro_1 = require("@lingui/macro");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
10
|
+
const InfoBars_1 = require("../InfoBars");
|
|
11
|
+
const Handler = {
|
|
12
|
+
Light: () => i18nUtils_1.i18n._(macro_1.t `Light`),
|
|
13
|
+
Moderate: () => i18nUtils_1.i18n._(macro_1.t `Moderate`),
|
|
14
|
+
Hard: () => i18nUtils_1.i18n._(macro_1.t `Hard`),
|
|
15
|
+
Post: () => i18nUtils_1.i18n._(macro_1.t `Post`),
|
|
16
|
+
};
|
|
17
|
+
class ActivityIntensity extends react_1.default.Component {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.render = () => {
|
|
21
|
+
const intensity = this.props.activityIntensity;
|
|
22
|
+
const style = activityIntensityStyles[intensity];
|
|
23
|
+
return (<react_native_1.View style={[InfoBars_1.infoStyles.margin, activityIntensityStyles.row]}>
|
|
24
|
+
<react_native_1.View style={activityIntensityStyles.intensityContainer}>
|
|
25
|
+
<react_native_1.View style={[activityIntensityStyles.intensityTextContainer, style]}>
|
|
26
|
+
<react_native_1.Text style={activityIntensityStyles.bold}>{Handler[this.props.activityIntensity]()}</react_native_1.Text>
|
|
27
|
+
</react_native_1.View>
|
|
28
|
+
</react_native_1.View>
|
|
29
|
+
<react_native_1.View style={activityIntensityStyles.intensityContainerOffset}/>
|
|
30
|
+
</react_native_1.View>);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = ActivityIntensity;
|
|
35
|
+
const activityIntensityStyles = react_native_1.StyleSheet.create({
|
|
36
|
+
row: {
|
|
37
|
+
flexDirection: `row`,
|
|
38
|
+
},
|
|
39
|
+
intensityTextContainer: {
|
|
40
|
+
alignItems: `center`,
|
|
41
|
+
justifyContent: `center`,
|
|
42
|
+
padding: `5%`,
|
|
43
|
+
borderRadius: 5,
|
|
44
|
+
},
|
|
45
|
+
Light: {
|
|
46
|
+
backgroundColor: `#A5D871`,
|
|
47
|
+
},
|
|
48
|
+
Moderate: {
|
|
49
|
+
backgroundColor: `#F9BD5A`,
|
|
50
|
+
},
|
|
51
|
+
Hard: {
|
|
52
|
+
backgroundColor: `#EC5466`,
|
|
53
|
+
},
|
|
54
|
+
Post: {
|
|
55
|
+
backgroundColor: `#C5D0E7`,
|
|
56
|
+
},
|
|
57
|
+
intensityContainer: {
|
|
58
|
+
flex: 5,
|
|
59
|
+
},
|
|
60
|
+
intensityContainerOffset: {
|
|
61
|
+
flex: 16,
|
|
62
|
+
},
|
|
63
|
+
bold: {
|
|
64
|
+
fontWeight: `bold`,
|
|
65
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 30,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ActivityIntensity as Intensity } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
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 { IActivityIntensity } from "../../types/types";
|
|
7
|
+
import { infoStyles } from "../InfoBars";
|
|
8
|
+
|
|
9
|
+
const Handler: Record<Intensity, () => string> = {
|
|
10
|
+
Light: (): string => i18n._(t`Light`),
|
|
11
|
+
Moderate: (): string => i18n._(t`Moderate`),
|
|
12
|
+
Hard: (): string => i18n._(t`Hard`),
|
|
13
|
+
Post: (): string => i18n._(t`Post`),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default class ActivityIntensity extends React.Component<IActivityIntensity> {
|
|
17
|
+
public render = (): JSX.Element => {
|
|
18
|
+
const intensity = this.props.activityIntensity;
|
|
19
|
+
const style = activityIntensityStyles[intensity];
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<View style={[infoStyles.margin, activityIntensityStyles.row]}>
|
|
23
|
+
<View style={activityIntensityStyles.intensityContainer}>
|
|
24
|
+
<View style={[activityIntensityStyles.intensityTextContainer, style]}>
|
|
25
|
+
<Text style={activityIntensityStyles.bold}>{Handler[this.props.activityIntensity]()}</Text>
|
|
26
|
+
</View>
|
|
27
|
+
</View>
|
|
28
|
+
<View style={activityIntensityStyles.intensityContainerOffset} />
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const activityIntensityStyles = StyleSheet.create({
|
|
35
|
+
row: {
|
|
36
|
+
flexDirection: `row`,
|
|
37
|
+
},
|
|
38
|
+
intensityTextContainer: {
|
|
39
|
+
alignItems: `center`,
|
|
40
|
+
justifyContent: `center`,
|
|
41
|
+
padding: `5%`,
|
|
42
|
+
borderRadius: 5,
|
|
43
|
+
},
|
|
44
|
+
Light: {
|
|
45
|
+
backgroundColor: `#A5D871`,
|
|
46
|
+
},
|
|
47
|
+
Moderate: {
|
|
48
|
+
backgroundColor: `#F9BD5A`,
|
|
49
|
+
},
|
|
50
|
+
Hard: {
|
|
51
|
+
backgroundColor: `#EC5466`,
|
|
52
|
+
},
|
|
53
|
+
Post: {
|
|
54
|
+
backgroundColor: `#C5D0E7`,
|
|
55
|
+
},
|
|
56
|
+
intensityContainer: {
|
|
57
|
+
flex: 5,
|
|
58
|
+
},
|
|
59
|
+
intensityContainerOffset: {
|
|
60
|
+
flex: 16,
|
|
61
|
+
},
|
|
62
|
+
bold: {
|
|
63
|
+
fontWeight: `bold`,
|
|
64
|
+
fontSize: Dimensions.get(`screen`).width / 30,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MoodEnum } from "../../types/enum";
|
|
3
|
+
interface IProps {
|
|
4
|
+
currentMood?: MoodEnum;
|
|
5
|
+
moodSelected(mood?: MoodEnum): void;
|
|
6
|
+
}
|
|
7
|
+
export default class Emotion extends React.Component<IProps> {
|
|
8
|
+
handleIconPress: (selected: number, toggle: boolean) => void;
|
|
9
|
+
MappedMoods: () => Array<JSX.Element>;
|
|
10
|
+
render(): JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -3,36 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const macro_1 = require("@lingui/macro");
|
|
6
7
|
const react_1 = __importDefault(require("react"));
|
|
7
8
|
const react_native_1 = require("react-native");
|
|
8
|
-
const i18nUtils_1 = require("
|
|
9
|
-
const enum_1 = require("
|
|
9
|
+
const i18nUtils_1 = require("../../locale/i18nUtils");
|
|
10
|
+
const enum_1 = require("../../types/enum");
|
|
10
11
|
const MoodIcon_1 = __importDefault(require("./MoodIcon"));
|
|
11
12
|
class Emotion extends react_1.default.Component {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
14
|
-
this.state = {
|
|
15
|
-
selected: 0,
|
|
16
|
-
};
|
|
17
15
|
this.handleIconPress = (selected, toggle) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
this.props.moodSelected(toggle ? selected : null);
|
|
17
|
+
};
|
|
18
|
+
this.MappedMoods = () => {
|
|
19
|
+
const values = Object.values(enum_1.MoodEnum).filter((val) => isNaN(Number(val)));
|
|
20
|
+
return values.map((key) => {
|
|
21
|
+
const moodValue = enum_1.MoodEnum[key];
|
|
22
|
+
return (<MoodIcon_1.default onPress={(toggle) => this.handleIconPress(moodValue, toggle)} active={moodValue === this.props.currentMood} mood={moodValue} key={moodValue}/>);
|
|
21
23
|
});
|
|
22
|
-
this.props.moodSelected(select);
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
render() {
|
|
26
|
-
const values = Object.values(enum_1.MoodEnum).filter((val) => isNaN(Number(val)));
|
|
27
|
-
const mapped = values.map((key) => {
|
|
28
|
-
const moodValue = enum_1.MoodEnum[key];
|
|
29
|
-
return (<MoodIcon_1.default onPress={(toggle) => this.handleIconPress(moodValue, toggle)} active={moodValue === this.state.selected} mood={moodValue} key={moodValue}/>);
|
|
30
|
-
});
|
|
31
27
|
return (<react_native_1.View style={emotionStyles.container}>
|
|
32
28
|
<react_native_1.View style={emotionStyles.feelingContainer}>
|
|
33
|
-
<react_native_1.Text style={emotionStyles.feelingText}>{i18nUtils_1.i18n._(
|
|
29
|
+
<react_native_1.Text style={emotionStyles.feelingText}>{i18nUtils_1.i18n._(macro_1.t `How are you feeling?`)}</react_native_1.Text>
|
|
34
30
|
</react_native_1.View>
|
|
35
|
-
<react_native_1.View style={emotionStyles.moodIconContainer}>{
|
|
31
|
+
<react_native_1.View style={emotionStyles.moodIconContainer}>{this.MappedMoods()}</react_native_1.View>
|
|
36
32
|
</react_native_1.View>);
|
|
37
33
|
}
|
|
38
34
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { MoodEnum } from "../../types/enum";
|
|
6
|
+
import MoodIcon from "./MoodIcon";
|
|
7
|
+
|
|
8
|
+
interface IProps {
|
|
9
|
+
currentMood?: MoodEnum;
|
|
10
|
+
moodSelected(mood?: MoodEnum): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type value = keyof typeof MoodEnum;
|
|
14
|
+
|
|
15
|
+
export default class Emotion extends React.Component<IProps> {
|
|
16
|
+
public handleIconPress = (selected: number, 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<value>;
|
|
22
|
+
|
|
23
|
+
return values.map(
|
|
24
|
+
(key): JSX.Element => {
|
|
25
|
+
const moodValue = MoodEnum[key];
|
|
26
|
+
return (
|
|
27
|
+
<MoodIcon
|
|
28
|
+
onPress={(toggle): void => this.handleIconPress(moodValue, toggle)}
|
|
29
|
+
active={moodValue === this.props.currentMood}
|
|
30
|
+
mood={moodValue}
|
|
31
|
+
key={moodValue}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
public render(): JSX.Element {
|
|
39
|
+
return (
|
|
40
|
+
<View style={emotionStyles.container}>
|
|
41
|
+
<View style={emotionStyles.feelingContainer}>
|
|
42
|
+
<Text style={emotionStyles.feelingText}>{i18n._(t`How are you feeling?`)}</Text>
|
|
43
|
+
</View>
|
|
44
|
+
<View style={emotionStyles.moodIconContainer}>{this.MappedMoods()}</View>
|
|
45
|
+
</View>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const emotionStyles = StyleSheet.create({
|
|
51
|
+
container: {
|
|
52
|
+
flex: 1,
|
|
53
|
+
},
|
|
54
|
+
feelingContainer: {
|
|
55
|
+
marginVertical: `3%`,
|
|
56
|
+
},
|
|
57
|
+
feelingText: {
|
|
58
|
+
textAlign: `center`,
|
|
59
|
+
color: `white`,
|
|
60
|
+
fontWeight: `bold`,
|
|
61
|
+
fontSize: Dimensions.get(`screen`).width / 26,
|
|
62
|
+
},
|
|
63
|
+
moodIconContainer: { flex: 1, flexDirection: `row`, justifyContent: `center` },
|
|
64
|
+
});
|
|
@@ -5,29 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const react_native_1 = require("react-native");
|
|
8
|
-
const enum_1 = require("
|
|
9
|
-
const
|
|
10
|
-
1: require(
|
|
11
|
-
2: require(
|
|
12
|
-
3: require(
|
|
13
|
-
4: require(
|
|
14
|
-
5: require(
|
|
8
|
+
const enum_1 = require("../../types/enum");
|
|
9
|
+
const MOODS_INACTIVE = {
|
|
10
|
+
1: require(`../../assets/mood/sad.png`),
|
|
11
|
+
2: require(`../../assets/mood/semi_sad.png`),
|
|
12
|
+
3: require(`../../assets/mood/neutral.png`),
|
|
13
|
+
4: require(`../../assets/mood/semi_happy.png`),
|
|
14
|
+
5: require(`../../assets/mood/happy.png`),
|
|
15
15
|
};
|
|
16
|
-
const
|
|
17
|
-
1: require(
|
|
18
|
-
2: require(
|
|
19
|
-
3: require(
|
|
20
|
-
4: require(
|
|
21
|
-
5: require(
|
|
16
|
+
const MOODS_ACTIVE = {
|
|
17
|
+
1: require(`../../assets/mood/sad_active.png`),
|
|
18
|
+
2: require(`../../assets/mood/semi_sad_active.png`),
|
|
19
|
+
3: require(`../../assets/mood/neutral_active.png`),
|
|
20
|
+
4: require(`../../assets/mood/semi_happy_active.png`),
|
|
21
|
+
5: require(`../../assets/mood/happy_active.png`),
|
|
22
22
|
};
|
|
23
23
|
class MoodIcon extends react_1.default.Component {
|
|
24
24
|
constructor() {
|
|
25
25
|
super(...arguments);
|
|
26
26
|
this.getMoodIcon = () => {
|
|
27
27
|
if (this.props.active) {
|
|
28
|
-
return
|
|
28
|
+
return MOODS_ACTIVE[this.props.mood];
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return MOODS_INACTIVE[this.props.mood];
|
|
31
31
|
};
|
|
32
32
|
this.handleOnPress = () => {
|
|
33
33
|
this.props.onPress(!this.props.active);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Dimensions, Image, ImageURISource, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
-
import { MoodEnum } from "
|
|
3
|
+
import { MoodEnum } from "../../types/enum";
|
|
4
4
|
|
|
5
5
|
interface IProps {
|
|
6
6
|
mood: MoodEnum;
|
|
@@ -8,35 +8,35 @@ interface IProps {
|
|
|
8
8
|
onPress(toggle: boolean): void;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
1: require(
|
|
13
|
-
2: require(
|
|
14
|
-
3: require(
|
|
15
|
-
4: require(
|
|
16
|
-
5: require(
|
|
11
|
+
const MOODS_INACTIVE: Record<number, ImageURISource> = {
|
|
12
|
+
1: require(`../../assets/mood/sad.png`),
|
|
13
|
+
2: require(`../../assets/mood/semi_sad.png`),
|
|
14
|
+
3: require(`../../assets/mood/neutral.png`),
|
|
15
|
+
4: require(`../../assets/mood/semi_happy.png`),
|
|
16
|
+
5: require(`../../assets/mood/happy.png`),
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
1: require(
|
|
21
|
-
2: require(
|
|
22
|
-
3: require(
|
|
23
|
-
4: require(
|
|
24
|
-
5: require(
|
|
19
|
+
const MOODS_ACTIVE: Record<number, ImageURISource> = {
|
|
20
|
+
1: require(`../../assets/mood/sad_active.png`),
|
|
21
|
+
2: require(`../../assets/mood/semi_sad_active.png`),
|
|
22
|
+
3: require(`../../assets/mood/neutral_active.png`),
|
|
23
|
+
4: require(`../../assets/mood/semi_happy_active.png`),
|
|
24
|
+
5: require(`../../assets/mood/happy_active.png`),
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export default class MoodIcon extends React.Component<IProps> {
|
|
28
28
|
public getMoodIcon = (): ImageURISource => {
|
|
29
29
|
if (this.props.active) {
|
|
30
|
-
return
|
|
30
|
+
return MOODS_ACTIVE[this.props.mood];
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return MOODS_INACTIVE[this.props.mood];
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
public handleOnPress = () => {
|
|
35
|
+
public handleOnPress = (): void => {
|
|
36
36
|
this.props.onPress(!this.props.active);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
public render() {
|
|
39
|
+
public render(): JSX.Element {
|
|
40
40
|
const { mood, active } = this.props;
|
|
41
41
|
const label = `${MoodEnum[mood]}_${active}`;
|
|
42
42
|
return (
|