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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
135 additions
and
61 deletions
+135
-61
appointmentActions.js
src/actions/appointmentActions.js
+0
-1
reminderAction.js
src/actions/reminderAction.js
+7
-1
AppointmentListItem.js
src/components/AppointmentListItem.js
+26
-8
ReminderBoxList.js
src/components/ReminderBoxList.js
+2
-0
ReminderListItem.js
src/components/ReminderListItem.js
+27
-10
CameraScreen.js
src/screens/CameraScreen.js
+62
-26
HomeScreen.js
src/screens/HomeScreen.js
+8
-8
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'
export
const
appointmentCreate
=
({
id
,
doctorName
,
date
,
place
,
time
})
=>
{
return
(
dispatch
)
=>
{
let
appointment
=
{
id
,
doctorName
,
date
,
place
,
time
}
realm
.
write
(()
=>
{
realm
.
create
(
'Appointments'
,
{
id
:
id
,
...
...
src/actions/reminderAction.js
View file @
fb253d7f
...
...
@@ -7,9 +7,15 @@ import {
import
realm
from
'./../Database/'
import
moment
from
'moment'
import
{
scheduleLocalNotification
,
cancleNotification
}
from
'./../Utils'
import
{
ToastAndroid
}
from
'react-native'
export
const
reminderCreate
=
({
id
,
medName
,
reminderTime
,
meal
,
period
,
dose
})
=>
{
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
.
create
(
'Reminder'
,
{
id
:
id
,
...
...
@@ -21,7 +27,7 @@ export const reminderCreate = ({ id, medName, reminderTime, meal, period, dose }
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
;
scheduleLocalNotification
(
msg
,
reminderTime
,
id
)
let
reminders
=
realm
.
objects
(
"Reminder"
)
...
...
src/components/AppointmentListItem.js
View file @
fb253d7f
import
React
,
{
Component
}
from
'react'
;
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
{
connect
}
from
'react-redux'
;
import
moment
from
'moment'
;
...
...
@@ -16,17 +16,34 @@ class AppointmentListItem extends Component {
}
render
()
{
const
{
listItem
}
=
styles
return
(
<
TouchableOpacity
onPress
=
{()
=>
this
.
deleteAppointment
(
this
.
props
.
data
.
id
)}
>
<
View
>
<
Text
>
{
this
.
props
.
data
.
doctorName
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
date
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
time
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
place
}
<
/Text
>
<
SwipeRow
rightOpenValue
=
{
-
75
}
body
=
{
<
View
style
=
{
listItem
}
>
<
Text
>
{
"แพทย์: "
+
this
.
props
.
data
.
doctorName
}
<
/Text
>
<
Text
>
{
"วันที่: "
+
moment
(
new
Date
(
this
.
props
.
data
.
date
)).
format
(
'DD MMM YYYY'
)}
<
/Text
>
<
Text
>
{
"เวลา: "
+
moment
(
new
Date
(
this
.
props
.
data
.
date
)).
format
(
'HH:mm'
)}
<
/Text
>
<
Text
>
{
"สถานที่: "
+
this
.
props
.
data
.
place
}
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
}
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
);
\ No newline at end of file
src/components/ReminderBoxList.js
View file @
fb253d7f
...
...
@@ -19,6 +19,7 @@ class ReminderBoxList extends React.Component {
<
View
>
<
Text
>
{
this
.
props
.
periodText
}
<
/Text
>
<
View
style
=
{
containerStyle
}
>
<
View
style
=
{{
height
:
190
}}
>
<
List
dataArray
=
{
this
.
props
.
items
}
renderRow
=
{(
item
)
=>
<
ListItem
>
...
...
@@ -28,6 +29,7 @@ class ReminderBoxList extends React.Component {
<
/List
>
<
/View
>
<
/View
>
<
/View
>
)
}
...
...
src/components/ReminderListItem.js
View file @
fb253d7f
import
React
,
{
Component
}
from
'react'
;
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
{
connect
}
from
'react-redux'
;
import
moment
from
'moment'
;
...
...
@@ -11,23 +11,39 @@ class ReminderListItem extends Component {
super
(
props
)
}
delete
Appointment
(
id
)
{
delete
Reminder
(
id
)
{
this
.
props
.
reminderDelete
(
id
)
}
render
()
{
const
{
listItem
}
=
styles
return
(
<
TouchableOpacity
onPress
=
{()
=>
this
.
deleteAppointment
(
this
.
props
.
data
.
id
)}
>
<
View
>
<
Text
>
{
this
.
props
.
data
.
medName
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
reminderTime
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
meal
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
period
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
dose
}
<
/Text
>
<
SwipeRow
rightOpenValue
=
{
-
75
}
body
=
{
<
View
style
=
{
listItem
}
>
<
Text
>
{
"ชื่อยา: "
+
this
.
props
.
data
.
medName
}
<
/Text
>
<
Text
>
{
"เวลา: "
+
moment
(
new
Date
(
this
.
props
.
data
.
reminderTime
)).
format
(
'HH:mm'
)}
<
/Text
>
<
Text
>
{
"ก่อน/หลังอาหาร: "
+
this
.
props
.
data
.
meal
}
<
/Text
>
<
Text
>
{
"จำนวน: "
+
this
.
props
.
data
.
dose
}
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
}
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
);
\ No newline at end of file
src/screens/CameraScreen.js
View file @
fb253d7f
...
...
@@ -10,9 +10,9 @@ import { IMAGE_TO_TEXT } from './../ServiceUrl';
import
{
Container
,
Header
,
Content
,
Icon
,
Button
}
from
'native-base'
;
import
{
MaterialDialog
}
from
'react-native-material-dialog'
;
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
{
reminderCreate
}
from
'./../actions'
import
{
reminderCreate
,
appointmentCreate
}
from
'./../actions'
import
ReminderDialogForm
from
'./../components/ReminderDialogForm'
;
import
moment
from
'moment'
;
import
realm
from
'./../Database/'
;
...
...
@@ -26,11 +26,14 @@ class AppCamera extends Component {
afternoonTime
:
""
,
eveningTime
:
""
,
nightTime
:
""
,
addItemVisible
:
tru
e
,
addItemVisible
:
fals
e
,
visible
:
false
,
imageToText
:
""
,
uploadProgress
:
"0"
,
addReminder
:
false
addReminder
:
false
,
dataType
:
''
,
qrData
:
{},
uuid
:
''
}
}
...
...
@@ -54,6 +57,7 @@ class AppCamera extends Component {
style
=
{
styles
.
preview
}
type
=
{
RNCamera
.
Constants
.
Type
.
back
}
fixOrientation
=
{
true
}
onBarCodeRead
=
{(
data
,
type
)
=>
this
.
_onBarCodeRead
(
data
,
type
)}
permissionDialogTitle
=
{
'Permission to use camera'
}
permissionDialogMessage
=
{
'We need your permission to use your camera phone'
}
/
>
...
...
@@ -74,7 +78,13 @@ class AppCamera extends Component {
uploadProgress
=
{
this
.
state
.
uploadProgress
}
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
>
<
/Container
>
);
...
...
@@ -108,28 +118,54 @@ class AppCamera extends Component {
}
}
// _onBarCodeRead(data, type) {
// if (data.type == 'QR_CODE') {
// var tmpData = JSON.parse(decodeURI(data.data))
// switch (tmpData.type) {
// case "medicine":
// if (this.state.addItemVisible) {
// this._addMedicine(tmpData)
// this.setState({ addItemVisible: false })
// }
// break;
// case "appointment":
// if (this.state.addItemVisible) {
// this._addAppointment(tmpData)
// this.setState({ addItemVisible: false })
// }
// break;
// }
// }
// }
_onBarCodeRead
(
data
,
type
)
{
if
(
data
.
type
==
'QR_CODE'
)
{
var
tmpData
=
JSON
.
parse
(
decodeURI
(
data
.
data
))
let
id
=
generateID
()
switch
(
tmpData
.
type
)
{
case
"reminder"
:
if
(
!
this
.
state
.
addItemVisible
)
{
this
.
setState
({
addItemVisible
:
true
,
dataType
:
tmpData
.
type
,
qrData
:
tmpData
,
uuid
:
id
})
}
break
;
case
"appointment"
:
if
(
!
this
.
state
.
addItemVisible
)
{
this
.
setState
({
addItemVisible
:
true
,
dataType
:
tmpData
.
type
,
qrData
:
tmpData
,
uuid
:
id
})
}
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
({
container
:
{
flex
:
1
,
...
...
@@ -152,4 +188,4 @@ const styles = StyleSheet.create({
}
});
export
default
connect
(
null
,
{
reminderCreate
})(
AppCamera
);
\ No newline at end of file
export
default
connect
(
null
,
{
reminderCreate
,
appointmentCreate
})(
AppCamera
);
\ No newline at end of file
src/screens/HomeScreen.js
View file @
fb253d7f
...
...
@@ -67,38 +67,38 @@ class HomeScreen extends Component {
<
Grid
>
<
Col
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodLeftStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
morningReminder
,
1
)}
>
<
View
style
=
{
timePeriodLeftStyle
}
>
<
ReminderBoxList
periodText
=
{
"Morning"
}
items
=
{
this
.
state
.
morningReminder
}
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodLeftStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
afternoonReminder
,
2
)}
>
<
View
style
=
{
timePeriodLeftStyle
}
>
<
ReminderBoxList
periodText
=
{
"Afternoon"
}
items
=
{
this
.
state
.
afternoonReminder
}
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
/Col
>
<
Col
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodRightStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
eveningReminder
,
3
)}
>
<
View
style
=
{
timePeriodRightStyle
}
>
<
ReminderBoxList
periodText
=
{
"Evening"
}
items
=
{
this
.
state
.
eveningReminder
}
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
Row
>
<
TouchableOpacity
style
=
{
timePeriodRightStyle
}
onPress
=
{()
=>
this
.
_timePeriodPress
(
this
.
state
.
nightReminder
,
4
)}
>
<
View
style
=
{
timePeriodRightStyle
}
>
<
ReminderBoxList
periodText
=
{
"Night"
}
items
=
{
this
.
state
.
nightReminder
}
/
>
<
/TouchableOpacity
>
<
/View
>
<
/Row
>
<
/Col
>
<
/Grid
>
...
...
src/screens/MedicationListScreen.js
View file @
fb253d7f
...
...
@@ -30,7 +30,7 @@ class MedicationListScreen extends Component {
return
(
<
Container
>
<
AppHeader
headerText
=
{
"
Medication
s"
}
headerText
=
{
"
Reminder
s"
}
headerLeft
=
{
<
Button
onPress
=
{()
=>
goBack
(
null
)}
>
<
Icon
name
=
'arrow-back'
/>
...
...
src/screens/MedicationsScreen.js
View file @
fb253d7f
...
...
@@ -157,7 +157,7 @@ class MedicationsScreen extends Component {
return
(
<
Container
>
<
AppHeader
headerText
=
{
'Add
Medication
'
}
headerText
=
{
'Add
Reminder
'
}
headerLeft
=
{
<
Button
onPress
=
{()
=>
goBack
(
null
)}
>
<
Icon
name
=
'arrow-back'
/>
...
...
@@ -166,7 +166,7 @@ class MedicationsScreen extends Component {
/
>
<
Content
>
<
MedForm
titleText
=
{
"Medic
ine
Name"
}
>
<
MedForm
titleText
=
{
"Medic
ation
Name"
}
>
<
Form
>
<
Item
floatingLabel
>
<
Label
>
medicine
or
brand
name
<
/Label
>
...
...
@@ -235,10 +235,6 @@ class MedicationsScreen extends Component {
<
/Content
>
<
/MedForm
>
<
MedForm
titleText
=
{
"Schedule"
}
>
<
Text
style
=
{
timeStyle
}
>
Start
date
:
{
formatDate
(
new
Date
(
Date
.
now
()))}
<
/Text
>
<
/MedForm
>
<
MedForm
titleText
=
{
"Dose"
}
>
<
View
style
=
{{
padding
:
15
}}
>
<
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