concept ProfileCard in category react native

This is an excerpt from Manning's book React Native in Action.
We’ll continue talking about some of the differences between platforms and look more deeply at flexbox. Because flexbox is a fundamental concept, it’s important to properly understand it so you can create layouts and UIs in React Native. You’ll probably use flexbox in every application you create. You’ll use some of your new styling techniques to continue building new features into the
ProfileCardexample from the previous chapter.
Figure 5.4 The
ProfileCardon iOS and Android after drop shadows have been added to the card container and the circular image container. The drop shadows on iOS are created using the iOS-specific shadow properties:shadowColor,shadowOffset, andshadowOpacity. On Android, theelevationproperty is used to try to create depth. It produces only a minor shadow effect, far inferior to the shadows produced on iOS.![]()
The code in this chapter begins with listing 4.20: the completed
ProfileCardexample from chapter 4. Listing 5.1 only shows the changes needed to apply the drop shadows to the component. You don’t need to add a lot of code to get the drop shadows on iOS. Look at the listing on an Android device, and see how theelevationsetting causes the faintest of shadows.Listing 5.1 Adding drop shadows to the
ProfileCardimport React, { Component } from 'react'; import { Image, Platform, StyleSheet, Text, View} from 'react-native'; #1 ... cardContainer: { ... height: 400, ...Platform.select({ #2 ios: { shadowColor: 'black', shadowOffset: { height: 10 }, shadowOpacity: 1 }, android: { elevation: 15 } }) }, cardImageContainer: { ... paddingTop: 15, ...Platform.select({ #3 ios: { shadowColor: 'black', shadowOffset: { height: 10, }, shadowOpacity: 1 }, android: { borderWidth: 3, borderColor: 'black', elevation: 15 } }) }, ... #1 Imports the Platform utility component to programmatically select styles based on the platform #2 Adds a drop shadow to the card container based on the platform #3 Adds a drop shadow to the circular image container !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":1,\"ch\":16},{\"line\":1,\"ch\":24}],[{\"line\":6,\"ch\":5},{\"line\":6,\"ch\":13}],[{\"line\":22,\"ch\":5},{\"line\":22,\"ch\":13}],[{\"line\":39,\"ch\":16},{\"line\":39,\"ch\":24}],[{\"line\":6,\"ch\":2},{\"line\":6,\"ch\":22}],[{\"line\":22,\"ch\":2},{\"line\":22,\"ch\":22}],[{\"line\":7,\"ch\":4},{\"line\":7,\"ch\":10}],[{\"line\":23,\"ch\":4},{\"line\":23,\"ch\":10}],[{\"line\":8,\"ch\":6},{\"line\":8,\"ch\":27}],[{\"line\":24,\"ch\":6},{\"line\":24,\"ch\":27}],[{\"line\":9,\"ch\":6},{\"line\":9,\"ch\":21}],[{\"line\":25,\"ch\":6},{\"line\":25,\"ch\":21}],[{\"line\":10,\"ch\":8},{\"line\":10,\"ch\":18}],[{\"line\":26,\"ch\":8},{\"line\":26,\"ch\":18}],[{\"line\":11,\"ch\":6},{\"line\":11,\"ch\":8}],[{\"line\":13,\"ch\":4},{\"line\":13,\"ch\":6}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":2}],[{\"line\":27,\"ch\":6},{\"line\":27,\"ch\":8}],[{\"line\":29,\"ch\":4},{\"line\":29,\"ch\":6}],[{\"line\":36,\"ch\":0},{\"line\":36,\"ch\":2}],[{\"line\":12,\"ch\":6},{\"line\":12,\"ch\":22}],[{\"line\":28,\"ch\":6},{\"line\":28,\"ch\":22}],[{\"line\":11,\"ch\":6},{\"line\":11,\"ch\":8}],[{\"line\":13,\"ch\":4},{\"line\":13,\"ch\":6}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":2}],[{\"line\":27,\"ch\":6},{\"line\":27,\"ch\":8}],[{\"line\":29,\"ch\":4},{\"line\":29,\"ch\":6}],[{\"line\":36,\"ch\":0},{\"line\":36,\"ch\":2}],[{\"line\":14,\"ch\":4},{\"line\":14,\"ch\":14}],[{\"line\":30,\"ch\":4},{\"line\":30,\"ch\":14}],[{\"line\":15,\"ch\":6},{\"line\":15,\"ch\":19}],[{\"line\":33,\"ch\":6},{\"line\":33,\"ch\":19}],[{\"line\":0,\"ch\":26},{\"line\":0,\"ch\":27}],[{\"line\":1,\"ch\":48},{\"line\":1,\"ch\":49}],[{\"line\":11,\"ch\":6},{\"line\":11,\"ch\":7}],[{\"line\":13,\"ch\":4},{\"line\":13,\"ch\":5}],[{\"line\":16,\"ch\":4},{\"line\":16,\"ch\":5}],[{\"line\":17,\"ch\":2},{\"line\":17,\"ch\":3}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":1}],[{\"line\":27,\"ch\":6},{\"line\":27,\"ch\":7}],[{\"line\":29,\"ch\":4},{\"line\":29,\"ch\":5}],[{\"line\":34,\"ch\":4},{\"line\":34,\"ch\":5}],[{\"line\":35,\"ch\":2},{\"line\":35,\"ch\":3}],[{\"line\":36,\"ch\":0},{\"line\":36,\"ch\":1}],[{\"line\":17,\"ch\":2},{\"line\":17,\"ch\":4}],[{\"line\":35,\"ch\":2},{\"line\":35,\"ch\":4}],[{\"line\":6,\"ch\":2},{\"line\":6,\"ch\":22}],[{\"line\":22,\"ch\":2},{\"line\":22,\"ch\":22}],[{\"line\":7,\"ch\":4},{\"line\":7,\"ch\":10}],[{\"line\":23,\"ch\":4},{\"line\":23,\"ch\":10}],[{\"line\":8,\"ch\":6},{\"line\":8,\"ch\":27}],[{\"line\":24,\"ch\":6},{\"line\":24,\"ch\":27}],[{\"line\":9,\"ch\":6},{\"line\":9,\"ch\":21}],[{\"line\":25,\"ch\":6},{\"line\":25,\"ch\":21}],[{\"line\":26,\"ch\":8},{\"line\":26,\"ch\":19}],[{\"line\":11,\"ch\":6},{\"line\":11,\"ch\":8}],[{\"line\":13,\"ch\":4},{\"line\":13,\"ch\":6}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":2}],[{\"line\":27,\"ch\":6},{\"line\":27,\"ch\":8}],[{\"line\":29,\"ch\":4},{\"line\":29,\"ch\":6}],[{\"line\":36,\"ch\":0},{\"line\":36,\"ch\":2}],[{\"line\":12,\"ch\":6},{\"line\":12,\"ch\":22}],[{\"line\":28,\"ch\":6},{\"line\":28,\"ch\":22}],[{\"line\":11,\"ch\":6},{\"line\":11,\"ch\":8}],[{\"line\":13,\"ch\":4},{\"line\":13,\"ch\":6}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":2}],[{\"line\":27,\"ch\":6},{\"line\":27,\"ch\":8}],[{\"line\":29,\"ch\":4},{\"line\":29,\"ch\":6}],[{\"line\":36,\"ch\":0},{\"line\":36,\"ch\":2}],[{\"line\":14,\"ch\":4},{\"line\":14,\"ch\":14}],[{\"line\":30,\"ch\":4},{\"line\":30,\"ch\":14}],[{\"line\":31,\"ch\":6},{\"line\":31,\"ch\":21}],[{\"line\":32,\"ch\":6},{\"line\":32,\"ch\":27}],[{\"line\":15,\"ch\":6},{\"line\":15,\"ch\":19}],[{\"line\":33,\"ch\":6},{\"line\":33,\"ch\":19}],[{\"line\":0,\"ch\":26},{\"line\":0,\"ch\":27}],[{\"line\":1,\"ch\":48},{\"line\":1,\"ch\":49}],[{\"line\":11,\"ch\":6},{\"line\":11,\"ch\":7}],[{\"line\":13,\"ch\":4},{\"line\":13,\"ch\":5}],[{\"line\":16,\"ch\":4},{\"line\":16,\"ch\":5}],[{\"line\":17,\"ch\":2},{\"line\":17,\"ch\":3}],[{\"line\":18,\"ch\":0},{\"line\":18,\"ch\":1}],[{\"line\":27,\"ch\":6},{\"line\":27,\"ch\":7}],[{\"line\":29,\"ch\":4},{\"line\":29,\"ch\":5}],[{\"line\":34,\"ch\":4},{\"line\":34,\"ch\":5}],[{\"line\":35,\"ch\":2},{\"line\":35,\"ch\":3}],[{\"line\":36,\"ch\":0},{\"line\":36,\"ch\":1}],[{\"line\":17,\"ch\":2},{\"line\":17,\"ch\":4}],[{\"line\":35,\"ch\":2},{\"line\":35,\"ch\":4}]]"} !@%STYLE%@!