[IMPROVEMENT] Apply new mention colors (#2351)

* New mention colors

* Increase letterSpacing for mentions

* Refactor

* UnreadBadge

* Add migration
This commit is contained in:
Diego Mello 2020-07-29 17:49:08 -03:00 committed by GitHub
parent b68b0b84df
commit 54bddf035d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 119 additions and 47 deletions

View File

@ -584,13 +584,17 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#1d74f5", "backgroundColor": "transparent",
"color": "#ffffff",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object {
"backgroundColor": "#ffe9ec",
"color": "#f5455c",
},
] ]
} }
> >
@ -627,13 +631,17 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#1d74f5",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object {
"backgroundColor": "#fff6d6",
"color": "#b68d00",
},
] ]
} }
> >
@ -669,15 +677,16 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#ffffff",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object { Object {
"backgroundColor": "#FF5B5A", "backgroundColor": "#fde8d7",
"color": "#f38c39",
}, },
] ]
} }
@ -714,15 +723,16 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#ffffff",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object { Object {
"backgroundColor": "#FF5B5A", "backgroundColor": "#fde8d7",
"color": "#f38c39",
}, },
] ]
} }
@ -818,13 +828,17 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#1d74f5", "backgroundColor": "transparent",
"color": "#ffffff",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object {
"backgroundColor": "#ffe9ec",
"color": "#f5455c",
},
] ]
} }
> >
@ -861,13 +875,17 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#1d74f5",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object {
"backgroundColor": "#fff6d6",
"color": "#b68d00",
},
] ]
} }
> >
@ -903,15 +921,16 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#ffffff",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object { Object {
"backgroundColor": "#FF5B5A", "backgroundColor": "#fde8d7",
"color": "#f38c39",
}, },
] ]
} }
@ -948,15 +967,16 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#ffffff",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object { Object {
"backgroundColor": "#FF5B5A", "backgroundColor": "#fde8d7",
"color": "#f38c39",
}, },
] ]
} }
@ -1052,17 +1072,21 @@ exports[`Storyshots Markdown list Markdown 1`] = `
style={ style={
Array [ Array [
Object { Object {
"backgroundColor": "#E8F2FF", "backgroundColor": "transparent",
"color": "#0072FE",
"fontFamily": "System", "fontFamily": "System",
"fontSize": 16, "fontSize": 16,
"fontWeight": "500", "fontWeight": "500",
"letterSpacing": 0.5,
"padding": 5, "padding": 5,
}, },
Object {
"backgroundColor": "#fff6d6",
"color": "#b68d00",
},
] ]
} }
> >
test-channel #test-channel
</Text> </Text>
<Text <Text
accessibilityLabel=" " accessibilityLabel=" "

View File

@ -10,6 +10,16 @@ export const SWITCH_TRACK_COLOR = {
true: '#2de0a5' true: '#2de0a5'
}; };
const mentions = {
unreadBackground: '#414852',
mentionMeColor: '#f5455c',
mentionMeBackground: '#ffe9ec',
mentionGroupColor: '#f38c39',
mentionGroupBackground: '#fde8d7',
mentionOtherColor: '#b68d00',
mentionOtherBackground: '#fff6d6'
};
export const themes = { export const themes = {
light: { light: {
backgroundColor: '#ffffff', backgroundColor: '#ffffff',
@ -53,7 +63,8 @@ export const themes = {
passcodeDotEmpty: '#CBCED1', passcodeDotEmpty: '#CBCED1',
passcodeDotFull: '#6C727A', passcodeDotFull: '#6C727A',
previewBackground: '#1F2329', previewBackground: '#1F2329',
previewTintColor: '#ffffff' previewTintColor: '#ffffff',
...mentions
}, },
dark: { dark: {
backgroundColor: '#030b1b', backgroundColor: '#030b1b',
@ -97,7 +108,8 @@ export const themes = {
passcodeDotEmpty: '#CBCED1', passcodeDotEmpty: '#CBCED1',
passcodeDotFull: '#6C727A', passcodeDotFull: '#6C727A',
previewBackground: '#030b1b', previewBackground: '#030b1b',
previewTintColor: '#ffffff' previewTintColor: '#ffffff',
...mentions
}, },
black: { black: {
backgroundColor: '#000000', backgroundColor: '#000000',
@ -141,6 +153,7 @@ export const themes = {
passcodeDotEmpty: '#CBCED1', passcodeDotEmpty: '#CBCED1',
passcodeDotFull: '#6C727A', passcodeDotFull: '#6C727A',
previewBackground: '#000000', previewBackground: '#000000',
previewTintColor: '#ffffff' previewTintColor: '#ffffff',
...mentions
} }
}; };

View File

@ -9,20 +9,32 @@ import styles from './styles';
const AtMention = React.memo(({ const AtMention = React.memo(({
mention, mentions, username, navToRoomInfo, style = [], useRealName, theme mention, mentions, username, navToRoomInfo, style = [], useRealName, theme
}) => { }) => {
let mentionStyle = { ...styles.mention, color: themes[theme].buttonText };
if (mention === 'all' || mention === 'here') { if (mention === 'all' || mention === 'here') {
return <Text style={[mentionStyle, styles.mentionAll, ...style]}>{mention}</Text>; return (
<Text
style={[
styles.mention,
{
color: themes[theme].mentionGroupColor,
backgroundColor: themes[theme].mentionGroupBackground
},
...style
]}
>{mention}
</Text>
);
} }
let mentionStyle = {};
if (mention === username) { if (mention === username) {
mentionStyle = { mentionStyle = {
...mentionStyle, color: themes[theme].mentionMeColor,
backgroundColor: themes[theme].actionTintColor backgroundColor: themes[theme].mentionMeBackground
}; };
} else { } else {
mentionStyle = { mentionStyle = {
...mentionStyle, color: themes[theme].mentionOtherColor,
color: themes[theme].actionTintColor backgroundColor: themes[theme].mentionOtherBackground
}; };
} }
@ -39,7 +51,7 @@ const AtMention = React.memo(({
if (user) { if (user) {
return ( return (
<Text <Text
style={[mentionStyle, ...style]} style={[styles.mention, mentionStyle, ...style]}
onPress={handlePress} onPress={handlePress}
> >
{useRealName && user.name ? user.name : user.username} {useRealName && user.name ? user.name : user.username}

View File

@ -21,10 +21,16 @@ const Hashtag = React.memo(({
if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) { if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) {
return ( return (
<Text <Text
style={[styles.mention, ...style]} style={[
styles.mention,
{
color: themes[theme].mentionOtherColor,
backgroundColor: themes[theme].mentionOtherBackground
},
...style]}
onPress={handlePress} onPress={handlePress}
> >
{hashtag} {`#${ hashtag }`}
</Text> </Text>
); );
} }

