Commit c634a92a authored by Phuengton Chummuel's avatar Phuengton Chummuel

add medicine & appointment reminder via qrcode

parent 1ff53183
...@@ -2526,795 +2526,6 @@ ...@@ -2526,795 +2526,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
}, },
"fsevents": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz",
"integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==",
"optional": true,
"requires": {
"nan": "2.8.0",
"node-pre-gyp": "0.6.39"
},
"dependencies": {
"abbrev": {
"version": "1.1.0",
"bundled": true,
"optional": true
},
"ajv": {
"version": "4.11.8",
"bundled": true,
"optional": true,
"requires": {
"co": "4.6.0",
"json-stable-stringify": "1.0.1"
}
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true
},
"aproba": {
"version": "1.1.1",
"bundled": true,
"optional": true
},
"are-we-there-yet": {
"version": "1.1.4",
"bundled": true,
"optional": true,
"requires": {
"delegates": "1.0.0",
"readable-stream": "2.2.9"
}
},
"asn1": {
"version": "0.2.3",
"bundled": true,
"optional": true
},
"assert-plus": {
"version": "0.2.0",
"bundled": true,
"optional": true
},
"asynckit": {
"version": "0.4.0",
"bundled": true,
"optional": true
},
"aws-sign2": {
"version": "0.6.0",
"bundled": true,
"optional": true
},
"aws4": {
"version": "1.6.0",
"bundled": true,
"optional": true
},
"balanced-match": {
"version": "0.4.2",
"bundled": true
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"bundled": true,
"optional": true,
"requires": {
"tweetnacl": "0.14.5"
}
},
"block-stream": {
"version": "0.0.9",
"bundled": true,
"requires": {
"inherits": "2.0.3"
}
},
"boom": {
"version": "2.10.1",
"bundled": true,
"requires": {
"hoek": "2.16.3"
}
},
"brace-expansion": {
"version": "1.1.7",
"bundled": true,
"requires": {
"balanced-match": "0.4.2",
"concat-map": "0.0.1"
}
},
"buffer-shims": {
"version": "1.0.0",
"bundled": true
},
"caseless": {
"version": "0.12.0",
"bundled": true,
"optional": true
},
"co": {
"version": "4.6.0",
"bundled": true,
"optional": true
},
"code-point-at": {
"version": "1.1.0",
"bundled": true
},
"combined-stream": {
"version": "1.0.5",
"bundled": true,
"requires": {
"delayed-stream": "1.0.0"
}
},
"concat-map": {
"version": "0.0.1",
"bundled": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true
},
"cryptiles": {
"version": "2.0.5",
"bundled": true,
"requires": {
"boom": "2.10.1"
}
},
"dashdash": {
"version": "1.14.1",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"debug": {
"version": "2.6.8",
"bundled": true,
"optional": true,
"requires": {
"ms": "2.0.0"
}
},
"deep-extend": {
"version": "0.4.2",
"bundled": true,
"optional": true
},
"delayed-stream": {
"version": "1.0.0",
"bundled": true
},
"delegates": {
"version": "1.0.0",
"bundled": true,
"optional": true
},
"detect-libc": {
"version": "1.0.2",
"bundled": true,
"optional": true
},
"ecc-jsbn": {
"version": "0.1.1",
"bundled": true,
"optional": true,
"requires": {
"jsbn": "0.1.1"
}
},
"extend": {
"version": "3.0.1",
"bundled": true,
"optional": true
},
"extsprintf": {
"version": "1.0.2",
"bundled": true
},
"forever-agent": {
"version": "0.6.1",
"bundled": true,
"optional": true
},
"form-data": {
"version": "2.1.4",
"bundled": true,
"optional": true,
"requires": {
"asynckit": "0.4.0",
"combined-stream": "1.0.5",
"mime-types": "2.1.15"
}
},
"fs.realpath": {
"version": "1.0.0",
"bundled": true
},
"fstream": {
"version": "1.0.11",
"bundled": true,
"requires": {
"graceful-fs": "4.1.11",
"inherits": "2.0.3",
"mkdirp": "0.5.1",
"rimraf": "2.6.1"
}
},
"fstream-ignore": {
"version": "1.0.5",
"bundled": true,
"optional": true,
"requires": {
"fstream": "1.0.11",
"inherits": "2.0.3",
"minimatch": "3.0.4"
}
},
"gauge": {
"version": "2.7.4",
"bundled": true,
"optional": true,
"requires": {
"aproba": "1.1.1",
"console-control-strings": "1.1.0",
"has-unicode": "2.0.1",
"object-assign": "4.1.1",
"signal-exit": "3.0.2",
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wide-align": "1.1.2"
}
},
"getpass": {
"version": "0.1.7",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"glob": {
"version": "7.1.2",
"bundled": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
},
"graceful-fs": {
"version": "4.1.11",
"bundled": true
},
"har-schema": {
"version": "1.0.5",
"bundled": true,
"optional": true
},
"har-validator": {
"version": "4.2.1",
"bundled": true,
"optional": true,
"requires": {
"ajv": "4.11.8",
"har-schema": "1.0.5"
}
},
"has-unicode": {
"version": "2.0.1",
"bundled": true,
"optional": true
},
"hawk": {
"version": "3.1.3",
"bundled": true,
"requires": {
"boom": "2.10.1",
"cryptiles": "2.0.5",
"hoek": "2.16.3",
"sntp": "1.0.9"
}
},
"hoek": {
"version": "2.16.3",
"bundled": true
},
"http-signature": {
"version": "1.1.1",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "0.2.0",
"jsprim": "1.4.0",
"sshpk": "1.13.0"
}
},
"inflight": {
"version": "1.0.6",
"bundled": true,
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
}
},
"inherits": {
"version": "2.0.3",
"bundled": true
},
"ini": {
"version": "1.3.4",
"bundled": true,
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"requires": {
"number-is-nan": "1.0.1"
}
},
"is-typedarray": {
"version": "1.0.0",
"bundled": true,
"optional": true
},
"isarray": {
"version": "1.0.0",
"bundled": true
},
"isstream": {
"version": "0.1.2",
"bundled": true,
"optional": true
},
"jodid25519": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"jsbn": "0.1.1"
}
},
"jsbn": {
"version": "0.1.1",
"bundled": true,
"optional": true
},
"json-schema": {
"version": "0.2.3",
"bundled": true,
"optional": true
},
"json-stable-stringify": {
"version": "1.0.1",
"bundled": true,
"optional": true,
"requires": {
"jsonify": "0.0.0"
}
},
"json-stringify-safe": {
"version": "5.0.1",
"bundled": true,
"optional": true
},
"jsonify": {
"version": "0.0.0",
"bundled": true,
"optional": true
},
"jsprim": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.0.2",
"json-schema": "0.2.3",
"verror": "1.3.6"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"mime-db": {
"version": "1.27.0",
"bundled": true
},
"mime-types": {
"version": "2.1.15",
"bundled": true,
"requires": {
"mime-db": "1.27.0"
}
},
"minimatch": {
"version": "3.0.4",
"bundled": true,
"requires": {
"brace-expansion": "1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true
},
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.0.0",
"bundled": true,
"optional": true
},
"node-pre-gyp": {
"version": "0.6.39",
"bundled": true,
"optional": true,
"requires": {
"detect-libc": "1.0.2",
"hawk": "3.1.3",
"mkdirp": "0.5.1",
"nopt": "4.0.1",
"npmlog": "4.1.0",
"rc": "1.2.1",
"request": "2.81.0",
"rimraf": "2.6.1",
"semver": "5.3.0",
"tar": "2.2.1",
"tar-pack": "3.4.0"
}
},
"nopt": {
"version": "4.0.1",
"bundled": true,
"optional": true,
"requires": {
"abbrev": "1.1.0",
"osenv": "0.1.4"
}
},
"npmlog": {
"version": "4.1.0",
"bundled": true,
"optional": true,
"requires": {
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
"gauge": "2.7.4",
"set-blocking": "2.0.0"
}
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true
},
"oauth-sign": {
"version": "0.8.2",
"bundled": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
"bundled": true,
"optional": true
},
"once": {
"version": "1.4.0",
"bundled": true,
"requires": {
"wrappy": "1.0.2"
}
},
"os-homedir": {
"version": "1.0.2",
"bundled": true,
"optional": true
},
"os-tmpdir": {
"version": "1.0.2",
"bundled": true,
"optional": true
},
"osenv": {
"version": "0.1.4",
"bundled": true,
"optional": true,
"requires": {
"os-homedir": "1.0.2",
"os-tmpdir": "1.0.2"
}
},
"path-is-absolute": {
"version": "1.0.1",
"bundled": true
},
"performance-now": {
"version": "0.2.0",
"bundled": true,
"optional": true
},
"process-nextick-args": {
"version": "1.0.7",
"bundled": true
},
"punycode": {
"version": "1.4.1",
"bundled": true,
"optional": true
},
"qs": {
"version": "6.4.0",
"bundled": true,
"optional": true
},
"rc": {
"version": "1.2.1",
"bundled": true,
"optional": true,
"requires": {
"deep-extend": "0.4.2",
"ini": "1.3.4",
"minimist": "1.2.0",
"strip-json-comments": "2.0.1"
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"bundled": true,
"optional": true
}
}
},
"readable-stream": {
"version": "2.2.9",
"bundled": true,
"requires": {
"buffer-shims": "1.0.0",
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "1.0.7",
"string_decoder": "1.0.1",
"util-deprecate": "1.0.2"
}
},
"request": {
"version": "2.81.0",
"bundled": true,
"optional": true,
"requires": {
"aws-sign2": "0.6.0",
"aws4": "1.6.0",
"caseless": "0.12.0",
"combined-stream": "1.0.5",
"extend": "3.0.1",
"forever-agent": "0.6.1",
"form-data": "2.1.4",
"har-validator": "4.2.1",
"hawk": "3.1.3",
"http-signature": "1.1.1",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.15",
"oauth-sign": "0.8.2",
"performance-now": "0.2.0",
"qs": "6.4.0",
"safe-buffer": "5.0.1",
"stringstream": "0.0.5",
"tough-cookie": "2.3.2",
"tunnel-agent": "0.6.0",
"uuid": "3.0.1"
}
},
"rimraf": {
"version": "2.6.1",
"bundled": true,
"requires": {
"glob": "7.1.2"
}
},
"safe-buffer": {
"version": "5.0.1",
"bundled": true
},
"semver": {
"version": "5.3.0",
"bundled": true,
"optional": true
},
"set-blocking": {
"version": "2.0.0",
"bundled": true,
"optional": true
},
"signal-exit": {
"version": "3.0.2",
"bundled": true,
"optional": true
},
"sntp": {
"version": "1.0.9",
"bundled": true,
"requires": {
"hoek": "2.16.3"
}
},
"sshpk": {
"version": "1.13.0",
"bundled": true,
"optional": true,
"requires": {
"asn1": "0.2.3",
"assert-plus": "1.0.0",
"bcrypt-pbkdf": "1.0.1",
"dashdash": "1.14.1",
"ecc-jsbn": "0.1.1",
"getpass": "0.1.7",
"jodid25519": "1.0.2",
"jsbn": "0.1.1",
"tweetnacl": "0.14.5"
},
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"bundled": true,
"optional": true
}
}
},
"string-width": {
"version": "1.0.2",
"bundled": true,
"requires": {
"code-point-at": "1.1.0",
"is-fullwidth-code-point": "1.0.0",
"strip-ansi": "3.0.1"
}
},
"string_decoder": {
"version": "1.0.1",
"bundled": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"stringstream": {
"version": "0.0.5",
"bundled": true,
"optional": true
},
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"requires": {
"ansi-regex": "2.1.1"
}
},
"strip-json-comments": {
"version": "2.0.1",
"bundled": true,
"optional": true
},
"tar": {
"version": "2.2.1",
"bundled": true,
"requires": {
"block-stream": "0.0.9",
"fstream": "1.0.11",
"inherits": "2.0.3"
}
},
"tar-pack": {
"version": "3.4.0",
"bundled": true,
"optional": true,
"requires": {
"debug": "2.6.8",
"fstream": "1.0.11",
"fstream-ignore": "1.0.5",
"once": "1.4.0",
"readable-stream": "2.2.9",
"rimraf": "2.6.1",
"tar": "2.2.1",
"uid-number": "0.0.6"
}
},
"tough-cookie": {
"version": "2.3.2",
"bundled": true,
"optional": true,
"requires": {
"punycode": "1.4.1"
}
},
"tunnel-agent": {
"version": "0.6.0",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"bundled": true,
"optional": true
},
"uid-number": {
"version": "0.0.6",
"bundled": true,
"optional": true
},
"util-deprecate": {
"version": "1.0.2",
"bundled": true
},
"uuid": {
"version": "3.0.1",
"bundled": true,
"optional": true
},
"verror": {
"version": "1.3.6",
"bundled": true,
"optional": true,
"requires": {
"extsprintf": "1.0.2"
}
},
"wide-align": {
"version": "1.1.2",
"bundled": true,
"optional": true,
"requires": {
"string-width": "1.0.2"
}
},
"wrappy": {
"version": "1.0.2",
"bundled": true
}
}
},
"fstream": { "fstream": {
"version": "1.0.11", "version": "1.0.11",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
...@@ -7316,6 +6527,16 @@ ...@@ -7316,6 +6527,16 @@
"react-timer-mixin": "0.13.3" "react-timer-mixin": "0.13.3"
} }
}, },
"react-native-material-dialog": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/react-native-material-dialog/-/react-native-material-dialog-0.7.4.tgz",
"integrity": "sha512-4WD2+oXEhRFRA3B8syHPNwzP8G/zFE6Qw/hLfkZziitW0HIGY4/d4aLq+S1SnVW4voNvzRRnRUrbX8xTH+JVxQ==",
"requires": {
"prop-types": "15.6.0",
"react-native-typography": "1.3.0",
"react-native-vector-icons": "4.4.2"
}
},
"react-native-modal": { "react-native-modal": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/react-native-modal/-/react-native-modal-3.1.0.tgz", "resolved": "https://registry.npmjs.org/react-native-modal/-/react-native-modal-3.1.0.tgz",
...@@ -7370,6 +6591,11 @@ ...@@ -7370,6 +6591,11 @@
"prop-types": "15.6.0" "prop-types": "15.6.0"
} }
}, },
"react-native-typography": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/react-native-typography/-/react-native-typography-1.3.0.tgz",
"integrity": "sha512-RqLQxapbyZpHnoUVy5xU3E1t+7cc0GKZfB6ZZQYhPkV+D3HXx4j++hnBUiIN8UFrUZbfz4HDh5W4RR/6QVCZ8Q=="
},
"react-native-vector-icons": { "react-native-vector-icons": {
"version": "4.4.2", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.4.2.tgz", "resolved": "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-4.4.2.tgz",
...@@ -7789,7 +7015,6 @@ ...@@ -7789,7 +7015,6 @@
"anymatch": "1.3.2", "anymatch": "1.3.2",
"exec-sh": "0.2.1", "exec-sh": "0.2.1",
"fb-watchman": "2.0.0", "fb-watchman": "2.0.0",
"fsevents": "1.1.3",
"minimatch": "3.0.4", "minimatch": "3.0.4",
"minimist": "1.2.0", "minimist": "1.2.0",
"walker": "1.0.7", "walker": "1.0.7",
......
...@@ -9,7 +9,9 @@ let realm = new Realm({ ...@@ -9,7 +9,9 @@ let realm = new Realm({
medName: 'string', medName: 'string',
reminderTime: 'date', reminderTime: 'date',
meal: 'string', meal: 'string',
period: 'int' period: 'int',
dose: 'string',
timeStamp: 'date',
} }
}, { }, {
name: 'TimePeriod', name: 'TimePeriod',
...@@ -17,9 +19,19 @@ let realm = new Realm({ ...@@ -17,9 +19,19 @@ let realm = new Realm({
morning: 'string', morning: 'string',
afternoon: 'string', afternoon: 'string',
evening: 'string', evening: 'string',
night: 'string' night: 'string',
} }
}] }, {
name: 'Appointments',
properties: {
id: 'int',
doctorName: 'string',
date: 'date',
place: 'string',
timeStamp: 'date'
}
}
]
}) })
export default realm; export default realm;
\ No newline at end of file
...@@ -31,6 +31,26 @@ export function scheduleLocalNotification(message, date, id, payload) { ...@@ -31,6 +31,26 @@ export function scheduleLocalNotification(message, date, id, payload) {
data: JSON.stringify(payload), data: JSON.stringify(payload),
}; };
//schedule the notification
PushNotification.localNotificationSchedule(notification);
}
export function appointmentNotification(message, date, id, payload) {
//message: type String
//date: type String format 'YYYY-MM-DD HH:mm' (NOTIFICATION_DATE_TIME_FORMAT)
//construct the notification parameters
// const fireDate = moment(date, NOTIFICATION_DATE_TIME_FORMAT).toDate();
const fireDate = date
const notification = {
id: id, //for android cancel notification (must be stringified number)
message,
number: 0, //necessary for iOS cancellation (not sure why)
date: fireDate,
//for android only
data: JSON.stringify(payload),
};
//schedule the notification //schedule the notification
PushNotification.localNotificationSchedule(notification); PushNotification.localNotificationSchedule(notification);
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ import { ...@@ -13,7 +13,7 @@ import {
class AppHeader extends Component { class AppHeader extends Component {
render() { render() {
return ( return (
<Header> <Header style={this.props.headerStyle}>
<Left> <Left>
{this.props.headerLeft} {this.props.headerLeft}
</Left> </Left>
......
...@@ -8,55 +8,88 @@ import SettingsScreen from './../screens/SettingsScreen'; ...@@ -8,55 +8,88 @@ import SettingsScreen from './../screens/SettingsScreen';
import MedicationsScreen from './../screens/MedicationsScreen'; import MedicationsScreen from './../screens/MedicationsScreen';
import SignInScreen from './../screens/SignInScreen'; import SignInScreen from './../screens/SignInScreen';
import MainScreen from './../screens/MainScreen'; import MainScreen from './../screens/MainScreen';
import SettingsTimePeriod from './../screens/SettingsTimePeriod' import SettingsTimePeriod from './../screens/SettingsTimePeriod';
import ReminderDetail from './../screens/ReminderDetail' import ReminderDetail from './../screens/ReminderDetail';
import AppointmentsScreen from './../screens/AppointmentsScreen' import AppointmentsScreen from './../screens/AppointmentsScreen';
import MedicationsListScreen from './../screens/MedicationListScreen';
import AppointmentsListScreen from './../screens/AppointmentListScreen';
const HomeNavigator = StackNavigator({
Home: {
screen: HomeScreen
},
Detail: {
screen: ReminderDetail
}
}, {
headerMode: 'none'
})
const CameraNavigator = StackNavigator({
Camera: {
screen: CameraScreen,
},
PreviewPhoto: {
screen: PreviewPhotoScreen,
}
}, {
headerMode: 'none'
})
const SettingsNavigator = StackNavigator({
Settings: {
screen: SettingsScreen
},
SettingsTime: {
screen: SettingsTimePeriod
}
}, {
headerMode: 'none'
})
const MedicationsNavigator = StackNavigator({
MedicationsList: {
screen: MedicationsListScreen
},
AddMedication: {
screen: MedicationsScreen
}
}, {
headerMode: 'none'
})
const AppointmentsNavigator = StackNavigator({
AppointmentsList: {
screen: AppointmentsListScreen,
},
AddAppointment: {
screen: AppointmentsScreen,
}
}, {
headerMode: 'none'
})
const RootNavigator = StackNavigator( const RootNavigator = StackNavigator(
{ {
Home: { Home: {
screen: DrawerNavigator({ screen: DrawerNavigator({
Home: { Home: {
screen: StackNavigator({ screen: HomeNavigator,
Home: {
screen: HomeScreen
},
Detail: {
screen: ReminderDetail
}
}, {
headerMode: 'none'
})
}, },
Camera: { Camera: {
screen: StackNavigator({ screen: CameraNavigator,
Camera: {
screen: CameraScreen,
},
PreviewPhoto: {
screen: PreviewPhotoScreen,
}
}, {
headerMode: 'none'
}),
}, },
Medications: { Medications: {
screen: MedicationsScreen screen: MedicationsNavigator
}, },
Appointments: { Appointments: {
screen: AppointmentsScreen screen: AppointmentsNavigator,
}, },
Settings: { Settings: {
screen: StackNavigator({ screen: SettingsNavigator,
Settings: {
screen: SettingsScreen
},
SettingsTime: {
screen: SettingsTimePeriod
}
}, {
headerMode: 'none'
})
} }
}) })
}, },
......
import React, { Component } from 'react';
import {
Container,
Content,
View,
Text,
Button,
Icon,
List,
ListItem,
Right,
Left,
} from 'native-base';
import AppHeader from './../components/Header';
import realm from './../Database/';
import moment from 'moment';
class AppointmentListScreen extends Component {
constructor(props) {
super(props)
this.state = {
appointmentList: [],
}
}
componentWillMount() {
this._queryDbAppointment()
}
render() {
const { appointmentListStyle } = styles
const { goBack } = this.props.navigation
return (
<Container>
<AppHeader
headerText={"Appointments"}
headerLeft={
<Button onPress={() => goBack(null)}>
<Icon name='arrow-back' />
</Button>
}
headerRight={
<Button onPress={() => this._addAppointment()}>
<Icon name='add' />
</Button>
}
/>
<Content>
<Text>Appointment List</Text>
<List dataArray={this.state.appointmentList}
renderRow={(item) =>
<ListItem style={appointmentListStyle}>
<View style={{ flex: 1 }}>
<Text>{"Doctor: " + item.doctorName}</Text>
<Text>{"Date: " + moment(item.date).format("DD MM YYYY")}</Text>
<Text>{"Time: " + moment(item.date).format("HH:mm")}</Text>
<Text>{"Place: " + item.place}</Text>
</View>
<View>
<Icon name='more' />
</View>
</ListItem>
}>
</List>
</Content>
</Container>
)
}
_addAppointment() {
this.props.navigation.navigate("AddAppointment")
}
_queryDbAppointment() {
const tmpAppointment = realm.objects("Appointments")
this.setState({ appointmentList: tmpAppointment })
}
}
const styles = {
appointmentListStyle: {
marginLeft: 0,
marginRight: 0,
marginTop: 0,
marginBottom: 0,
padding: 15,
}
}
export default AppointmentListScreen;
\ No newline at end of file
import React from 'react'; import React from 'react';
import { DatePickerAndroid, TimePickerAndroid, Alert, Keyboard } from 'react-native'; import { DatePickerAndroid, TimePickerAndroid, Alert, Keyboard, ToastAndroid } from 'react-native';
import { import {
Container, Container,
Content, Content,
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
import AppHeader from './../components/Header'; import AppHeader from './../components/Header';
import MedForm from './../components/MedForm'; import MedForm from './../components/MedForm';
import { Grid, Col } from 'react-native-easy-grid'; import { Grid, Col } from 'react-native-easy-grid';
import { appointmentNotification } from './../Utils';
import realm from './../Database'; import realm from './../Database';
import moment from 'moment'; import moment from 'moment';
...@@ -80,12 +81,12 @@ class AppointmentsScreen extends React.Component { ...@@ -80,12 +81,12 @@ class AppointmentsScreen extends React.Component {
<Grid> <Grid>
<Col> <Col>
<Button full style={btnAddNoti}> <Button full style={btnAddNoti} onPress={() => this._onResetPressed()}>
<Text style={{ color: "#1686C4" }}>Reset</Text> <Text style={{ color: "#1686C4" }}>Reset</Text>
</Button> </Button>
</Col> </Col>
<Col> <Col>
<Button full style={btnAddNoti}> <Button full style={btnAddNoti} onPress={() => this._addAppointment()}>
<Text style={{ color: "#1686C4" }}>Add</Text> <Text style={{ color: "#1686C4" }}>Add</Text>
</Button> </Button>
</Col> </Col>
...@@ -96,8 +97,59 @@ class AppointmentsScreen extends React.Component { ...@@ -96,8 +97,59 @@ class AppointmentsScreen extends React.Component {
) )
} }
_onResetPressed() {
realm.write(() => {
let allReminder = realm.objects('Appointments')
realm.delete(allReminder)
})
ToastAndroid.show("reset", ToastAndroid.SHORT)
}
_addAppointment() { _addAppointment() {
if (this.state.doctor && this.state.date && this.state.time) {
Alert.alert(
'Confrim?',
'Are you sure to add this appointment?',
[
{ text: 'CANCLE', onPress: () => ToastAndroid.show("Cancled", ToastAndroid.SHORT) },
{
text: 'OK', onPress: () => {
var id = Math.random() * 10000
var time = this.state.time.split(':')
var appointmentDate = moment(this.state.date).hour(time[0]).minute(time[1]).second(0).toDate()
var msg = "แจ้งเตือนการนัดพบแพทย์\n" + "แพทย์: " + this.state.doctor + "เวลา: " + this.state.time
appointmentNotification(msg, appointmentDate, id)
realm.write(() => {
realm.create('Appointments', {
id: id,
doctorName: this.state.doctor,
date: appointmentDate,
place: this.state.place,
timeStamp: moment().toDate()
})
})
this.props.navigation.goBack(null)
}
},
],
{ cancelable: false }
)
} else {
Alert.alert(
'Please enter Doctor name / Select appointment date and time',
'',
[
{ text: 'OK', onPress: () => ToastAndroid.show("Please enter medine name / Select reminder time", ToastAndroid.SHORT) },
],
{ cancelable: false }
)
}
} }
_datePicker() { _datePicker() {
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { BackHandler, ToastAndroid } from 'react-native'; import { BackHandler, ToastAndroid, Alert } from 'react-native';
import { import {
Dimensions, Dimensions,
StyleSheet, StyleSheet,
Text, Text,
View View
} from 'react-native'; } from 'react-native';
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 Camera from 'react-native-camera'; import Camera from 'react-native-camera';
import { scheduleLocalNotification, appointmentNotification } from './../Utils';
import moment from 'moment';
import realm from './../Database/';
class AppCamera extends Component { class AppCamera extends Component {
constructor(props) {
super(props)
this.state = {
morningTime: "",
afternoonTime: "",
eveningTime: "",
nightTime: "",
addItemVisible: true,
visible: true,
}
}
componentWillMount() {
let timePeriod = realm.objects('TimePeriod')
var morningTime = timePeriod[0].morning
var afternoonTime = timePeriod[0].afternoon
var eveningTime = timePeriod[0].evening
var nightTime = timePeriod[0].night
this.setState({ morningTime, afternoonTime, eveningTime, nightTime })
}
render() { render() {
return ( return (
<Container style={styles.container}> <Container style={styles.container}>
...@@ -23,13 +48,14 @@ class AppCamera extends Component { ...@@ -23,13 +48,14 @@ class AppCamera extends Component {
aspect={Camera.constants.Aspect.fill} aspect={Camera.constants.Aspect.fill}
captureTarget={Camera.constants.CaptureTarget.temp} captureTarget={Camera.constants.CaptureTarget.temp}
playSoundOnCapture={false} playSoundOnCapture={false}
onBarCodeRead={(data, type) => this._onBarCodeRead(data, type)}
defaultTouchToFocus> defaultTouchToFocus>
<Button onPress={this.takePicture.bind(this)} style={styles.capture}> <Button onPress={this.takePicture.bind(this)} style={styles.capture}>
<Text>[CAPTURE]</Text> <Text>[CAPTURE]</Text>
</Button> </Button>
</Camera> </Camera>
</Container> </Container >
); );
} }
...@@ -44,6 +70,117 @@ class AppCamera extends Component { ...@@ -44,6 +70,117 @@ class AppCamera extends Component {
.catch(err => console.error(err)); .catch(err => console.error(err));
} }
_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;
}
}
}
_addMedicine(data) {
var time = null
switch (data.period) {
case 1:
time = this.state.morningTime.split(":")
break;
case 2:
time = this.state.afternoonTime.split(":")
break;
case 3:
time = this.state.eveningTime.split(":")
break;
case 4:
time = this.state.nightTime.split(":")
break;
}
Alert.alert(
'Confrim?',
JSON.stringify(data),
[
{ text: 'CANCLE', onPress: () => this.setState({ addItemVisible: true }) },
{
text: 'OK', onPress: () => {
var id = Math.random() * 10000
var reminderDate = moment().hour(time[0]).minute(time[1]).second(0).toDate()
var beforeMeal = data.beforeMeal ? "\tก่อนอาหาร" : "\tหลังอาหาร";
var msg = "แจ้งเตือนกินยา\n" + "เวลา: " + time[0] + ":" + time[1] + "\nยา: " + data.medName + beforeMeal;
scheduleLocalNotification(msg, reminderDate, id)
realm.write(() => {
realm.create('Reminder', {
id: id,
medName: data.medName,
reminderTime: reminderDate,
meal: beforeMeal.trim(),
period: data.period,
dose: data.dose.toString(),
timeStamp: moment().toDate()
})
})
this.props.navigation.goBack(null)
}
},
],
{ cancelable: false }
)
}
_addAppointment(data) {
const time = data.date.split(':')
Alert.alert(
'Confrim?',
"Doctor: " + data.doctorName + "\nDate: " + moment(data.date).format("DD MMM YYYY") + "\nTime: " + moment(data.date).format("HH:mm") + "\nPlace: " + data.place,
[
{ text: 'CANCLE', onPress: () => this.setState({ addItemVisible: true }) },
{
text: 'OK', onPress: () => {
var id = Math.random() * 10000
var appointmentDate = moment(data.date).hour(time[0]).minute(time[1]).second(0).toDate()
var msg = "แจ้งเตือนการนัดพบแพทย์\n" + "แพทย์: " + data.doctorName + "เวลา: " + moment(data.date).format("HH:mm")
appointmentNotification(msg, appointmentDate, id)
realm.write(() => {
realm.create('Appointments', {
id: id,
doctorName: data.doctorName,
date: appointmentDate,
place: data.place,
timeStamp: moment().toDate()
})
})
this.props.navigation.goBack(null)
}
},
],
{ cancelable: false }
)
}
} }
......
...@@ -23,8 +23,8 @@ import { formatDate } from './../Utils'; ...@@ -23,8 +23,8 @@ import { formatDate } from './../Utils';
import realm from './../Database'; import realm from './../Database';
class HomeScreen extends Component { class HomeScreen extends Component {
constructor() { constructor(props) {
super(); super(props);
this.state = { this.state = {
firstLaunch: null, firstLaunch: null,
active: false, active: false,
...@@ -117,7 +117,7 @@ class HomeScreen extends Component { ...@@ -117,7 +117,7 @@ class HomeScreen extends Component {
} }
onAddMedicinePressed() { onAddMedicinePressed() {
this.props.navigation.navigate('Medications') this.props.navigation.navigate('AddMedication')
} }
onMenuPressed() { onMenuPressed() {
......
import React, { Component } from 'react';
import {
Container,
Content,
View,
Button,
Icon,
Text,
List,
ListItem
} from 'native-base';
import AppHeader from './../components/Header';
import realm from './../Database/'
class MedicationListScreen extends Component {
constructor(props) {
super(props)
this.state = {
reminderList: []
}
}
componentWillMount() {
this._queryMedicineList()
}
render() {
const { reminderListStyle } = styles
const { goBack } = this.props.navigation
return (
<Container>
<AppHeader
headerText={"Medications"}
headerLeft={
<Button onPress={() => goBack(null)}>
<Icon name='arrow-back' />
</Button>
}
headerRight={
<Button onPress={() => this._addReminder()}>
<Icon name='add' />
</Button>
}
/>
<Content>
<Text>Reminder List</Text>
<List dataArray={this.state.reminderList}
renderRow={(item) =>
<ListItem style={reminderListStyle}>
<Text>{item.medName}</Text>
</ListItem>
}>
</List>
</Content>
</Container>
)
}
_queryMedicineList() {
var tmpReminder = realm.objects("Reminder")
this.setState({ reminderList: tmpReminder })
}
_addReminder() {
this.props.navigation.navigate("AddMedication")
}
}
const styles = {
reminderListStyle: {
marginLeft: 0,
marginRight: 0,
marginTop: 0,
marginBottom: 0,
padding: 15
}
}
export default MedicationListScreen;
\ No newline at end of file
...@@ -2,7 +2,7 @@ import React, { Component } from 'react'; ...@@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { DeviceEventEmitter, ToastAndroid, Alert } from 'react-native'; import { DeviceEventEmitter, ToastAndroid, Alert } from 'react-native';
import { formatDate, scheduleLocalNotification } from './../Utils'; import { formatDate, scheduleLocalNotification } from './../Utils';
import { Grid, Col } from 'react-native-easy-grid'; import { Grid, Col } from 'react-native-easy-grid';
import { MaterialDialog } from 'react-native-material-dialog'; import { SinglePickerMaterialDialog } from 'react-native-material-dialog';
import PushNotification from 'react-native-push-notification'; import PushNotification from 'react-native-push-notification';
import { import {
Container, Container,
...@@ -67,7 +67,9 @@ class MedicationsScreen extends Component { ...@@ -67,7 +67,9 @@ class MedicationsScreen extends Component {
nightTime: "", nightTime: "",
beforeMeal: true, beforeMeal: true,
afterMeal: false, afterMeal: false,
visible: null, dose: '1',
singlePickerVisible: false,
singlePickerSelectedItem: undefined
}; };
} }
...@@ -99,16 +101,19 @@ class MedicationsScreen extends Component { ...@@ -99,16 +101,19 @@ class MedicationsScreen extends Component {
} }
render() { render() {
var { goBack } = this.props.navigation
var { timeStyle, btnAddNoti } = styles; var { timeStyle, btnAddNoti } = styles;
const dose = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
return ( return (
<Container> <Container>
<AppHeader <AppHeader
headerText={'Medications'} headerText={'Add Medication'}
headerLeft={ headerLeft={
<Button onPress={this._onMenuPressed.bind(this)}> <Button onPress={() => goBack(null)}>
<Icon name='menu' /> <Icon name='arrow-back' />
</Button> </Button>
} }
/> />
...@@ -200,15 +205,23 @@ class MedicationsScreen extends Component { ...@@ -200,15 +205,23 @@ class MedicationsScreen extends Component {
</MedForm> </MedForm>
<MedForm titleText={"Dose"}> <MedForm titleText={"Dose"}>
{/* <MaterialDialog <View style={{ padding: 15 }}>
title="Use Google's Location Service?" <Button style={{ backgroundColor: 'white' }} onPress={() => this.setState({ singlePickerVisible: true })}>
visible={true} <Text style={{ color: "#1686C4" }}>{this.state.dose}</Text>
onOk={() => this.setState({ visible: false })} </Button>
onCancel={() => this.setState({ visible: false })}>
<Text style={styles.dialogText}> <SinglePickerMaterialDialog
Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running. title={'Pick one element!'}
</Text> scrolled
</MaterialDialog>; */} items={dose.map((row, index) => ({ value: index, label: row }))}
visible={this.state.singlePickerVisible}
selectedItem={this.state.singlePickerSelectedItem}
onCancel={() => this.setState({ singlePickerVisible: false })}
onOk={result => {
this.setState({ singlePickerVisible: false });
this.setState({ dose: result.selectedItem["label"].toString() });
}} />
</View>
</MedForm> </MedForm>
...@@ -305,7 +318,9 @@ class MedicationsScreen extends Component { ...@@ -305,7 +318,9 @@ class MedicationsScreen extends Component {
medName: this.state.text, medName: this.state.text,
reminderTime: reminderDate, reminderTime: reminderDate,
meal: beforeMeal.trim(), meal: beforeMeal.trim(),
period: period period: period,
dose: this.state.dose,
timeStamp: moment().toDate()
}) })
}) })
} }
......
...@@ -19,13 +19,16 @@ class Menu extends Component { ...@@ -19,13 +19,16 @@ class Menu extends Component {
} }
render() { render() {
var { goBack } = this.props.navigation
return ( return (
<Container> <Container>
<AppHeader <AppHeader
headerText={"Setting"} headerText={"Setting"}
headerLeft={ headerLeft={
<Button onPress={this._onMenuPressed.bind(this)}> <Button onPress={() => goBack(null)}>
<Icon name='menu' /> <Icon name='arrow-back' />
</Button> </Button>
} }
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment