Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. import React from 'react';
  2. import { View, StyleSheet } from 'react-native';
  3. import { HEADER_HEIGHT, STATUSBAR_HEIGHT, ICON_SIZE_LARGE } from '../../../utils/Sizes';
  4. import { LEFT_ARROW, RIGHT_ARROW, CALENDAR } from '../../../utils/Icons';
  5. import { LIGHT_BLUE } from '../../../utils/Colors';
  6. import LeftArrowWithText from '../../UI/LeftArrowWithText/LeftArrowWithText';
  7. import RightArrowWithText from '../../UI/RightArrowWithText/RightArrowWithText';
  8. import CalendarModal from '../../Modals/CalendarModal/CalendarModal';
  9. import CalendarIcon from '../../UI/CalendarIcon/CalendarIcon';
  10. import Icon from 'react-native-vector-icons/FontAwesome';
  11.  
  12.  
  13. export default class RangeHeader extends React.Component {
  14.  
  15. constructor(props) {
  16. super(props);
  17.  
  18. this.state = {
  19. calendarVisible: false,
  20. icons: []
  21. }
  22. }
  23.  
  24. componentDidMount() {
  25. Promise.all([
  26. Icon.getImageSource(LEFT_ARROW, ICON_SIZE_LARGE, 'white'),
  27. Icon.getImageSource(RIGHT_ARROW, ICON_SIZE_LARGE, 'white'),
  28. Icon.getImageSource(CALENDAR, ICON_SIZE_LARGE, 'white')
  29. ]).then(sources => {
  30. this.setState(() => ({
  31. icons: sources
  32. }));
  33. });
  34. }
  35.  
  36. toggleModal = () => {
  37. this.setState(prevState => ({
  38. calendarVisible: !prevState.calendarVisible
  39. }));
  40. }
  41.  
  42. render() {
  43. return (
  44. <View
  45. style={styles.container}
  46. { ...this.props}
  47. >
  48. <CalendarModal
  49. minDate={this.props.dates.minDate}
  50. selectedDate={this.props.dates.selectedDate}
  51. toggleModal={this.toggleModal}
  52. visible={this.state.calendarVisible}
  53. dateSelected={this.props.onCalendarDateSelected}
  54. />
  55.  
  56. <View style={styles.datesContainer}>
  57. <LeftArrowWithText
  58. date={this.props.dates.fromDate}
  59. onPress={this.props.onPrevWeekPressed}
  60. icon={this.state.icons[0]}
  61. />
  62. <RightArrowWithText
  63. date={this.props.dates.toDate}
  64. onPress={this.props.onNextWeekPressed}
  65. icon={this.state.icons[1]}
  66. />
  67. </View>
  68. <CalendarIcon
  69. icon={this.state.icons[2]}
  70. toggleModal={this.toggleModal}
  71. />
  72. </View>
  73. )
  74. }
  75. }
  76.  
  77. const styles = StyleSheet.create({
  78. container: {
  79. height: HEADER_HEIGHT(),
  80. backgroundColor: LIGHT_BLUE,
  81. justifyContent: 'center',
  82. alignItems: 'center',
  83. flexDirection: 'row',
  84. paddingTop: STATUSBAR_HEIGHT,
  85. paddingHorizontal: 16,
  86. width:'100%'
  87. },
  88. datesContainer: {
  89. alignItems: 'center',
  90. flexDirection: 'row',
  91. }
  92. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement