Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
pill_minder
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phuengton Chummuel
pill_minder
Commits
fb253d7f
Commit
fb253d7f
authored
Mar 22, 2018
by
Phuengton Chummuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
little change
parent
c60f4dea
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
345 additions
and
270 deletions
+345
-270
appointmentActions.js
src/actions/appointmentActions.js
+0
-1
reminderAction.js
src/actions/reminderAction.js
+7
-1
AppointmentListItem.js
src/components/AppointmentListItem.js
+27
-9
ReminderBoxList.js
src/components/ReminderBoxList.js
+10
-8
ReminderListItem.js
src/components/ReminderListItem.js
+28
-11
CameraScreen.js
src/screens/CameraScreen.js
+62
-26
HomeScreen.js
src/screens/HomeScreen.js
+208
-207
MedicationListScreen.js
src/screens/MedicationListScreen.js
+1
-1
MedicationsScreen.js
src/screens/MedicationsScreen.js
+2
-6
No files found.
src/actions/appointmentActions.js
View file @
fb253d7f
...
@@ -10,7 +10,6 @@ import { appointmentNotification, cancleNotification } from './../Utils'
...
@@ -10,7 +10,6 @@ import { appointmentNotification, cancleNotification } from './../Utils'
export
const
appointmentCreate
=
({
id
,
doctorName
,
date
,
place
,
time
})
=>
{
export
const
appointmentCreate
=
({
id
,
doctorName
,
date
,
place
,
time
})
=>
{
return
(
dispatch
)
=>
{
return
(
dispatch
)
=>
{
let
appointment
=
{
id
,
doctorName
,
date
,
place
,
time
}
realm
.
write
(()
=>
{
realm
.
write
(()
=>
{
realm
.
create
(
'Appointments'
,
{
realm
.
create
(
'Appointments'
,
{
id
:
id
,
id
:
id
,
...
...
src/actions/reminderAction.js
View file @
fb253d7f
...
@@ -7,9 +7,15 @@ import {
...
@@ -7,9 +7,15 @@ import {
import
realm
from
'./../Database/'
import
realm
from
'./../Database/'
import
moment
from
'moment'
import
moment
from
'moment'
import
{
scheduleLocalNotification
,
cancleNotification
}
from
'./../Utils'
import
{
scheduleLocalNotification
,
cancleNotification
}
from
'./../Utils'
import
{
ToastAndroid
}
from
'react-native'
export
const
reminderCreate
=
({
id
,
medName
,
reminderTime
,
meal
,
period
,
dose
})
=>
{
export
const
reminderCreate
=
({
id
,
medName
,
reminderTime
,
meal
,
period
,
dose
})
=>
{
return
(
dispatch
)
=>
{
return
(
dispatch
)
=>
{
let
isPast
=
moment
().
diff
(
reminderTime
)
if
(
isPast
>
0
)
{
reminderTime
=
new
Date
(
moment
(
reminderTime
).
add
(
1
,
'day'
))
}
ToastAndroid
.
show
(
isPast
.
toString
(),
ToastAndroid
.
SHORT
)
realm
.
write
(()
=>
{
realm
.
write
(()
=>
{
realm
.
create
(
'Reminder'
,
{
realm
.
create
(
'Reminder'
,
{
id
:
id
,
id
:
id
,
...
@@ -21,7 +27,7 @@ export const reminderCreate = ({ id, medName, reminderTime, meal, period, dose }
...
@@ -21,7 +27,7 @@ export const reminderCreate = ({ id, medName, reminderTime, meal, period, dose }
timeStamp
:
moment
().
toDate
()
timeStamp
:
moment
().
toDate
()
})
})
})
})
var
time
=
moment
(
dat
e
).
format
(
'HH:mm'
).
split
(
':'
)
var
time
=
moment
(
reminderTim
e
).
format
(
'HH:mm'
).
split
(
':'
)
var
msg
=
"แจ้งเตือนกินยา
\n
"
+
"เวลา: "
+
time
[
0
]
+
":"
+
time
[
1
]
+
"
\n
ยา: "
+
medName
+
'
\
n'
+
meal
;
var
msg
=
"แจ้งเตือนกินยา
\n
"
+
"เวลา: "
+
time
[
0
]
+
":"
+
time
[
1
]
+
"
\n
ยา: "
+
medName
+
'
\
n'
+
meal
;
scheduleLocalNotification
(
msg
,
reminderTime
,
id
)
scheduleLocalNotification
(
msg
,
reminderTime
,
id
)
let
reminders
=
realm
.
objects
(
"Reminder"
)
let
reminders
=
realm
.
objects
(
"Reminder"
)
...
...
src/components/AppointmentListItem.js
View file @
fb253d7f
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
{
TouchableOpacity
}
from
'react-native'
;
import
{
TouchableOpacity
}
from
'react-native'
;
import
{
View
,
Text
}
from
'native-base'
;
import
{
View
,
Text
,
SwipeRow
,
Button
,
Icon
}
from
'native-base'
;
import
{
appointmentDelete
}
from
'./../actions'
import
{
appointmentDelete
}
from
'./../actions'
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
...
@@ -16,17 +16,34 @@ class AppointmentListItem extends Component {
...
@@ -16,17 +16,34 @@ class AppointmentListItem extends Component {
}
}
render
()
{
render
()
{
const
{
listItem
}
=
styles
return
(
return
(
<
TouchableOpacity
onPress
=
{()
=>
this
.
deleteAppointment
(
this
.
props
.
data
.
id
)}
>
<
SwipeRow
<
View
>
rightOpenValue
=
{
-
75
}
<
Text
>
{
this
.
props
.
data
.
doctorName
}
<
/Text
>
body
=
{
<
Text
>
{
this
.
props
.
data
.
date
}
<
/Text
>
<
View
style
=
{
listItem
}
>
<
Text
>
{
this
.
props
.
data
.
time
}
<
/Text
>
<
Text
>
{
"แพทย์: "
+
this
.
props
.
data
.
doctorName
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
place
}
<
/Text
>
<
Text
>
{
"วันที่: "
+
moment
(
new
Date
(
this
.
props
.
data
.
date
)).
format
(
'DD MMM YYYY'
)}
<
/Text
>
<
/View
>
<
Text
>
{
"เวลา: "
+
moment
(
new
Date
(
this
.
props
.
data
.
date
)).
format
(
'HH:mm'
)}
<
/Text
>
<
/TouchableOpacity
>
<
Text
>
{
"สถานที่: "
+
this
.
props
.
data
.
place
}
<
/Text
>
<
/View
>
}
right
=
{
<
Button
danger
onPress
=
{()
=>
this
.
deleteAppointment
(
this
.
props
.
data
.
id
)}
>
<
Icon
active
name
=
"trash"
/>
<
/Button
>
}
/
>
)
)
}
}
}
}
const
styles
=
{
listItem
:
{
paddingLeft
:
15
}
}
export
default
connect
(
null
,
{
appointmentDelete
})(
AppointmentListItem
);
export
default
connect
(
null
,
{
appointmentDelete
})(
AppointmentListItem
);
\ No newline at end of file
src/components/ReminderBoxList.js
View file @
fb253d7f
...
@@ -19,15 +19,17 @@ class ReminderBoxList extends React.Component {
...
@@ -19,15 +19,17 @@ class ReminderBoxList extends React.Component {
<
View
>
<
View
>
<
Text
>
{
this
.
props
.
periodText
}
<
/Text
>
<
Text
>
{
this
.
props
.
periodText
}
<
/Text
>
<
View
style
=
{
containerStyle
}
>
<
View
style
=
{
containerStyle
}
>
<
List
dataArray
=
{
this
.
props
.
items
}
<
View
style
=
{{
height
:
190
}}
>
renderRow
=
{(
item
)
=>
<
List
dataArray
=
{
this
.
props
.
items
}
<
ListItem
>
renderRow
=
{(
item
)
=>
<
Text
>
{
item
.
medName
}
<
/Text
>
<
ListItem
>
<
/ListItem
>
<
Text
>
{
item
.
medName
}
<
/Text
>
}
>
<
/ListItem
>
<
/List
>
}
>
<
/List
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
)
)
}
}
...
...
src/components/ReminderListItem.js
View file @
fb253d7f
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
{
TouchableOpacity
}
from
'react-native'
;
import
{
TouchableOpacity
}
from
'react-native'
;
import
{
View
,
Text
}
from
'native-base'
;
import
{
View
,
Text
,
SwipeRow
,
Button
,
Icon
}
from
'native-base'
;
import
{
reminderDelete
}
from
'./../actions'
import
{
reminderDelete
}
from
'./../actions'
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
...
@@ -11,23 +11,39 @@ class ReminderListItem extends Component {
...
@@ -11,23 +11,39 @@ class ReminderListItem extends Component {
super
(
props
)
super
(
props
)
}
}
delete
Appointment
(
id
)
{
delete
Reminder
(
id
)
{
this
.
props
.
reminderDelete
(
id
)
this
.
props
.
reminderDelete
(
id
)
}
}
render
()
{
render
()
{
const
{
listItem
}
=
styles
return
(
return
(
<
TouchableOpacity
onPress
=
{()
=>
this
.
deleteAppointment
(
this
.
props
.
data
.
id
)}
>
<
SwipeRow
<
View
>
rightOpenValue
=
{
-
75
}
<
Text
>
{
this
.
props
.
data
.
medName
}
<
/Text
>
body
=
{
<
Text
>
{
this
.
props
.
data
.
reminderTime
}
<
/Text
>
<
View
style
=
{
listItem
}
>
<
Text
>
{
this
.
props
.
data
.
meal
}
<
/Text
>
<
Text
>
{
"ชื่อยา: "
+
this
.
props
.
data
.
medName
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
period
}
<
/Text
>
<
Text
>
{
"เวลา: "
+
moment
(
new
Date
(
this
.
props
.
data
.
reminderTime
)).
format
(
'HH:mm'
)}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
dose
}
<
/Text
>
<
Text
>
{
"ก่อน/หลังอาหาร: "
+
this
.
props
.
data
.
meal
}
<
/Text
>
<
/View
>
<
Text
>
{
"จำนวน: "
+
this
.
props
.
data
.
dose
}
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
}
right
=
{
<
Button
danger
onPress
=
{()
=>
this
.
deleteReminder
(
this
.
props
.
data
.
id
)}
>
<
Icon
active
name
=
"trash"
/>
<
/Button
>
}
/
>
)
)
}
}
}
}
const
styles
=
{
listItem
:
{
paddingLeft
:
15
}
}
export
default
connect
(
null
,
{
reminderDelete
})(
ReminderListItem
);
export
default
connect
(
null
,
{
reminderDelete
})(
ReminderListItem
);
\ No newline at end of file
src/screens/CameraScreen.js
View file @
fb253d7f
...
@@ -10,9 +10,9 @@ import { IMAGE_TO_TEXT } from './../ServiceUrl';
...
@@ -10,9 +10,9 @@ import { IMAGE_TO_TEXT } from './../ServiceUrl';
import
{
Container
,
Header
,
Content
,
Icon
,
Button
}
from
'native-base'
;
import
{
Container
,
Header
,
Content
,
Icon
,
Button
}
from
'native-base'
;
import
{
MaterialDialog
}
from
'react-native-material-dialog'
;
import
{
MaterialDialog
}
from
'react-native-material-dialog'
;
import
{
RNCamera
}
from
'react-native-camera'
;
import
{
RNCamera
}
from
'react-native-camera'
;
import
{
scheduleLocalNotification
,
appointmentNotification
,
futch
}
from
'./../Utils'
;
import
{
scheduleLocalNotification
,
appointmentNotification
,
futch
,
generateID
}
from
'./../Utils'
;
import
{
connect
}
from
'react-redux'
import
{
connect
}
from
'react-redux'
import
{
reminderCreate
}
from
'./../actions'
import
{
reminderCreate
,
appointmentCreate
}
from
'./../actions'
import
ReminderDialogForm
from
'./../components/ReminderDialogForm'
;
import
ReminderDialogForm
from
'./../components/ReminderDialogForm'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
realm
from
'./../Database/'
;
import
realm
from
'./../Database/'
;
...
@@ -26,11 +26,14 @@ class AppCamera extends Component {
...
@@ -26,11 +26,14 @@ class AppCamera extends Component {
afternoonTime
:
""
,
afternoonTime
:
""
,
eveningTime
:
""
,
eveningTime
:
""
,
nightTime
:
""
,
nightTime
:
""
,
addItemVisible
:
tru
e
,
addItemVisible
:
fals
e
,
visible
:
false
,
visible
:
false
,
imageToText
:
""
,
imageToText
:
""
,
uploadProgress
:
"0"
,
uploadProgress
:
"0"
,
addReminder
:
false
addReminder
:
false
,
dataType
:
''
,
qrData
:
{},
uuid
:
''
}
}
}
}
...
@@ -54,6 +57,7 @@ class AppCamera extends Component {
...
@@ -54,6 +57,7 @@ class AppCamera extends Component {
style
=
{
styles
.
preview
}
style
=
{
styles
.
preview
}
type
=
{
RNCamera
.
Constants
.
Type
.
back
}
type
=
{
RNCamera
.
Constants
.
Type
.
back
}
fixOrientation
=
{
true
}
fixOrientation
=
{
true
}
onBarCodeRead
=
{(
data
,
type
)
=>
this
.
_onBarCodeRead
(
data
,
type
)}
permissionDialogTitle
=
{
'Permission to use camera'
}
permissionDialogTitle
=
{
'Permission to use camera'
}
permissionDialogMessage
=
{
'We need your permission to use your camera phone'
}
permissionDialogMessage
=
{
'We need your permission to use your camera phone'
}
/
>
/
>
...
@@ -74,7 +78,13 @@ class AppCamera extends Component {
...
@@ -74,7 +78,13 @@ class AppCamera extends Component {
uploadProgress
=
{
this
.
state
.
uploadProgress
}
uploadProgress
=
{
this
.
state
.
uploadProgress
}
imageToText
=
{
this
.
state
.
imageToText
}
imageToText
=
{
this
.
state
.
imageToText
}
/
>
/
>
<
/MaterialDialog
>
<
MaterialDialog
title
=
"QRcode"
visible
=
{
this
.
state
.
addItemVisible
}
onOk
=
{()
=>
this
.
addQr
(
this
.
state
.
uuid
,
this
.
state
.
dataType
,
this
.
state
.
qrData
)}
onCancel
=
{()
=>
this
.
setState
({
addItemVisible
:
false
,
dataType
:
''
,
qrData
:
{}
})}
>
<
Text
>
{
JSON
.
stringify
(
this
.
state
.
qrData
)}
<
/Text
>
<
/MaterialDialog
>
<
/MaterialDialog
>
<
/Container
>
<
/Container
>
);
);
...
@@ -108,28 +118,54 @@ class AppCamera extends Component {
...
@@ -108,28 +118,54 @@ class AppCamera extends Component {
}
}
}
}
// _onBarCodeRead(data, type) {
_onBarCodeRead
(
data
,
type
)
{
// if (data.type == 'QR_CODE') {
if
(
data
.
type
==
'QR_CODE'
)
{
// var tmpData = JSON.parse(decodeURI(data.data))
var
tmpData
=
JSON
.
parse
(
decodeURI
(
data
.
data
))
// switch (tmpData.type) {
let
id
=
generateID
()
// case "medicine":
switch
(
tmpData
.
type
)
{
// if (this.state.addItemVisible) {
case
"reminder"
:
// this._addMedicine(tmpData)
if
(
!
this
.
state
.
addItemVisible
)
{
// this.setState({ addItemVisible: false })
this
.
setState
({
addItemVisible
:
true
,
dataType
:
tmpData
.
type
,
qrData
:
tmpData
,
uuid
:
id
})
// }
}
// break;
break
;
// case "appointment":
case
"appointment"
:
// if (this.state.addItemVisible) {
if
(
!
this
.
state
.
addItemVisible
)
{
// this._addAppointment(tmpData)
this
.
setState
({
addItemVisible
:
true
,
dataType
:
tmpData
.
type
,
qrData
:
tmpData
,
uuid
:
id
})
// this.setState({ addItemVisible: false })
}
// }
break
;
// break;
}
// }
}
// }
}
// }
addQr
(
id
,
dataType
,
qrData
)
{
switch
(
dataType
)
{
case
"reminder"
:
this
.
props
.
reminderCreate
({
id
,
medName
:
qrData
.
medName
,
reminderTime
:
new
Date
(
moment
(
qrData
.
reminderTime
)),
meal
:
qrData
.
meal
,
period
:
parseInt
(
qrData
.
period
),
dose
:
qrData
.
dose
})
this
.
setState
({
addItemVisible
:
false
,
dataType
:
''
,
qrData
:
{}
})
break
;
case
"appointment"
:
this
.
props
.
appointmentCreate
({
id
,
doctorName
:
qrData
.
doctorName
,
date
:
new
Date
(
moment
(
qrData
.
date
)),
place
:
qrData
.
place
,
time
:
moment
().
date
(),
})
this
.
setState
({
addItemVisible
:
false
,
dataType
:
''
,
qrData
:
{}
})
break
;
}
}
}
}
const
styles
=
StyleSheet
.
create
({
const
styles
=
StyleSheet
.
create
({
container
:
{
container
:
{
flex
:
1
,
flex
:
1
,
...
@@ -152,4 +188,4 @@ const styles = StyleSheet.create({
...
@@ -152,4 +188,4 @@ const styles = StyleSheet.create({
}
}
});
});
export
default
connect
(
null
,
{
reminderCreate
})(
AppCamera
);
export
default
connect
(
null
,
{
reminderCreate
,
appointmentCreate
})(
AppCamera
);
\ No newline at end of file
\ No newline at end of file
src/screens/HomeScreen.js
View file @
fb253d7f
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
{
ToastAndroid
,
AsyncStorage
,
TouchableOpacity
}
from
'react-native'
;
import
{
ToastAndroid
,
AsyncStorage
,
TouchableOpacity
}
from
'react-native'
;
import
{
import
{
Container
,
Container
,
Content
,
Content
,
Footer
,
Footer
,
FooterTab
,
FooterTab
,
Left
,
Left
,
Button
,
Button
,
Icon
,
Icon
,
Fab
,
Fab
,
View
,
View
,
Text
Text
}
from
'native-base'
;
}
from
'native-base'
;
import
{
import
{
Col
,
Col
,
Row
,
Row
,
Grid
Grid
}
from
'react-native-easy-grid'
}
from
'react-native-easy-grid'
import
AppHeader
from
'./../components/Header'
;
import
AppHeader
from
'./../components/Header'
;
import
ReminderBoxList
from
'./../components/ReminderBoxList'
;
import
ReminderBoxList
from
'./../components/ReminderBoxList'
;
...
@@ -23,205 +23,205 @@ import { formatDate } from './../Utils';
...
@@ -23,205 +23,205 @@ import { formatDate } from './../Utils';
import
realm
from
'./../Database'
;
import
realm
from
'./../Database'
;
class
HomeScreen
extends
Component
{
class
HomeScreen
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
firstLaunch
:
null
,
firstLaunch
:
null
,
active
:
false
,
active
:
false
,
today
:
formatDate
(
new
Date
(
Date
.
now
())),
today
:
formatDate
(
new
Date
(
Date
.
now
())),
initDB
:
false
,
initDB
:
false
,
morningReminder
:
[],
morningReminder
:
[],
afternoonReminder
:
[],
afternoonReminder
:
[],
eveningReminder
:
[],
eveningReminder
:
[],
nightReminder
:
[],
nightReminder
:
[],
};
};
}
}
componentWillMount
()
{
componentWillMount
()
{
this
.
_isFirstLaunched
()
this
.
_isFirstLaunched
()
this
.
_initDB
()
this
.
_initDB
()
this
.
_queryReminder
()
this
.
_queryReminder
()
}
}
render
()
{
render
()
{
var
{
containerStyle
,
timePeriodLeftStyle
,
timePeriodRightStyle
,
dateTitle
}
=
styles
;
var
{
containerStyle
,
timePeriodLeftStyle
,
timePeriodRightStyle
,
dateTitle
}
=
styles
;
return
(
return
(
<
Container
style
=
{{
backgroundColor
:
'white'
}}
>
<
Container
style
=
{{
backgroundColor
:
'white'
}}
>
<
AppHeader
<
AppHeader
headerText
=
{
'Pill Minder'
}
headerText
=
{
'Pill Minder'
}
headerLeft
=
{
headerLeft
=
{
<
Button
onPress
=
{
this
.
onMenuPressed
.
bind
(
this
)}
>
<
Button
onPress
=
{
this
.
onMenuPressed
.
bind
(
this
)}
>
<
Icon
name
=
'menu'
/>
<
Icon
name
=
'menu'
/>
<
/Button
>
<
/Button
>
}
}
headerRight
=
{
headerRight
=
{
<
Button
onPress
=
{
this
.
onAddMedicinePressed
.
bind
(
this
)}
>
<
Button
onPress
=
{
this
.
onAddMedicinePressed
.
bind
(
this
)}
>
<
Icon
name
=
'add'
/>
<
Icon
name
=
'add'
/>
<
/Button
>
<
/Button
>
}
}
/
>
/
>
<
Content
style
=
{{
flex
:
1
}}
>
<
Content
style
=
{{
flex
:
1
}}
>
<
Text
style
=
{
dateTitle
}
>
{
this
.
state
.
today
}
<
/Text
>
<
Text
style
=
{
dateTitle
}
>
{
this
.
state
.
today
}
<
/Text
>
<
Grid
>
<
Grid
>
<
Col
>
<
Col
>
<
Row
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodLeftStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
morningReminder
,
1
)}
>
<
View
style
=
{
timePeriodLeftStyle
}
>
<
ReminderBoxList
<
ReminderBoxList
periodText
=
{
"Morning"
}
periodText
=
{
"Morning"
}
items
=
{
this
.
state
.
morningReminder
}
items
=
{
this
.
state
.
morningReminder
}
/
>
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
/Row
>
<
Row
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodLeftStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
afternoonReminder
,
2
)}
>
<
View
style
=
{
timePeriodLeftStyle
}
>
<
ReminderBoxList
<
ReminderBoxList
periodText
=
{
"Afternoon"
}
periodText
=
{
"Afternoon"
}
items
=
{
this
.
state
.
afternoonReminder
}
items
=
{
this
.
state
.
afternoonReminder
}
/
>
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
/Row
>
<
/Col
>
<
/Col
>
<
Col
>
<
Col
>
<
Row
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodRightStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
eveningReminder
,
3
)}
>
<
View
style
=
{
timePeriodRightStyle
}
>
<
ReminderBoxList
<
ReminderBoxList
periodText
=
{
"Evening"
}
periodText
=
{
"Evening"
}
items
=
{
this
.
state
.
eveningReminder
}
items
=
{
this
.
state
.
eveningReminder
}
/
>
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
/Row
>
<
Row
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodRightStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
nightReminder
,
4
)}
>
<
View
style
=
{
timePeriodRightStyle
}
>
<
ReminderBoxList
<
ReminderBoxList
periodText
=
{
"Night"
}
periodText
=
{
"Night"
}
items
=
{
this
.
state
.
nightReminder
}
items
=
{
this
.
state
.
nightReminder
}
/
>
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
/Row
>
<
/Col
>
<
/Col
>
<
/Grid
>
<
/Grid
>
<
/Content
>
<
/Content
>
<
/Container
>
<
/Container
>
)
)
}
}
onHomePressed
()
{
onHomePressed
()
{
this
.
props
.
navigation
.
navigate
(
'Home'
);
this
.
props
.
navigation
.
navigate
(
'Home'
);
}
}
onCameraPressed
()
{
onCameraPressed
()
{
this
.
props
.
navigation
.
navigate
(
'Camera'
);
this
.
props
.
navigation
.
navigate
(
'Camera'
);
}
}
onAddMedicinePressed
()
{
onAddMedicinePressed
()
{
this
.
props
.
navigation
.
navigate
(
'AddMedication'
)
this
.
props
.
navigation
.
navigate
(
'AddMedication'
)
}
}
onMenuPressed
()
{
onMenuPressed
()
{
this
.
props
.
navigation
.
navigate
(
'DrawerToggle'
);
this
.
props
.
navigation
.
navigate
(
'DrawerToggle'
);
}
}
_timePeriodPress
(
data
,
period
)
{
_timePeriodPress
(
data
,
period
)
{
// ToastAndroid.show(JSON.stringify(data), ToastAndroid.SHORT)
// ToastAndroid.show(JSON.stringify(data), ToastAndroid.SHORT)
this
.
props
.
navigation
.
navigate
(
'Detail'
,
{
items
:
data
,
period
:
period
})
this
.
props
.
navigation
.
navigate
(
'Detail'
,
{
items
:
data
,
period
:
period
})
}
}
_queryReminder
()
{
_queryReminder
()
{
let
myReminder
=
realm
.
objects
(
'Reminder'
)
let
myReminder
=
realm
.
objects
(
'Reminder'
)
let
morningReminder
=
myReminder
.
filtered
(
'period == 1'
)
let
morningReminder
=
myReminder
.
filtered
(
'period == 1'
)
let
afternoonReminder
=
myReminder
.
filtered
(
'period == 2'
)
let
afternoonReminder
=
myReminder
.
filtered
(
'period == 2'
)
let
eveningReminder
=
myReminder
.
filtered
(
'period == 3'
)
let
eveningReminder
=
myReminder
.
filtered
(
'period == 3'
)
let
nightReminder
=
myReminder
.
filtered
(
'period == 4'
)
let
nightReminder
=
myReminder
.
filtered
(
'period == 4'
)
var
tmpMorning
=
[]
var
tmpMorning
=
[]
morningReminder
.
forEach
(
i
=>
{
morningReminder
.
forEach
(
i
=>
{
tmpMorning
.
push
(
i
)
tmpMorning
.
push
(
i
)
});
});
var
tmpAfternoon
=
[]
var
tmpAfternoon
=
[]
afternoonReminder
.
forEach
(
i
=>
{
afternoonReminder
.
forEach
(
i
=>
{
tmpAfternoon
.
push
(
i
)
tmpAfternoon
.
push
(
i
)
})
var
tmpEvening
=
[]
eveningReminder
.
forEach
(
i
=>
{
tmpEvening
.
push
(
i
)
})
var
tmpNight
=
[]
nightReminder
.
forEach
(
i
=>
{
tmpNight
.
push
(
i
)
})
this
.
setState
({
morningReminder
:
tmpMorning
,
afternoonReminder
:
tmpAfternoon
,
eveningReminder
:
tmpEvening
,
nightReminder
:
tmpNight
})
// ToastAndroid.show(JSON.stringify(myReminder), ToastAndroid.LONG)
// ToastAndroid.show(JSON.stringify(this.state.morningReminder), ToastAndroid.LONG)
}
_isFirstLaunched
()
{
AsyncStorage
.
getItem
(
"alreadyLaunched"
).
then
(
value
=>
{
if
(
value
==
null
)
{
AsyncStorage
.
setItem
(
'alreadyLaunched'
,
'true'
)
.
catch
(
error
=>
{
ToastAndroid
.
show
(
error
.
toString
(),
ToastAndroid
.
SHORT
)
})
// No need to wait for `setItem` to finish, although you might want to handle errors
this
.
setState
({
firstLaunch
:
true
});
// ToastAndroid.show("Frist Launch:" + this.state.firstLaunch, ToastAndroid.LONG)
}
else
{
this
.
setState
({
firstLaunch
:
false
});
// ToastAndroid.show("Frist Launch:" + this.state.firstLaunch, ToastAndroid.LONG)
}
})
// Add some error handling, also you can simply do this.setState({fistLaunch: value == null})
}
_initDB
()
{
AsyncStorage
.
getItem
(
"alreadyInitDB"
).
then
(
value
=>
{
if
(
value
==
null
)
{
ToastAndroid
.
show
(
"Init DB"
,
ToastAndroid
.
LONG
)
AsyncStorage
.
setItem
(
'alreadyInitDB'
,
'true'
)
realm
.
write
(()
=>
{
realm
.
create
(
'TimePeriod'
,
{
morning
:
'08:00'
,
afternoon
:
'12:00'
,
evening
:
'16:00'
,
night
:
'20:00'
})
})
})
}
})
var
tmpEvening
=
[]
}
eveningReminder
.
forEach
(
i
=>
{
tmpEvening
.
push
(
i
)
})
var
tmpNight
=
[]
nightReminder
.
forEach
(
i
=>
{
tmpNight
.
push
(
i
)
})
this
.
setState
({
morningReminder
:
tmpMorning
,
afternoonReminder
:
tmpAfternoon
,
eveningReminder
:
tmpEvening
,
nightReminder
:
tmpNight
})
// ToastAndroid.show(JSON.stringify(myReminder), ToastAndroid.LONG)
// ToastAndroid.show(JSON.stringify(this.state.morningReminder), ToastAndroid.LONG)
}
_isFirstLaunched
()
{
AsyncStorage
.
getItem
(
"alreadyLaunched"
).
then
(
value
=>
{
if
(
value
==
null
)
{
AsyncStorage
.
setItem
(
'alreadyLaunched'
,
'true'
)
.
catch
(
error
=>
{
ToastAndroid
.
show
(
error
.
toString
(),
ToastAndroid
.
SHORT
)
})
// No need to wait for `setItem` to finish, although you might want to handle errors
this
.
setState
({
firstLaunch
:
true
});
// ToastAndroid.show("Frist Launch:" + this.state.firstLaunch, ToastAndroid.LONG)
}
else
{
this
.
setState
({
firstLaunch
:
false
});
// ToastAndroid.show("Frist Launch:" + this.state.firstLaunch, ToastAndroid.LONG)
}
})
// Add some error handling, also you can simply do this.setState({fistLaunch: value == null})
}
_initDB
()
{
AsyncStorage
.
getItem
(
"alreadyInitDB"
).
then
(
value
=>
{
if
(
value
==
null
)
{
ToastAndroid
.
show
(
"Init DB"
,
ToastAndroid
.
LONG
)
AsyncStorage
.
setItem
(
'alreadyInitDB'
,
'true'
)
realm
.
write
(()
=>
{
realm
.
create
(
'TimePeriod'
,
{
morning
:
'08:00'
,
afternoon
:
'12:00'
,
evening
:
'16:00'
,
night
:
'20:00'
})
})
}
})
}
}
}
const
styles
=
{
const
styles
=
{
timePeriodLeftStyle
:
{
timePeriodLeftStyle
:
{
flex
:
1
,
flex
:
1
,
marginLeft
:
20
,
marginLeft
:
20
,
marginRight
:
10
,
marginRight
:
10
,
marginTop
:
20
,
marginTop
:
20
,
marginBottom
:
20
marginBottom
:
20
},
},
timePeriodRightStyle
:
{
timePeriodRightStyle
:
{
flex
:
1
,
flex
:
1
,
marginLeft
:
10
,
marginLeft
:
10
,
marginRight
:
20
,
marginRight
:
20
,
marginTop
:
20
,
marginTop
:
20
,
marginBottom
:
20
marginBottom
:
20
},
},
dateTitle
:
{
dateTitle
:
{
fontSize
:
20
,
fontSize
:
20
,
textAlign
:
'center'
,
textAlign
:
'center'
,
marginTop
:
20
,
marginTop
:
20
,
marginLeft
:
20
,
marginLeft
:
20
,
marginLeft
:
20
,
marginLeft
:
20
,
marginBottom
:
10
,
marginBottom
:
10
,
}
}
}
}
export
default
HomeScreen
;
export
default
HomeScreen
;
\ No newline at end of file
src/screens/MedicationListScreen.js
View file @
fb253d7f
...
@@ -30,7 +30,7 @@ class MedicationListScreen extends Component {
...
@@ -30,7 +30,7 @@ class MedicationListScreen extends Component {
return
(
return
(
<
Container
>
<
Container
>
<
AppHeader
<
AppHeader
headerText
=
{
"
Medication
s"
}
headerText
=
{
"
Reminder
s"
}
headerLeft
=
{
headerLeft
=
{
<
Button
onPress
=
{()
=>
goBack
(
null
)}
>
<
Button
onPress
=
{()
=>
goBack
(
null
)}
>
<
Icon
name
=
'arrow-back'
/>
<
Icon
name
=
'arrow-back'
/>
...
...
src/screens/MedicationsScreen.js
View file @
fb253d7f
...
@@ -157,7 +157,7 @@ class MedicationsScreen extends Component {
...
@@ -157,7 +157,7 @@ class MedicationsScreen extends Component {
return
(
return
(
<
Container
>
<
Container
>
<
AppHeader
<
AppHeader
headerText
=
{
'Add
Medication
'
}
headerText
=
{
'Add
Reminder
'
}
headerLeft
=
{
headerLeft
=
{
<
Button
onPress
=
{()
=>
goBack
(
null
)}
>
<
Button
onPress
=
{()
=>
goBack
(
null
)}
>
<
Icon
name
=
'arrow-back'
/>
<
Icon
name
=
'arrow-back'
/>
...
@@ -166,7 +166,7 @@ class MedicationsScreen extends Component {
...
@@ -166,7 +166,7 @@ class MedicationsScreen extends Component {
/
>
/
>
<
Content
>
<
Content
>
<
MedForm
titleText
=
{
"Medic
ine
Name"
}
>
<
MedForm
titleText
=
{
"Medic
ation
Name"
}
>
<
Form
>
<
Form
>
<
Item
floatingLabel
>
<
Item
floatingLabel
>
<
Label
>
medicine
or
brand
name
<
/Label
>
<
Label
>
medicine
or
brand
name
<
/Label
>
...
@@ -235,10 +235,6 @@ class MedicationsScreen extends Component {
...
@@ -235,10 +235,6 @@ class MedicationsScreen extends Component {
<
/Content
>
<
/Content
>
<
/MedForm
>
<
/MedForm
>
<
MedForm
titleText
=
{
"Schedule"
}
>
<
Text
style
=
{
timeStyle
}
>
Start
date
:
{
formatDate
(
new
Date
(
Date
.
now
()))}
<
/Text
>
<
/MedForm
>
<
MedForm
titleText
=
{
"Dose"
}
>
<
MedForm
titleText
=
{
"Dose"
}
>
<
View
style
=
{{
padding
:
15
}}
>
<
View
style
=
{{
padding
:
15
}}
>
<
Button
style
=
{{
backgroundColor
:
'white'
}}
onPress
=
{()
=>
this
.
setState
({
singlePickerVisible
:
true
})}
>
<
Button
style
=
{{
backgroundColor
:
'white'
}}
onPress
=
{()
=>
this
.
setState
({
singlePickerVisible
:
true
})}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment