forked from Ivasoft/mattermost-mobile
corrections from reviews
This commit is contained in:
@@ -15,18 +15,18 @@ import {showSnackBar} from '@utils/snack_bar';
|
||||
import type PostModel from '@typings/database/models/servers/post';
|
||||
|
||||
type Props = {
|
||||
location: typeof Screens[keyof typeof Screens];
|
||||
sourceScreen: typeof Screens[keyof typeof Screens];
|
||||
post: PostModel;
|
||||
teamName: string;
|
||||
}
|
||||
const CopyPermalinkOption = ({teamName, post, location}: Props) => {
|
||||
const CopyPermalinkOption = ({teamName, post, sourceScreen}: Props) => {
|
||||
const serverUrl = useServerUrl();
|
||||
|
||||
const handleCopyLink = useCallback(async () => {
|
||||
const permalink = `${serverUrl}/${teamName}/pl/${post.id}`;
|
||||
Clipboard.setString(permalink);
|
||||
await dismissBottomSheet(Screens.POST_OPTIONS);
|
||||
showSnackBar({barType: SNACK_BAR_TYPE.LINK_COPIED, location});
|
||||
showSnackBar({barType: SNACK_BAR_TYPE.LINK_COPIED, sourceScreen});
|
||||
}, [teamName, post.id]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,14 +12,14 @@ import {dismissBottomSheet} from '@screens/navigation';
|
||||
import {showSnackBar} from '@utils/snack_bar';
|
||||
|
||||
type Props = {
|
||||
location: typeof Screens[keyof typeof Screens];
|
||||
sourceScreen: typeof Screens[keyof typeof Screens];
|
||||
postMessage: string;
|
||||
}
|
||||
const CopyTextOption = ({postMessage, location}: Props) => {
|
||||
const CopyTextOption = ({postMessage, sourceScreen}: Props) => {
|
||||
const handleCopyText = useCallback(async () => {
|
||||
Clipboard.setString(postMessage);
|
||||
await dismissBottomSheet(Screens.POST_OPTIONS);
|
||||
showSnackBar({barType: SNACK_BAR_TYPE.MESSAGE_COPIED, location});
|
||||
showSnackBar({barType: SNACK_BAR_TYPE.MESSAGE_COPIED, sourceScreen});
|
||||
}, [postMessage]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -31,7 +31,7 @@ type PostOptionsProps = {
|
||||
canReply: boolean;
|
||||
combinedPost?: Post;
|
||||
isSaved: boolean;
|
||||
location: typeof Screens[keyof typeof Screens];
|
||||
sourceScreen: typeof Screens[keyof typeof Screens];
|
||||
post: PostModel;
|
||||
thread?: ThreadModel;
|
||||
componentId: string;
|
||||
@@ -41,7 +41,7 @@ const PostOptions = ({
|
||||
canAddReaction, canDelete, canEdit,
|
||||
canMarkAsUnread, canPin, canReply,
|
||||
combinedPost, componentId, isSaved,
|
||||
location, post, thread,
|
||||
sourceScreen, post, thread,
|
||||
}: PostOptionsProps) => {
|
||||
const managedConfig = useManagedConfig<ManagedConfig>();
|
||||
|
||||
@@ -67,7 +67,7 @@ const PostOptions = ({
|
||||
const canCopyPermalink = !isSystemPost && managedConfig?.copyAndPasteProtection !== 'true';
|
||||
const canCopyText = canCopyPermalink && post.message;
|
||||
|
||||
const shouldRenderFollow = !(location !== Screens.CHANNEL || !thread);
|
||||
const shouldRenderFollow = !(sourceScreen !== Screens.CHANNEL || !thread);
|
||||
|
||||
const snapPoints = [
|
||||
canAddReaction, canCopyPermalink, canCopyText,
|
||||
@@ -88,10 +88,10 @@ const PostOptions = ({
|
||||
{canMarkAsUnread && !isSystemPost &&
|
||||
<MarkAsUnreadOption postId={post.id}/>
|
||||
}
|
||||
{ Boolean(canCopyPermalink && post.message) &&
|
||||
{ canCopyPermalink &&
|
||||
<CopyPermalinkOption
|
||||
post={post}
|
||||
location={location}
|
||||
sourceScreen={sourceScreen}
|
||||
/>
|
||||
}
|
||||
{!isSystemPost &&
|
||||
@@ -103,7 +103,7 @@ const PostOptions = ({
|
||||
{Boolean(canCopyText && post.message) &&
|
||||
<CopyTextOption
|
||||
postMessage={post.message}
|
||||
location={location}
|
||||
sourceScreen={sourceScreen}
|
||||
/>}
|
||||
{canPin &&
|
||||
<PinChannelOption
|
||||
@@ -127,7 +127,7 @@ const PostOptions = ({
|
||||
};
|
||||
|
||||
// This fixes opening "post options modal" on top of "thread modal"
|
||||
const additionalSnapPoints = location === Screens.THREAD ? 3 : 2;
|
||||
const additionalSnapPoints = sourceScreen === Screens.THREAD ? 3 : 2;
|
||||
|
||||
return (
|
||||
<BottomSheet
|
||||
|
||||
@@ -15,6 +15,7 @@ import {useIsTablet} from '@hooks/device';
|
||||
import {dismissOverlay} from '@screens/navigation';
|
||||
import {makeStyleSheetFromTheme} from '@utils/theme';
|
||||
import {typography} from '@utils/typography';
|
||||
|
||||
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
|
||||
return {
|
||||
text: {
|
||||
@@ -29,11 +30,12 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
|
||||
|
||||
type SnackBarProps = {
|
||||
componentId: string;
|
||||
onPress?: () => void;
|
||||
onUndoPress?: () => void;
|
||||
barType: keyof typeof SNACK_BAR_TYPE;
|
||||
location: typeof Screens[keyof typeof Screens];
|
||||
sourceScreen: typeof Screens[keyof typeof Screens];
|
||||
}
|
||||
const SnackBar = ({barType, componentId, onPress, location}: SnackBarProps) => {
|
||||
|
||||
const SnackBar = ({barType, componentId, onUndoPress, sourceScreen}: SnackBarProps) => {
|
||||
const [showToast, setShowToast] = useState<boolean | undefined>();
|
||||
const intl = useIntl();
|
||||
const theme = useTheme();
|
||||
@@ -45,14 +47,14 @@ const SnackBar = ({barType, componentId, onPress, location}: SnackBarProps) => {
|
||||
|
||||
const onPressHandler = useCallback(() => {
|
||||
dismissOverlay(componentId);
|
||||
onPress?.();
|
||||
}, [onPress, componentId]);
|
||||
onUndoPress?.();
|
||||
}, [onUndoPress, componentId]);
|
||||
|
||||
const animatedStyle = useAnimatedStyle(() => {
|
||||
const DRAFT_INPUT_HEIGHT = 130;
|
||||
let delta: number;
|
||||
|
||||
switch (location) {
|
||||
switch (sourceScreen) {
|
||||
case Screens.MENTIONS:
|
||||
delta = BOTTOM_TAB_HEIGHT - 15;
|
||||
break;
|
||||
@@ -77,21 +79,21 @@ const SnackBar = ({barType, componentId, onPress, location}: SnackBarProps) => {
|
||||
let tabletStyle: Partial<ViewStyle>;
|
||||
|
||||
switch (true) {
|
||||
case location === Screens.THREAD :
|
||||
case sourceScreen === Screens.THREAD :
|
||||
tabletStyle = {
|
||||
marginLeft: 0,
|
||||
width: `${TABLET_PORTRAIT_RATIO}%`,
|
||||
marginBottom: 30,
|
||||
};
|
||||
break;
|
||||
case location === Screens.SAVED_POSTS :
|
||||
case sourceScreen === Screens.SAVED_POSTS :
|
||||
tabletStyle = {
|
||||
marginBottom: 20,
|
||||
marginLeft: TABLET_SIDEBAR_WIDTH,
|
||||
width: (TABLET_PORTRAIT_RATIO / 100) * diffWidth,
|
||||
};
|
||||
break;
|
||||
case [Screens.PERMALINK, Screens.MENTIONS].includes(location):
|
||||
case [Screens.PERMALINK, Screens.MENTIONS].includes(sourceScreen):
|
||||
tabletStyle = {
|
||||
marginBottom: 0,
|
||||
marginLeft: 0,
|
||||
@@ -144,17 +146,16 @@ const SnackBar = ({barType, componentId, onPress, location}: SnackBarProps) => {
|
||||
textStyle={styles.text}
|
||||
style={toastStyle}
|
||||
>
|
||||
{config.canUndo && onPress && (
|
||||
{config.canUndo && onUndoPress && (
|
||||
<TouchableOpacity onPress={onPressHandler}>
|
||||
<Text
|
||||
style={styles.undo}
|
||||
>
|
||||
<Text style={styles.undo}>
|
||||
{intl.formatMessage({
|
||||
id: 'snack.bar.undo',
|
||||
defaultMessage: 'Undo',
|
||||
})}
|
||||
</Text>
|
||||
</TouchableOpacity>)}
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</Toast>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import {showOverlay} from '@screens/navigation';
|
||||
type ShowSnackBarArgs = {
|
||||
barType: keyof typeof SNACK_BAR_TYPE;
|
||||
onPress?: () => void;
|
||||
location?: typeof Screens[keyof typeof Screens];
|
||||
sourceScreen?: typeof Screens[keyof typeof Screens];
|
||||
};
|
||||
export const showSnackBar = (passProps: ShowSnackBarArgs) => {
|
||||
const screen = Screens.SNACK_BAR;
|
||||
|
||||
Reference in New Issue
Block a user