项目作者: radhakishan404

项目描述 :
This is react native accordion for those who wanted to style accordion according to there requirements.
高级语言: Java
项目地址: git://github.com/radhakishan404/react-native-stylish-accordion.git
创建时间: 2020-10-31T11:16:45Z
项目社区:https://github.com/radhakishan404/react-native-stylish-accordion

开源协议:MIT License

下载


react-native-stylish-accordion

Simple Stylish React Native Accordion

Table of Contents

Install

  1. $ npm install react-native-stylish-accordion

or

  1. $ yarn add react-native-stylish-accordion

Now we need to install react-native-reanimated and react-native-animatable.

If you are using Expo, to ensure that you get the compatible versions of the libraries, run:

  1. expo install react-native-reanimated react-native-gesture-handler react-native-redash

If you are not using Expo, run the following:

  1. yarn add react-native-reanimated react-native-gesture-handler react-native-redash

Note

This is created with the help of “react-native-accordion-view” package.

Usage

gif1

  1. import StylishAccordion from 'react-native-stylish-accordion'
  2. export default function App() {
  3. const [firstOpen, setFirstOpen] = useState(false);
  4. const [secondOpen, setSecondOpen] = useState(false);
  5. return (
  6. <View style={styles.container}>
  7. <StylishAccordion
  8. open={firstOpen}
  9. title="Click me first"
  10. onPress={() => setFirstOpen(!firstOpen)}
  11. titleStyle={{ fontSize: 18, fontWeight: "bold" }}
  12. headerStyle={[styles.accordionHeader]}
  13. subContainerStyle={[styles.accordionSubContainer]}
  14. timingTransition={150}
  15. iconSize={14}
  16. >
  17. <View>
  18. <Text>You clicked me thanks for testing this package, this is my first package, do give it a start in GitHub</Text>
  19. </View>
  20. </StylishAccordion>
  21. <StylishAccordion
  22. open={secondOpen}
  23. title="Click me first not that"
  24. onPress={() => setSecondOpen(!secondOpen)}
  25. titleStyle={{ fontSize: 18, fontWeight: "bold" }}
  26. headerStyle={[styles.accordionHeader]}
  27. subContainerStyle={[styles.accordionSubContainer]}
  28. timingTransition={150}
  29. iconSize={14}
  30. >
  31. <View>
  32. <Text>You clicked me thanks for testing this package, this is my first package, do give it a start in GitHub</Text>
  33. </View>
  34. </StylishAccordion>
  35. </View>
  36. );
  37. }
  38. const styles = StyleSheet.create({
  39. container: {
  40. flex: 1,
  41. backgroundColor: '#fff',
  42. alignItems: 'center',
  43. justifyContent: 'center',
  44. },
  45. accordionHeader: {
  46. backgroundColor: "#ff9d9d",
  47. borderTopLeftRadius: 12,
  48. borderTopRightRadius: 12,
  49. marginLeft: 5,
  50. marginRight: 5,
  51. marginBottom: 10,
  52. shadowColor: '#000',
  53. shadowOffset: { width: 0, height: 2 },
  54. shadowOpacity: 0.8,
  55. shadowRadius: 2,
  56. elevation: 8,
  57. },
  58. accordionSubContainer: {
  59. backgroundColor: "#fff",
  60. marginLeft: 5,
  61. marginRight: 5,
  62. shadowColor: '#000',
  63. shadowOffset: { width: 0, height: 2 },
  64. shadowOpacity: 0.8,
  65. shadowRadius: 2,
  66. elevation: 8,
  67. marginBottom: 13,
  68. },
  69. });

Props

  • title (string)
  • titleStyle (TextStyle)
  • iconSize (number)
  • headerStyle (ViewStyle)
  • subContainerStyle (ViewStyle)
  • style (ViewStyle)
  • headerComponent (ReactNode)
  • open (boolean)
  • onPress (void)
  • timingTransition (number default:400) opening speed
  • containerRadius (number)

License

MIT © Radhakishan Jangid