Advertisement
TheGustavo

Untitled

Mar 21st, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState } from 'react'
  2. import { View, Text, StyleSheet, Button } from 'react-native'
  3. import { Ionicons } from '@expo/vector-icons'
  4. import { THEME } from '../theme'
  5. import {
  6.     Collapse,
  7.     CollapseHeader,
  8.     CollapseBody,
  9.     AccordionList
  10. } from 'accordion-collapse-react-native'
  11. import { DATES_TIMES } from '../datetimes'
  12.  
  13. export const DateTimeScreen = ({ navigation, route }) => {
  14.     const { selectedDate } = route.params
  15.     const { fullDate } = route.params
  16.  
  17.     function Header({ title }) {
  18.         return (
  19.             <CollapseHeader style={styles.headerCol}>
  20.                 <Text style={styles.headerColTextAct}>{title}</Text>
  21.             </CollapseHeader>
  22.         )
  23.     }
  24.  
  25.     function Body({ data }) {
  26.         const times = []
  27.  
  28.         for (const [index, value] of data.entries()) {
  29.             times.push(
  30.                 <View key={index} style={styles.datePickItem}>
  31.                     <Button
  32.                         title={value}
  33.                         color={THEME.MAIN_COLOR}
  34.                         onPress={() => console.log(selectedDate + '-' + value)}
  35.                     />
  36.                     <Ionicons
  37.                         name='md-arrow-dropright'
  38.                         size={28}
  39.                         color={THEME.MAIN_COLOR}
  40.                         style={styles.dateIcon}
  41.                     />
  42.                 </View>
  43.             )
  44.         }
  45.  
  46.         return (
  47.             <CollapseBody>
  48.                 <View style={styles.datePicks}>{times}</View>
  49.             </CollapseBody>
  50.         )
  51.     }
  52.  
  53.     return (
  54.         <View>
  55.             <AccordionList
  56.                 list={DATES_TIMES}
  57.                 keyExtractor={(data, index) => data + index}
  58.                 header={Header}
  59.                 body={Body}
  60.                 expandedIndex={0}
  61.             />
  62.             <Button
  63.                 title='Выбрать другую дату'
  64.                 onPress={() => navigation.navigate('Онлайн запись', { selectedDate })}
  65.             />
  66.         </View>
  67.     )
  68. }
  69.  
  70. const styles = StyleSheet.create({
  71.     center: {
  72.         /* flex: 1,
  73.         justifyContent: 'center',
  74.         alignItems: 'center' */
  75.     },
  76.     datePicks: {
  77.         flexDirection: 'row',
  78.         justifyContent: 'space-between'
  79.         /* flex: 1,
  80.         ,
  81.         ,
  82.         justifyContent: 'flex-start',
  83.         padding: 0,
  84.        
  85.         fontSize: 14,
  86.        
  87.         width: 80,
  88.         height: 30 */
  89.     },
  90.     datePickItem: {
  91.         flexDirection: 'row',
  92.         backgroundColor: '#fff',
  93.         padding: 2,
  94.         paddingRight: 10,
  95.         borderWidth: 1,
  96.         borderColor: THEME.PINK_COLOR,
  97.         borderRadius: 4,
  98.         margin: 4,
  99.         width: 84
  100.     },
  101.     dateIcon: { paddingTop: 5 },
  102.     headerCol: {
  103.         backgroundColor: '#fff'
  104.     },
  105.     headerColText: {
  106.         padding: 14,
  107.         fontFamily: 'rale-light'
  108.     },
  109.     headerColTextAct: {
  110.         padding: 14,
  111.         fontFamily: 'rale-bold',
  112.         fontSize: 16
  113.     }
  114. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement