Files
mattermost-mobile/app/components/post_priority/post_priority_label.tsx
Kyriakos Z ab4f65020a [MM-49540] Message Priority Phase 3 (#7142)
* Init

* i18 and types

* Acknowledge button, api

* Ack button + display ackd users

* Saves priority on draft and addresses some comments

* Addresses review comments round 2

* Moves fetching userprofiles upon opening ACKs

* Adds metadata column in drafts table

+ Addresses some more review comments.

* Small refactor according to review comments

* Addresses some review comments

* Addresses some review comments

* Uses local action when ACKing

* Fixes first time selecting priority and other

* Updates snapshots

* Fixes i18n

* Fixes ts errors

---------

Co-authored-by: Anurag Shivarathri <anurag6713@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2023-04-27 11:22:03 +00:00

68 lines
1.9 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {useIntl} from 'react-intl';
import {type StyleProp, StyleSheet, Text, View, type ViewStyle} from 'react-native';
import CompassIcon from '@components/compass_icon';
import {PostPriorityColors, PostPriorityType} from '@constants/post';
import {typography} from '@utils/typography';
const style = StyleSheet.create({
container: {
alignSelf: 'flex-start',
flexDirection: 'row',
borderRadius: 4,
alignItems: 'center',
paddingHorizontal: 4,
},
urgent: {
backgroundColor: PostPriorityColors.URGENT,
},
important: {
backgroundColor: PostPriorityColors.IMPORTANT,
},
label: {
color: '#fff',
...typography('Body', 25, 'SemiBold'),
},
icon: {
color: '#fff',
fontSize: 12,
marginRight: 4,
},
});
type Props = {
label: PostPriority['priority'];
};
const PostPriorityLabel = ({label}: Props) => {
const intl = useIntl();
const containerStyle: StyleProp<ViewStyle> = [style.container];
let iconName = '';
let labelText = '';
if (label === PostPriorityType.URGENT) {
containerStyle.push(style.urgent);
iconName = 'alert-outline';
labelText = intl.formatMessage({id: 'post_priority.label.urgent', defaultMessage: 'URGENT'});
} else if (label === PostPriorityType.IMPORTANT) {
containerStyle.push(style.important);
iconName = 'alert-circle-outline';
labelText = intl.formatMessage({id: 'post_priority.label.important', defaultMessage: 'IMPORTANT'});
}
return (
<View style={containerStyle}>
<CompassIcon
name={iconName}
style={style.icon}
/>
<Text style={style.label}>{labelText}</Text>
</View>
);
};
export default PostPriorityLabel;