mattermost-mobile/app/components/progressive_image/thumbnail.tsx
Elias Nahum edef4ec4a3
Update libraries and dependencies (#7678)
* update js dependencies

* update react-native libraries

* update watermelonDB

* update RN to 0.72.7

* update fastlane

* fix remove_markdown/at_mention import

* update mattermost libraries

* update fastlane deps

* remove haptic-feedback patch

* update okhttp to 4.12.0 and patch netinfo to accurately identify VPN connections

* create ImaegStyles intersection type
2023-11-25 07:46:13 +08:00

45 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 {Image, type ColorValue, type StyleProp, type ImageStyle} from 'react-native';
import FastImage, {type ImageStyle as FastImageStyle, type Source} from 'react-native-fast-image';
import Animated, {type SharedValue} from 'react-native-reanimated';
// @ts-expect-error FastImage does work with Animated.createAnimatedComponent
const AnimatedFastImage = Animated.createAnimatedComponent(FastImage);
const AnimatedImage = Animated.createAnimatedComponent(Image);
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 as StyleProp<FastImageStyle>)}
testID='progressive_image.miniPreview'
/>
);
}
return (
<AnimatedImage
resizeMode='contain'
onError={onError}
source={require('@assets/images/thumb.png')}
style={[style, {opacity: opacity?.value, tintColor}]}
testID='progressive_image.thumbnail'
/>
);
};
export default Thumbnail;