Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
432c56c0
Commit
432c56c0
authored
6 years ago
by
tina
Browse files
Options
Downloads
Patches
Plain Diff
information about bleeding data is shown on home screen
parent
e0474400
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/home.js
+34
-6
34 additions, 6 deletions
components/home.js
components/labels.js
+9
-0
9 additions, 0 deletions
components/labels.js
package-lock.json
+1545
-1545
1545 additions, 1545 deletions
package-lock.json
with
1588 additions
and
1551 deletions
components/home.js
+
34
−
6
View file @
432c56c0
...
@@ -5,10 +5,11 @@ import {
...
@@ -5,10 +5,11 @@ import {
Text
,
Text
,
ScrollView
ScrollView
}
from
'
react-native
'
}
from
'
react-native
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
LocalDate
,
ChronoUnit
}
from
'
js-joda
'
import
styles
from
'
../styles/index
'
import
styles
from
'
../styles/index
'
import
cycleModule
from
'
../lib/cycle
'
import
cycleModule
from
'
../lib/cycle
'
import
{
getOrCreateCycleDay
,
bleedingDaysSortedByDate
,
fillWithDummyData
,
deleteAll
}
from
'
../db
'
import
{
getOrCreateCycleDay
,
bleedingDaysSortedByDate
,
fillWithDummyData
,
deleteAll
}
from
'
../db
'
import
{
bleedingPrediction
as
labels
}
from
'
./labels
'
const
getCycleDayNumber
=
cycleModule
().
getCycleDayNumber
const
getCycleDayNumber
=
cycleModule
().
getCycleDayNumber
...
@@ -19,23 +20,25 @@ export default class Home extends Component {
...
@@ -19,23 +20,25 @@ export default class Home extends Component {
const
cycleDayNumber
=
getCycleDayNumber
(
this
.
todayDateString
)
const
cycleDayNumber
=
getCycleDayNumber
(
this
.
todayDateString
)
this
.
state
=
{
this
.
state
=
{
welcomeText
:
determineWelcomeText
(
cycleDayNumber
)
welcomeText
:
determineWelcomeText
(
cycleDayNumber
),
predictionText
:
determinePredictionText
()
}
}
this
.
setStateWithCurrent
Welcome
Text
=
(
function
(
HomeComponent
)
{
this
.
setStateWithCurrentText
=
(
function
(
HomeComponent
)
{
return
function
()
{
return
function
()
{
const
cycleDayNumber
=
getCycleDayNumber
(
HomeComponent
.
todayDateString
)
const
cycleDayNumber
=
getCycleDayNumber
(
HomeComponent
.
todayDateString
)
HomeComponent
.
setState
({
HomeComponent
.
setState
({
welcomeText
:
determineWelcomeText
(
cycleDayNumber
)
welcomeText
:
determineWelcomeText
(
cycleDayNumber
),
predictionText
:
determinePredictionText
()
})
})
}
}
})(
this
)
})(
this
)
bleedingDaysSortedByDate
.
addListener
(
this
.
setStateWithCurrent
Welcome
Text
)
bleedingDaysSortedByDate
.
addListener
(
this
.
setStateWithCurrentText
)
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
bleedingDaysSortedByDate
.
removeListener
(
this
.
setStateWithCurrent
Welcome
Text
)
bleedingDaysSortedByDate
.
removeListener
(
this
.
setStateWithCurrentText
)
}
}
passTodayToDayView
()
{
passTodayToDayView
()
{
...
@@ -49,6 +52,7 @@ export default class Home extends Component {
...
@@ -49,6 +52,7 @@ export default class Home extends Component {
return
(
return
(
<
ScrollView
>
<
ScrollView
>
<
Text
style
=
{
styles
.
welcome
}
>
{
this
.
state
.
welcomeText
}
<
/Text
>
<
Text
style
=
{
styles
.
welcome
}
>
{
this
.
state
.
welcomeText
}
<
/Text
>
<
Text
style
=
{
styles
.
welcome
}
>
{
this
.
state
.
predictionText
}
<
/Text
>
<
View
style
=
{
styles
.
homeButtons
}
>
<
View
style
=
{
styles
.
homeButtons
}
>
<
View
style
=
{
styles
.
homeButton
}
>
<
View
style
=
{
styles
.
homeButton
}
>
<
Button
<
Button
...
@@ -80,3 +84,27 @@ function determineWelcomeText(cycleDayNumber) {
...
@@ -80,3 +84,27 @@ function determineWelcomeText(cycleDayNumber) {
return
cycleDayNumber
?
welcomeTextWithCycleDay
:
welcomeText
return
cycleDayNumber
?
welcomeTextWithCycleDay
:
welcomeText
}
}
function
determinePredictionText
()
{
const
bleedingPrediction
=
cycleModule
().
getPredictedMenses
()
if
(
!
bleedingPrediction
.
length
)
return
labels
.
noPrediction
const
todayDate
=
LocalDate
.
now
()
const
bleedingStart
=
LocalDate
.
parse
(
bleedingPrediction
[
0
][
0
])
const
bleedingEnd
=
LocalDate
.
parse
(
bleedingPrediction
[
0
][
bleedingPrediction
[
0
].
length
-
1
])
if
(
todayDate
.
isBefore
(
bleedingStart
))
{
return
labels
.
predictionInFuture
(
todayDate
.
until
(
bleedingStart
,
ChronoUnit
.
DAYS
),
todayDate
.
until
(
bleedingEnd
,
ChronoUnit
.
DAYS
)
)
}
if
(
todayDate
.
isAfter
(
bleedingEnd
))
{
return
labels
.
predictionInPast
(
bleedingStart
.
toString
(),
bleedingEnd
.
toString
())
}
const
daysToEnd
=
todayDate
.
until
(
bleedingEnd
,
ChronoUnit
.
DAYS
)
if
(
daysToEnd
===
0
)
{
return
labels
.
predictionStartedNoDaysLeft
}
else
if
(
daysToEnd
===
1
)
{
return
labels
.
predictionStarted1DayLeft
}
else
{
return
labels
.
predictionStartedXDaysLeft
(
daysToEnd
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
components/labels.js
+
9
−
0
View file @
432c56c0
...
@@ -56,4 +56,13 @@ export const stats = {
...
@@ -56,4 +56,13 @@ export const stats = {
minLabel
:
'
Shortest cycle
'
,
minLabel
:
'
Shortest cycle
'
,
maxLabel
:
'
Longest cycle
'
,
maxLabel
:
'
Longest cycle
'
,
stdLabel
:
'
Standard deviation
'
stdLabel
:
'
Standard deviation
'
}
export
const
bleedingPrediction
=
{
noPrediction
:
'
There is not enough period data to predict the next one.
'
,
predictionInFuture
:
(
startDays
,
endDays
)
=>
`Your next period is likely to start in
${
startDays
}
to
${
endDays
}
days.`
,
predictionStartedXDaysLeft
:
(
numberOfDays
)
=>
`Your period is likely to start today or during the next
${
numberOfDays
}
days.`
,
predictionStarted1DayLeft
:
'
Your period is likely to start today or tomorrow.
'
,
predictionStartedNoDaysLeft
:
'
Your period is likely to start today.
'
,
predictionInPast
:
(
startDate
,
endDate
)
=>
`Based on your documented data, your period was likely to start between
${
startDate
}
and
${
endDate
}
.`
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
package-lock.json
+
1545
−
1545
View file @
432c56c0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment