facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.32k stars 24.36k forks source link

Flatlist inverted props not working in huawei p9 #16213

Closed rhenmark closed 7 years ago

rhenmark commented 7 years ago

Flatlist render items cannot be seen when using inverted props only in huawei p9 phones. Any suggestions/help is very much appreciated.

enahum commented 7 years ago

I had to extend the FlatList and change the style to this

vertical: Platform.select({
        android: {
            scaleY: -1
        },
        ios: {
            transform: [{scaleY: -1}]
        }
    }),

is the only way is working on Huawei devices, the whole thing seems to be that Huawei devices do not support the transform: [{scaleY: -1}] style for some reason.

pull-bot commented 7 years ago

@facebook-github-bot no-template

facebook-github-bot commented 7 years ago

Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See "What to Expect from Maintainers" to learn more.

almostintuitive commented 7 years ago

This is actually a useful issue with a great suggestion!

We're having the same issue with a Huawei tablet, but

android: {
            scaleY: -1
        },

Is actually also inverting the FlatList's row's content, nut just FlatList itself.

Also we're getting a deprecation warning.

Does anyone have any info regarding why this could be happening with some Huawei devices?

lekenny commented 7 years ago

same problem

mindaugas-zaluba commented 7 years ago

Same on Honor 8 (Huawei sub-brand)

rhenmark commented 7 years ago

When setting transform style in the View the Text inside it makes blurry.

yury commented 7 years ago

{perspective: 1} fixes transformation on Huawei

const FLIP_Y_TRANSFORM = [{scaleY: -1}];
const FLIP_X_TRANSFORM = [{scaleX: -1}];

if (Platform.OS === 'android') {
  FLIP_Y_TRANSFORM.push({perspective: 1});
  FLIP_X_TRANSFORM.push({perspective: 1});
}
enahum commented 7 years ago

@yury can you confirm that fix actually works?

yury commented 7 years ago

Yep, we shipped that fix in production. RN v0.43.4

henninghall commented 7 years ago

@yury Looks good, where did you put that code?

yury commented 7 years ago

@henninghall

it is in our components/theme.js

const theme = {
   /* ... */
  flipX: { transform: FLIP_Y_TRANSFORM },
  flipY: { transform: FLIP_Y_TRANSFORM }
  /* ... */
}

export default theme;

Basic usage


import theme from '../theme';

class XComponent extends Component {
  render() {
     return <View style={ styles.wrapper }>/*...*/</View>
  }
}

const styles = StyleSheet.create({
  wrapper: {
    marginTop: 12,
    ...theme.flipY,
  },
});
henninghall commented 7 years ago

@yury's solution also inverts the FlatList's row's content, not just FlatList itself (discussed earlier)

yury commented 7 years ago

@henninghall yep, if you want just flip listview, you should apply this transform on list and on row. That’s the trick.

sondremare commented 7 years ago

@facebook-github-bot reopen