Skip to content

Commit d263347

Browse files
committed
Changes in images and src
1 parent 5492070 commit d263347

File tree

6 files changed

+139
-110
lines changed

6 files changed

+139
-110
lines changed

Component/Constant.js

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import { Dimensions } from "react-native";
1+
import { Dimensions } from 'react-native'
22

33
// constants
4-
const DEVICE_WIDTH = Dimensions.get("window").width;
5-
const DEVICE_HEIGHT = Dimensions.get("window").height;
4+
const DEVICE_WIDTH = Dimensions.get('window').width
5+
const DEVICE_HEIGHT = Dimensions.get('window').height
66

7-
const SQUARE_WIDTH_PERCENT = 8.1333 / 100;
8-
const GUTTER_WIDTH_PERCENT = 2.6667 / 100;
9-
const CONTAINER_WIDTH_PERCENTAGE = 100 / 100;
7+
const SQUARE_WIDTH_PERCENT = 8.1333 / 100
8+
const GUTTER_WIDTH_PERCENT = 2.6667 / 100
9+
const CONTAINER_WIDTH_PERCENTAGE = 100 / 100
1010

11-
const SQUARE_WIDTH = DEVICE_WIDTH * SQUARE_WIDTH_PERCENT;
12-
const GUTTER_WIDTH = DEVICE_WIDTH * GUTTER_WIDTH_PERCENT;
11+
const SQUARE_WIDTH = DEVICE_WIDTH * SQUARE_WIDTH_PERCENT
12+
const GUTTER_WIDTH = DEVICE_WIDTH * GUTTER_WIDTH_PERCENT
1313

14-
const CONTAINER_WIDTH = DEVICE_WIDTH * CONTAINER_WIDTH_PERCENTAGE;
14+
const CONTAINER_WIDTH = DEVICE_WIDTH * CONTAINER_WIDTH_PERCENTAGE
1515

16-
const CONTAINER_HEIGHT = DEVICE_HEIGHT;
16+
const CONTAINER_HEIGHT = DEVICE_HEIGHT
1717

1818
// functions
1919
export function getSectionSize(xSquares = 1, ySquares = 1, fullScreenWidth = false) {
20-
let width;
21-
if (fullScreenWidth === true) {
22-
width = DEVICE_WIDTH;
23-
} else {
24-
width = xSquares < 0 ? 0 : xSquares * SQUARE_WIDTH + (xSquares - 1) * GUTTER_WIDTH;
25-
}
26-
let height = null || ySquares < 0 ? 0 : ySquares * SQUARE_WIDTH + (ySquares - 1) * GUTTER_WIDTH;
27-
28-
return {
29-
width: width,
30-
height: height,
31-
margin: GUTTER_WIDTH,
32-
};
20+
let width
21+
if (fullScreenWidth === true) {
22+
width = DEVICE_WIDTH
23+
} else {
24+
width = xSquares < 0 ? 0 : xSquares * SQUARE_WIDTH + (xSquares - 1) * GUTTER_WIDTH
25+
}
26+
let height = null || ySquares < 0 ? 0 : ySquares * SQUARE_WIDTH + (ySquares - 1) * GUTTER_WIDTH
27+
28+
return {
29+
width: width,
30+
height: height,
31+
margin: GUTTER_WIDTH,
32+
}
3333
}
3434

3535
export default {
36-
DEVICE_WIDTH,
37-
DEVICE_HEIGHT,
38-
SQUARE_WIDTH_PERCENT,
39-
GUTTER_WIDTH_PERCENT,
40-
CONTAINER_WIDTH_PERCENTAGE,
41-
SQUARE_WIDTH,
42-
GUTTER_WIDTH,
43-
CONTAINER_WIDTH,
44-
CONTAINER_HEIGHT,
45-
getSectionSize,
46-
};
36+
DEVICE_WIDTH,
37+
DEVICE_HEIGHT,
38+
SQUARE_WIDTH_PERCENT,
39+
GUTTER_WIDTH_PERCENT,
40+
CONTAINER_WIDTH_PERCENTAGE,
41+
SQUARE_WIDTH,
42+
GUTTER_WIDTH,
43+
CONTAINER_WIDTH,
44+
CONTAINER_HEIGHT,
45+
getSectionSize,
46+
}

Component/Container.js

+62-55
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,66 @@
1-
import React, { PureComponent } from "react";
2-
import { SafeAreaView, ScrollView, View, Text } from "react-native";
3-
import { styles } from "./SectionStyle";
4-
import Constant from "./Constant";
5-
import PropTypes from "prop-types";
1+
import React, { PureComponent } from 'react'
2+
import { SafeAreaView, ScrollView, View } from 'react-native'
3+
import { styles } from './SectionStyle'
4+
import Constant from './Constant'
5+
import PropTypes from 'prop-types'
66

