From 9020cb35e039f14d7170bdb78fd4fdf64cf37133 Mon Sep 17 00:00:00 2001 From: Thomas Coldwell <31568400+thomas-coldwell@users.noreply.github.com> Date: Thu, 10 Nov 2022 18:41:37 +0000 Subject: [PATCH] feat: Add fast image to attachments view Signed-off-by: Thomas Coldwell <31568400+thomas-coldwell@users.noreply.github.com> --- src/components/ImageView/index.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/ImageView/index.js b/src/components/ImageView/index.js index 84cce4f2909..fd91b568351 100644 --- a/src/components/ImageView/index.js +++ b/src/components/ImageView/index.js @@ -3,11 +3,16 @@ import PropTypes from 'prop-types'; import { View, Image, Pressable, } from 'react-native'; +import FastImage from '@pieter-pot/react-native-fast-image'; +import {withOnyx} from 'react-native-onyx'; +import lodashGet from 'lodash/get'; import styles from '../../styles/styles'; import * as StyleUtils from '../../styles/StyleUtils'; import canUseTouchScreen from '../../libs/canUseTouchscreen'; import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; import FullscreenLoadingIndicator from '../FullscreenLoadingIndicator'; +import compose from '../../libs/compose'; +import ONYXKEYS from '../../ONYXKEYS'; const propTypes = { /** URL to full-sized image */ @@ -205,8 +210,13 @@ class ImageView extends PureComponent { style={[styles.imageViewContainer, styles.overflowHidden]} onLayout={this.onContainerLayoutChanged} > - 1 ? 'center' : 'contain'} + resizeMode={this.state.zoomScale > 1 ? FastImage.resizeMode.center : FastImage.resizeMode.contain} onLoadStart={this.imageLoadingStart} onLoadEnd={this.imageLoadingEnd} /> @@ -248,13 +258,13 @@ class ImageView extends PureComponent { onPressIn={this.onContainerPressIn} onPress={this.onContainerPress} > - @@ -271,4 +281,6 @@ class ImageView extends PureComponent { } ImageView.propTypes = propTypes; -export default withWindowDimensions(ImageView); +export default compose(withWindowDimensions, withOnyx({ + session: {key: ONYXKEYS.SESSION}, +}))(ImageView);