Files
mattermost-mobile/app/components/progressive_image/thumbnail.tsx
Elias Nahum 5de54471b7 [Gekidou] Gallery (#6008)
* Gallery screen (ground work)

* Open the gallery from posts

* Open the gallery from post draft

* feedback review

* Feedback review 2

* do not remove dm channel names and localization fix

* update to the latest network-client

* do not override file width, height and imageThumbail if received file does not have it set

* bring back ScrollView wrapper for message component

* Remove Text wrapper for markdown paragraph

* Fix YouTube play icon placeholder

* Make video file play button container round

* Add gif image placeholder

* Save images & videos to camera roll

* Feedback review 3

* load video thumbnail when post is in viewport

* simplify prefix
2022-03-01 13:55:44 -03:00

47 lines
1.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {StyleProp, StyleSheet} from 'react-native';
import FastImage, {ImageStyle, Source} from 'react-native-fast-image';
import Animated, {SharedValue} from 'react-native-reanimated';
// @ts-expect-error FastImage does work with Animated.createAnimatedComponent
const AnimatedFastImage = Animated.createAnimatedComponent(FastImage);
type ThumbnailProps = {
onError: () => void;
opacity?: SharedValue<number>;
source?: Source;
style: StyleProp<ImageStyle>;
}
const Thumbnail = ({onError, opacity, style, source}: ThumbnailProps) => {
if (source?.uri) {
return (
<AnimatedFastImage
onError={onError}
resizeMode='cover'
source={source}
style={style}
testID='progressive_image.miniPreview'
/>
);
}
const tintColor = StyleSheet.flatten(style).tintColor;
return (
<AnimatedFastImage
resizeMode='contain'
onError={onError}
source={require('@assets/images/thumb.png')}
style={[style, {opacity: opacity?.value}]}
testID='progressive_image.thumbnail'
tintColor={tintColor}
/>
);
};
export default Thumbnail;