View File

@ -54,13 +54,9 @@ export default StyleSheet.create({
temp: { opacity: 0.3 }, temp: { opacity: 0.3 },
mention: { mention: {
fontSize: 16, fontSize: 16,
color: '#0072FE',
padding: 5, padding: 5,
...sharedStyles.textMedium, ...sharedStyles.textMedium,
backgroundColor: '#E8F2FF' letterSpacing: 0.5
},
mentionAll: {
backgroundColor: '#FF5B5A'
}, },
paragraph: { paragraph: {
marginTop: 0, marginTop: 0,

View File

@ -40,6 +40,8 @@ export default class Subscription extends Model {
@field('user_mentions') userMentions; @field('user_mentions') userMentions;
@field('group_mentions') groupMentions;
@date('room_updated_at') roomUpdatedAt; @date('room_updated_at') roomUpdatedAt;
@field('ro') ro; @field('ro') ro;

View File

@ -118,6 +118,17 @@ export default schemaMigrations({
] ]
}) })
] ]
},
{
toVersion: 9,
steps: [
addColumns({
table: 'subscriptions',
columns: [
{ name: 'group_mentions', type: 'number', isOptional: true }
]
})
]
} }
] ]
}); });

View File

@ -1,7 +1,7 @@
import { appSchema, tableSchema } from '@nozbe/watermelondb'; import { appSchema, tableSchema } from '@nozbe/watermelondb';
export default appSchema({ export default appSchema({
version: 8, version: 9,
tables: [ tables: [
tableSchema({ tableSchema({
name: 'subscriptions', name: 'subscriptions',
@ -19,6 +19,7 @@ export default appSchema({
{ name: 'roles', type: 'string', isOptional: true }, { name: 'roles', type: 'string', isOptional: true },
{ name: 'unread', type: 'number' }, { name: 'unread', type: 'number' },
{ name: 'user_mentions', type: 'number' }, { name: 'user_mentions', type: 'number' },
{ name: 'group_mentions', type: 'number' },
{ name: 'room_updated_at', type: 'number' }, { name: 'room_updated_at', type: 'number' },
{ name: 'ro', type: 'boolean' }, { name: 'ro', type: 'boolean' },
{ name: 'last_open', type: 'number', isOptional: true }, { name: 'last_open', type: 'number', isOptional: true },

View File

@ -6,7 +6,7 @@ import styles from './styles';
import { themes } from '../../constants/colors'; import { themes } from '../../constants/colors';
const UnreadBadge = React.memo(({ const UnreadBadge = React.memo(({
theme, unread, userMentions, type theme, unread, userMentions, groupMentions
}) => { }) => {
if (!unread || unread <= 0) { if (!unread || unread <= 0) {
return; return;
@ -14,19 +14,26 @@ const UnreadBadge = React.memo(({
if (unread >= 1000) { if (unread >= 1000) {
unread = '999+'; 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 ( return (
<View <View
style={[ style={[
styles.unreadNumberContainer, styles.unreadNumberContainer,
{ backgroundColor: mentioned ? themes[theme].tintColor : themes[theme].borderColor } { backgroundColor }
]} ]}
> >
<Text <Text
style={[ style={[
styles.unreadText, styles.unreadText,
{ color: mentioned ? themes[theme].buttonText : themes[theme].bodyText } { color }
]} ]}
>{ unread } >{ unread }
</Text> </Text>
@ -38,7 +45,7 @@ UnreadBadge.propTypes = {
theme: PropTypes.string, theme: PropTypes.string,
unread: PropTypes.number, unread: PropTypes.number,
userMentions: PropTypes.number, userMentions: PropTypes.number,
type: PropTypes.string groupMentions: PropTypes.number
}; };
export default UnreadBadge; export default UnreadBadge;

View File

@ -189,7 +189,7 @@ const RoomItem = React.memo(({
<UnreadBadge <UnreadBadge
unread={item.unread} unread={item.unread}
userMentions={item.userMentions} userMentions={item.userMentions}
type={item.t} groupMentions={item.groupMentions}
theme={theme} theme={theme}
/> />
</View> </View>