Skip to content

Commit afa790b

Browse files
committed
released 0.1.8
1 parent a0d1be9 commit afa790b

File tree

11 files changed

+363
-36
lines changed

11 files changed

+363
-36
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ We want this community to be friendly and respectful to each other. Please follo
66

77
## Development workflow
88

9-
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
9+
This project is managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
1010

1111
- The library package in the root directory.
1212
- An example app in the `example/` directory.
@@ -21,7 +21,7 @@ yarn
2121
2222
The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
2323

24-
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
24+
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild.
2525

2626
You can use various commands from the root directory to work with the project.
2727

@@ -79,24 +79,22 @@ We follow the [conventional commits specification](https://www.conventionalcommi
7979
- `test`: adding or updating tests, e.g. add integration tests using detox.
8080
- `chore`: tooling changes, e.g. change CI config.
8181

82-
Our pre-commit hooks verify that your commit message matches this format when committing.
8382

8483
### Linting and tests
8584

8685
[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
8786

8887
We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
8988

90-
Our pre-commit hooks verify that the linter and tests pass when committing.
9189

9290
### Publishing to npm
9391

94-
We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
92+
Our project's new versions are carefully curated and published to npm by our core maintainers to ensure the integrity and stability of the package. They manually update the version in <code>package.json</code> according to semantic versioning (semver) rules. This steps are crucial for tracking different versions of the package, ensuring compatibility, maintaining the quality and reliability of our releases.
93+
9594

96-
To publish new versions, run the following:
9795

9896
```sh
99-
yarn release
97+
npm publish
10098
```
10199

102100
### Scripts

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,21 @@ A lower value results in more frequent updates, offering smoother visual updates
306306
<td>Defines the threshold for triggering <code>onVerticalEndReached</code>. Represented as a fraction of the total height of the scrollable grid, indicating how far from the end the vertical scroll must be to trigger the event.</td>
307307
</tr>
308308

309+
<tr>
310+
<td><code>HeaderComponent</code></td>
311+
<td><code>React.ComponentType&lt;any&gt; | React.ReactElement | null | undefined</code></td>
312+
<td><code>null</code></td>
313+
<td><code>false</code></td>
314+
<td>Accepts a React component or element that will be rendered at the top of the grid, before any grid items are displayed. Suitable for titles, search bar, etc</td>
315+
</tr>
316+
<tr>
317+
<td><code>FooterComponent</code></td>
318+
<td><code>React.ComponentType&lt;any&gt; | React.ReactElement | null | undefined</code></td>
319+
<td><code>null</code></td>
320+
<td><code>false</code></td>
321+
<td>Accepts a React component or element that will be rendered at the bottom of the grid, after all the grid items have been displayed. Suitable for load more buttons, indicator or component</td>
322+
</tr>
323+
309324
</tbody>
310325
</table>
311326

@@ -431,6 +446,21 @@ A lower value results in more frequent updates, offering smoother visual updates
431446
<td> Defines the distance from the end of the content at which <code>onEndReached</code> should be triggered, expressed as a proportion of the total content length. For example, a value of <code>0.1</code> triggers the callback when the user has scrolled to within 10% of the end of the content. </td>
432447
</tr>
433448

449+
<tr>
450+
<td><code>HeaderComponent</code></td>
451+
<td><code>React.ComponentType&lt;any&gt; | React.ReactElement | null | undefined</code></td>
452+
<td><code>null</code></td>
453+
<td><code>false</code></td>
454+
<td>Accepts a React component or element that will be rendered at the top of the grid, before any grid items are displayed. Suitable for titles, search bar, etc</td>
455+
</tr>
456+
<tr>
457+
<td><code>FooterComponent</code></td>
458+
<td><code>React.ComponentType&lt;any&gt; | React.ReactElement | null | undefined</code></td>
459+
<td><code>null</code></td>
460+
<td><code>false</code></td>
461+
<td>Accepts a React component or element that will be rendered at the bottom of the grid, after all the grid items have been displayed. Suitable for load more buttons, indicator or component</td>
462+
</tr>
463+
434464
</tbody>
435465
</table>
436466

example/src/App.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import InstagramExploreExample from './InstagramExploreExample';
1212
import PinterestExample from './PinterestHomeExample';
1313
import GridBoardExamplePage from './GridBoardExample';
1414
import InfiniteScrollExample from './InfiniteScrollExample';
15+
import MultiDirectionScrollExample from './MultiDirectionScrollExample';
1516

1617
type ScreenName =
1718
| 'Landing'
1819
| 'InstagramExplore'
1920
| 'Pinterest'
2021
| 'InfiniteScrollExample'
21-
| 'GridBoardExample';
22+
| 'GridBoardExample'
23+
| 'MultiDirectionScrollExample';
2224

2325
interface LandingProps {
2426
onNavigate: (screenName: ScreenName) => void;
@@ -54,6 +56,13 @@ const Landing = ({ onNavigate }: LandingProps) => {
5456
>
5557
<Text style={styles.text}>Infinite Scroll Example </Text>
5658
</TouchableOpacity>
59+
60+
<TouchableOpacity
61+
onPress={() => onNavigate('MultiDirectionScrollExample')}
62+
style={styles.button}
63+
>
64+
<Text style={styles.text}>Multi-Direction Scroll Example </Text>
65+
</TouchableOpacity>
5766
</View>
5867
);
5968
};
@@ -90,6 +99,9 @@ const App = () => {
9099
{currentScreen === 'InstagramExplore' && <InstagramExploreExample />}
91100
{currentScreen === 'Pinterest' && <PinterestExample />}
92101
{currentScreen === 'GridBoardExample' && <GridBoardExamplePage />}
102+
{currentScreen === 'MultiDirectionScrollExample' && (
103+
<MultiDirectionScrollExample />
104+
)}
93105
</SafeAreaView>
94106
);
95107
};

example/src/InfiniteScrollExample.tsx

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable react-native/no-inline-styles */
33

44
import React, { useState, useEffect } from 'react';
5-
import { View, Text, TouchableOpacity } from 'react-native';
5+
import { View, Text, TouchableOpacity, ActivityIndicator } from 'react-native';
66
import { ResponsiveGrid } from 'react-native-flexible-grid';
77

88
const InfiniteScrollExample = () => {
@@ -53,19 +53,50 @@ const InfiniteScrollExample = () => {
5353
setTimeout(() => {
5454
// Simulate network request
5555
const newData = getData(5);
56+
5657
setData((prevData) => [...prevData, ...newData]); // Append new data
5758
setLoading(false);
58-
}, 1500);
59+
}, 4000);
5960
};
6061

