ErnestoOrtiz2 3 years ago
parent
commit
fa2ed6e0ae
2 changed files with 34 additions and 25 deletions
  1. 26
    25
      screens/main/Calendar.js
  2. 8
    0
      screens/main/Confirm.js

+ 26
- 25
screens/main/Calendar.js View File

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

+ 8
- 0
screens/main/Confirm.js View File

127
             console.log("date");
127
             console.log("date");
128
           }}
128
           }}
129
           >
129
           >
130
+            <List.Item
131
+            title='Usuario:'
132
+            description={item.User}
133
+            titleNumberOfLines={1}
134
+            titleStyle={styles.listTitle}
135
+            descriptionStyle={styles.listDescription}
136
+            descriptionNumberOfLines={1}
137
+          />
130
           <List.Item
138
           <List.Item
131
             title='Usuario:'
139
             title='Usuario:'
132
             description={item.User}
140
             description={item.User}