mattermost-mobile/app/components/tablet_title/index.tsx
Kyriakos Z 2645f7e66e
MM-39710: saved posts screen and DB (#6020)
* MM-39710: saved posts screen and DB

- Adds ids of saved posts to the systems table, as we do with recent
mentions.
- Adds a new remote action to fetch saved posts (getFlaggedPosts).
- Adds a new screen to display those in a mobile.
- Displays saved posts in the tablet view next to profile card.

* Uses Preferences instead of System table

Renames to saved posts wherever possible

* Adds text to localization file

* Fixes fetching/saving saved posts

* Refactor mini post to components folder

* Fixes hooks dependencies according to review

* Removes unnecessary 'withObservables'

* Small refactor

* Satisfies linter

* Adds empty state

And fixes empty state icon to be theme sensitive.
Both recent_mentions and saved_posts.

* Fixes empty screen's alignment

* Add missing preference

* add missing translation strings

* remove unused database type definition

* Fetch newly saved post

* Fix return type for client.getSavedPosts

* Remove usage of lodash compose

* Rename get remote actions to fetch

* Include close button for savedPost modal

* fix tablet view for SavePosts and use lottie loading indicator

* Render post with content for save posts and recent mentions

* post list viewable items type definition

* Add layout width to post content for saved post screen

* Use PostWithChannel and viewableItems for saved posts and recent mentions

* Layout margin of 20

* openGraphImage margin

* Fix openGraphImage display

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-03-12 16:40:24 -03:00

88 lines
2.6 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Platform, Text, View} from 'react-native';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import {useTheme} from '@context/theme';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
type Props = {
action?: string;
enabled?: boolean;
onPress?: () => void;
title: string;
testID: string;
}
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({
actionContainer: {
alignItems: 'flex-end',
justifyContent: 'center',
right: 20,
bottom: 7,
position: 'absolute',
},
action: {
color: changeOpacity(theme.centerChannelColor, 0.7),
fontFamily: 'OpenSans-SemiBold',
fontSize: 16,
lineHeight: 24,
},
container: {
backgroundColor: theme.centerChannelBg,
borderBottomWidth: 1,
borderBottomColor: changeOpacity(theme.centerChannelColor, 0.08),
flexDirection: 'row',
height: 34,
width: '100%',
alignItems: 'center',
paddingBottom: 5,
},
enabled: {
color: theme.buttonBg,
},
titleContainer: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
title: {
color: theme.centerChannelColor,
fontFamily: 'OpenSans-SemiBold',
fontSize: 18,
lineHeight: 24,
},
}));
const TabletTitle = ({action, enabled = true, onPress, testID, title}: Props) => {
const theme = useTheme();
const styles = getStyleSheet(theme);
const textStyle = [styles.action, enabled && styles.enabled];
return (
<>
<View style={styles.container}>
<View style={styles.titleContainer}>
<Text style={styles.title}>{title}</Text>
</View>
{Boolean(action) &&
<View style={styles.actionContainer}>
<TouchableWithFeedback
disabled={!enabled}
onPress={onPress}
type={Platform.select({android: 'native', ios: 'opacity'})}
testID={testID}
underlayColor={changeOpacity(theme.centerChannelColor, 0.1)}
>
<Text style={textStyle}>{action}</Text>
</TouchableWithFeedback>
</View>
}
</View>
</>
);
};
export default TabletTitle;