From 8c5538b148f8a11b2dc25728a6a787445bc8d27c Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 18 May 2020 13:25:13 -0300 Subject: [PATCH] [FIX] UIKit crash when some app send a list (#2117) * [FIX] StoryBook * [FIX] UIKit crash when some app send a list * [CHORE] Update snapshot * [CHORE] Remove token & id --- .../__snapshots__/Storyshots.test.js.snap | 19 ++++++++++ app/containers/UIKit/Section.js | 9 +---- app/containers/UIKit/index.js | 15 ++++++-- storybook/stories/Message.js | 38 ++++++------------- storybook/stories/UiKitMessage.js | 11 ++++++ storybook/stories/index.js | 32 ++++++++++++++++ 6 files changed, 86 insertions(+), 38 deletions(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 3169fb2e..0b28e1ae 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -5161,6 +5161,25 @@ exports[`Storyshots UiKitMessage list uikitmessage 1`] = ` > Section + + Section + Markdown List + - {text ? {parser.text(text)} : null} + {text ? {parser.text(text)} : null} {fields ? : null} {accessory ? : null} diff --git a/app/containers/UIKit/index.js b/app/containers/UIKit/index.js index 5d8e36bf..84cac886 100644 --- a/app/containers/UIKit/index.js +++ b/app/containers/UIKit/index.js @@ -1,6 +1,6 @@ /* eslint-disable class-methods-use-this */ import React, { useContext } from 'react'; -import { StyleSheet } from 'react-native'; +import { StyleSheet, Text } from 'react-native'; import { uiKitMessage, UiKitParserMessage, @@ -13,8 +13,9 @@ import Markdown from '../markdown'; import Button from '../Button'; import TextInput from '../TextInput'; -import { useBlockContext } from './utils'; +import { useBlockContext, textParser } from './utils'; import { themes } from '../../constants/colors'; +import sharedStyles from '../../views/Styles'; import { Divider } from './Divider'; import { Section } from './Section'; @@ -37,6 +38,12 @@ const styles = StyleSheet.create({ }, button: { marginBottom: 16 + }, + text: { + fontSize: 16, + lineHeight: 22, + textAlignVertical: 'center', + ...sharedStyles.textRegular } }); @@ -46,7 +53,7 @@ class MessageParser extends UiKitParserMessage { text({ text, type } = { text: '' }, context) { const { theme } = useContext(ThemeContext); if (type !== 'mrkdwn') { - return text; + return {text}; } const isContext = context === BLOCK_CONTEXT.CONTEXT; @@ -70,7 +77,7 @@ class MessageParser extends UiKitParserMessage {