项目作者: hamidhadi

项目描述 :
A ReactNative collapsible list component
高级语言: Objective-C
项目地址: git://github.com/hamidhadi/react-native-collapsible-list.git
创建时间: 2018-03-04T09:11:31Z
项目社区:https://github.com/hamidhadi/react-native-collapsible-list

开源协议:MIT License

下载


react-native-collapsible-list

A ReactNative collapsible list component

react-native-collapsible-list example

Installation

You can install this package via yarn:

  1. yarn add react-native-collapsible-list

or npm

  1. npm install react-native-collapsible-list --save

Basic Usage

  1. import React, { Component } from "react";
  2. import { Text, View } from "react-native";
  3. import CollapsibleList from "react-native-collapsible-list";
  4. export default class App extends Component {
  5. render() {
  6. return (
  7. <View style={styles.container}>
  8. <CollapsibleList
  9. numberOfVisibleItems={1}
  10. wrapperStyle={styles.wrapperCollapsibleList}
  11. buttonContent={
  12. <View style={styles.button}>
  13. <Text style={styles.buttonText}>{buttonText}</Text>
  14. </View>
  15. }
  16. >
  17. <View style={styles.collapsibleItem}>
  18. <Text>Hello Collapsable List :)</Text>
  19. </View>
  20. <View style={styles.collapsibleItem}>
  21. <Text>Collapsable List Item</Text>
  22. </View>
  23. <View style={styles.collapsibleItem}>
  24. <Text>Another Collapsable List Item</Text>
  25. </View>
  26. </CollapsibleList>
  27. </View>
  28. );
  29. }
  30. }
  31. const styles = StyleSheet.create({
  32. container: {
  33. flex: 1,
  34. justifyContent: "center",
  35. alignItems: "center",
  36. backgroundColor: "rgba(0, 0, 0, 0.1)"
  37. },
  38. wrapperCollapsibleList: {
  39. flex: 1,
  40. marginTop: 20,
  41. overflow: "hidden",
  42. backgroundColor: "#FFF",
  43. borderRadius: 5
  44. },
  45. collapsibleItem: {
  46. borderBottomWidth: StyleSheet.hairlineWidth,
  47. borderColor: "#CCC",
  48. padding: 10
  49. }
  50. });

Properties

Prop Type Default Description
animationConfig ReactNative.LayoutAnimationConfig {duration: 700, update: { type: "spring", springDamping: 0.7, property: "scaleXY" }} Overrides each property of the default value if specified
buttonContent React.ReactNode null Content of collapse button
buttonPosition string (top or bottom) bottom Position of collapse button
numberOfVisibleItems number 1 Number of visible items when lis is not collapsed
onToggle function null Callback function for toggling the list with collapsed parameter which can be true(list is collapsed) or false(list is not collapsed)
wrapperStyle ReactNative.ViewStyle null The style of the list wrapper

Contribution

You can fork the repository, improve or fix some part of it and then send the pull requests back if you want to see them here. I really appreciate that. :wink:

License

Licensed under the MIT.