|
1 | 1 | /**
|
| 2 | + * Copyright (c) 2013-present, Facebook, Inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * This source code is licensed under the BSD-style license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 7 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 8 | + * |
2 | 9 | * The examples provided by Facebook are for non-commercial testing and
|
3 | 10 | * evaluation purposes only.
|
4 | 11 | *
|
@@ -30,7 +37,13 @@ var styles = StyleSheet.create({
|
30 | 37 | backgroundColor: '#527FE4',
|
31 | 38 | borderColor: '#000033',
|
32 | 39 | borderWidth: 1,
|
33 |
| - } |
| 40 | + }, |
| 41 | + zIndex: { |
| 42 | + justifyContent: 'space-around', |
| 43 | + width: 100, |
| 44 | + height: 50, |
| 45 | + marginTop: -10, |
| 46 | + }, |
34 | 47 | });
|
35 | 48 |
|
36 | 49 | var ViewBorderStyleExample = React.createClass({
|
@@ -74,6 +87,53 @@ var ViewBorderStyleExample = React.createClass({
|
74 | 87 | }
|
75 | 88 | });
|
76 | 89 |
|
| 90 | +var ZIndexExample = React.createClass({ |
| 91 | + getInitialState() { |
| 92 | + return { |
| 93 | + flipped: false |
| 94 | + }; |
| 95 | + }, |
| 96 | + |
| 97 | + render() { |
| 98 | + const indices = this.state.flipped ? [-1, 0, 1, 2] : [2, 1, 0, -1]; |
| 99 | + return ( |
| 100 | + <TouchableWithoutFeedback onPress={this._handlePress}> |
| 101 | + <View> |
| 102 | + <Text style={{paddingBottom: 10}}>Tap to flip sorting order</Text> |
| 103 | + <View style={[ |
| 104 | + styles.zIndex, |
| 105 | + {marginTop: 0, backgroundColor: '#E57373', zIndex: indices[0]} |
| 106 | + ]}> |
| 107 | + <Text>ZIndex {indices[0]}</Text> |
| 108 | + </View> |
| 109 | + <View style={[ |
| 110 | + styles.zIndex, |
| 111 | + {marginLeft: 50, backgroundColor: '#FFF176', zIndex: indices[1]} |
| 112 | + ]}> |
| 113 | + <Text>ZIndex {indices[1]}</Text> |
| 114 | + </View> |
| 115 | + <View style={[ |
| 116 | + styles.zIndex, |
| 117 | + {marginLeft: 100, backgroundColor: '#81C784', zIndex: indices[2]} |
| 118 | + ]}> |
| 119 | + <Text>ZIndex {indices[2]}</Text> |
| 120 | + </View> |
| 121 | + <View style={[ |
| 122 | + styles.zIndex, |
| 123 | + {marginLeft: 150, backgroundColor: '#64B5F6', zIndex: indices[3]} |
| 124 | + ]}> |
| 125 | + <Text>ZIndex {indices[3]}</Text> |
| 126 | + </View> |
| 127 | + </View> |
| 128 | + </TouchableWithoutFeedback> |
| 129 | + ); |
| 130 | + }, |
| 131 | + |
| 132 | + _handlePress() { |
| 133 | + this.setState({flipped: !this.state.flipped}); |
| 134 | + } |
| 135 | +}); |
| 136 | + |
77 | 137 | exports.title = '<View>';
|
78 | 138 | exports.description = 'Basic building block of all UI, examples that ' +
|
79 | 139 | 'demonstrate some of the many styles available.';
|
@@ -188,5 +248,10 @@ exports.examples = [
|
188 | 248 | </View>
|
189 | 249 | );
|
190 | 250 | },
|
| 251 | + }, { |
| 252 | + title: 'ZIndex', |
| 253 | + render: function() { |
| 254 | + return <ZIndexExample />; |
| 255 | + }, |
191 | 256 | },
|
192 | 257 | ];
|
0 commit comments