Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var notificationsDummy = [
  2.     {
  3.         author: 'Павел Иохин',
  4.         avatarUrl: 'https://cp.bitrix.ru/upload/resize_cache/main/570/212_212_1/tmp.png',
  5.         text: 'Напоминание о событии Отгул, 26.02.2020 отмеченного в Вашем календаре "Павел Иохин"',
  6.         moreText: 'Посмотреть подробности',
  7.         time: '01:45, 26 Февраля 2020'
  8.     },
  9.     {
  10.         author: 'Павел Юрин',
  11.         avatarUrl: 'https://cp.bitrix.ru/upload/resize_cache/main/f2a/212_212_1/P1066310.png',
  12.         text: 'Мне нравится ваше сообщение "есть" в чате "Работа в выходные - калининградский офис"',
  13.         moreText: '',
  14.         time: '10:51, 24 Февраля 2020'
  15.     },
  16.     {
  17.         author: 'Евгений Шеленков',
  18.         avatarUrl: 'https://cp.bitrix.ru/upload/resize_cache/main/593/212_212_1/btr_1759.png',
  19.         text: 'Мне нравится ваше сообщение "В пн 24-го на 5м кто-то будет?" в чате "Работа в выходные - калининградский офис"',
  20.         moreText: '',
  21.         time: '15:29, 21 Февраля 2020'
  22.     },
  23.     {
  24.         author: 'Валерия Котанова',
  25.         avatarUrl: 'https://cp.bitrix.ru/upload/resize_cache/main/6d3/212_212_1/%D1%84%D0%BE%D1%82%D0%BE%20%D0%B4%D0%BB%D1%8F%20%D0%B1%D0%B8%D1%82.png',
  26.         text: 'Тикет №80108',
  27.         moreText: '',
  28.         subData: {
  29.             title: 'Уведомления Mantis',
  30.             icon: 'https://framalibre.org/sites/default/files/leslogos/mantis_logo_for_google_400x400.png',
  31.             subtitle1: 'Открыть Mantis',
  32.             subtitle2: 'Открыть Mantis из внешней сети',
  33.             properties: [
  34.                 {
  35.                     name: 'Проект',
  36.                     value: 'Features',
  37.                     direction: 'row'
  38.                 },
  39.                 {
  40.                     name: 'Категория',
  41.                     value: 'mobile',
  42.                     direction: 'row'
  43.                 },
  44.                 {
  45.                     name: 'Добавлено',
  46.                     value: 'Теплякова Ольга',
  47.                     direction: 'row'
  48.                 },
  49.                 {
  50.                     name: 'Назначено',
  51.                     value: 'Петриченко Евгений',
  52.                     direction: 'row'
  53.                 },
  54.                 {
  55.                     name: 'Статус',
  56.                     value: 'новый',
  57.                     direction: 'row'
  58.                 },
  59.                 {
  60.                     name: 'Критичность',
  61.                     value: 'нормальный',
  62.                     direction: 'row'
  63.                 },
  64.                 {
  65.                     name: 'Сводка',
  66.                     value: 'б24: возможность открыть файл и просмотреть в событии календаря в мобильном приложеии',
  67.                     direction: 'col'
  68.                 },
  69.                 {
  70.                     separator: true
  71.                 },
  72.                 {
  73.                     name: 'Тикеты',
  74.                     value: '10-й тикет: imol|1437841',
  75.                     direction: 'row'
  76.                 },
  77.                 {
  78.                     name: 'Следить',
  79.                     value: 'Котанова Валерия',
  80.                     direction: 'row'
  81.                 },
  82.             ]
  83.         },
  84.         time: 'Вчера, 23:00'
  85.     },
  86. ]
  87.  
  88. var notifications = [
  89.     ...notificationsDummy,
  90.     ...notificationsDummy,
  91.     ...notificationsDummy,
  92.     ...notificationsDummy
  93. ]
  94.  
  95. var NotificationItemElement = (notification) => View(
  96.     {
  97.         style: {
  98.             backgroundColor: '#ffffff'
  99.         }
  100.     },
  101.     View(
  102.         {
  103.             style: {
  104.                 flexDirection: 'row',
  105.                 padding: 10
  106.             }
  107.         },
  108.         Image(
  109.             {
  110.                 uri: notification.avatarUrl,
  111.                 resizeMode: 'cover',
  112.                 style: {
  113.                     width: 50,
  114.                     height: 50,
  115.                     marginRight: 10,
  116.                     borderRadius: 25
  117.                 }
  118.             }
  119.         ),
  120.         View(
  121.             { style: { width: 150, flexGrow: 1 } },
  122.             Text(
  123.                 {
  124.                     text: notification.author,
  125.                     style: {
  126.                         color: '#000000',
  127.                         fontWeight: 'bold',
  128.                         fontSize: 14,
  129.                         marginBottom: 5
  130.                     }
  131.                 }
  132.             ),
  133.             Text(
  134.                 {
  135.                     text: notification.text,
  136.                     style: {
  137.                         color: '#000000',
  138.                         fontSize: 14,
  139.                     }
  140.                 }
  141.             ),
  142.             notification.moreText ? Text(
  143.                 {
  144.                     text: notification.moreText,
  145.                     style: {
  146.                         color: '#000099',
  147.                         fontWeight: 'bold',
  148.                         fontSize: 12,
  149.                         marginTop: 2
  150.                     }
  151.                 }
  152.             ) : View({}),
  153.             notification.subData ? SubDataElement(notification.subData) : View({}),
  154.             Text(
  155.                 {
  156.                     text: notification.time,
  157.                     style: {
  158.                         color: '#999999',
  159.                         fontSize: 12,
  160.                         marginTop: 2
  161.                     }
  162.                 }
  163.             )
  164.         ),
  165.         Button(
  166.             {
  167.                 text: 'X',
  168.                 style: {
  169.                     color: '#999999',
  170.                     width: 20,
  171.                     height: 20
  172.                 }
  173.             }
  174.         )
  175.     ),
  176.     View({ style: { height: 1, backgroundColor: '#cccccc' } })
  177. )
  178.  
  179. var SubDataElement = (data) => View(
  180.     {},
  181.     View(
  182.         { style: { flexDirection: 'row', marginTop: 5 } },
  183.         View({ style: { width: 2, backgroundColor: '#000099' } }),
  184.         View(
  185.             { style: { paddingLeft: 10 } },
  186.             View(
  187.                 { style: { flexDirection: 'row' } },
  188.                 Image(
  189.                     {
  190.                         uri: data.icon,
  191.                         resizeMode: 'cover',
  192.                         style: {
  193.                             width: 30,
  194.                             height: 30,
  195.                             marginRight: 10,
  196.                             borderRadius: 15
  197.                         }
  198.                     }
  199.                 ),
  200.                 Text(
  201.                     {
  202.                         text: data.title,
  203.                         style: {
  204.                             color: '#000000',
  205.                             fontWeight: 'bold',
  206.                             fontSize: 14,
  207.                             marginBottom: 5
  208.                         }
  209.                     }
  210.                 ),
  211.             ),
  212.             Text(
  213.                 {
  214.                     text: data.subtitle1,
  215.                     style: {
  216.                         color: '#000099',
  217.                         fontWeight: 'bold',
  218.                         fontSize: 12,
  219.                         marginTop: 2
  220.                     }
  221.                 }
  222.             ),
  223.             Text(
  224.                 {
  225.                     text: data.subtitle2,
  226.                     style: {
  227.                         color: '#000099',
  228.                         fontWeight: 'bold',
  229.                         fontSize: 12,
  230.                         marginTop: 2
  231.                     }
  232.                 }
  233.             ),
  234.             View(
  235.                 { style: { height: 1, backgroundColor: '#999999', marginTop: 5 } }
  236.             ),
  237.             ...data.properties.map(property => property.separator ? View(
  238.                 { style: { height: 1, backgroundColor: '#999999', marginTop: 5 } }
  239.             ) : View(
  240.                 {
  241.                     style: {
  242.                         flexDirection: property.direction === 'row' ? 'row': 'column',
  243.                         //justifyContent: property.direction === 'row' ? 'space-between' : 'flex-start',
  244.                         marginTop: 5,
  245.                     },
  246.                 },
  247.                 Text(
  248.                     {
  249.                         text: property.name,
  250.                         style: {
  251.                             color: '#000000',
  252.                             fontWeight: 'bold',
  253.                             fontSize: 12,
  254.                             width: 100
  255.                         }
  256.                     }
  257.                 ),
  258.                 Text(
  259.                     {
  260.                         text: property.value,
  261.                         style: {
  262.                             color: '#000000',
  263.                             fontSize: 12,
  264.                         }
  265.                     }
  266.                 ),
  267.             ))
  268.         )
  269.     )
  270. )
  271.  
  272. class NotificationsComponent extends JNLayoutComponent {
  273.     constructor() {
  274.         super({ notifications: notifications })
  275.     }
  276.  
  277.     render(state) {
  278.         return ScrollView(
  279.             { style: { backgroundColor: '#ffffff' } },
  280.             View(
  281.                 {},
  282.                 ...state.notifications.map(notification => NotificationItemElement(notification))
  283.             )
  284.         )
  285.     }
  286. }
  287.  
  288. var notificationsComponent = new NotificationsComponent()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement