Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { View, Image } from 'react-native';
  3.  
  4. import { TextLabel } from 'src/components/Texts/TextVariant';
  5.  
  6. import IHabitStep from 'src/entities/Habits/types/IHabitStep';
  7.  
  8. import TStepStatuses from 'src/entities/Habits/types/TStepStatuses';
  9. import { format } from 'src/utils/datefns';
  10. import { createStyles } from 'src/utils/helpers'
  11. import Theme from 'src/Theme';
  12.  
  13. interface Props {
  14.   data : IHabitStep;
  15.   shortText?: boolean;
  16.   hidePhoto?: boolean;
  17. }
  18.  
  19. interface Status {
  20.   status : TStepStatuses;
  21.   icon : string;
  22.   style : any;
  23. }
  24.  
  25. export default class Note extends Component<Props> {
  26.  
  27.   renderStatus : Status[] = [
  28.     {
  29.       status : 'Done',
  30.       icon : Theme.Icons.doneBold,
  31.       style : styles.statusDone
  32.     },
  33.     {
  34.       status : 'Skip',
  35.       icon : Theme.Icons.closeAlternativeBold,
  36.       style : styles.statusNotDone
  37.     }
  38.   ]
  39.  
  40.   render() {
  41.     const { data, shortText = false, hidePhoto = false } = this.props;
  42.     const { comment, status, updatedUtc } = data;
  43.  
  44.     let text = comment;
  45.     if (shortText && !!text) {
  46.       text = text.substr(0, 56);
  47.     }
  48.  
  49.     return (
  50.       <View>
  51.         <View style={styles.head}>
  52.           <TextLabel color={Theme.Colors.barChartGreen}>{format(new Date(updatedUtc), 'MM MMM')}</TextLabel>
  53.           {/* TODO: smile */}
  54.           {this.renderStatus.map(e => e.status === status && <Image key={status} source={{uri : e.icon}} style={e.style}/>)}
  55.         </View>
  56.         {comment && (
  57.           <TextLabel
  58.             style={styles.text}
  59.             color={Theme.Colors.calendarMonthDay}
  60.             family={Theme.Fonts.alternative}
  61.             weight={'600'}
  62.             numberOfLines={!!shortText ? 2 : undefined}
  63.           >
  64.             {text}
  65.           </TextLabel>
  66.         )}
  67.         {hidePhoto || null /* TODO: photo */}
  68.       </View>
  69.     );
  70.   }
  71. }
  72.  
  73. const styles = createStyles({
  74.   head: {
  75.     flexDirection: 'row',
  76.     justifyContent: 'space-between',
  77.     alignItems: 'center',
  78.   },
  79.   text: {
  80.     marginTop: 14,
  81.   },
  82.   statusDone: {
  83.     width: 14,
  84.     height: 11,
  85.   },
  86.   statusNotDone: {
  87.     width: 14.52,
  88.     height: 14.52,
  89.   },
  90. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement