mattermost-mobile/app/components/progressive_image/thumbnail.tsx
Elias Nahum 784b05fe97
Upgrade Dependencies (#7299)
* upgrade reanimated

* update devDependencies

* upgrade react-intl

* update react-native and some dependencies

* update react-native-permissions

* update RN

* use Share sheet for Report a problem

* update Sentry

* remove step to downloadWebRTC

* update detox deps

* feedback review
2023-04-21 12:16:54 -04:00

46 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 FastImage, {type ImageStyle, type Source} from 'react-native-fast-image';
import Animated, {type SharedValue} from 'react-native-reanimated';
import type {ColorValue, StyleProp} from 'react-native';
// @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>;
tintColor?: ColorValue;
}
const Thumbnail = ({onError, opacity, style, source, tintColor}: ThumbnailProps) => {
if (source?.uri) {
return (
<AnimatedFastImage
onError={onError}
resizeMode='cover'
source={source}
style={style}
testID='progressive_image.miniPreview'
/>
);
}
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;