No Description

Calendar.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. };
  14. this.onDateChange = this.onDateChange.bind(this);
  15. }
  16. onDateChange(date) {
  17. this.setState({
  18. selectedStartDate: date,
  19. });
  20. console.log(date)
  21. console.log(this.props.route.params.Flag)
  22. if(this.state.mapflag == false){
  23. this.props.navigation.navigate('StateTime', {Appointment_Date: date._d, int_id : this.state.interpreter_id, Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token});
  24. }
  25. else{
  26. this.props.navigation.navigate('Map', {Appointment_Date: date._d, int_id : this.state.interpreter_id, Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token});
  27. }
  28. }
  29. render() {
  30. const { selectedStartDate } = this.state;
  31. const today = new Date();
  32. console.log(today)
  33. const appointment = selectedStartDate ? selectedStartDate.toString() : '';
  34. console.log(this.props.route.params)
  35. return (
  36. <View style = {styles.container}>
  37. <CalendarPicker
  38. minDate={today}
  39. onDateChange={this.onDateChange}
  40. selectionMode="singleDay"
  41. scrollMode="oneMonth"
  42. monthsAfter={24}
  43. />
  44. </View>
  45. );
  46. }
  47. }
  48. const styles = StyleSheet.create({
  49. container: {
  50. flex: 1,
  51. backgroundColor: '#FFFFFF',
  52. marginTop: 100,
  53. },
  54. });