설명 없음

Calendar.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. console.log(date)
  28. if(this.state.markedDates[date.dateString] != undefined){
  29. if(this.state.markedDates[date.dateString].selected == true){
  30. if(this.state.mapflag == false){
  31. this.props.navigation.navigate('StateTime', {Day: date.day, Month: date.month, int_id : this.state.interpreter_id,
  32. Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token
  33. ,Username: this.state.username, I_Username: this.state.I_username});
  34. }
  35. else{
  36. this.props.navigation.navigate('Map', {Day: date.day, Month: date.month, int_id : this.state.interpreter_id,
  37. Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token
  38. ,Username: this.state.username, I_Username: this.state.I_username});
  39. }
  40. }
  41. }
  42. }
  43. render() {
  44. const { selectedStartDate } = this.state;
  45. const today = new Date();
  46. //const appointment = selectedStartDate ? selectedStartDate.toString() : '';
  47. return (
  48. <View style = {styles.container}>
  49. <Calendar
  50. markedDates={this.state.markedDates}
  51. minDate={today}
  52. onDayPress={this.onDateChange}
  53. selectionMode="singleDay"
  54. scrollMode="oneMonth"
  55. monthsAfter={24}
  56. />
  57. </View>
  58. );
  59. }
  60. }
  61. const styles = StyleSheet.create({
  62. container: {
  63. flex: 1,
  64. backgroundColor: '#FFFFFF',
  65. marginTop: 100,
  66. },
  67. });