@@ -5,45 +5,56 @@ import Constant from "./Constant";
5
5
import PropTypes from "prop-types" ;
6
6
7
7
export default class Square extends PureComponent {
8
- render ( ) {
9
- const { xSquares, ySquares, fullScreenWidth, allowHeightExcess, backgroundColor } = this . props ;
10
- let dimensions = Constant . getSectionSize ( xSquares , ySquares , fullScreenWidth ) ;
11
- const maxHeight = allowHeightExcess ? null : dimensions . height ;
8
+ render ( ) {
9
+ const { fullScreenWidth, allowHeightExcess, backgroundColor } = this . props ;
10
+ let xSquares = this . props . xSquares ;
11
+ let ySquares = this . props . ySquares ;
12
+ if ( xSquares >= 10 ) {
13
+ xSquares = 9 ;
14
+ }
15
+ if ( xSquares <= 0 ) {
16
+ xSquares = 1 ;
17
+ }
18
+ if ( ySquares <= 0 ) {
19
+ ySquares = 1 ;
20
+ }
21
+ let dimensions = Constant . getSectionSize ( xSquares , ySquares , fullScreenWidth ) ;
22
+ const maxHeight = allowHeightExcess ? null : dimensions . height ;
12
23
13
- return (
14
- < View
15
- style = { [
16
- styles . secondaryContainer ,
17
- {
18
- backgroundColor : backgroundColor ,
19
- margin : dimensions . margin ,
20
- minHeight : dimensions . height ,
21
- maxHeight : maxHeight ,
22
- width : dimensions . width ,
23
- } ,
24
- fullScreenWidth ? styles . fullScreenWidth : null ,
25
- { ...this . props . style } ,
26
- ] }
27
- >
28
- { this . props . children }
29
- </ View >
30
- ) ;
31
- }
24
+ return (
25
+ < View
26
+ style = { [
27
+ styles . secondaryContainer ,
28
+ {
29
+ backgroundColor : backgroundColor ,
30
+ margin : dimensions . margin ,
31
+ minHeight : dimensions . height ,
32
+ maxHeight : maxHeight ,
33
+ width : dimensions . width
34
+ } ,
35
+ fullScreenWidth ? styles . fullScreenWidth : null ,
36
+ { ...this . props . style }
37
+ ] }
38
+ >
39
+ { this . props . children }
40
+ </ View >
41
+ ) ;
42
+ }
32
43
}
33
44
Square . propTypes = {
34
- xSquares : PropTypes . number ,
35
- ySquares : PropTypes . number ,
36
- backgroundColor : PropTypes . string ,
37
- allowHeightExcess : PropTypes . bool ,
38
- fullScreenWidth : PropTypes . bool ,
39
- style : PropTypes . oneOf ( PropTypes . object , PropTypes . array , PropTypes . number ) ,
40
- children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] ) ,
45
+ xSquares : PropTypes . number ,
46
+ ySquares : PropTypes . number ,
47
+ backgroundColor : PropTypes . string ,
48
+ allowHeightExcess : PropTypes . bool ,
49
+ fullScreenWidth : PropTypes . bool ,
50
+ style : PropTypes . oneOf ( PropTypes . object , PropTypes . array , PropTypes . number ) ,
51
+ children : PropTypes . oneOfType ( [ PropTypes . arrayOf ( PropTypes . node ) , PropTypes . node ] )
41
52
} ;
42
53
Square . defaultProps = {
43
- xSquares : 1 ,
44
- ySquares : 1 ,
45
- backgroundColor : "#D3D3D3" ,
46
- allowHeightExcess : false ,
47
- fullScreenWidth : false ,
48
- style : null ,
54
+ xSquares : 1 ,
55
+ ySquares : 1 ,
56
+ backgroundColor : "#D3D3D3" ,
57
+ allowHeightExcess : false ,
58
+ fullScreenWidth : false ,
59
+ style : null
49
60
} ;
0 commit comments