-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored screens, test improvements
- Loading branch information
1 parent
1a2e646
commit 6724711
Showing
11 changed files
with
285 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'test-file-stub' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "DiabetorRnGui", | ||
"name": "diabetor-gui", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,82 @@ | ||
import React, {useState} from 'react' | ||
import {Text, View} from 'react-native' | ||
import React from 'react' | ||
import {SafeAreaView, Text, View} from 'react-native' | ||
import {DbNumericTextInput} from '../components/DbNumericTextInputComponent' | ||
import {screenStyles} from './styles' | ||
//import {ScreenComponentType} from '@react-navigation/core/src/types' | ||
|
||
// interface NightGlycemiaInterval { | ||
// glycemiaBefore: number | ||
// glycemiaAfter: number | ||
// } | ||
|
||
export function BasalAdaptationScreen() { | ||
const [glycemiasBefore, setGlycemiaBefore] = useState<number[]>([]) | ||
|
||
const [glycemiasAfter, setGlycemiaAfter] = useState<number[]>([]) | ||
interface BasalState { | ||
glycemiasBefore: number[] | ||
glycemiasAfter: number[] | ||
} | ||
|
||
const manageGlycemiaBefore = (i: number, glycemiaStr: string) => { | ||
setGlycemiaBefore((existing: number[]) => { | ||
existing[i] = parseFloat(glycemiaStr) | ||
return existing | ||
}) | ||
export class BasalAdaptationScreen extends React.Component<{}, BasalState> { | ||
constructor(props: {}) { | ||
super(props) | ||
this.state = { | ||
glycemiasBefore: [], | ||
glycemiasAfter: [], | ||
} | ||
} | ||
|
||
const manageGlycemiaAfter = (i: number, glycemiaStr: string) => { | ||
setGlycemiaAfter((existing: number[]) => { | ||
existing[i] = parseFloat(glycemiaStr) | ||
return existing | ||
}) | ||
} | ||
render() { | ||
const manageGlycemiaBefore = (i: number, glycemiaStr: string) => { | ||
let newBefore = Array.from(this.state.glycemiasBefore) | ||
newBefore[i] = parseFloat(glycemiaStr) | ||
|
||
const glycemiaIntervalInputs = [] | ||
for (let i = 0; i < 3; i++) { | ||
glycemiaIntervalInputs.push( | ||
<View key={i} style={{flexDirection: 'row'}}> | ||
<Text style={{color: 'black', verticalAlign: 'middle'}}> | ||
Interval {i + 1}:{' '} | ||
</Text> | ||
<DbNumericTextInput | ||
placeholder={'glycemia before ' + (i + 1)} | ||
onChangeText={newtText => { | ||
manageGlycemiaBefore(i, newtText) | ||
}} | ||
/> | ||
<DbNumericTextInput | ||
placeholder={'glycemia after ' + (i + 1)} | ||
onChangeText={newtText => { | ||
manageGlycemiaAfter(i, newtText) | ||
}} | ||
/> | ||
</View>, | ||
) | ||
} | ||
this.setState({ | ||
glycemiasBefore: newBefore, | ||
}) | ||
} | ||
|
||
const manageGlycemiaAfter = (i: number, glycemiaStr: string) => { | ||
let newAfter = Array.from(this.state.glycemiasAfter) | ||
newAfter[i] = parseFloat(glycemiaStr) | ||
|
||
return ( | ||
<View> | ||
<Text style={{color: 'black'}}>Basal adaptation</Text> | ||
this.setState({ | ||
glycemiasAfter: newAfter, | ||
}) | ||
} | ||
|
||
{glycemiaIntervalInputs} | ||
const glycemiaIntervalInputs = [] | ||
for (let i = 0; i < 3; i++) { | ||
glycemiaIntervalInputs.push( | ||
<View key={i} style={screenStyles.intervalContainer}> | ||
<Text style={screenStyles.intervalLabel}>Interval {i + 1}: </Text> | ||
<DbNumericTextInput | ||
placeholder={'glycemia before ' + (i + 1)} | ||
onChangeText={newtText => { | ||
manageGlycemiaBefore(i, newtText) | ||
}} | ||
/> | ||
<DbNumericTextInput | ||
placeholder={'glycemia after ' + (i + 1)} | ||
onChangeText={newtText => { | ||
manageGlycemiaAfter(i, newtText) | ||
}} | ||
/> | ||
</View>, | ||
) | ||
} | ||
|
||
<View> | ||
<Text style={{color: 'black'}}>{glycemiasBefore.join(', ')}</Text> | ||
<Text style={{color: 'black'}}>{glycemiasAfter.join(', ')}</Text> | ||
</View> | ||
</View> | ||
) | ||
return ( | ||
<SafeAreaView style={screenStyles.screenBackground}> | ||
<View> | ||
{glycemiaIntervalInputs} | ||
<View> | ||
<Text style={screenStyles.intervalSummary}> | ||
{this.state.glycemiasBefore.join(', ')} | ||
</Text> | ||
<Text style={screenStyles.intervalSummary}> | ||
{this.state.glycemiasAfter.join(', ')} | ||
</Text> | ||
</View> | ||
</View> | ||
</SafeAreaView> | ||
) | ||
} | ||
} | ||
|
||
// interface NightGlycemiaInterval { | ||
// glycemiaBefore: number | ||
// glycemiaAfter: number | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.