react-native-shadow-view icon indicating copy to clipboard operation
react-native-shadow-view copied to clipboard

ShadowView styles problem

Open TommysG opened this issue 3 years ago • 6 comments
trafficstars

There is problem when i try to pass some styles in to the ShadowView. These styles doesn't apply:

<ShadowView style={styles.container}>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
</ShadowView>


const styles = StyleSheet.create({
  container: {
          shadowColor: '#000',
          shadowOffset: {
            width: 1,
            height: 2,
          },
          shadowOpacity: 0.25,
          shadowRadius: 1.22,
          backgroundColor: '#fff',
          flexDirection: 'row',
          alignItems: 'center',
          width: 250,
          height: 250,
  }
});

In the above example the Texts (children) will not be next to each other as a row, but it will be aligned as a stack.

TommysG avatar May 03 '22 14:05 TommysG

Thanks for the report. I'll take a look, once I have time. Meanwhile, you can wrap text with another view as workaround.

dimaportenko avatar May 03 '22 14:05 dimaportenko

Yes i tried wrapping it inside another View with the styles i want but when i reload the app or navigate to another screen and back it's realigning all the children as a stack.

TommysG avatar May 03 '22 15:05 TommysG

Can you share what you tried? I'd like to check this case as well.

dimaportenko avatar May 03 '22 15:05 dimaportenko

I mean to do like

<ShadowView style={styles.container}>
    <View style={styles.inner}>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
    </View>            
</ShadowView>


const styles = StyleSheet.create({
  container: {
          shadowColor: '#000',
          shadowOffset: {
            width: 1,
            height: 2,
          },
          shadowOpacity: 0.25,
          shadowRadius: 1.22,
          backgroundColor: '#fff',
          
  },
  inner: {
          flexDirection: 'row',
          alignItems: 'center',
          width: 250,
          height: 250,
  }
});

dimaportenko avatar May 03 '22 15:05 dimaportenko

I mean to do like

<ShadowView style={styles.container}>
    <View style={styles.inner}>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
            <Text>Hello this is text</Text>
    </View>            
</ShadowView>


const styles = StyleSheet.create({
  container: {
          shadowColor: '#000',
          shadowOffset: {
            width: 1,
            height: 2,
          },
          shadowOpacity: 0.25,
          shadowRadius: 1.22,
          backgroundColor: '#fff',
          
  },
  inner: {
          flexDirection: 'row',
          alignItems: 'center',
          width: 250,
          height: 250,
  }
});

Yes this is exactly how i implemented it. On hot reload it works. But if i reload/restart the app or navigate back and forth it is buggy again (all the children aligned as a stack).

TommysG avatar May 03 '22 15:05 TommysG

I think I found workaround. Inner view style should have backgroundColor. In this case, everything works fine for me. Unfortunately, I haven't had time for a proper fix for it.

dimaportenko avatar May 20 '22 16:05 dimaportenko