@hedia/recommendation-screen 1.0.3 → 1.0.5

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 (38) hide show
  1. package/Changelog.md +0 -4
  2. package/package.json +1 -1
  3. package/index.d.ts +0 -5
  4. package/index.js +0 -16
  5. package/src/RecommendationScreen.d.ts +0 -42
  6. package/src/RecommendationScreen.js +0 -141
  7. package/src/components/Emotion.d.ts +0 -14
  8. package/src/components/Emotion.js +0 -54
  9. package/src/components/Header.d.ts +0 -52
  10. package/src/components/Header.js +0 -82
  11. package/src/components/InfoBars.d.ts +0 -67
  12. package/src/components/InfoBars.js +0 -89
  13. package/src/components/InvisibleNumberInput.d.ts +0 -24
  14. package/src/components/InvisibleNumberInput.js +0 -64
  15. package/src/components/MoodIcon.d.ts +0 -14
  16. package/src/components/MoodIcon.js +0 -53
  17. package/src/components/RecentInsulin.d.ts +0 -9
  18. package/src/components/RecentInsulin.js +0 -90
  19. package/src/components/RecommendedCarbs.d.ts +0 -30
  20. package/src/components/RecommendedCarbs.js +0 -192
  21. package/src/components/RecommendedInsulin.d.ts +0 -22
  22. package/src/components/RecommendedInsulin.js +0 -109
  23. package/src/components/Remeasure.d.ts +0 -13
  24. package/src/components/Remeasure.js +0 -88
  25. package/src/components/TransferToLogbook.d.ts +0 -14
  26. package/src/components/TransferToLogbook.js +0 -80
  27. package/src/locale/i18nUtils.d.ts +0 -5
  28. package/src/locale/i18nUtils.js +0 -22
  29. package/src/types/enum.d.ts +0 -26
  30. package/src/types/enum.js +0 -34
  31. package/src/types/types.d.ts +0 -21
  32. package/src/types/types.js +0 -2
  33. package/src/utils/Constants.d.ts +0 -3
  34. package/src/utils/Constants.js +0 -6
  35. package/src/utils/RecommendationError.d.ts +0 -9
  36. package/src/utils/RecommendationError.js +0 -16
  37. package/src/utils/Utils.d.ts +0 -5
  38. package/src/utils/Utils.js +0 -24
package/Changelog.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Changelog
2
2
 
3
- ### V1.0.2
4
-
5
- - Added back transpiled files
6
-
7
3
  ### V1.0.1
8
4
 
9
5
  - Fixed Lingui by removing @lingui/macro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedia/recommendation-screen",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Hedia Recommendation Screen for Bolus and Carbohydrates",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import RecommendationScreen from "./src/RecommendationScreen";
