Giphy / giphy-react-native-sdk

GIPHY React Native SDK
https://developers.giphy.com
Apache License 2.0
68 stars 25 forks source link

How to render GiphyMediaView without aspectRatio, knowing just id #65

Closed mikhail-talkshoplive closed 2 years ago

mikhail-talkshoplive commented 2 years ago
import React from 'react';
import { GiphyMediaView, GiphySDK } from '@giphy/react-native-sdk';
GiphySDK.configure({ apiKey: '***********' });
const CommentItem = ({ comment = {} }) => {
  return (
    <GiphyMediaView
      style={{ height: 50 }}
      renditionType={'FixedHeightSmall'}
      media={{
        id: 't64oxIpnQwF8ilGfZQ',
      }}
      autoPlay={true}
    />
  );
};

export default CommentItem;

Simulator Screen Shot - iPhone 13 - 2022-06-17 at 00 10

pshoniuk commented 2 years ago

Hi @mikhail-talkshoplive , thanks for reaching out.

The GIPHY RN SDK has no logic for scaling images when the aspect ratio is not specified. We have prepared a release candidate that should fix this problem. You can try this version 1.8.0-rc.0 for testing. It would be great to get your feedback before we release v1.8.0.

mikhail-talkshoplive commented 2 years ago

Hi @mikhail-talkshoplive , thanks for reaching out.

The GIPHY RN SDK has no logic for scaling images when the aspect ratio is not specified. We have prepared a release candidate that should fix this problem. You can try this version 1.8.0-rc.0 for testing. It would be great to get your feedback before we release v1.8.0.

unfortunately same result, should I pass any specific props? (test id t64oxIpnQwF8ilGfZQ)

pshoniuk commented 2 years ago

In 1.8.0-rc.0 we scale the content to fill the view bounds and maintain the aspect ratio. It works similarly to "resizeMode": "cover". We will add a resizeMode property similar to what we have for the Image component in React Native. I think we'll do it next week. Currently, you can work with the "cover" mode, for example:

const CommentItem = ({ comment = {} }) => {
  return (
    <GiphyMediaView
      style={{ height: 200, width: 200 }}
      renditionType={GiphyRendition.FixedHeightSmall}
      media={{
        id: 't64oxIpnQwF8ilGfZQ',
      }}
      autoPlay={true}
    />
  )
}
mikhail-talkshoplive commented 2 years ago

@pshoniuk your example works perfectly, thank you. resizeMode - it will be fantastic

mikhail-talkshoplive commented 2 years ago

Дзякуй за дапамогу братка @pshoniuk , Слава Украіне і Жыве Беларусь

pshoniuk commented 2 years ago

GIPHY RN SDK v1.8.0 has been released. This version supports the resizeMode property for the GiphyMediaView component to determine how to resize an image when the frame does not match the size of the raw image.