No Description

Calendar.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { Component } from 'react';
  2. import {StyleSheet,View} from 'react-native';
  3. import { Calendar } from 'react-native-calendars';
  4. export default class Calendario extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. markedDates: this.props.route.params.markedDates,
  9. selectedStartDate: null,
  10. interpreter_id : this.props.route.params.Intereprete_id,
  11. mapflag : this.props.route.params.Flag,
  12. i_token: this.props.route.params.I_Token,
  13. u_token: this.props.route.params.U_Token,
  14. username: this.props.route.params.Username,
  15. I_username: this.props.route.params.I_Username,
  16. };
  17. this.onDateChange = this.onDateChange.bind(this);
  18. }
  19. componentDidMount(){
  20. this.forceUpdate();
  21. this.setState({markedDates: this.props.route.params.markedDates});
  22. };
  23. onDateChange(date) {
  24. this.setState({
  25. selectedStartDate: date,
  26. });
  27. if(this.state.markedDates[date.dateString] != undefined){
  28. if(this.state.markedDates[date.dateString].selected == true){
  29. if(this.state.mapflag == false){
  30. this.props.navigation.navigate('StateTime', {Appointment: date._d, int_id : this.state.interpreter_id,
  31. Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token
  32. ,Username: this.state.username, I_Username: this.state.I_username});
  33. }
  34. else{
  35. this.props.navigation.navigate('Map', {Appointment_Date: date._d, int_id : this.state.interpreter_id,
  36. Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token
  37. ,Username: this.state.username, I_Username: this.state.I_username});
  38. }
  39. }
  40. }
  41. }
  42. render() {
  43. const { selectedStartDate } = this.state;
  44. const today = new Date();
  45. //const appointment = selectedStartDate ? selectedStartDate.toString() : '';
  46. return (
  47. <View style = {styles.container}>
  48. <Calendar
  49. markedDates={this.state.markedDates}
  50. minDate={today}
  51. onDayPress={this.onDateChange}
  52. selectionMode="singleDay"
  53. scrollMode="oneMonth"
  54. monthsAfter={24}
  55. />
  56. </View>
  57. );
  58. }
  59. }
  60. const styles = StyleSheet.create({
  61. container: {
  62. flex: 1,
  63. backgroundColor: '#FFFFFF',
  64. marginTop: 100,
  65. },
  66. });