2
- import { RecommendationErrorEnum } from "./src/types/enum";
3
- import { ActivityNullError, ActivityRangeError, CarbohydrateLimitError, InsulinLimitError, RecommendationError } from "./src/utils/RecommendationError";
4
- export default RecommendationScreen;
5
- export { ActivityNullError, ActivityRangeError, CarbohydrateLimitError, InsulinLimitError, RecommendationError, RecommendationErrorEnum, };
package/index.js DELETED
@@ -1,16 +0,0 @@
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.RecommendationErrorEnum = exports.RecommendationError = exports.InsulinLimitError = exports.CarbohydrateLimitError = exports.ActivityRangeError = exports.ActivityNullError = void 0;
7
- const RecommendationScreen_1 = __importDefault(require("./src/RecommendationScreen"));
8
- const enum_1 = require("./src/types/enum");
9
- Object.defineProperty(exports, "RecommendationErrorEnum", { enumerable: true, get: function () { return enum_1.RecommendationErrorEnum; } });
10
- const RecommendationError_1 = require("./src/utils/RecommendationError");
11
- Object.defineProperty(exports, "ActivityNullError", { enumerable: true, get: function () { return RecommendationError_1.ActivityNullError; } });
12
- Object.defineProperty(exports, "ActivityRangeError", { enumerable: true, get: function () { return RecommendationError_1.ActivityRangeError; } });
13
- Object.defineProperty(exports, "CarbohydrateLimitError", { enumerable: true, get: function () { return RecommendationError_1.CarbohydrateLimitError; } });
14
- Object.defineProperty(exports, "InsulinLimitError", { enumerable: true, get: function () { return RecommendationError_1.InsulinLimitError; } });
15
- Object.defineProperty(exports, "RecommendationError", { enumerable: true, get: function () { return RecommendationError_1.RecommendationError; } });
16
- exports.default = RecommendationScreen_1.default;
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { BGUnit, InjectionMethod, Languages, MoodEnum } from "./types/enum";
3
- import * as Calculator from "@hedia/recommendation-calculator";
4
- import { RecommendationError } from "./utils/RecommendationError";
5
- interface IResult {
6
- suggested: number;
7
- entered?: number;
8
- }
9
- export interface IRecommendationProps {
10
- units: BGUnit;
11
- language: Languages;
12
- calculatorParams: Calculator.IRecommendationParams;
13
- injectionMethod: InjectionMethod;
14
- exitCallback(): void;
15
- removeRecommendedCarbs(): void;
16
- onRecentInsulinYes(): void;
17
- transferToLogbook(carbs: IResult, insulin: IResult, reminder: number): void;
18
- onError(error: RecommendationError): void;
19
- }
20
- interface IState {
21
- remeasureTime: number;
22
- showRecentInsulin: boolean;
23
- insulinRecommendation: number;
24
- activityReduction?: number;
25
- carbRecommendation: number;
26
- activeInsulin: number;
27
- selectedMood: MoodEnum | 0;
28
- enteredCarbs?: number;
29
- enteredInsulin?: number;
30
- }
31
- export default class RecommendationScreen extends React.Component<IRecommendationProps, IState> {
32
- constructor(props: IRecommendationProps);
33
- updateRemeasureTime: (remeasureTime: number) => void;
34
- handleNoRecentInsulin: () => void;
35
- removeCarbRecommendation: () => void;
36
- handleMoodSelected: (selectedMood: IState["selectedMood"]) => void;
37
- updateCarbRecommendation: (enteredCarbs: number) => void;
38
- updateInsulinRecommendation: (enteredInsulin: number) => void;
39
- handleTransfer: () => void;
40
- render(): JSX.Element;
41
- }
42
- export {};
@@ -1,141 +0,0 @@
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 Constants_1 = require("./utils/Constants");
28
- const Header_1 = __importStar(require("./components/Header"));
29
- const InfoBars_1 = __importStar(require("./components/InfoBars"));
30
- const RecentInsulin_1 = __importDefault(require("./components/RecentInsulin"));
31
- const RecommendedCarbs_1 = __importDefault(require("./components/RecommendedCarbs"));
32
- const RecommendedInsulin_1 = __importDefault(require("./components/RecommendedInsulin"));
33
- const Remeasure_1 = __importDefault(require("./components/Remeasure"));
34
- const Calculator = __importStar(require("@hedia/recommendation-calculator"));
35
- const react_2 = require("@lingui/react");
36
- const Emotion_1 = __importDefault(require("./components/Emotion"));
37
- const TransferToLogbook_1 = __importDefault(require("./components/TransferToLogbook"));
38
- const i18nUtils_1 = require("./locale/i18nUtils");
39
- const Utils_1 = require("./utils/Utils");
40
- class RecommendationScreen extends react_1.default.Component {
41
- constructor(props) {
42
- super(props);
43
- this.updateRemeasureTime = (remeasureTime) => {
44
- this.setState({
45
- remeasureTime,
46
- });
47
- };
48
- this.handleNoRecentInsulin = () => {
49
- this.setState({
50
- showRecentInsulin: false,
51
- });
52
- };
53
- this.removeCarbRecommendation = () => {
54
- this.setState({
55
- enteredCarbs: null,
56
- carbRecommendation: null,
57
- });
58
- this.props.removeRecommendedCarbs();
59
- };
60
- this.handleMoodSelected = (selectedMood) => {
61
- this.setState({
62
- selectedMood,
63
- });
64
- };
65
- this.updateCarbRecommendation = (enteredCarbs) => {
66
- this.setState({
67
- enteredCarbs,
68
- });
69
- };
70
- this.updateInsulinRecommendation = (enteredInsulin) => {
71
- this.setState({
72
- enteredInsulin,
73
- });
74
- };
75
- this.handleTransfer = () => {
76
- this.props.transferToLogbook({
77
- suggested: this.state.carbRecommendation,
78
- entered: this.state.enteredCarbs,
79
- }, {
80
- suggested: this.state.insulinRecommendation,
81
- entered: this.state.enteredInsulin,
82
- }, this.state.remeasureTime);
83
- };
84
- i18nUtils_1.changeLanguage(props.language);
85
- const { bolus, carbRecommendation, activityReduction } = Calculator.calculateRecommendation(props.calculatorParams);
86
- this.state = {
87
- remeasureTime: 1.5,
88
- showRecentInsulin: true,
89
- insulinRecommendation: Utils_1.Utils.roundValue(bolus, props.injectionMethod),
90
- activityReduction,
91
- carbRecommendation,
92
- activeInsulin: 0.0,
93
- selectedMood: 0,
94
- };
95
- }
96
- render() {
97
- return (<react_2.I18nProvider language={this.props.language} i18n={i18nUtils_1.i18n}>
98
- <react_native_1.ScrollView style={containerStyles.container}>
99
- <Header_1.default exitCallback={this.props.exitCallback}/>
100
- <InfoBars_1.default label={i18nUtils_1.i18n._("Active Insulin")} value={`${this.state.activeInsulin}`} units={i18nUtils_1.i18n._("units")} showZeroAsDash={false}/>
101
- <InfoBars_1.default label={i18nUtils_1.i18n._("Blood Glucose Level")} value={`${this.props.calculatorParams.currentBGL}`} units={this.props.units} showZeroAsDash={true}/>
102
- <react_native_1.View style={containerStyles.calcContainer}>
103
- <react_native_1.View style={containerStyles.calcMargin}>
104
- <react_native_1.View style={[
105
- containerStyles.calcBorder,
106
- {
107
- borderColor: this.state.carbRecommendation
108
- ? Constants_1.BORDER_COLOUR_TEAL
109
- : Constants_1.BORDER_COLOUR_WHITE,
110
- },
111
- ]}>
112
- <RecommendedCarbs_1.default enteredCarbs={`${this.props.calculatorParams.carbohydrates}`} changedRecommendedCarbs={this.updateCarbRecommendation} recommendedCarbs={`${this.state.enteredCarbs ?? this.state.carbRecommendation}`} removeRecommendedCarbs={this.removeCarbRecommendation} onError={this.props.onError}/>
113
- <Remeasure_1.default onSliderChange={this.updateRemeasureTime} remeasureTime={this.state.remeasureTime}/>
114
- </react_native_1.View>
115
- </react_native_1.View>
116
- </react_native_1.View>
117
- {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}/>)}
118
- <Emotion_1.default moodSelected={this.handleMoodSelected}/>
119
- <TransferToLogbook_1.default visible={!this.state.showRecentInsulin} transfer={this.handleTransfer}/>
120
- </react_native_1.ScrollView>
121
- </react_2.I18nProvider>);
122
- }
123
- }
124
- exports.default = RecommendationScreen;
125
- const containerStyles = react_native_1.StyleSheet.create({
126
- container: {
127
- flex: 1,
128
- backgroundColor: Constants_1.BACKGROUND_COLOUR_PURPLE,
129
- },
130
- calcContainer: {
131
- flex: 1,
132
- },
133
- calcMargin: {
134
- flex: 1,
135
- margin: Header_1.headerStyles.margin.margin,
136
- },
137
- calcBorder: {
138
- ...InfoBars_1.infoStyles.border,
139
- borderColor: Constants_1.BORDER_COLOUR_TEAL,
140
- },
141
- });
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import { MoodEnum } from "../types/enum";
3
- interface IProps {
4
- moodSelected(mood: MoodEnum | 0): void;
5
- }
6
- interface IState {
7
- selected: MoodEnum | 0;
8
- }
9
- export default class Emotion extends React.Component<IProps, IState> {
10
- state: IState;
11
- handleIconPress: (selected: number, toggle: boolean) => void;
12
- render(): JSX.Element;
13
- }
14
- export {};
@@ -1,54 +0,0 @@
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 i18nUtils_1 = require("../locale/i18nUtils");
9
- const enum_1 = require("../types/enum");
10
- const MoodIcon_1 = __importDefault(require("./MoodIcon"));
11
- class Emotion extends react_1.default.Component {
12
- constructor() {
13
- super(...arguments);
14
- this.state = {
15
- selected: 0,
16
- };
17
- this.handleIconPress = (selected, toggle) => {
18
- const select = toggle ? selected : 0;
19
- this.setState({
20
- selected: select,
21
- });
22
- this.props.moodSelected(select);
23
- };
24
- }
25
- 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
- return (<react_native_1.View style={emotionStyles.container}>
32
- <react_native_1.View style={emotionStyles.feelingContainer}>
33
- <react_native_1.Text style={emotionStyles.feelingText}>{i18nUtils_1.i18n._("How are you feeling?")}</react_native_1.Text>
34
- </react_native_1.View>
35
- <react_native_1.View style={emotionStyles.moodIconContainer}>{mapped}</react_native_1.View>
36
- </react_native_1.View>);
37
- }
38
- }
39
- exports.default = Emotion;
40
- const emotionStyles = react_native_1.StyleSheet.create({
41
- container: {
42
- flex: 1,
43
- },
44
- feelingContainer: {
45
- marginVertical: `3%`,
46
- },
47
- feelingText: {
48
- textAlign: `center`,
49
- color: `white`,
50
- fontWeight: `bold`,
51
- fontSize: react_native_1.Dimensions.get(`screen`).width / 26,
52
- },
53
- moodIconContainer: { flex: 1, flexDirection: `row`, justifyContent: `center` },
54
- });
@@ -1,52 +0,0 @@
1
- import React from "react";
2
- import { IRecommendationProps } from "../RecommendationScreen";
3
- interface IProps {
4
- exitCallback: IRecommendationProps["exitCallback"];
5
- }
6
- interface IState {
7
- hello: string;
8
- }
9
- export default class Header extends React.Component<IProps, IState> {
10
- state: IState;
11
- render(): JSX.Element;
12
- }
13
- export declare const headerStyles: {
14
- backgroundColour: {
15
- backgroundColor: string;
16
- };
17
- margin: {
18
- margin: string;
19
- flexDirection: "row";
20
- flex: number;
21
- };
22
- headerContainer: {
23
- flexDirection: "row";
24
- flex: number;
25
- };
26
- exitButtonContainer: {
27
- flex: number;
28
- };
29
- exitButton: {
30
- flex: number;
31
- };
32
- iconStyle: {
33
- fontSize: number;
34
- color: string;
35
- };
36
- headerTextContainer: {
37
- flex: number;
38
- justifyContent: "center";
39
- alignItems: "center";
40
- marginTop: string;
41
- };
42
- headerText: {
43
- fontSize: number;
44
- fontWeight: "bold";
45
- textAlign: "center";
46
- color: string;
47
- };
48
- headerFiller: {
49
- flex: number;
50
- };
51
- };
52
- export {};
@@ -1,82 +0,0 @@
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 react_1 = __importDefault(require("react"));
8
- const react_native_1 = require("react-native");
9
- const i18nUtils_1 = require("../locale/i18nUtils");
10
- const Constants_1 = require("../utils/Constants");
11
- const Icon_1 = __importDefault(require("./Icon"));
12
- class Header extends react_1.default.Component {
13
- constructor() {
14
- super(...arguments);
15
- this.state = {
16
- hello: `World`,
17
- };
18
- }
19
- render() {
20
- return (<react_1.default.Fragment>
21
- <react_native_1.SafeAreaView style={exports.headerStyles.backgroundColour}/>
22
- <react_native_1.View style={exports.headerStyles.headerContainer}>
23
- <react_native_1.View style={exports.headerStyles.margin}>
24
- <react_native_1.View style={exports.headerStyles.exitButtonContainer}>
25
- <react_native_1.View style={exports.headerStyles.exitButton}>
26
- <react_native_1.TouchableOpacity accessibilityLabel="exitButton" style={exports.headerStyles.exitButton} onPress={this.props.exitCallback}>
27
- <Icon_1.default iconIdentifier={`Ionicons/ios-close-circle-outline`} style={exports.headerStyles.iconStyle}/>
28
- </react_native_1.TouchableOpacity>
29
- <react_native_1.View style={exports.headerStyles.headerFiller}/>
30
- </react_native_1.View>
31
- </react_native_1.View>
32
- <react_native_1.View style={exports.headerStyles.headerTextContainer}>
33
- <react_native_1.Text style={exports.headerStyles.headerText} testID="headerText">
34
- {i18nUtils_1.i18n._("INSULIN\nRECOMMENDATION")}
35
- </react_native_1.Text>
36
- </react_native_1.View>
37
- <react_native_1.View style={exports.headerStyles.headerFiller}/>
38
- </react_native_1.View>
39
- </react_native_1.View>
40
- </react_1.default.Fragment>);
41
- }
42
- }
43
- exports.default = Header;
44
- exports.headerStyles = react_native_1.StyleSheet.create({
45
- backgroundColour: {
46
- backgroundColor: Constants_1.BACKGROUND_COLOUR_PURPLE,
47
- },
48
- margin: {
49
- margin: `3%`,
50
- flexDirection: `row`,
51
- flex: 1,
52
- },
53
- headerContainer: {
54
- flexDirection: `row`,
55
- flex: 1,
56
- },
57
- exitButtonContainer: {
58
- flex: 1,
59
- },
60
- exitButton: {
61
- flex: 1,
62
- },
63
- iconStyle: {
64
- fontSize: react_native_1.Dimensions.get(`screen`).width / 10,
65
- color: Constants_1.BORDER_COLOUR_WHITE,
66
- },
67
- headerTextContainer: {
68
- flex: 5,
69
- justifyContent: `center`,
70
- alignItems: `center`,
71
- marginTop: `5%`,
72
- },
73
- headerText: {
74
- fontSize: react_native_1.Dimensions.get(`screen`).width / 14,
75
- fontWeight: `bold`,
76
- textAlign: `center`,
77
- color: `white`,
78
- },
79
- headerFiller: {
80
- flex: 1,
81
- },
82
- });
@@ -1,67 +0,0 @@
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
- };
@@ -1,89 +0,0 @@
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
- });
@@ -1,24 +0,0 @@
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 {};
@@ -1,64 +0,0 @@
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
- });