From 54d5a79e3359a826c1fafd8322ee835b79438fd9 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 10 Jun 2021 16:33:53 -0400 Subject: Fix type warning --- src/components/moments/MomentCommentPreview.tsx | 6 ---- src/components/moments/MomentPostContent.tsx | 2 +- src/utils/comments.tsx | 38 ++++++++++++------------- 3 files changed, 20 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/components/moments/MomentCommentPreview.tsx b/src/components/moments/MomentCommentPreview.tsx index 03f30dda..94fcb008 100644 --- a/src/components/moments/MomentCommentPreview.tsx +++ b/src/components/moments/MomentCommentPreview.tsx @@ -23,12 +23,6 @@ const MomentCommentPreview: React.FC = ({ ? 'No Comments' : moment.comments_count + ' comments'; - /** - * TODO: - * - figure out why mention PartTypes have type warnings - * - fix padding for all types (double check on iPhone 8) - */ - return ( = ({ renderTextWithMentions({ value: moment.caption, styles: styles.captionText, - partTypes: mentionPartTypes('white'), + partTypes: mentionPartTypes('momentCaption'), onPress: (user: UserType) => navigateToProfile(state, dispatch, navigation, screenType, user), })} diff --git a/src/utils/comments.tsx b/src/utils/comments.tsx index e700da88..161ede0b 100644 --- a/src/utils/comments.tsx +++ b/src/utils/comments.tsx @@ -79,9 +79,23 @@ export const renderTextWithMentions: React.FC = ({ ); }; -const textStyle: (theme: 'blue' | 'white' | 'commentPreview') => PartType = ( - theme, -) => { +export const mentionPartTypes: ( + theme: 'blue' | 'momentCaption' | 'commentPreview', +) => PartType[] = (theme) => { + return [ + { + trigger: '@', + renderSuggestions: (props) => , + allowedSpacesCount: 0, + isInsertSpaceAfterMention: true, + textStyle: _textStyle(theme), + }, + ]; +}; + +const _textStyle: ( + theme: 'blue' | 'momentCaption' | 'commentPreview', +) => StyleProp = (theme) => { switch (theme) { case 'blue': return { @@ -94,26 +108,12 @@ const textStyle: (theme: 'blue' | 'white' | 'commentPreview') => PartType = ( fontWeight: '800', top: normalize(3), }; - case 'white': + case 'momentCaption': default: return { color: 'white', fontWeight: '800', - top: normalize(7.5), + top: normalize(4.5), }; } }; - -export const mentionPartTypes: ( - theme: 'blue' | 'white' | 'commentPreview', -) => PartType[] = (theme) => { - return [ - { - trigger: '@', - renderSuggestions: (props) => , - allowedSpacesCount: 0, - isInsertSpaceAfterMention: true, - textStyle: textStyle(theme), - }, - ]; -}; -- cgit v1.2.3-70-g09d2