Skip to content

Commit f6a13e4

Browse files
authored
Merge pull request #27 from adithyavis/feat/fixes-enhancements-before-0.5.0
Feat/fixes enhancements before 0.5.0
2 parents 6459c4a + cbc1e1c commit f6a13e4

8 files changed

Lines changed: 33 additions & 19 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Adithya Viswa
3+
Copyright (c) 2024 Adithya Viswamithiran
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights

docs/docs/guides/scrollable/collapsible-headers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The `renderHeader` callback receives `HeaderRendererProps`:
5454

5555
| Prop | Type | Description |
5656
|------|------|-------------|
57-
| `collapsedPercentage` | `SharedValue<number>` | Animated value from 0 (expanded) to 1 (fully collapsed) |
57+
| `collapsedPercentage` | `SharedValue<number>` | Animated value from 0 (expanded) to 100 (fully collapsed) |
5858
| `collapsedHeaderHeight` | `SharedValue<number>` | Animated value representing the current collapsed height |
5959

6060
You can use these shared values to create animated header effects:
@@ -64,7 +64,7 @@ import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated
6464

6565
const renderHeader = ({ collapsedPercentage }) => {
6666
const animatedStyle = useAnimatedStyle(() => ({
67-
opacity: interpolate(collapsedPercentage.value, [0, 1], [1, 0]),
67+
opacity: interpolate(collapsedPercentage.value, [0, 100], [1, 0]),
6868
}));
6969

7070
return (

docs/docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const config = {
108108
],
109109
},
110110
],
111-
copyright: `Copyright ${new Date().getFullYear()} Adithya Viswa. Built with Docusaurus.`,
111+
copyright: `Copyright ${new Date().getFullYear()} Adithya Viswamithiran. Built with Docusaurus.`,
112112
},
113113
prism: {
114114
theme: prismThemes.github,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"type": "git",
4848
"url": "git+https://github.com/adithyavis/reanimated-tab-view.git"
4949
},
50-
"author": "Adithya Viswa <adithyaviswam@gmail.com> (https://github.com/adithyavis)",
50+
"author": "Adithya Viswamithiran <adithyaviswam@gmail.com> (https://github.com/adithyavis)",
5151
"license": "MIT",
5252
"bugs": {
5353
"url": "https://github.com/adithyavis/reanimated-tab-view/issues"

src/components/TabBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const TabBar = React.memo((props: TabBarProps) => {
196196
style={[styles.tabBar, styles.nonScrollableTabBar]}
197197
>
198198
{routes.map((route, index) => (
199-
<React.Fragment key={index}>
199+
<React.Fragment key={route.key}>
200200
{renderItem({ item: route, index })}
201201
</React.Fragment>
202202
))}

src/hooks/useStateUpdatesListener.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { useEffect, useRef } from 'react';
22

3-
export const useStateUpdatesListener = (state: any, callback: () => void) => {
4-
const prevStateRef = useRef(null);
3+
export const useStateUpdatesListener = (
4+
state: any,
5+
callback: () => void,
6+
listenToInitialStateUpdate = false
7+
) => {
8+
const prevStateRef = useRef(listenToInitialStateUpdate ? null : state);
59

610
useEffect(() => {
711
if (state !== prevStateRef.current) {

src/hooks/useTabBarAutoScroll.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export const useTabBarAutoScroll = (
5656
setTimeout(() => {
5757
autoScrollToRouteIndex(currentRouteIndex);
5858
}, 500);
59-
}, [autoScrollToRouteIndex, currentRouteIndex])
59+
}, [autoScrollToRouteIndex, currentRouteIndex]),
60+
true
6061
);
6162

6263
const handleScrollToIndexFailed = useCallback(

src/providers/TabLayout.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { createContext, useContext, useState } from 'react';
1+
import React, { createContext, useContext, useMemo, useState } from 'react';
22
import { useSharedValue, type SharedValue } from 'react-native-reanimated';
33
import type {
44
RouteIndexToTabContentWidthMap,
@@ -33,16 +33,25 @@ export const TabLayoutContextProvider: React.FC = React.memo(
3333
const routeIndexToTabOffsetMapSV = useSharedValue({});
3434
const routeIndexToTabContentWidthMapSV = useSharedValue({});
3535

36+
const value = useMemo(
37+
() => ({
38+
routeIndexToTabContentWidthMap,
39+
setRouteIndexToTabContentWidthMap,
40+
routeIndexToTabWidthMapSV,
41+
routeIndexToTabOffsetMapSV,
42+
routeIndexToTabContentWidthMapSV,
43+
}),
44+
[
45+
routeIndexToTabContentWidthMap,
46+
setRouteIndexToTabContentWidthMap,
47+
routeIndexToTabWidthMapSV,
48+
routeIndexToTabOffsetMapSV,
49+
routeIndexToTabContentWidthMapSV,
50+
]
51+
);
52+
3653
return (
37-
<TabLayoutContext.Provider
38-
value={{
39-
routeIndexToTabContentWidthMap,
40-
setRouteIndexToTabContentWidthMap,
41-
routeIndexToTabWidthMapSV,
42-
routeIndexToTabOffsetMapSV,
43-
routeIndexToTabContentWidthMapSV,
44-
}}
45-
>
54+
<TabLayoutContext.Provider value={value}>
4655
{children}
4756
</TabLayoutContext.Provider>
4857
);

0 commit comments

Comments
 (0)