7-
export default class Container extends PureComponent {
8-
render() {
9-
const isNested = this.props.isNested;
10-
const isFullHeight = this.props.isFullHeight;
11-
const zero = 0;
12-
let height;
13-
if (isFullHeight) {
14-
height = "100%";
15-
} else {
16-
height = isNested ? "100%" : this.props.height;
17-
}
18-
return (
19-
<SafeAreaView
20-
style={{
21-
height: height,
22-
...this.props.style,
23-
backgroundColor: "#fff",
24-
}}
25-
>
26-
{isNested || isFullHeight ? (
27-
<View
28-
style={[
29-
styles.scrollContent,
30-
{ ...this.props.style, marginHorizontal: isNested ? zero : Constant.GUTTER_WIDTH },
31-
]}
32-
>
33-
{this.props.children}
34-
</View>
35-
) : (
36-
<ScrollView
37-
ref={scrollView => {
38-
this.scrollView = scrollView;
39-
}}
40-
contentContainerStyle={[styles.scrollContent, { ...this.props.style }]}
41-
removeClippedSubviews={false}
42-
alwaysBounceVertical={false} // for iOS
43-
>
44-
{this.props.children}
45-
</ScrollView>
46-
)}
47-
</SafeAreaView>
48-
);
49-
}
7+
class Container extends PureComponent {
8+
render() {
9+
const { isNested, backgroundColor } = this.props
10+
const zero = 0
11+
let height = isNested ? '100%' : this.props.height
12+
const color = '#fff'
13+
return (
14+
<SafeAreaView
15+
style={{
16+
height: height,
17+
...this.props.style,
18+
backgroundColor: color,
19+
}}
20+
>
21+
{isNested ? (
22+
<View
23+
style={[
24+
styles.scrollContent,
25+
{
26+
backgroundColor: backgroundColor,
27+
...this.props.style,
28+
marginHorizontal: isNested ? zero : Constant.GUTTER_WIDTH,
29+
},
30+
]}
31+
>
32+
{this.props.children}
33+
</View>
34+
) : (
35+
<ScrollView
36+
ref={(scrollView) => {
37+
this.scrollView = scrollView
38+
}}
39+
contentContainerStyle={[styles.scrollContent, { ...this.props.style }]}
40+
removeClippedSubviews={false}
41+
alwaysBounceVertical={false} // for iOS
42+
>
43+
{this.props.children}
44+
</ScrollView>
45+
)}
46+
</SafeAreaView>
47+
)
48+
}
5049
}
5150

52-
Container.prototypes = {
53-
height: PropTypes.number,
54-
width: PropTypes.number,
55-
};
51+
export default Container
52+
53+
Container.propTypes = {
54+
height: PropTypes.number,
55+
isNested: PropTypes.bool,
56+
backgroundColor: PropTypes.string,
57+
style: PropTypes.oneOf(PropTypes.object, PropTypes.array, PropTypes.number),
58+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
59+
}
5660
Container.defaultProps = {
57-
height: Constant.CONTAINER_HEIGHT,
58-
width: Constant.CONTAINER_WIDTH,
59-
};
61+
height: Constant.CONTAINER_HEIGHT,
62+
isNested: false,
63+
backgroundColor: 'white',
64+
style:null,
65+
children:null
66+
}

Component/SectionStyle.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import { StyleSheet } from "react-native";
2-
import Constant from "./Constant";
1+
import { StyleSheet } from 'react-native'
2+
import Constant from './Constant'
33

44
export const styles = StyleSheet.create({
5-
fullScreenWidth: {},
6-
scrollContent: {
7-
flexDirection: "row",
8-
flexWrap: "wrap",
9-
width: Constant.CONTAINER_WIDTH,
10-
},
11-
secondaryContainer: {
12-
marginBottom: 0,
13-
marginRight: 0,
14-
padding: 0,
15-
},
16-
});
5+
fullScreenWidth: {
6+
margin: 0,
7+
width: Constant.CONTAINER_WIDTH,
8+
},
9+
scrollContent: {
10+
flexDirection: 'row',
11+
flexWrap: 'wrap',
12+
width: Constant.CONTAINER_WIDTH,
13+
},
14+
secondaryContainer: {
15+
marginBottom: 0,
16+
marginRight: 0,
17+
padding: 0,
18+
},
19+
})
20+

Component/Square.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ import React, { PureComponent } from "react";
22
import { View } from "react-native";
33
import { styles } from "./SectionStyle";
44
import Constant from "./Constant";
5+
import PropTypes from "prop-types";
56

67
export default class Square extends PureComponent {
78
render() {
8-
const { xSquares, ySquares, fullScreenWidth, allowHeightExcess } = this.props;
9+
const { xSquares, ySquares, fullScreenWidth, allowHeightExcess, backgroundColor } = this.props;
910
let dimensions = Constant.getSectionSize(xSquares, ySquares, fullScreenWidth);
1011
const maxHeight = allowHeightExcess ? null : dimensions.height;
12+
1113
return (
1214
<View
1315
style={[
1416
styles.secondaryContainer,
1517
{
16-
backgroundColor: "pink",
18+
backgroundColor: backgroundColor,
1719
margin: dimensions.margin,
1820
minHeight: dimensions.height,
1921
maxHeight: maxHeight,
@@ -28,7 +30,20 @@ export default class Square extends PureComponent {
2830
);
2931
}
3032
}
31-
Square.prototypes = {
32-
height: PropTypes.number,
33-
width: PropTypes.number,
33+
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]),
41+
};
42+
Square.defaultProps = {
43+
xSquares: 1,
44+
ySquares: 1,
45+
backgroundColor: "#D3D3D3",
46+
allowHeightExcess: false,
47+
fullScreenWidth: false,
48+
style: null,
3449
};

RNGrid.png

-1.96 KB
Loading

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@logisticinfotech/react-native-grid",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Grid Layout library for React Native",
55
"main": "index.js",
66
"scripts": {
@@ -23,5 +23,8 @@
2323
"bugs": {
2424
"url": "https://github.com/logisticinfotech/react-native-grid/issues"
2525
},
26-
"homepage": "https://github.com/logisticinfotech/react-native-grid#readme"
26+
"homepage": "https://github.com/logisticinfotech/react-native-grid#readme",
27+
"dependencies": {
28+
"prop-types": "^15.7.2"
29+
}
2730
}

0 commit comments

Comments
 (0)