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
2f58db84
Commit
2f58db84
authored
6 years ago
by
emelko
Browse files
Options
Downloads
Patches
Plain Diff
Edit temperature, save value to db, show on dayview
parent
933b6405
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
app.js
+5
-3
5 additions, 3 deletions
app.js
day-view.js
+18
-4
18 additions, 4 deletions
day-view.js
db.js
+9
-11
9 additions, 11 deletions
db.js
home.js
+1
-5
1 addition, 5 deletions
home.js
list.js
+0
-60
0 additions, 60 deletions
list.js
temperature.js
+76
-0
76 additions, 0 deletions
temperature.js
with
109 additions
and
83 deletions
app.js
+
5
−
3
View file @
2f58db84
import
{
createStackNavigator
}
from
'
react-navigation
'
import
Home
from
'
./home
'
import
TemperatureList
from
'
./list
'
import
Temperature
from
'
./temperature
'
import
Calendar
from
'
./calendar
'
import
DayView
from
'
./day-view
'
import
Bleeding
from
'
./bleeding
'
...
...
@@ -11,8 +12,9 @@ YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated'])
export
default
createStackNavigator
({
home
:
{
screen
:
Home
},
temperatureList
:
{
screen
:
TemperatureList
},
temperature
:
{
screen
:
Temperature
},
calendar
:
{
screen
:
Calendar
},
dayView
:
{
screen
:
DayView
},
bleeding
:
{
screen
:
Bleeding
}
})
\ No newline at end of file
})
This diff is collapsed.
Click to expand it.
day-view.js
+
18
−
4
View file @
2f58db84
...
...
@@ -19,24 +19,38 @@ export default class DayView extends Component {
render
()
{
const
navigate
=
this
.
props
.
navigation
.
navigate
const
d
ay
=
this
.
state
.
cycleDay
const
bleedingValue
=
d
ay
.
bleeding
&&
d
ay
.
bleeding
.
value
const
cycleD
ay
=
this
.
state
.
cycleDay
const
bleedingValue
=
cycleD
ay
.
bleeding
&&
cycleD
ay
.
bleeding
.
value
let
bleedingLabel
if
(
typeof
bleedingValue
===
'
number
'
)
{
bleedingLabel
=
`Bleeding:
${
labels
[
bleedingValue
]}
`
if
(
cycleDay
.
bleeding
.
exclude
)
bleedingLabel
+=
"
(Excluded)
"
}
else
{
bleedingLabel
=
''
}
const
temperatureValue
=
cycleDay
.
temperature
&&
cycleDay
.
temperature
.
value
let
temperatureLabel
if
(
typeof
temperatureValue
===
'
number
'
)
{
temperatureLabel
=
`Temperature:
${
temperatureValue
}
`
if
(
cycleDay
.
temperature
.
exclude
)
temperatureLabel
+=
"
(Excluded)
"
}
else
{
temperatureLabel
=
''
}
return
(
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
welcome
}
>
{
formatDateForViewHeader
(
d
ay
.
date
)}
<
/Text
>
<
Text
style
=
{
styles
.
welcome
}
>
{
formatDateForViewHeader
(
cycleD
ay
.
date
)}
<
/Text
>
<
Text
>
Cycle
day
{
getCycleDay
()}
<
/Text
>
<
Text
style
=
{
styles
.
welcome
}
>
{
bleedingLabel
}
<
/Text
>
<
Text
style
=
{
styles
.
welcome
}
>
{
temperatureLabel
}
<
/Text
>
<
Button
onPress
=
{()
=>
navigate
(
'
bleeding
'
,
{
cycleDay
:
day
})}
onPress
=
{()
=>
navigate
(
'
bleeding
'
,
{
cycleDay
})}
title
=
"
Edit bleeding
"
>
<
/Button
>
<
Button
onPress
=
{()
=>
navigate
(
'
temperature
'
,
{
cycleDay
})}
title
=
"
Edit temperature
"
>
<
/Button
>
<
/View
>
)
}
...
...
This diff is collapsed.
Click to expand it.
db.js
+
9
−
11
View file @
2f58db84
import
realm
from
'
realm
'
let
db
let
cycleDaysSortedbyTempValueView
=
[]
let
bleedingDaysSortedByDate
=
[]
let
cycleDaysSortedbyDate
=
[]
const
TemperatureSchema
=
{
name
:
'
Temperature
'
,
...
...
@@ -46,19 +47,17 @@ async function openDatabase() {
// we only want this in dev mode
deleteRealmIfMigrationNeeded
:
true
})
bleedingDaysSortedByDate
=
db
.
objects
(
'
CycleDay
'
).
fil
<<<<<<<
933
b64056a13d04c3bfdebf531962b84d9daa4ce
// just for testing purposes, the highest temperature will be topmost
// because I was too layz to make a scroll view
cycleDaysSortedbyTempValueView
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
temperature != null
'
).
sorted
(
'
temperature.value
'
,
true
)
bleeding
DaysSorted
B
yDate
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
bleeding != null
'
).
sorted
(
'
date
'
,
true
)
cycleDaysSortedbyTempValueView
=
db
.
objects
(
'
CycleDay
'
).
filtered
(
'
temperature != null
'
).
sorted
(
'
temperature.value
'
,
true
)
tered
(
'
bleeding != null
'
).
sorted
(
'
date
'
,
true
)
cycle
DaysSorted
b
yDate
=
db
.
objects
(
'
CycleDay
'
).
sorted
(
'
date
'
,
true
)
}
function
saveTemperature
(
date
,
temperature
)
{
function
saveTemperature
(
cycleDay
,
temperature
)
{
db
.
write
(()
=>
{
const
doc
=
{
date
,
temperature
}
db
.
create
(
'
CycleDay
'
,
doc
)
cycleDay
.
temperature
=
temperature
})
}
...
...
@@ -81,10 +80,9 @@ function getOrCreateCycleDay(localDate) {
}
export
{
cycleDaysSortedbyTempValueView
,
openDatabase
,
saveTemperature
,
saveBleeding
,
getOrCreateCycleDay
,
bleedingDaysSortedByDate
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
home.js
+
1
−
5
View file @
2f58db84
...
...
@@ -17,10 +17,6 @@ export default class Home extends Component {
return
(
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
welcome
}
>
Welcome
!
Today
is
day
{
getCycleDay
()}
of
your
current
cycle
<
/Text
>
<
Button
onPress
=
{()
=>
navigate
(
'
temperatureList
'
)}
title
=
"
Edit symptoms for today
"
>
<
/Button
>
<
Button
onPress
=
{()
=>
navigate
(
'
calendar
'
)}
title
=
"
Go to calendar
"
>
...
...
@@ -28,4 +24,4 @@ export default class Home extends Component {
<
/View
>
)
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
list.js
deleted
100644 → 0
+
0
−
60
View file @
933b6405
import
React
,
{
Component
}
from
'
react
'
import
{
View
,
Text
,
Button
,
TextInput
,
FlatList
,
Keyboard
}
from
'
react-native
'
import
*
as
styles
from
'
./styles
'
import
{
cycleDaysSortedbyTempValueView
,
saveTemperature
}
from
'
./db
'
export
default
class
Temp
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
currentValue
:
''
,
rerenderToggle
:
false
}
}
render
()
{
return
(
<
View
style
=
{
styles
.
container
}
>
<
TextInput
placeholder
=
"
Enter your temperature
"
onChangeText
=
{(
val
)
=>
{
this
.
setState
({
currentValue
:
val
})
}}
keyboardType
=
'
numeric
'
value
=
{
this
.
state
.
currentValue
}
/
>
<
Button
onPress
=
{()
=>
{
console
.
log
(
Number
(
this
.
state
.
currentValue
))
saveTemperature
(
new
Date
(),
{
value
:
Number
(
this
.
state
.
currentValue
),
exclude
:
false
}
)
this
.
setState
({
currentValue
:
''
})
// FlatList only reacts to primitive value changes,
// this boolean toggle makes sure the list updates
this
.
setState
({
reRender
:
!
this
.
state
.
rerenderToggle
})
Keyboard
.
dismiss
()
}}
title
=
"
Save
"
/>
<
FlatList
data
=
{
cycleDaysSortedbyTempValueView
}
renderItem
=
{({
item
})
=>
<
Text
>
{
item
.
temperature
.
value
}
<
/Text>
}
extraData
=
{
this
.
state
}
/
>
<
/View
>
)
}
}
This diff is collapsed.
Click to expand it.
temperature.js
0 → 100644
+
76
−
0
View file @
2f58db84
import
React
,
{
Component
}
from
'
react
'
import
{
View
,
Text
,
Button
,
TextInput
,
Switch
}
from
'
react-native
'
import
styles
from
'
./styles
'
import
{
saveTemperature
}
from
'
./db
'
import
{
formatDateForViewHeader
}
from
'
./format
'
import
getCycleDay
from
'
./get-cycle-day
'
export
default
class
Temp
extends
Component
{
constructor
(
props
)
{
super
(
props
)
const
cycleDay
=
props
.
navigation
.
state
.
params
.
cycleDay
console
.
log
(
cycleDay
.
temperature
?
cycleDay
.
temperature
.
value
:
''
)
this
.
state
=
{
cycleDay
,
currentValue
:
cycleDay
.
temperature
?
cycleDay
.
temperature
.
value
.
toString
()
:
''
,
exclude
:
cycleDay
.
temperature
?
cycleDay
.
temperature
.
exclude
:
false
}
}
render
()
{
const
navigate
=
this
.
props
.
navigation
.
navigate
const
cycleDay
=
this
.
state
.
cycleDay
return
(
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
welcome
}
>
{
formatDateForViewHeader
(
cycleDay
.
date
)}
<
/Text
>
<
Text
>
Cycle
day
{
getCycleDay
()}
<
/Text
>
<
Text
>
Temperature
<
/Text
>
<
TextInput
placeholder
=
"
Enter temperature
"
onChangeText
=
{(
val
)
=>
{
this
.
setState
({
currentValue
:
val
})
}}
keyboardType
=
'
numeric
'
value
=
{
this
.
state
.
currentValue
}
/
>
<
Text
>
Exclude
<
/Text
>
<
Switch
onValueChange
=
{(
val
)
=>
{
this
.
setState
({
exclude
:
val
})
}}
value
=
{
this
.
state
.
exclude
}
/
>
<
Button
onPress
=
{()
=>
{
navigate
(
'
dayView
'
,
{
cycleDay
})
}}
title
=
"
Cancel
"
>
<
/Button
>
<
Button
onPress
=
{()
=>
{
saveTemperature
(
cycleDay
)
navigate
(
'
dayView
'
,
{
cycleDay
})
}}
title
=
"
Delete entry
"
>
<
/Button
>
<
Button
onPress
=
{()
=>
{
saveTemperature
(
cycleDay
,
{
value
:
Number
(
this
.
state
.
currentValue
),
exclude
:
this
.
state
.
exclude
})
navigate
(
'
dayView
'
,
{
cycleDay
})
}}
title
=
"
Save
"
>
<
/Button
>
<
/View
>
)
}
}
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