Socket
Socket
Sign inDemoInstall

@metasys96/react-native-custom-table

Package Overview
Dependencies
5
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @metasys96/react-native-custom-table

Cross-platform development is now an essential aspect of software development. Node Packet Manager, the online repository is a go to site for React Programmers. This is MetaSys’ contribution based on challenges we had while developing a single application


Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-native-custom-table

Cross-platform development is now an essential aspect of software development. Node Packet Manager, the online repository is a go to site for React Programmers. This is MetaSys’ contribution based on challenges we had while developing a single application for both Android and iOS. We offer a flexible NPM package, for custom table widgets which will work on both Android and iOS platforms. The package is based on React hooks and typescript, which provides an error-free custom table. It also gives you a clean and consistent look and feel on iOS and Android devices with high performance.

This React Native package has the Custom Flatlist with most of the common usage functionalities like swipe buttons, filter table row, pull to refresh and load more on reach end of the data. The code takes care of most use cases for the flat list and swipe functionality. Developers can pass the required properties and get the results easily and very quickly. The documentation below will help you to easily integrate with your React Native projects.

This version is compatible with react-native 0.60 and above.

Content

  1. Installation and Linking

  2. Screenshots

  3. Getting stated

  4. Properties

  5. Contribution

Installation

Run npm i @metasys96/react-native-custom-table –save

Screenshot

Getting started Add @metasys96/react-native-custom-table to your JS file.

CustomTable

import {CustomTable} from '@metasys96/react-native-custom-table';
import {data} from ‘./src/data';

// Right button props
const swipeRightBtns = [
{
text: 'Delete',
backgroundColor: '#D11A2A',
underlayColor: 'rgba(0, 0, 0, 1, 0.6)',
},
];

// Left button props
const swipeLeftBtns = [
{
text: 'Archive',
backgroundColor: '#009d00',
underlayColor: 'rgba(0, 0, 0, 1, 0.6)',
},
];

const App = () => {
const [isFetching, setIsFetching] = useState(false);
const onChangeText = (text: string) => {
setText(text);
};

const archiveRow = (rowData: any) => {
console.log('rowData to archive :-', rowData);
};

const deleteRow = (rowData: any) => {
console.log('rowData to delete :-', rowData);
};

const getSwipeLeftBtns = (dataRow: any) => {
return swipeLeftBtns.map((element) => ({
...element,
onPress: () => archiveRow(dataRow),
}));
};

const getSwipeRightBtns = (dataRow: any) => {
return swipeRightBtns.map((element) => ({
...element,
onPress: () => deleteRow(dataRow),
}));
};

const getTableRow = ({item, index}: any) => {  // Returning table rows
return (
<View style={styles.tableCell}>
<Text key={index}>{item.name}</Text>
</View>
);
};

const onRefresh = () => {
setIsFetching(true);
setTimeout(() => { setIsFetching(false); }, 1000);
};

return (
<View style={styles.conatiner}>
<CustomTable
tableData={data}
renderRow={getTableRow}
searchText={inputValue}
searchTextForKey={'name'}
swipeLeftButtons={getSwipeLeftBtns}
swipeRightButtons={getSwipeRightBtns}
tableContainerStyle={styles.tableContainer}
ItemSeparatorComponent={() => (
<View style={styles.tableCellSeparator} />
)}
onRefresh={() => onRefresh()}
refreshing={isFetching}
/>
</View>
);};

const styles = StyleSheet.create({
conatiner: {
backgroundColor: '#3498DB',
paddingTop: 50,
},
tableContainer: {
backgroundColor: '#FFFFFF',
},
tableCellSeparator: {
height: 0.5,
backgroundColor: '#d3d3d3',
},
tableCell: {
height: 60,
padding: 20,
borderTopWidth: 2,
borderBottomWidth: 2,
borderColor: '#d3d3d3',
}});

export default App;

Data

export const data = [ { name: 'Liam' }, { name: ‘Noah }, { name: 'William' }, { name: ‘James' }, { name: 'Oliver' }, { name: ‘Benjamin' }, { name: 'Lucas'}, ];

Properties

NameDescriptionTypeRequired
tableDataData in arrayArrayRequired
renderRowProvide an item from data to render the table rowReactNodeRequired
renderRowProvide an item from data to render the table rowReactNodeRequired
searchTextUse to filter the table rows by search textString NotRequired
searchTextForKeyUse to specify the key to compare the search text for a rowStringNot Required
swipeLeftButtonsSwipe-out button props for leftarrayNot Required
swipeRightButtonsSwipe-out button props for rightarrayNot Required
tableContainerStyleTable container StyleObjectNot Required
ItemSeparatorComponentRendered in between each item[ReactClass]Not Required
extraDataA property for telling the list to re-renderAnyNot Required
keyExtractorUse to set unique key for an itemStringRequired
HorizontalIf true, renders items next to each other horizontallyBooleanNot Required
initialScrollIndexDisplay table row at initialScrollIndexNumberNot Required
InvertReverses the direction of scrollBooleanNot Required
onEndReachedCalled over when scroll reached to end of the table row(info: {distanceFromEnd: number}) => voidNot Required
onEndReachedThresholdHow far from the end in units of visible length of the listNumberNot Required
onRefreshIt is called when pulled the table rows to refresh table data functionality() => voidNot Required
refreshingWaiting for the new data to load on pulled to refresh functionality.BooleanNot Required
autoCloseAuto close on swipe button pressBooleanNot Required
Closeclose on swipe button pressBooleanNot Required
disabledWhether to disable the sSwipe-outBooleanNot Required
onOpenCalled on opening swipe out buttons(sectionId, rowId, direction:string)=> voidNot Required
onCloseCalled when on close of swipe out buttons(sectionId, rowId, direction:string)=> voidNot Required
SensitivityChange the sensitivity of Swipe-out button gestureNumberNot Required (Default 50)
buttonWidthEach button with of Swipe-out buttonsNumberNot Required

Methods

1. scrollToEnd()

To schools to the end of the content. scrollToEnd(([params]: object));

Example: this.flatListRef.scrollToEnd();

2. scrollToIndex()

To schools to the item at the specified index. scrollToIndex(([params]: object));

Example: this.flatListRef.scrollToIndex({animated: true, index: randomIndex});

Button Properties

NameDescriptionTypeDefault
backgroundColorBackground colorString'#b6bec0'
colortext colorString'#ffffff'
componentpass custom component to Swipe-out buttonsReactNodenull
onPressfunction executed onPressFunctionnull
textTextString'Click Me'
typedefault, delete, primary, secondaryString'default'
underlayColorSwipe-out button underlay color on pressStringNull
disableddisable swipe-out buttonBooleanfalse

Contribution

Any type of issues are welcome. Please add screenshots of the bug and code snippet. Also the quickest way to solve the bug is to reproduce it with one of the examples. We would also welcome Pull Requests.

git clone https://github.com/metasys96/CustomTable.git

npm install

react-native run-android or react-native run-android

Copyright and License

Author

MetaSys Software Pvt. Ltd.

License

MIT

Copyright 2020 MetaSys Software Pvt. Ltd. All rights reserved.

Keywords

FAQs

Last updated on 28 Sep 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc