From 54bddf035de7a2eed5b09add2b78e9c1e64dea64 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 29 Jul 2020 17:49:08 -0300 Subject: [PATCH] [IMPROVEMENT] Apply new mention colors (#2351) * New mention colors * Increase letterSpacing for mentions * Refactor * UnreadBadge * Add migration --- .../__snapshots__/Storyshots.test.js.snap | 70 +++++++++++++------ app/constants/colors.js | 19 ++++- app/containers/markdown/AtMention.js | 26 +++++-- app/containers/markdown/Hashtag.js | 10 ++- app/containers/markdown/styles.js | 6 +- app/lib/database/model/Subscription.js | 2 + app/lib/database/model/migrations.js | 11 +++ app/lib/database/schema/app.js | 3 +- app/presentation/RoomItem/UnreadBadge.js | 17 +++-- app/presentation/RoomItem/index.js | 2 +- 10 files changed, 119 insertions(+), 47 deletions(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 4b04cc4a8..f70e4a6a9 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -584,13 +584,17 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#1d74f5", - "color": "#ffffff", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, + Object { + "backgroundColor": "#ffe9ec", + "color": "#f5455c", + }, ] } > @@ -627,13 +631,17 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#1d74f5", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, + Object { + "backgroundColor": "#fff6d6", + "color": "#b68d00", + }, ] } > @@ -669,15 +677,16 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#ffffff", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, Object { - "backgroundColor": "#FF5B5A", + "backgroundColor": "#fde8d7", + "color": "#f38c39", }, ] } @@ -714,15 +723,16 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#ffffff", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, Object { - "backgroundColor": "#FF5B5A", + "backgroundColor": "#fde8d7", + "color": "#f38c39", }, ] } @@ -818,13 +828,17 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#1d74f5", - "color": "#ffffff", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, + Object { + "backgroundColor": "#ffe9ec", + "color": "#f5455c", + }, ] } > @@ -861,13 +875,17 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#1d74f5", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, + Object { + "backgroundColor": "#fff6d6", + "color": "#b68d00", + }, ] } > @@ -903,15 +921,16 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#ffffff", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, Object { - "backgroundColor": "#FF5B5A", + "backgroundColor": "#fde8d7", + "color": "#f38c39", }, ] } @@ -948,15 +967,16 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#ffffff", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, Object { - "backgroundColor": "#FF5B5A", + "backgroundColor": "#fde8d7", + "color": "#f38c39", }, ] } @@ -1052,17 +1072,21 @@ exports[`Storyshots Markdown list Markdown 1`] = ` style={ Array [ Object { - "backgroundColor": "#E8F2FF", - "color": "#0072FE", + "backgroundColor": "transparent", "fontFamily": "System", "fontSize": 16, "fontWeight": "500", + "letterSpacing": 0.5, "padding": 5, }, + Object { + "backgroundColor": "#fff6d6", + "color": "#b68d00", + }, ] } > - test-channel + #test-channel { - let mentionStyle = { ...styles.mention, color: themes[theme].buttonText }; if (mention === 'all' || mention === 'here') { - return {mention}; + return ( + {mention} + + ); } + let mentionStyle = {}; if (mention === username) { mentionStyle = { - ...mentionStyle, - backgroundColor: themes[theme].actionTintColor + color: themes[theme].mentionMeColor, + backgroundColor: themes[theme].mentionMeBackground }; } else { mentionStyle = { - ...mentionStyle, - color: themes[theme].actionTintColor + color: themes[theme].mentionOtherColor, + backgroundColor: themes[theme].mentionOtherBackground }; } @@ -39,7 +51,7 @@ const AtMention = React.memo(({ if (user) { return ( {useRealName && user.name ? user.name : user.username} diff --git a/app/containers/markdown/Hashtag.js b/app/containers/markdown/Hashtag.js index 655d3a737..cccb1fb27 100644 --- a/app/containers/markdown/Hashtag.js +++ b/app/containers/markdown/Hashtag.js @@ -21,10 +21,16 @@ const Hashtag = React.memo(({ if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) { return ( - {hashtag} + {`#${ hashtag }`} ); } diff --git a/app/containers/markdown/styles.js b/app/containers/markdown/styles.js index c60c77c9d..d005f90f1 100644 --- a/app/containers/markdown/styles.js +++ b/app/containers/markdown/styles.js @@ -54,13 +54,9 @@ export default StyleSheet.create({ temp: { opacity: 0.3 }, mention: { fontSize: 16, - color: '#0072FE', padding: 5, ...sharedStyles.textMedium, - backgroundColor: '#E8F2FF' - }, - mentionAll: { - backgroundColor: '#FF5B5A' + letterSpacing: 0.5 }, paragraph: { marginTop: 0, diff --git a/app/lib/database/model/Subscription.js b/app/lib/database/model/Subscription.js index 77efd3783..a94e09423 100644 --- a/app/lib/database/model/Subscription.js +++ b/app/lib/database/model/Subscription.js @@ -40,6 +40,8 @@ export default class Subscription extends Model { @field('user_mentions') userMentions; + @field('group_mentions') groupMentions; + @date('room_updated_at') roomUpdatedAt; @field('ro') ro; diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index 260209427..db3b92dc3 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -118,6 +118,17 @@ export default schemaMigrations({ ] }) ] + }, + { + toVersion: 9, + steps: [ + addColumns({ + table: 'subscriptions', + columns: [ + { name: 'group_mentions', type: 'number', isOptional: true } + ] + }) + ] } ] }); diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index 97784b3f9..59336e3f0 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -1,7 +1,7 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb'; export default appSchema({ - version: 8, + version: 9, tables: [ tableSchema({ name: 'subscriptions', @@ -19,6 +19,7 @@ export default appSchema({ { name: 'roles', type: 'string', isOptional: true }, { name: 'unread', type: 'number' }, { name: 'user_mentions', type: 'number' }, + { name: 'group_mentions', type: 'number' }, { name: 'room_updated_at', type: 'number' }, { name: 'ro', type: 'boolean' }, { name: 'last_open', type: 'number', isOptional: true }, diff --git a/app/presentation/RoomItem/UnreadBadge.js b/app/presentation/RoomItem/UnreadBadge.js index af745f811..83fadca60 100644 --- a/app/presentation/RoomItem/UnreadBadge.js +++ b/app/presentation/RoomItem/UnreadBadge.js @@ -6,7 +6,7 @@ import styles from './styles'; import { themes } from '../../constants/colors'; const UnreadBadge = React.memo(({ - theme, unread, userMentions, type + theme, unread, userMentions, groupMentions }) => { if (!unread || unread <= 0) { return; @@ -14,19 +14,26 @@ const UnreadBadge = React.memo(({ if (unread >= 1000) { unread = '999+'; } - const mentioned = userMentions > 0 && type !== 'd'; + + let backgroundColor = themes[theme].unreadBackground; + const color = themes[theme].buttonText; + if (userMentions > 0) { + backgroundColor = themes[theme].mentionMeColor; + } else if (groupMentions > 0) { + backgroundColor = themes[theme].mentionGroupColor; + } return ( { unread } @@ -38,7 +45,7 @@ UnreadBadge.propTypes = { theme: PropTypes.string, unread: PropTypes.number, userMentions: PropTypes.number, - type: PropTypes.string + groupMentions: PropTypes.number }; export default UnreadBadge; diff --git a/app/presentation/RoomItem/index.js b/app/presentation/RoomItem/index.js index 487c22430..0bb4c3157 100644 --- a/app/presentation/RoomItem/index.js +++ b/app/presentation/RoomItem/index.js @@ -189,7 +189,7 @@ const RoomItem = React.memo(({