Commit 39127469 authored by Phuengton Chummuel's avatar Phuengton Chummuel

add radio button for pick reminder time

parent dd2a0aa3
This diff is collapsed.
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"moment": "^2.20.1",
"native-base": "^2.3.3", "native-base": "^2.3.3",
"react": "16.0.0", "react": "16.0.0",
"react-native": "0.50.3", "react-native": "0.50.3",
"react-native-camera": "^0.12.0", "react-native-camera": "^0.12.0",
"react-native-datepicker": "^1.6.0",
"react-native-firebase": "^3.1.0", "react-native-firebase": "^3.1.0",
"react-native-google-signin": "^0.12.0", "react-native-google-signin": "^0.12.0",
"react-native-modal-datetime-picker": "^4.13.0", "react-native-modal-datetime-picker": "^4.13.0",
......
...@@ -11,9 +11,12 @@ import { ...@@ -11,9 +11,12 @@ import {
Form, Form,
Item, Item,
Label, Label,
Input Input,
ListItem,
Radio,
Right
} from 'native-base'; } from 'native-base';
import DateTimePicker from 'react-native-modal-datetime-picker'; import DatePicker from 'react-native-datepicker'
import AppHeader from './../components/Header'; import AppHeader from './../components/Header';
import MedForm from '../components/MedForm'; import MedForm from '../components/MedForm';
...@@ -23,10 +26,14 @@ class MedicationsScreen extends Component { ...@@ -23,10 +26,14 @@ class MedicationsScreen extends Component {
super(); super();
this.state = { this.state = {
text: "", text: "",
date: Date.now(), date: new Date(Date.now()).toISOString().split('T')[0],
time: "08.00", minDate: new Date(Date.now()).toISOString().split('T')[0],
isDatePickerVisible: false, hour: 0,
isTimePickerVisible: false minute: 0,
today: Date.now(),
morning: false,
lunch: false,
night: false
}; };
} }
...@@ -36,10 +43,10 @@ class MedicationsScreen extends Component { ...@@ -36,10 +43,10 @@ class MedicationsScreen extends Component {
console.log('Notification action received: ' + action); console.log('Notification action received: ' + action);
const info = JSON.parse(action.dataJSON); const info = JSON.parse(action.dataJSON);
if (info.action == 'Yes') { if (info.action == 'Yes') {
console.log("Yes"); ToastAndroid.show('Yes', ToastAndroid.SHORT)
} else if (info.action == 'No') { } else if (info.action == 'No') {
console.log("No"); ToastAndroid.show('No', ToastAndroid.LONG)
} }
}); });
...@@ -72,72 +79,91 @@ class MedicationsScreen extends Component { ...@@ -72,72 +79,91 @@ class MedicationsScreen extends Component {
</Form> </Form>
</MedForm> </MedForm>
<MedForm titleText={"Reminder Time"}> {/* <MedForm titleText={"Reminder Time"}>
<Text onPress={() => this._showTimePicker()} style={timeStyle}> <DatePicker
{this.state.time} style={timeStyle}
</Text> date={this.state.time}
<DateTimePicker
mode="time" mode="time"
isVisible={this.state.isTimePickerVisible} format="HH:mm"
onConfirm={this._handleTimePicked} confirmBtnText="Confirm"
onCancel={this._hideTimePicker} cancelBtnText="Cancel"
minuteInterval={10}
onDateChange={(time) => { this.setState({ time: time }); }}
/> />
</MedForm> */}
<MedForm titleText={"Reminder Time"}>
<Content>
<ListItem onPress={() => this._onReminderTimePresses("1")}>
<Text>Morning</Text>
<Right>
<Radio selected={this.state.morning} />
</Right>
</ListItem>
<ListItem onPress={() => this._onReminderTimePresses("2")}>
<Text>Lunch</Text>
<Right>
<Radio selected={this.state.lunch} />
</Right>
</ListItem>
<ListItem onPress={() => this._onReminderTimePresses("3")}>
<Text>Night</Text>
<Right>
<Radio selected={this.state.night} />
</Right>
</ListItem>
</Content>
</MedForm> </MedForm>
<MedForm titleText={"Schedule"}> <MedForm titleText={"Schedule"}>
<Text onPress={() => this._showDatePicker()} style={timeStyle}> <DatePicker
{this.state.date} style={timeStyle}
</Text> date={new Date(this.state.date).toISOString().split('T')[0]}
<DateTimePicker
mode="date" mode="date"
isVisible={this.state.isDatePickerVisible} placeholder="placeholder"
onConfirm={this._handleDatePicked} format="YYYY-MM-DD"
onCancel={this._hideDatePicker} minDate={this.state.minDate}
confirmBtnText="Confirm"
cancelBtnText="Cancel"
onDateChange={(date) => { this.setState({ date: date }); }}
/> />
</MedForm> </MedForm>
<Button style={btnAddNoti} onPress={() => this._setNotification()}> <Button style={btnAddNoti} onPress={() => this._setNotification()}>
<Text style={{ color: "#1686C4" }}>Add nonotification</Text> <Text style={{ color: "#1686C4" }}>Add nonotification</Text>
</Button> </Button>
</Content> </Content>
</Container> </Container>
) )
}; };
_showTimePicker = () => this.setState({ isTimePickerVisible: true });
_hideTimePicker = () => this.setState({ isTimePickerVisible: false });
_showDatePicker = () => this.setState({ isDatePickerVisible: true });
_hideDatePicker = () => this.setState({ isDatePickerVisible: false });
_handleTimePicked = (date) => {
var time = date.toTimeString().split(' ')[0].split(':')
this.setState({ time: time[0] + ':' + time[1] })
this._hideTimePicker();
}
_handleDatePicked = (date) => {
this.setState({ date: date.toDateString() })
this._hideDatePicker();
}
_setNotification() { _setNotification() {
// if (this.state.text) {
// PushNotification.localNotificationSchedule({
// id: '1234',
// title: "ถึงเวลารับประทานยา " + this.state.text,
// message: "My Notification Message",
// date: new Date(Date.now() + (5 * 1000)),
// actions: '["Yes", "No"]',
// })
// }
ToastAndroid.show(this.state.date.toString(), ToastAndroid.SHORT)
}
if (this.state.text) { _onReminderTimePresses(id) {
PushNotification.localNotificationSchedule({ switch (id) {
id: '1234', case '1':
title: "ถึงเวลารับประทานยา " + this.state.text, this.setState({ morning: !this.state.morning, lunch: false, night: false })
message: "My Notification Message", break
date: new Date(Date.now() + (5 * 1000)), case '2':
actions: '["Yes", "No"]', this.setState({ lunch: !this.state.lunch, morning: false, night: false })
}) break
case '3':
this.setState({ night: !this.state.night, morning: false, lunch: false })
break
} }
} }
_onMenuPressed() { _onMenuPressed() {
...@@ -147,9 +173,8 @@ class MedicationsScreen extends Component { ...@@ -147,9 +173,8 @@ class MedicationsScreen extends Component {
const styles = { const styles = {
timeStyle: { timeStyle: {
fontSize: 18,
color: "#1686C4",
padding: 15, padding: 15,
width: 200,
}, },
btnAddNoti: { btnAddNoti: {
justifyContent: 'center', justifyContent: 'center',
......
This diff is collapsed.
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