Skip to content

Commit 00189fd

Browse files
authored
Use flex to automatically size optionContainer to its contents.
overlayStyle and cancelContainer adjusted accordingly to dynamically center content in a generic fashion.
1 parent a2d0b9b commit 00189fd

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

style.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,34 @@ const PADDING = 8;
88
const BORDER_RADIUS = 5;
99
const FONT_SIZE = 16;
1010
const HIGHLIGHT_COLOR = 'rgba(0,118,255,0.9)';
11-
const OPTION_CONTAINER_HEIGHT = 400;
1211

1312
export default StyleSheet.create({
1413

1514
overlayStyle: {
1615
width: width,
1716
height: height,
17+
padding:width*0.1,
18+
justifyContent: 'center',
1819
backgroundColor: 'rgba(0,0,0,0.7)'
1920
},
2021

2122
optionContainer: {
2223
borderRadius:BORDER_RADIUS,
23-
width:width*0.8,
24-
height:OPTION_CONTAINER_HEIGHT,
24+
flexShrink: 1,
25+
marginBottom: 8,
26+
padding: PADDING,
2527
backgroundColor:'rgba(255,255,255,0.8)',
26-
left:width*0.1,
27-
top:(height-OPTION_CONTAINER_HEIGHT)/2
2828
},
2929

3030
cancelContainer: {
31-
left:width*0.1,
32-
top:(height-OPTION_CONTAINER_HEIGHT)/2 + 10
31+
alignSelf: 'center'
3332
},
3433

3534
selectStyle: {
3635
flex: 1,
3736
borderColor: '#ccc',
3837
borderWidth: 1,
39-
padding: 8,
38+
padding: PADDING,
4039
borderRadius: BORDER_RADIUS
4140
},
4241

@@ -81,4 +80,4 @@ export default StyleSheet.create({
8180
textAlign: 'center',
8281
fontSize: FONT_SIZE
8382
}
84-
});
83+
});

0 commit comments

Comments
 (0)