No Description

Calendar.js 2.1KB

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