Skip to content

Commit 21a6418

Browse files
rustyconoversahrens
authored andcommitted
[TicTacToe] Fix missing image styles for TicTacToe example
Summary: Without a width or height set for the X or O image they don't appear, fix this problem by adding styles with width and height specified. Closes #1122 Github Author: Rusty Conover <[email protected]> Test Plan: Imported from GitHub, without a `Test Plan:` line.
1 parent 1295c00 commit 21a6418

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Examples/TicTacToe/TicTacToeApp.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ var Cell = React.createClass({
118118
}
119119
},
120120

121+
imageStyle() {
122+
switch (this.props.player) {
123+
case 1:
124+
return styles.imageX;
125+
case 2:
126+
return styles.imageO;
127+
default:
128+
return {};
129+
}
130+
},
131+
121132
textContents() {
122133
switch (this.props.player) {
123134
case 1:
@@ -147,7 +158,7 @@ var Cell = React.createClass({
147158
underlayColor="transparent"
148159
activeOpacity={0.5}>
149160
<View style={[styles.cell, this.cellStyle()]}>
150-
<Image source={{uri: this.imageContents()}} />
161+
<Image source={{uri: this.imageContents()}} style={this.imageStyle()}/>
151162
</View>
152163
</TouchableHighlight>
153164
);
@@ -293,6 +304,17 @@ var styles = StyleSheet.create({
293304
color: '#b9dc2f',
294305
},
295306

307+
// CELL IMAGE
308+
309+
imageX: {
310+
width: 34,
311+
height: 42,
312+
},
313+
imageO: {
314+
width: 45,
315+
height: 41,
316+
},
317+
296318
// GAME OVER
297319

298320
overlay: {

0 commit comments

Comments
 (0)