2.2.0 • Published 2 years ago

rn-accordion v2.2.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

rn-accordion

基于 react-native-reanimated 实现的手风琴组件

安装

yarn

yarn add rn-accordion react-native-reanimated

npm

npm install --save rn-accordion react-native-reanimated

示例

import * as React from 'react';
import { SafeAreaView, Text } from 'react-native';
import {
  AccordionFlatList,
  AccordionPanel,
  AccordionContent,
} from 'rn-accordion';

const Item = React.memo(({ item }: { item: any }) => {
  const [count, setCount] = React.useState(6);

  return (
    <>
      <AccordionPanel style={{ height: 100, backgroundColor: 'blue' }}>
        <Text style={{ fontSize: 30 }}>{item}</Text>
      </AccordionPanel>
      <AccordionContent style={{ backgroundColor: 'red' }}>
        <Text onPress={() => setCount(count + 10)} style={{ fontSize: 24 }}>
          {item} -1
        </Text>
        {new Array(count).fill(0).map((v, i) => {
          return (
            <Text key={i} style={{ fontSize: 16 }}>
              {item}
              {i}
            </Text>
          );
        })}
      </AccordionContent>
    </>
  );
});

function App () {
  return (
    <SafeAreaView>
      <AccordionFlatList
        // accordion
        renderItem={({ item }) => {
          return <Item item={item} />;
        }}
        // selected={'2'}
        keyExtractor={(i) => i + ''}
        data={new Array(100).fill(0).map((v, i) => i)}
      />
    </SafeAreaView>
  );
}
2.2.0

2 years ago

3.0.0-beta1

2 years ago

3.0.0-beta2

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago