Skip to content

Commit c5a69fb

Browse files
committed
Merge branch 'develop' into main
2 parents a7bdfc1 + 96fb7bc commit c5a69fb

File tree

14 files changed

+72
-28
lines changed

14 files changed

+72
-28
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ For more complete example open [App.tsx](https://github.com/dev-event/react-nati
7575
```tsx
7676
import React, { useState, useCallback } from "react";
7777
import { StyleSheet, View, Text, StatusBar} from "react-native";
78-
import { AnimatedAccordion } from 'react-native-accordion';
78+
import AnimatedAccordion from 'react-native-accordion';
7979

8080

8181
const App: React.FC = () => {
@@ -97,6 +97,7 @@ const App: React.FC = () => {
9797
sizeIcon={16}
9898
styleChevron={styles.icon}
9999
renderContent={handleContent}
100+
onChangeState={(isShow) => setShow(isShow)}
100101
styleTouchable={styles.touchable}
101102
activeBackgroundIcon={theme.light_gray}
102103
inactiveBackgroundIcon={theme.light_gray}
@@ -147,6 +148,8 @@ const styles = StyleSheet.create({
147148
- `inactiveBackgroundIcon?`: string;
148149
- `contentHeight?`: number
149150
- `handleIcon?`: () => void
151+
- `onAnimatedEndExpanded?`: () => void
152+
- `onAnimatedEndCollapsed?`: () => void
150153
- `handleCustomTouchable?`: () => void
151154
- `handleContentTouchable?`: () => void
152155
- `renderContent?`: () => void;
@@ -191,5 +194,3 @@ Reach out to me at one of the following places!
191194
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)
192195

193196
- **[MIT license](http://opensource.org/licenses/mit-license.php)**
194-
195-
[react-native-country-picker-modal]: https://github.com/xcarpentier/react-native-country-picker-modal

example/src/screens/home/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Image,
88
ScrollView,
99
} from 'react-native';
10-
import { AnimatedAccordion } from 'react-native-accordion';
10+
import AnimatedAccordion from '../../../../src';
1111
import { useCallback } from 'react';
1212
import { assets } from '../../assets';
1313
import { Sport, Event } from '../../components';
@@ -167,13 +167,18 @@ const HomeScreen = () => {
167167
);
168168
return (
169169
<SafeAreaView style={styles.container}>
170-
<ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={{paddingBottom: 100}}>
170+
<ScrollView
171+
showsVerticalScrollIndicator={false}
172+
contentContainerStyle={{ paddingBottom: 100 }}
173+
>
171174
{hasHeader}
172175
{hasBanner}
173176
{hasSports}
174177
{array.map(({ image, events, county, title }) => (
175178
<AnimatedAccordion
176179
key={title}
180+
onAnimatedEndExpanded={() => console.log('expanded')}
181+
onAnimatedEndCollapsed={() => console.log('collapsed')}
177182
handleContentTouchable={() =>
178183
handleContentTouchable(title, image, county)
179184
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dev-event/react-native-accordion",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "A performant interactive collapsed view with fully configurable options",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
@@ -26,6 +26,7 @@
2626
"typescript": "tsc --noEmit",
2727
"prepare": "bob build",
2828
"release": "release-it",
29+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
2930
"example": "yarn --cwd example",
3031
"pods": "cd example && pod-install --quiet",
3132
"bootstrap": "yarn example && yarn && yarn pods",
@@ -42,7 +43,7 @@
4243
"animated view"
4344
],
4445
"repository": "https://github.com/dev-event/react-native-accordion",
45-
"author": "Aliaksei Petrusevich <effectwaater@gmail.com> (https://github.com/dev-event)",
46+
"author": "dev-event <effectwaater@gmail.com> (https://github.com/dev-event)",
4647
"license": "MIT",
4748
"bugs": {
4849
"url": "https://github.com/dev-event/react-native-accordion/issues"

src/components/accordion/accordion.tsx renamed to src/accordion/accordion.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import Animated, {
1010
useDerivedValue,
1111
withTiming,
1212
runOnUI,
13+
runOnJS,
1314
} from 'react-native-reanimated';
14-
import { Chevron } from '../chevron';
15-
import type { AnimatedAccordionProps } from '../accordion/types';
16-
import { styles } from '../accordion/styles';
17-
import { useLayout } from '../../hooks';
15+
import Chevron from '../chevron';
16+
import type { IAccordionProps } from './types';
17+
import { styles } from './styles';
18+
import { useLayout } from '../hooks';
1819

19-
const AnimatedAccordion: FC<AnimatedAccordionProps> = ({
20+
const AnimatedAccordion: FC<IAccordionProps> = ({
2021
isArrow = true,
2122
sizeIcon = 16,
2223
disabled = false,
@@ -35,9 +36,11 @@ const AnimatedAccordion: FC<AnimatedAccordionProps> = ({
3536
isStatusFetching = false,
3637
activeBackgroundIcon = '#e5f6ff',
3738
handleCustomTouchable,
38-
handleIndicatorFetching,
39+
onAnimatedEndExpanded,
40+
onAnimatedEndCollapsed,
3941
handleContentTouchable,
4042
inactiveBackgroundIcon = '#fff0e4',
43+
handleIndicatorFetching,
4144
}) => {
4245
const [layout, onLayout] = useLayout(0);
4346

@@ -63,7 +66,15 @@ const AnimatedAccordion: FC<AnimatedAccordionProps> = ({
6366
}, [isStatusFetching, layout, size]);
6467

6568
const progress = useDerivedValue(() =>
66-
open.value ? withTiming(1, configExpanded) : withTiming(0, configCollapsed)
69+
open.value
70+
? withTiming(1, configExpanded, () => {
71+
'worklet';
72+
runOnJS(onAnimatedEndExpanded)();
73+
})
74+
: withTiming(0, configCollapsed, () => {
75+
'worklet';
76+
runOnJS(onAnimatedEndCollapsed)();
77+
})
6778
);
6879

6980
const style = useAnimatedStyle(() => ({
@@ -154,4 +165,4 @@ const AnimatedAccordion: FC<AnimatedAccordionProps> = ({
154165
);
155166
};
156167

157-
export { AnimatedAccordion };
168+
export default AnimatedAccordion;

src/accordion/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './accordion';
2+
export type { IAccordionProps } from './types';
File renamed without changes.

src/components/accordion/types.d.ts renamed to src/accordion/types.d.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FC } from 'react';
22
import { ViewStyle, ViewProps } from 'react-native';
33
import type Animated from 'react-native-reanimated';
44

5-
export interface AnimatedAccordionProps {
5+
export interface IAccordionProps {
66
/**
77
* active/inactive TouchableWithoutFeedback
88
*/
@@ -50,6 +50,16 @@ export interface AnimatedAccordionProps {
5050
*/
5151
onChangeState: (value: boolean) => void;
5252

53+
/**
54+
*
55+
*/
56+
onAnimatedEndExpanded?: () => void;
57+
58+
/**
59+
*
60+
*/
61+
onAnimatedEndCollapsed?: () => void;
62+
5363
/**
5464
*
5565
*/

src/components/chevron/index.tsx renamed to src/chevron/chevron.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
33
import Svg, { Path } from 'react-native-svg';
44
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
55
import { mix, mixColor } from 'react-native-redash';
6-
import type { AccordionIconProps } from './types';
6+
import type { IChevronProps } from './types';
77

88
const Chevron = ({
99
sizeIcon,
@@ -13,7 +13,7 @@ const Chevron = ({
1313
styleChevron,
1414
activeBackgroundIcon,
1515
inactiveBackgroundIcon,
16-
}: AccordionIconProps) => {
16+
}: IChevronProps) => {
1717
const style = useAnimatedStyle(() => ({
1818
// @ts-ignore
1919
backgroundColor: mixColor(
@@ -55,7 +55,7 @@ const Chevron = ({
5555
);
5656
};
5757

58-
export { Chevron };
58+
export default Chevron;
5959

6060
const styles = StyleSheet.create({
6161
container: {

src/chevron/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './chevron';
2+
export type { IChevronProps } from './types';

src/components/chevron/types.d.ts renamed to src/chevron/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Animated from 'react-native-reanimated';
22
import { FC } from 'react';
33
import { StyleProp, ViewStyle } from 'react-native';
4-
export interface AccordionIconProps {
4+
export interface IChevronProps {
55
progress: Animated.SharedValue<number>;
66
sizeIcon?: number;
77
/**

0 commit comments

Comments
 (0)