61-
// const renderFooter = () => {
62-
// if (!loading) return null;
63-
// return (
64-
// <View style={styles.loader}>
65-
// <ActivityIndicator size="large" />
66-
// </View>
67-
// );
68-
// };
62+
const renderFooter = () => {
63+
if (!loading) return null;
64+
return (
65+
<View
66+
style={{
67+
padding: 20,
68+
justifyContent: 'center',
69+
alignItems: 'center',
70+
backgroundColor: 'white',
71+
height: 100,
72+
}}
73+
>
74+
<ActivityIndicator size="large" />
75+
</View>
76+
);
77+
};
78+
79+
const renderHeader = () => {
80+
return (
81+
<View
82+
style={{
83+
padding: 20,
84+
justifyContent: 'center',
85+
alignItems: 'center',
86+
backgroundColor: 'white',
87+
}}
88+
>
89+
<Text
90+
style={{
91+
fontSize: 25,
92+
fontWeight: 'bold',
93+
}}
94+
>
95+
Infinite Grid Example
96+
</Text>
97+
</View>
98+
);
99+
};
69100

70101
const renderItem = ({ item }: any) => {
71102
return (
@@ -102,22 +133,28 @@ const InfiniteScrollExample = () => {
102133
};
103134

104135
return (
105-
<ResponsiveGrid
106-
maxItemsPerColumn={4}
107-
data={data}
108-
itemContainerStyle={{
109-
padding: 2,
110-
}}
111-
renderItem={renderItem}
136+
<View
112137
style={{
113-
backgroundColor: 'white',
138+
flex: 1,
114139
}}
115-
//FooterComponent={renderFooter}
116-
keyExtractor={(item) => item.id}
117-
onEndReached={loadData}
118-
onEndReachedThreshold={0.5}
119-
virtualization={false}
120-
/>
140+
>
141+
<ResponsiveGrid
142+
maxItemsPerColumn={4}
143+
data={data}
144+
itemContainerStyle={{
145+
padding: 2,
146+
}}
147+
renderItem={renderItem}
148+
style={{
149+
backgroundColor: 'white',
150+
}}
151+
HeaderComponent={renderHeader}
152+
FooterComponent={renderFooter}
153+
keyExtractor={(item) => item.id}
154+
onEndReached={loadData}
155+
onEndReachedThreshold={0.2}
156+
/>
157+
</View>
121158
);
122159
};
123160

0 commit comments

Comments
 (0)