-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
904ee16
commit 942d665
Showing
3 changed files
with
45 additions
and
15 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,36 @@ | ||
import type {ForwardedRef} from 'react'; | ||
import {forwardRef} from 'react'; | ||
import type {View} from 'react-native'; | ||
import {StyleSheet} from 'react-native'; | ||
import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import MenuItem from './MenuItem'; | ||
import type {MenuItemProps} from './MenuItem'; | ||
|
||
type Props = MenuItemProps & { | ||
highlighted?: boolean; | ||
}; | ||
|
||
function HighlightableMenuItem({wrapperStyle, highlighted, ...restOfProps}: Props, ref: ForwardedRef<View>) { | ||
const styles = useThemeStyles(); | ||
|
||
const flattenedWrapperStyles = StyleSheet.flatten(wrapperStyle); | ||
const animatedHighlightStyle = useAnimatedHighlightStyle({ | ||
shouldHighlight: highlighted ?? false, | ||
height: flattenedWrapperStyles?.height ? Number(flattenedWrapperStyles.height) : styles.sectionMenuItem.height, | ||
borderRadius: flattenedWrapperStyles?.borderRadius ? Number(flattenedWrapperStyles.borderRadius) : styles.sectionMenuItem.borderRadius, | ||
}); | ||
|
||
return ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<MenuItem | ||
{...restOfProps} | ||
wrapperStyle={animatedHighlightStyle} | ||
ref={ref} | ||
/> | ||
); | ||
} | ||
|
||
HighlightableMenuItem.displayName = 'HighlightableMenuItem'; | ||
|
||
export default forwardRef(HighlightableMenuItem); |
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