Skip to content

Commit d2d5edd

Browse files
committed
Merge branch 'fix/🪗-bugs-api' into develop
2 parents 23b21c7 + ab5156c commit d2d5edd

File tree

13 files changed

+177
-91
lines changed

13 files changed

+177
-91
lines changed

.eslintrc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['@react-native-community', 'prettier'],
4+
rules: {
5+
'no-console': ['error', { allow: ['warn', 'error'] }],
6+
'prettier/prettier': [
7+
'error',
8+
{
9+
printWidth: 80,
10+
arrowParens: 'avoid',
11+
singleQuote: true,
12+
tabWidth: 2,
13+
trailingComma: 'es5',
14+
useTabs: false,
15+
},
16+
],
17+
},
18+
};

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Буду благодарен за отзыв
1+
## Thanks
22
<p>Please, click on ⭐ button.</p>
33

44

@@ -11,16 +11,11 @@
1111
- [Props](#props)
1212
- [Methods](#methods)
1313
- [FAQ](#faq)
14-
- [Is it supported and tested both on android and iOS?](#is-it-supported-and-tested-both-on-android-and-ios)
15-
- [NSURLResponse allHeaderFields: unrecognized selector sent to instance XX crash?](#nsurlresponse-allheaderfields-unrecognized-selector-sent-to-instance-xx-crash)
16-
- [Contributing](#contributing)
17-
- [Step 1](#step-1)
18-
- [Step 2](#step-2)
19-
- [Step 3](#step-3)
2014
- [Support](#support)
2115
- [License](#license)
2216
- [Hire](#hire)
2317

18+
2419
## Installation
2520

2621
<p>Expo:</p>
@@ -41,6 +36,13 @@ and package:
4136
```bash
4237
$ yarn add react-native-accordion
4338
```
39+
## Built with ❤️ and
40+
41+
- [expo](https://www.npmjs.com/package/react-native)
42+
- [react-native](https://www.npmjs.com/package/react-native)
43+
- [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/)
44+
45+
4446

4547
## Features
4648

@@ -55,13 +57,14 @@ For more complete example open [App.tsx](https://github.com/garganurag893/react-
5557

5658
```
5759

60+
61+
5862
## Props
5963

6064
- `isArrow?`: boolean
6165
- `initExpand?`: boolean
6266
- `isPointerEvents?`: boolean;
6367
- `isUnmountOnCollapse?`: boolean;
64-
- `isBackgroundChevron?`: boolean;
6568
- `colorIcon?`: string
6669
- `sizeIcon?`: number
6770
- `activeBackgroundIcon?`: string;
@@ -82,6 +85,14 @@ For more complete example open [App.tsx](https://github.com/garganurag893/react-
8285
- `onChangeState`: (value: boolean) => boolean
8386

8487

88+
## 🎉 Example
89+
90+
Checkout the example [here](https://github.com/timelessco/react-native-reanimated-switch/tree/master/example/RNSearch).
91+
92+
## ✌️ Contributing
93+
94+
Pull requests are always welcome! Feel free to open a new GitHub issue for any changes that can be made.
95+
8596
## Support
8697

8798
Reach out to me at one of the following places!

example/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@
1313
},
1414
"dependencies": {
1515
"@react-native-community/masked-view": "0.1.10",
16-
"@react-navigation/bottom-tabs": "^5.11.11",
17-
"@react-navigation/native": "^5.9.4",
18-
"@react-navigation/stack": "^5.14.5",
19-
"expo": "^40.0.0",
16+
"@react-navigation/bottom-tabs": "5.11.11",
17+
"@react-navigation/native": "5.9.4",
18+
"@react-navigation/stack": "5.14.5",
19+
"expo": "40.0.0",
2020
"expo-splash-screen": "~0.8.1",
2121
"expo-status-bar": "~1.0.3",
2222
"react": "16.13.1",
2323
"react-dom": "16.13.1",
2424
"react-native": "0.63.4",
2525
"react-native-gesture-handler": "~1.8.0",
26-
"react-native-reanimated": "~1.13.0",
27-
"react-native-redash": "^16.0.11",
26+
"react-native-reanimated": "2.1.0",
27+
"react-native-redash": "16.0.11",
2828
"react-native-safe-area-context": "3.1.9",
2929
"react-native-screens": "~2.15.2",
30-
"react-native-svg": "^12.1.1",
30+
"react-native-svg": "12.1.1",
3131
"react-native-unimodules": "~0.12.0",
3232
"react-native-web": "~0.14.9"
3333
},
3434
"devDependencies": {
3535
"@babel/core": "~7.12.10",
3636
"@babel/runtime": "^7.9.6",
37-
"babel-plugin-module-resolver": "^4.0.0",
37+
"babel-plugin-module-resolver": "4.0.0",
3838
"babel-preset-expo": "8.3.0",
39-
"expo-cli": "^4.0.13"
39+
"expo-cli": "4.0.13"
4040
}
4141
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export type Sports = {
2+
image: string;
3+
title: string;
4+
};
5+
6+
type Events = {
7+
command: {
8+
one: string;
9+
two: string;
10+
};
11+
icon: {
12+
one: string;
13+
two: string;
14+
};
15+
score: {
16+
one: 3;
17+
two: 4;
18+
};
19+
type: string;
20+
};
21+
export type Array = {
22+
image: string;
23+
title: string;
24+
county: string;
25+
events: Events[];
26+
};

example/src/screens/home/index.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { AnimatedAccordion } from 'react-native-accordion';
1111
import { useCallback } from 'react';
1212
import { assets } from '../../assets';
1313
import { Sport, Event } from '../../components';
14+
import { Array, Sports } from './index.d.';
1415

15-
const sports: any = [
16+
const sports: Sports[] = [
1617
{ image: assets.pingpong, title: 'Ping-pong' },
1718
{ image: assets.badminton, title: 'Badminton' },
1819
{ image: assets.baseball, title: 'Baseball' },
@@ -21,7 +22,7 @@ const sports: any = [
2122
{ image: assets.basketball, title: 'Basketball' },
2223
];
2324

24-
const events: any = [
25+
const array: Array[] = [
2526
{
2627
image: assets.flag_1,
2728
title: 'La League',
@@ -64,7 +65,7 @@ const HomeScreen = () => {
6465
);
6566

6667
const handleContent = useCallback(
67-
(data) =>
68+
data =>
6869
data.map(({ command, icon, score, type }) => (
6970
<Event
7071
key={command.one}
@@ -129,16 +130,18 @@ const HomeScreen = () => {
129130
{hasBanner}
130131
{hasSports}
131132

132-
{events.map(({ image, events, county, title }) => (
133+
{array.map(({ image, events, county, title }) => (
133134
<AnimatedAccordion
134135
key={title}
135136
// data={events} FIXME
136-
onChangeState={(value: boolean) => console.log(value)}
137+
// onChangeState={(value: boolean) => console.log(value)}
137138
handleContentTouchable={handleContentTouchable}
138139
renderContent={() => handleContent(events)}
139-
styleTouchable={styles.touchable}
140-
styleContainer={styles.content}
141-
// isBackgroundChevron={'#181829'} //FIXME
140+
styleTouchable={styles.touchable} // work
141+
styleContainer={styles.content} // work
142+
// colorIcon={'#FFFFFF'} work
143+
// handleIndicatorFetching={}
144+
// isStatusFetching={true} //work
142145
/>
143146
))}
144147
</SafeAreaView>

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
"pod-install": "^0.1.0",
6464
"prettier": "^2.0.5",
6565
"react": "16.13.1",
66-
"react-native": "0.63.4",
66+
"react-native": "0.64.1",
6767
"react-native-builder-bob": "^0.18.1",
68-
"release-it": "^14.2.2",
68+
"release-it": "^14.6.2",
6969
"typescript": "^4.2.4"
7070
},
7171
"peerDependencies": {
@@ -152,8 +152,9 @@
152152
]
153153
},
154154
"dependencies": {
155-
"react-native-reanimated": "2.0.0-rc.0",
156-
"react-native-redash": "^16.0.11",
157-
"react-native-svg": "^12.1.1"
155+
"@react-native-community/bob": "^0.17.1",
156+
"react-native-reanimated": ">=1.9.0",
157+
"react-native-redash": "16.0.11",
158+
"react-native-svg": "12.1.1"
158159
}
159160
}

src/components/accordion/index.tsx

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import React, { useCallback, useState } from 'react';
2-
import { TouchableWithoutFeedback, View } from 'react-native';
1+
import React, { useCallback, useMemo, useState } from 'react';
2+
import {
3+
ActivityIndicator,
4+
TouchableWithoutFeedback,
5+
View,
6+
} from 'react-native';
37
import Animated, {
48
useSharedValue,
59
useAnimatedStyle,
@@ -28,12 +32,13 @@ const AnimatedAccordion = ({
2832
configExpanded,
2933
styleContainer,
3034
configCollapsed,
35+
isStatusFetching = false,
3136
isPointerEvents = false,
32-
isBackgroundChevron = true,
3337
isUnmountOnCollapse = false,
3438
activeBackgroundIcon = '#e5f6ff',
3539
onAnimatedEndExpanded,
3640
handleCustomTouchable,
41+
handleIndicatorFetching,
3742
handleContentTouchable,
3843
onAnimatedEndCollapsed,
3944
inactiveBackgroundIcon = '#fff0e4',
@@ -52,7 +57,7 @@ const AnimatedAccordion = ({
5257
);
5358

5459
const handleExpandedCallback = useCallback(
55-
(isFinished) => {
60+
isFinished => {
5661
if (isUnmountOnCollapse && !open.value && isFinished) setUnmounted(true);
5762

5863
onAnimatedEndCollapsed(isFinished);
@@ -78,39 +83,53 @@ const AnimatedAccordion = ({
7883
onChangeState && onChangeState(!open.value);
7984
}, [layout?.height, onChangeState, open, size]);
8085

86+
const hasLoader = useMemo(
87+
() =>
88+
isStatusFetching ? (
89+
handleIndicatorFetching ? (
90+
handleIndicatorFetching()
91+
) : (
92+
<ActivityIndicator size="small" color="#AAAAAA" />
93+
)
94+
) : (
95+
<Chevron
96+
sizeIcon={sizeIcon}
97+
progress={progress}
98+
colorIcon={colorIcon}
99+
handleIcon={handleIcon}
100+
styleChevron={styleChevron}
101+
activeBackgroundIcon={activeBackgroundIcon}
102+
inactiveBackgroundIcon={inactiveBackgroundIcon}
103+
/>
104+
),
105+
[
106+
activeBackgroundIcon,
107+
colorIcon,
108+
handleIcon,
109+
handleIndicatorFetching,
110+
inactiveBackgroundIcon,
111+
isStatusFetching,
112+
progress,
113+
sizeIcon,
114+
styleChevron,
115+
]
116+
);
117+
81118
const renderHeader = useCallback(() => {
82119
return handleCustomTouchable ? (
83120
handleCustomTouchable()
84121
) : (
85122
<Animated.View style={[styles.header, styleTouchable]}>
86123
{handleContentTouchable ? handleContentTouchable() : null}
87-
{isArrow ? (
88-
<Chevron
89-
sizeIcon={sizeIcon}
90-
progress={progress}
91-
colorIcon={colorIcon}
92-
handleIcon={handleIcon}
93-
styleChevron={styleChevron}
94-
isBackgroundChevron={isBackgroundChevron}
95-
activeBackgroundIcon={activeBackgroundIcon}
96-
inactiveBackgroundIcon={inactiveBackgroundIcon}
97-
/>
98-
) : null}
124+
{isArrow ? hasLoader : null}
99125
</Animated.View>
100126
);
101127
}, [
102-
isArrow,
103-
progress,
104-
sizeIcon,
105-
colorIcon,
106-
handleIcon,
107-
styleChevron,
108-
styleTouchable,
109-
isBackgroundChevron,
110-
activeBackgroundIcon,
111128
handleCustomTouchable,
129+
styleTouchable,
112130
handleContentTouchable,
113-
inactiveBackgroundIcon,
131+
isArrow,
132+
hasLoader,
114133
]);
115134

116135
const pointerEvents = !isPointerEvents && open.value ? 'none' : 'auto';
@@ -129,7 +148,11 @@ const AnimatedAccordion = ({
129148
pointerEvents={pointerEvents}
130149
>
131150
<View onLayout={onLayout} style={[styles.container, styleContainer]}>
132-
{isUnmounted ? null : renderContent ? renderContent() : null}
151+
{isUnmounted || isStatusFetching
152+
? null
153+
: renderContent
154+
? renderContent()
155+
: null}
133156
</View>
134157
</Animated.View>
135158
</>

src/components/accordion/types.d.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@ export interface AccordionProps {
2525
*/
2626
contentHeight?: number;
2727

28+
/**
29+
*
30+
*/
31+
isStatusFetching: boolean;
32+
2833
/**
2934
*
3035
*/
3136
handleCustomTouchable?: () => FC | null;
3237

38+
/**
39+
*
40+
*/
41+
handleIndicatorFetching?: () => FC | null;
42+
3343
/**
3444
*
3545
*/
@@ -57,10 +67,6 @@ export interface AccordionProps {
5767
*/
5868
isUnmountOnCollapse?: boolean;
5969

60-
/**
61-
* background icon arrow
62-
*/
63-
isBackgroundChevron?: boolean;
6470

6571
/**
6672
* component icon.
@@ -78,7 +84,7 @@ export interface AccordionProps {
7884
*/
7985
inactiveBackgroundIcon?: string;
8086

81-
isPointerEvents?: false;
87+
isPointerEvents?: boolean;
8288

8389
/**
8490
* color icon

0 commit comments

Comments
 (0)