@hedia/recommendation-screen 1.0.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.
- package/.prettierignore +2 -0
- package/Changelog.md +5 -0
- package/README.md +3 -0
- package/android/app/BUCK +55 -0
- package/android/app/build.gradle +226 -0
- package/android/app/build_defs.bzl +19 -0
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +10 -0
- package/android/app/src/debug/AndroidManifest.xml +8 -0
- package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +72 -0
- package/android/app/src/main/AndroidManifest.xml +27 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +15 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +80 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/values/strings.xml +3 -0
- package/android/app/src/main/res/values/styles.xml +9 -0
- package/android/build.gradle +38 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +28 -0
- package/android/gradlew +188 -0
- package/android/gradlew.bat +100 -0
- package/android/settings.gradle +3 -0
- package/index-git.sh +5 -0
- package/index.d.ts +5 -0
- package/index.js +16 -0
- package/index.ts +19 -0
- package/ios/HediaRecommendationScreen/AppDelegate.h +8 -0
- package/ios/HediaRecommendationScreen/AppDelegate.m +58 -0
- package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +42 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +38 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +6 -0
- package/ios/HediaRecommendationScreen/Info.plist +57 -0
- package/ios/HediaRecommendationScreen/main.m +9 -0
- package/ios/HediaRecommendationScreen-tvOS/Info.plist +53 -0
- package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +24 -0
- package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +807 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +88 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +88 -0
- package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +65 -0
- package/ios/HediaRecommendationScreenTests/Info.plist +24 -0
- package/ios/Podfile +104 -0
- package/package.json +75 -0
- package/src/RecommendationScreen.d.ts +42 -0
- package/src/RecommendationScreen.js +142 -0
- package/src/RecommendationScreen.tsx +210 -0
- package/src/assets/happy.png +0 -0
- package/src/assets/happy_active.png +0 -0
- package/src/assets/neutral.png +0 -0
- package/src/assets/neutral_active.png +0 -0
- package/src/assets/sad.png +0 -0
- package/src/assets/sad_active.png +0 -0
- package/src/assets/semi_happy.png +0 -0
- package/src/assets/semi_happy_active.png +0 -0
- package/src/assets/semi_sad.png +0 -0
- package/src/assets/semi_sad_active.png +0 -0
- package/src/components/Emotion.d.ts +14 -0
- package/src/components/Emotion.js +55 -0
- package/src/components/Emotion.tsx +71 -0
- package/src/components/Header.d.ts +52 -0
- package/src/components/Header.js +83 -0
- package/src/components/Header.tsx +94 -0
- package/src/components/Icon.js +41 -0
- package/src/components/InfoBars.d.ts +67 -0
- package/src/components/InfoBars.js +89 -0
- package/src/components/InfoBars.tsx +93 -0
- package/src/components/InvisibleNumberInput.d.ts +24 -0
- package/src/components/InvisibleNumberInput.js +64 -0
- package/src/components/InvisibleNumberInput.tsx +88 -0
- package/src/components/MoodIcon.d.ts +14 -0
- package/src/components/MoodIcon.js +53 -0
- package/src/components/MoodIcon.tsx +58 -0
- package/src/components/RecentInsulin.d.ts +9 -0
- package/src/components/RecentInsulin.js +91 -0
- package/src/components/RecentInsulin.tsx +97 -0
- package/src/components/RecommendedCarbs.d.ts +30 -0
- package/src/components/RecommendedCarbs.js +193 -0
- package/src/components/RecommendedCarbs.tsx +242 -0
- package/src/components/RecommendedInsulin.d.ts +22 -0
- package/src/components/RecommendedInsulin.js +110 -0
- package/src/components/RecommendedInsulin.tsx +147 -0
- package/src/components/Remeasure.d.ts +13 -0
- package/src/components/Remeasure.js +89 -0
- package/src/components/Remeasure.tsx +105 -0
- package/src/components/TransferToLogbook.d.ts +14 -0
- package/src/components/TransferToLogbook.js +81 -0
- package/src/components/TransferToLogbook.tsx +97 -0
- package/src/locale/da/messages.js +1 -0
- package/src/locale/da/messages.po +119 -0
- package/src/locale/en/messages.js +1 -0
- package/src/locale/en/messages.po +119 -0
- package/src/locale/i18nUtils.d.ts +5 -0
- package/src/locale/i18nUtils.js +22 -0
- package/src/locale/i18nUtils.ts +21 -0
- package/src/types/enum.d.ts +26 -0
- package/src/types/enum.js +34 -0
- package/src/types/enum.ts +30 -0
- package/src/types/types.d.ts +21 -0
- package/src/types/types.js +2 -0
- package/src/types/types.ts +23 -0
- package/src/utils/Constants.d.ts +3 -0
- package/src/utils/Constants.js +6 -0
- package/src/utils/Constants.ts +3 -0
- package/src/utils/RecommendationError.d.ts +9 -0
- package/src/utils/RecommendationError.js +17 -0
- package/src/utils/RecommendationError.ts +30 -0
- package/src/utils/Utils.d.ts +5 -0
- package/src/utils/Utils.js +24 -0
- package/src/utils/Utils.ts +26 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface IProps {
|
|
3
|
+
label: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
units: string;
|
|
6
|
+
showZeroAsDash: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default class InfoBars extends React.Component<IProps> {
|
|
9
|
+
render(): JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
export declare const infoStyles: {
|
|
12
|
+
container: {
|
|
13
|
+
flex: number;
|
|
14
|
+
};
|
|
15
|
+
margin: {
|
|
16
|
+
flex: number;
|
|
17
|
+
margin: string;
|
|
18
|
+
marginBottom: number;
|
|
19
|
+
};
|
|
20
|
+
border: {
|
|
21
|
+
borderWidth: number;
|
|
22
|
+
borderColor: string;
|
|
23
|
+
borderRadius: number;
|
|
24
|
+
};
|
|
25
|
+
borderContainer: {
|
|
26
|
+
flex: number;
|
|
27
|
+
flexDirection: "row";
|
|
28
|
+
justifyContent: "space-between";
|
|
29
|
+
paddingLeft: string;
|
|
30
|
+
paddingRight: string;
|
|
31
|
+
};
|
|
32
|
+
labelContainer: {
|
|
33
|
+
flex: number;
|
|
34
|
+
justifyContent: "center";
|
|
35
|
+
};
|
|
36
|
+
label: {
|
|
37
|
+
color: string;
|
|
38
|
+
fontSize: number;
|
|
39
|
+
fontWeight: "bold";
|
|
40
|
+
};
|
|
41
|
+
valueUnitContainer: {
|
|
42
|
+
flex: number;
|
|
43
|
+
justifyContent: "flex-end";
|
|
44
|
+
flexDirection: "row";
|
|
45
|
+
};
|
|
46
|
+
valueContainer: {
|
|
47
|
+
flex: number;
|
|
48
|
+
justifyContent: "flex-end";
|
|
49
|
+
};
|
|
50
|
+
value: {
|
|
51
|
+
color: string;
|
|
52
|
+
fontSize: number;
|
|
53
|
+
fontWeight: "bold";
|
|
54
|
+
textAlign: "right";
|
|
55
|
+
};
|
|
56
|
+
unitContainer: {
|
|
57
|
+
flex: number;
|
|
58
|
+
justifyContent: "flex-end";
|
|
59
|
+
paddingBottom: string;
|
|
60
|
+
};
|
|
61
|
+
units: {
|
|
62
|
+
color: string;
|
|
63
|
+
fontSize: number;
|
|
64
|
+
textAlign: "left";
|
|
65
|
+
paddingLeft: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
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.infoStyles = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const Constants_1 = require("../utils/Constants");
|
|
10
|
+
const Header_1 = require("./Header");
|
|
11
|
+
class InfoBars extends react_1.default.Component {
|
|
12
|
+
render() {
|
|
13
|
+
return (<react_native_1.View style={exports.infoStyles.container}>
|
|
14
|
+
<react_native_1.View style={exports.infoStyles.margin}>
|
|
15
|
+
<react_native_1.View style={exports.infoStyles.border}>
|
|
16
|
+
<react_native_1.View style={exports.infoStyles.borderContainer}>
|
|
17
|
+
<react_native_1.View style={exports.infoStyles.labelContainer}>
|
|
18
|
+
<react_native_1.Text style={exports.infoStyles.label}>{this.props.label}</react_native_1.Text>
|
|
19
|
+
</react_native_1.View>
|
|
20
|
+
<react_native_1.View style={exports.infoStyles.valueUnitContainer}>
|
|
21
|
+
<react_native_1.View style={exports.infoStyles.valueContainer}>
|
|
22
|
+
<react_native_1.Text style={exports.infoStyles.value}>{this.props.value ? this.props.value : `-.-`}</react_native_1.Text>
|
|
23
|
+
</react_native_1.View>
|
|
24
|
+
<react_native_1.View style={exports.infoStyles.unitContainer}>
|
|
25
|
+
<react_native_1.Text style={exports.infoStyles.units}>{this.props.units}</react_native_1.Text>
|
|
26
|
+
</react_native_1.View>
|
|
27
|
+
</react_native_1.View>
|
|
28
|
+
</react_native_1.View>
|
|
29
|
+
</react_native_1.View>
|
|
30
|
+
</react_native_1.View>
|
|
31
|
+
</react_native_1.View>);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = InfoBars;
|
|
35
|
+
exports.infoStyles = react_native_1.StyleSheet.create({
|
|
36
|
+
container: { flex: 1 },
|
|
37
|
+
margin: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
margin: Header_1.headerStyles.margin.margin,
|
|
40
|
+
marginBottom: 0,
|
|
41
|
+
},
|
|
42
|
+
border: {
|
|
43
|
+
borderWidth: 2,
|
|
44
|
+
borderColor: Constants_1.BORDER_COLOUR_WHITE,
|
|
45
|
+
borderRadius: 5,
|
|
46
|
+
},
|
|
47
|
+
borderContainer: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
flexDirection: `row`,
|
|
50
|
+
justifyContent: `space-between`,
|
|
51
|
+
paddingLeft: `3%`,
|
|
52
|
+
paddingRight: `3%`,
|
|
53
|
+
},
|
|
54
|
+
labelContainer: {
|
|
55
|
+
flex: 7,
|
|
56
|
+
justifyContent: `center`,
|
|
57
|
+
},
|
|
58
|
+
label: {
|
|
59
|
+
color: `white`,
|
|
60
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 22,
|
|
61
|
+
fontWeight: `bold`,
|
|
62
|
+
},
|
|
63
|
+
valueUnitContainer: {
|
|
64
|
+
flex: 4,
|
|
65
|
+
justifyContent: `flex-end`,
|
|
66
|
+
flexDirection: `row`,
|
|
67
|
+
},
|
|
68
|
+
valueContainer: {
|
|
69
|
+
flex: 1,
|
|
70
|
+
justifyContent: `flex-end`,
|
|
71
|
+
},
|
|
72
|
+
value: {
|
|
73
|
+
color: `white`,
|
|
74
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 16,
|
|
75
|
+
fontWeight: `bold`,
|
|
76
|
+
textAlign: `right`,
|
|
77
|
+
},
|
|
78
|
+
unitContainer: {
|
|
79
|
+
flex: 1,
|
|
80
|
+
justifyContent: `flex-end`,
|
|
81
|
+
paddingBottom: `3%`,
|
|
82
|
+
},
|
|
83
|
+
units: {
|
|
84
|
+
color: `white`,
|
|
85
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 30,
|
|
86
|
+
textAlign: `left`,
|
|
87
|
+
paddingLeft: `5%`,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Dimensions, StyleSheet, Text, View } from "react-native";
|
|
3
|
+
import { BORDER_COLOUR_WHITE } from "../utils/Constants";
|
|
4
|
+
import { headerStyles } from "./Header";
|
|
5
|
+
|
|
6
|
+
export interface IProps {
|
|
7
|
+
label: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
units: string;
|
|
10
|
+
showZeroAsDash: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class InfoBars extends React.Component<IProps> {
|
|
14
|
+
public render() {
|
|
15
|
+
return (
|
|
16
|
+
<View style={infoStyles.container}>
|
|
17
|
+
<View style={infoStyles.margin}>
|
|
18
|
+
<View style={infoStyles.border}>
|
|
19
|
+
<View style={infoStyles.borderContainer}>
|
|
20
|
+
<View style={infoStyles.labelContainer}>
|
|
21
|
+
<Text style={infoStyles.label}>{this.props.label}</Text>
|
|
22
|
+
</View>
|
|
23
|
+
<View style={infoStyles.valueUnitContainer}>
|
|
24
|
+
<View style={infoStyles.valueContainer}>
|
|
25
|
+
<Text style={infoStyles.value}>{this.props.value ? this.props.value : `-.-`}</Text>
|
|
26
|
+
</View>
|
|
27
|
+
<View style={infoStyles.unitContainer}>
|
|
28
|
+
<Text style={infoStyles.units}>{this.props.units}</Text>
|
|
29
|
+
</View>
|
|
30
|
+
</View>
|
|
31
|
+
</View>
|
|
32
|
+
</View>
|
|
33
|
+
</View>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const infoStyles = StyleSheet.create({
|
|
40
|
+
container: { flex: 1 },
|
|
41
|
+
margin: {
|
|
42
|
+
flex: 1,
|
|
43
|
+
margin: headerStyles.margin.margin,
|
|
44
|
+
marginBottom: 0,
|
|
45
|
+
},
|
|
46
|
+
border: {
|
|
47
|
+
borderWidth: 2,
|
|
48
|
+
borderColor: BORDER_COLOUR_WHITE,
|
|
49
|
+
borderRadius: 5,
|
|
50
|
+
},
|
|
51
|
+
borderContainer: {
|
|
52
|
+
flex: 1,
|
|
53
|
+
flexDirection: `row`,
|
|
54
|
+
justifyContent: `space-between`,
|
|
55
|
+
paddingLeft: `3%`,
|
|
56
|
+
paddingRight: `3%`,
|
|
57
|
+
},
|
|
58
|
+
labelContainer: {
|
|
59
|
+
flex: 7,
|
|
60
|
+
justifyContent: `center`,
|
|
61
|
+
},
|
|
62
|
+
label: {
|
|
63
|
+
color: `white`,
|
|
64
|
+
fontSize: Dimensions.get(`screen`).width / 22,
|
|
65
|
+
fontWeight: `bold`,
|
|
66
|
+
},
|
|
67
|
+
valueUnitContainer: {
|
|
68
|
+
flex: 4,
|
|
69
|
+
justifyContent: `flex-end`,
|
|
70
|
+
flexDirection: `row`,
|
|
71
|
+
},
|
|
72
|
+
valueContainer: {
|
|
73
|
+
flex: 1,
|
|
74
|
+
justifyContent: `flex-end`,
|
|
75
|
+
},
|
|
76
|
+
value: {
|
|
77
|
+
color: `white`,
|
|
78
|
+
fontSize: Dimensions.get(`screen`).width / 16,
|
|
79
|
+
fontWeight: `bold`,
|
|
80
|
+
textAlign: `right`,
|
|
81
|
+
},
|
|
82
|
+
unitContainer: {
|
|
83
|
+
flex: 1,
|
|
84
|
+
justifyContent: `flex-end`,
|
|
85
|
+
paddingBottom: `3%`,
|
|
86
|
+
},
|
|
87
|
+
units: {
|
|
88
|
+
color: `white`,
|
|
89
|
+
fontSize: Dimensions.get(`screen`).width / 30,
|
|
90
|
+
textAlign: `left`,
|
|
91
|
+
paddingLeft: `5%`,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextInput } from "react-native";
|
|
3
|
+
interface IProps {
|
|
4
|
+
startValue?: string;
|
|
5
|
+
decimalPlaces: number;
|
|
6
|
+
cleanPartialInput: boolean;
|
|
7
|
+
negativeAllowed: boolean;
|
|
8
|
+
visible(toggle: () => void): void;
|
|
9
|
+
onEnd?(value: number): void;
|
|
10
|
+
partialInput?(value: string): void;
|
|
11
|
+
}
|
|
12
|
+
interface IState {
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
export default class InvisibleNumberInput extends React.Component<IProps, IState> {
|
|
16
|
+
textInput: TextInput;
|
|
17
|
+
state: IState;
|
|
18
|
+
componentDidMount(): void;
|
|
19
|
+
cleanInput: (text: string) => string;
|
|
20
|
+
handleOnChangeText: (text: string) => void;
|
|
21
|
+
onEndEdit: () => void;
|
|
22
|
+
render(): JSX.Element;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
class InvisibleNumberInput extends react_1.default.Component {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.state = {
|
|
12
|
+
value: `0`,
|
|
13
|
+
};
|
|
14
|
+
this.cleanInput = (text) => {
|
|
15
|
+
const replaced = text.replace(/\,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
16
|
+
const round = (value) => {
|
|
17
|
+
const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
|
|
18
|
+
const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
|
|
19
|
+
if (this.props.negativeAllowed) {
|
|
20
|
+
return rounded.toFixed(this.props.decimalPlaces);
|
|
21
|
+
}
|
|
22
|
+
return Math.abs(rounded).toFixed(this.props.decimalPlaces);
|
|
23
|
+
};
|
|
24
|
+
if (!isNaN(Number(replaced))) {
|
|
25
|
+
return round(replaced);
|
|
26
|
+
}
|
|
27
|
+
return `0`;
|
|
28
|
+
};
|
|
29
|
+
this.handleOnChangeText = (text) => {
|
|
30
|
+
const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
|
|
31
|
+
const replacedSeperator = cleaned.replace(/\.+/g, `.`);
|
|
32
|
+
this.setState({
|
|
33
|
+
value: `${replacedSeperator}`,
|
|
34
|
+
});
|
|
35
|
+
this.props.partialInput?.(`${replacedSeperator}`);
|
|
36
|
+
};
|
|
37
|
+
this.onEndEdit = () => {
|
|
38
|
+
const cleaned = this.cleanInput(this.state.value);
|
|
39
|
+
this.props.onEnd?.(Number(cleaned));
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
componentDidMount() {
|
|
43
|
+
this.setState({
|
|
44
|
+
value: this.props.startValue ?? `0`,
|
|
45
|
+
});
|
|
46
|
+
this.props.visible(() => {
|
|
47
|
+
this.setState({
|
|
48
|
+
value: this.props.startValue ?? `0`,
|
|
49
|
+
});
|
|
50
|
+
return this.textInput.focus();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
return (<react_native_1.TextInput accessibilityLabel="InvisibleNumberInput" value={`${this.state.value}`} ref={(textInput) => (this.textInput = textInput)} style={inputStyles.textInput} keyboardType="numeric" onChangeText={this.handleOnChangeText} onEndEditing={this.onEndEdit}/>);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = InvisibleNumberInput;
|
|
58
|
+
const inputStyles = react_native_1.StyleSheet.create({
|
|
59
|
+
textInput: {
|
|
60
|
+
width: 0,
|
|
61
|
+
height: 0,
|
|
62
|
+
padding: 0.2,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
visible(toggle: () => void): void;
|
|
10
|
+
onEnd?(value: number): void;
|
|
11
|
+
partialInput?(value: string): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface IState {
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default class InvisibleNumberInput extends React.Component<IProps, IState> {
|
|
19
|
+
public textInput: TextInput;
|
|
20
|
+
|
|
21
|
+
public state: IState = {
|
|
22
|
+
value: `0`,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
public componentDidMount() {
|
|
26
|
+
this.setState({
|
|
27
|
+
value: this.props.startValue ?? `0`,
|
|
28
|
+
});
|
|
29
|
+
this.props.visible(() => {
|
|
30
|
+
this.setState({
|
|
31
|
+
value: this.props.startValue ?? `0`,
|
|
32
|
+
});
|
|
33
|
+
return this.textInput.focus();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public cleanInput = (text: string): string => {
|
|
38
|
+
const replaced = text.replace(/\,/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
|
|
39
|
+
const round = (value: string) => {
|
|
40
|
+
const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
|
|
41
|
+
const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
|
|
42
|
+
if (this.props.negativeAllowed) {
|
|
43
|
+
return rounded.toFixed(this.props.decimalPlaces);
|
|
44
|
+
}
|
|
45
|
+
return Math.abs(rounded).toFixed(this.props.decimalPlaces);
|
|
46
|
+
};
|
|
47
|
+
if (!isNaN(Number(replaced))) {
|
|
48
|
+
return round(replaced);
|
|
49
|
+
}
|
|
50
|
+
return `0`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
public handleOnChangeText = (text: string) => {
|
|
54
|
+
const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
|
|
55
|
+
const replacedSeperator = cleaned.replace(/\.+/g, `.`);
|
|
56
|
+
this.setState({
|
|
57
|
+
value: `${replacedSeperator}`,
|
|
58
|
+
});
|
|
59
|
+
this.props.partialInput?.(`${replacedSeperator}`);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
public onEndEdit = () => {
|
|
63
|
+
const cleaned = this.cleanInput(this.state.value);
|
|
64
|
+
this.props.onEnd?.(Number(cleaned));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
public render() {
|
|
68
|
+
return (
|
|
69
|
+
<TextInput
|
|
70
|
+
accessibilityLabel="InvisibleNumberInput"
|
|
71
|
+
value={`${this.state.value}`}
|
|
72
|
+
ref={(textInput) => (this.textInput = textInput)}
|
|
73
|
+
style={inputStyles.textInput}
|
|
74
|
+
keyboardType="numeric"
|
|
75
|
+
onChangeText={this.handleOnChangeText}
|
|
76
|
+
onEndEditing={this.onEndEdit}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const inputStyles = StyleSheet.create({
|
|
83
|
+
textInput: {
|
|
84
|
+
width: 0,
|
|
85
|
+
height: 0,
|
|
86
|
+
padding: 0.2,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ImageURISource } from "react-native";
|
|
3
|
+
import { MoodEnum } from "../types/enum";
|
|
4
|
+
interface IProps {
|
|
5
|
+
mood: MoodEnum;
|
|
6
|
+
active: boolean;
|
|
7
|
+
onPress(toggle: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
export default class MoodIcon extends React.Component<IProps> {
|
|
10
|
+
getMoodIcon: () => ImageURISource;
|
|
11
|
+
handleOnPress: () => void;
|
|
12
|
+
render(): JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
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 react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const enum_1 = require("../types/enum");
|
|
9
|
+
const moods_inactive = {
|
|
10
|
+
1: require(`../assets/sad.png`),
|
|
11
|
+
2: require(`../assets/semi_sad.png`),
|
|
12
|
+
3: require(`../assets/neutral.png`),
|
|
13
|
+
4: require(`../assets/semi_happy.png`),
|
|
14
|
+
5: require(`../assets/happy.png`),
|
|
15
|
+
};
|
|
16
|
+
const moods_active = {
|
|
17
|
+
1: require(`../assets/sad_active.png`),
|
|
18
|
+
2: require(`../assets/semi_sad_active.png`),
|
|
19
|
+
3: require(`../assets/neutral_active.png`),
|
|
20
|
+
4: require(`../assets/semi_happy_active.png`),
|
|
21
|
+
5: require(`../assets/happy_active.png`),
|
|
22
|
+
};
|
|
23
|
+
class MoodIcon extends react_1.default.Component {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.getMoodIcon = () => {
|
|
27
|
+
if (this.props.active) {
|
|
28
|
+
return moods_active[this.props.mood];
|
|
29
|
+
}
|
|
30
|
+
return moods_inactive[this.props.mood];
|
|
31
|
+
};
|
|
32
|
+
this.handleOnPress = () => {
|
|
33
|
+
this.props.onPress(!this.props.active);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
const { mood, active } = this.props;
|
|
38
|
+
const label = `${enum_1.MoodEnum[mood]}_${active}`;
|
|
39
|
+
return (<react_native_1.TouchableOpacity style={moodIconStyles.container} onPress={this.handleOnPress} accessibilityLabel={label}>
|
|
40
|
+
<react_native_1.Image style={moodIconStyles.icon} source={this.getMoodIcon()}/>
|
|
41
|
+
</react_native_1.TouchableOpacity>);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = MoodIcon;
|
|
45
|
+
const moodIconStyles = react_native_1.StyleSheet.create({
|
|
46
|
+
container: {
|
|
47
|
+
marginHorizontal: `1%`,
|
|
48
|
+
},
|
|
49
|
+
icon: {
|
|
50
|
+
width: react_native_1.Dimensions.get(`screen`).width / 8,
|
|
51
|
+
height: react_native_1.Dimensions.get(`screen`).width / 8,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Dimensions, Image, ImageURISource, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
+
import { MoodEnum } from "../types/enum";
|
|
4
|
+
|
|
5
|
+
interface IProps {
|
|
6
|
+
mood: MoodEnum;
|
|
7
|
+
active: boolean;
|
|
8
|
+
onPress(toggle: boolean): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const moods_inactive: Record<number, ImageURISource> = {
|
|
12
|
+
1: require(`../assets/sad.png`),
|
|
13
|
+
2: require(`../assets/semi_sad.png`),
|
|
14
|
+
3: require(`../assets/neutral.png`),
|
|
15
|
+
4: require(`../assets/semi_happy.png`),
|
|
16
|
+
5: require(`../assets/happy.png`),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const moods_active: Record<number, ImageURISource> = {
|
|
20
|
+
1: require(`../assets/sad_active.png`),
|
|
21
|
+
2: require(`../assets/semi_sad_active.png`),
|
|
22
|
+
3: require(`../assets/neutral_active.png`),
|
|
23
|
+
4: require(`../assets/semi_happy_active.png`),
|
|
24
|
+
5: require(`../assets/happy_active.png`),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default class MoodIcon extends React.Component<IProps> {
|
|
28
|
+
public getMoodIcon = (): ImageURISource => {
|
|
29
|
+
if (this.props.active) {
|
|
30
|
+
return moods_active[this.props.mood];
|
|
31
|
+
}
|
|
32
|
+
return moods_inactive[this.props.mood];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
public handleOnPress = () => {
|
|
36
|
+
this.props.onPress(!this.props.active);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
public render() {
|
|
40
|
+
const { mood, active } = this.props;
|
|
41
|
+
const label = `${MoodEnum[mood]}_${active}`;
|
|
42
|
+
return (
|
|
43
|
+
<TouchableOpacity style={moodIconStyles.container} onPress={this.handleOnPress} accessibilityLabel={label}>
|
|
44
|
+
<Image style={moodIconStyles.icon} source={this.getMoodIcon()} />
|
|
45
|
+
</TouchableOpacity>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const moodIconStyles = StyleSheet.create({
|
|
51
|
+
container: {
|
|
52
|
+
marginHorizontal: `1%`,
|
|
53
|
+
},
|
|
54
|
+
icon: {
|
|
55
|
+
width: Dimensions.get(`screen`).width / 8,
|
|
56
|
+
height: Dimensions.get(`screen`).width / 8,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -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 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
|
+
class RecentInsulin extends react_1.default.Component {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.render = () => {
|
|
15
|
+
return (<react_native_1.View style={recentInsulinStyles.container}>
|
|
16
|
+
<react_native_1.View style={recentInsulinStyles.titleContainer}>
|
|
17
|
+
<react_native_1.Text style={recentInsulinStyles.recommended}>{i18nUtils_1.i18n._(macro_1.t `Recommended amount of insulin`)}</react_native_1.Text>
|
|
18
|
+
</react_native_1.View>
|
|
19
|
+
<react_native_1.View style={recentInsulinStyles.takenInsulinContainer}>
|
|
20
|
+
<react_native_1.Text style={recentInsulinStyles.takenInsulin}>
|
|
21
|
+
{i18nUtils_1.i18n._(macro_1.t `Have you taken insulin within the last 4 hours?`)}
|
|
22
|
+
</react_native_1.Text>
|
|
23
|
+
</react_native_1.View>
|
|
24
|
+
<react_native_1.View style={recentInsulinStyles.buttonContainer}>
|
|
25
|
+
<react_native_1.View style={recentInsulinStyles.filler}/>
|
|
26
|
+
<react_native_1.TouchableOpacity onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
|
|
27
|
+
<react_native_1.Text style={recentInsulinStyles.yesNoText}>{i18nUtils_1.i18n._(macro_1.t `Yes`)}</react_native_1.Text>
|
|
28
|
+
</react_native_1.TouchableOpacity>
|
|
29
|
+
<react_native_1.TouchableOpacity onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
|
|
30
|
+
<react_native_1.Text style={recentInsulinStyles.yesNoText}>{i18nUtils_1.i18n._(macro_1.t `No`)}</react_native_1.Text>
|
|
31
|
+
</react_native_1.TouchableOpacity>
|
|
32
|
+
<react_native_1.View style={recentInsulinStyles.filler}/>
|
|
33
|
+
</react_native_1.View>
|
|
34
|
+
</react_native_1.View>);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = RecentInsulin;
|
|
39
|
+
const recentInsulinStyles = react_native_1.StyleSheet.create({
|
|
40
|
+
container: {
|
|
41
|
+
...InfoBars_1.infoStyles.margin,
|
|
42
|
+
backgroundColor: `rgba(118, 82, 255, 0.5)`,
|
|
43
|
+
borderRadius: 5,
|
|
44
|
+
},
|
|
45
|
+
titleContainer: {
|
|
46
|
+
flex: 1,
|
|
47
|
+
justifyContent: `center`,
|
|
48
|
+
alignItems: `center`,
|
|
49
|
+
marginTop: `4%`,
|
|
50
|
+
marginBottom: `4%`,
|
|
51
|
+
},
|
|
52
|
+
recommended: {
|
|
53
|
+
...InfoBars_1.infoStyles.label,
|
|
54
|
+
},
|
|
55
|
+
takenInsulinContainer: {
|
|
56
|
+
flex: 1,
|
|
57
|
+
justifyContent: `center`,
|
|
58
|
+
alignItems: `center`,
|
|
59
|
+
marginTop: `2%`,
|
|
60
|
+
},
|
|
61
|
+
takenInsulin: {
|
|
62
|
+
...InfoBars_1.infoStyles.label,
|
|
63
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 27,
|
|
64
|
+
},
|
|
65
|
+
buttonContainer: {
|
|
66
|
+
flex: 1,
|
|
67
|
+
flexDirection: `row`,
|
|
68
|
+
justifyContent: `space-evenly`,
|
|
69
|
+
marginTop: `4%`,
|
|
70
|
+
marginBottom: `5%`,
|
|
71
|
+
},
|
|
72
|
+
yesNoContainer: {
|
|
73
|
+
flex: 1,
|
|
74
|
+
borderColor: `white`,
|
|
75
|
+
borderRadius: 100,
|
|
76
|
+
borderWidth: 2,
|
|
77
|
+
paddingHorizontal: `2%`,
|
|
78
|
+
paddingVertical: `1%`,
|
|
79
|
+
},
|
|
80
|
+
yesNoText: {
|
|
81
|
+
textAlign: `center`,
|
|
82
|
+
paddingTop: `1%`,
|
|
83
|
+
paddingBottom: `1%`,
|
|
84
|
+
color: `white`,
|
|
85
|
+
fontSize: react_native_1.Dimensions.get(`screen`).width / 25,
|
|
86
|
+
fontWeight: `bold`,
|
|
87
|
+
},
|
|
88
|
+
filler: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
},
|
|
91
|
+
});
|