mattermost-mobile/app/components/EditedIndicator/index.tsx
Rajat Dabade 5cceaee7c5
Changed the Edited text style in the post from (edited) to icon + Edited (#8937)
* Viewing Files in Edit mode in mobile with ability to delete and save

* Added upload attachment to keyboard tracker view

* using state instread of use ref

* Minor

* Added tests

* intl extract

* new function getFiles
ById, batch file deletion and tests

* Files fetching in edit options and tests

* Removed DeviceEventEmitter and used React context

* Added support to check minimum required version to show edit file attachments

* resolve forward ref issue

* Minor

* memotized props for context and observe config with value

* Ability to show quick action and add files to edit post

* type safety for EditPostContext

* Reverted back the post priority props

* constant shift

* Added test for QuickAction to show slashcomand

* Added test for edit_post, upload_item and upload_remove

* Added test for Edit_post_input and edit_post index

* fix the height issue between attachment and keyboard due to safeArea

* Minor: removed debugging border color

* Changed the Edited text style in the post from (edited) to icon + Edited

* Import fixes

* Ability to show quick action and add files to edit post

* type safety for EditPostContext

* Reverted back the post priority props

* constant shift

* Added test for QuickAction to show slashcomand

* Added test for edit_post, upload_item and upload_remove

* Added test for Edit_post_input and edit_post index

* fix the height issue between attachment and keyboard due to safeArea

* Minor: removed debugging border color

* Addressed dev review comments

* Import fixes

* Address UX comments

* Fixed props for UploadItem and remove effective Edit mode

* handled save button disabled state when uploading attachments

* handled newly added and retry file removal without alert message

* Test updated

* Added test for input_quick_action index.tsx

* Added test for not in edit mode for upload_item index

* Added test for upload_remove component when not in edit mode

* added tests for file_upload_error hook

* Added test for calling callback when in edit mode

* Test for edit post input for server version check

* linter fixes

* Changed font size from 16 to 14px for edited

* separated common component and test

* Removed the margin styles from the text as it is not been applied.

* removed the duplicate code from rebase
2025-06-29 12:39:18 +05:30

83 lines
2.3 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Platform, type StyleProp, Text, type TextStyle} from 'react-native';
import CompassIcon from '@components/compass_icon';
import FormattedText from '@components/formatted_text';
import {blendColors, makeStyleSheetFromTheme} from '@utils/theme';
import {typography} from '@utils/typography';
type EditedIndicatorProps = {
baseTextStyle: StyleProp<TextStyle>;
theme: Theme;
context: string[];
iconSize?: number;
checkHeadings?: boolean;
testID?: string;
}
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
// Android has trouble giving text transparency depending on how it's nested,
// so we calculate the resulting colour manually
const editedOpacity = Platform.select({
ios: 0.56,
android: 1.0,
});
const editedColor = Platform.select({
ios: theme.centerChannelColor,
android: blendColors(theme.centerChannelBg, theme.centerChannelColor, 0.3),
});
return {
editedIndicatorText: {
color: editedColor,
opacity: editedOpacity,
fontStyle: 'italic',
...typography('Body', 25, 'Regular'),
},
editedText: {
...typography('Body', 100, 'Regular'),
},
};
});
const EditedIndicator = ({
baseTextStyle,
theme,
context,
iconSize = 14,
checkHeadings = false,
testID = 'edited_indicator',
}: EditedIndicatorProps) => {
const style = getStyleSheet(theme);
let spacer = '';
const styles = [baseTextStyle, style.editedIndicatorText];
// Add space for paragraphs, and optionally for headings
if (context[0] === 'paragraph' || (checkHeadings && context[0]?.startsWith('heading'))) {
spacer = ' ';
}
return (
<Text
style={styles}
testID={testID}
>
{spacer}
<CompassIcon
name='pencil-outline'
size={iconSize}
color={theme.centerChannelColor}
/>
<FormattedText
id='post_message_view.edited'
defaultMessage='Edited'
style={style.editedText}
/>
</Text>
);
};
export default EditedIndicator;