-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update name * update useCarousel ref type * export Carousel and useCarousel * Make accessible on iOS * fix type for useCarousel * fix to work a Carousel * remove onLayout * remove unused import * Added changesets
- Loading branch information
Showing
5 changed files
with
64 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
'@react-native-ama/internal': minor | ||
'@react-native-ama/extras': minor | ||
'@react-native-ama/forms': minor | ||
'@react-native-ama/animations': minor | ||
'@react-native-ama/core': minor | ||
'@react-native-ama/lists': minor | ||
'@react-native-ama/react-native': minor | ||
--- | ||
|
||
Added Carousel and useCarousel to extras package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as React from 'react'; | ||
import { FlatListProps } from 'react-native'; | ||
import { FlatList } from 'react-native-gesture-handler'; | ||
|
||
import { useCarousel } from '../hooks/useCarousel'; | ||
|
||
function fixedForwardRef<T, P = {}>( | ||
render: (props: P, ref: React.Ref<T>) => React.ReactNode, | ||
): (props: P & React.RefAttributes<T>) => React.ReactNode { | ||
return React.forwardRef(render) as any; | ||
} | ||
|
||
export type CarouselProps<T = any> = Omit< | ||
FlatListProps<T>, | ||
| 'accessibilityLabel' | ||
| 'accessibilityRole' | ||
| 'accessibilityActions' | ||
| 'onAccessibilityAction' | ||
> & { | ||
accessibilityLabel: string; | ||
}; | ||
|
||
const CarouselInner = <T,>( | ||
props: CarouselProps<T>, | ||
forwardedRef: React.ForwardedRef<FlatList<T>>, | ||
) => { | ||
const a11yProps = useCarousel({ | ||
data: props.data, | ||
flatListRef: forwardedRef, | ||
}); | ||
|
||
return ( | ||
<FlatList | ||
ref={forwardedRef} | ||
showsHorizontalScrollIndicator={false} | ||
showsVerticalScrollIndicator={false} | ||
decelerationRate="fast" | ||
horizontal | ||
{...props} | ||
{...a11yProps} | ||
/> | ||
); | ||
}; | ||
|
||
export const Carousel = fixedForwardRef(CarouselInner); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// Components | ||
export { BottomSheet } from './components/BottomSheet'; | ||
export { Carousel } from './components/Carousel'; | ||
|
||
// Hooks | ||
export { useBottomSheetGestureHandler } from './hooks/useBottomSheetGestureHandler'; | ||
export { useKeyboard } from './hooks/useKeyboard'; | ||
export { useCarousel } from './hooks/useCarousel'; |