forked from Ivasoft/mattermost-mobile
* edit screen - in progress * edit screen - in progress * edit post screen - post input - in progress * edit post screen - post input - in progress * edit post screen - post input - in progress * edit post screen - post input - in progress * edit post screen - post error component - in progress * edit post screen - post error component - in progress * edit post screen -emitEditing - in progress * edit post screen - in progress * edit post screen - in progress * edit post screen - in progress * able to edit post * edit post screen - in progress * edit post screen - in progress * edit post screen - in progress * edit post screen - in progress * updated errorLine * corrections * edit post screen - in progress * edit post screen - in progress * edit post screen - in progress * properly closes modal on tablets * starts with Save button set to false * refactored onTextSelectionChange * added useTheme to ErrorTextComponent * passing canEdit and hasFilesAttached * passing canEdit and hasFilesAttached * fix API call * change canEdit to canDelete * nearly there * displays alert * maxPostSize * autocomplete - fixing layout * autocomplete - fixing layout * autocomplete - work in progress * autocomplete - work in progress * clean up delete * fixing autocomplete * code fix * added server error message * update i18n * removed comment * code fix * fix bug on empty post message * post input top corrections * post draft limit * code corrections as per review * removed theme from useEffect * update edit_post - delete call * refactor PostInputRef to EditPostInputRef * autocomplete position fix and feedback addressed * Navigation title & subtitle fonts / navigation button builder * ux feedback * delay focus of edit input by 20 frames * properly dismiss the PostOptions screen this comes from the fix for the BottomSheet screen * using device info to check for physical keyboard * autocomplete with keyboard closed Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {StyleProp, Text, TextStyle, ViewStyle} from 'react-native';
|
|
|
|
import FormattedText from '@components/formatted_text';
|
|
import {useTheme} from '@context/theme';
|
|
import {makeStyleSheetFromTheme} from '@utils/theme';
|
|
|
|
type ErrorProps = {
|
|
error: ErrorText;
|
|
testID?: string;
|
|
textStyle?: StyleProp<ViewStyle> | StyleProp<TextStyle>;
|
|
}
|
|
|
|
const ErrorTextComponent = ({error, testID, textStyle}: ErrorProps) => {
|
|
const theme = useTheme();
|
|
const style = getStyleSheet(theme);
|
|
const message = typeof (error) === 'string' ? error : error.message;
|
|
|
|
if (typeof (error) !== 'string' && error.intl) {
|
|
const {intl} = error;
|
|
return (
|
|
<FormattedText
|
|
testID={testID}
|
|
id={intl.id}
|
|
defaultMessage={intl.defaultMessage}
|
|
values={intl.values}
|
|
style={[style.errorLabel, textStyle]}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Text
|
|
testID={testID}
|
|
style={[style.errorLabel, textStyle]}
|
|
>
|
|
{message}
|
|
</Text>
|
|
);
|
|
};
|
|
|
|
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
|
|
return {
|
|
errorLabel: {
|
|
color: (theme?.errorTextColor || '#DA4A4A'),
|
|
marginTop: 15,
|
|
marginBottom: 15,
|
|
fontSize: 12,
|
|
textAlign: 'left',
|
|
},
|
|
};
|
|
});
|
|
|
|
export default ErrorTextComponent;
|