Files
jellyfin-audio-player/src/components/ListButton.tsx

50 lines
1.5 KiB
TypeScript
Raw Normal View History

import React, { useCallback, useState } from 'react';
import { TouchableOpacityProps } from 'react-native';
2023-06-19 23:03:17 +02:00
import ChevronRight from '@/assets/icons/chevron-right.svg';
2022-05-11 23:57:30 +02:00
import styled from 'styled-components/native';
import useDefaultStyles from './Colors';
2020-06-21 13:02:23 +02:00
2020-07-07 13:21:03 +02:00
const BUTTON_SIZE = 14;
const Container = styled.Pressable<{ active?: boolean }>`
2022-05-11 23:57:30 +02:00
padding: 14px 16px;
border-radius: 8px;
margin: 4px 8px;
2020-06-21 13:02:23 +02:00
flex-direction: row;
justify-content: space-between;
2022-05-11 23:57:30 +02:00
align-items: center;
`;
const Label = styled.Text<{ active?: boolean }>`
font-size: 16px;
2020-06-21 13:02:23 +02:00
`;
const ListButton: React.FC<TouchableOpacityProps> = ({ children, ...props }) => {
const defaultStyles = useDefaultStyles();
const [isPressed, setPressed] = useState(false);
const handlePressIn = useCallback(() => setPressed(true), []);
const handlePressOut = useCallback(() => setPressed(false), []);
2020-06-21 13:02:23 +02:00
return (
<Container
{...props}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
2022-05-11 23:57:30 +02:00
style={[
defaultStyles.border,
isPressed ? defaultStyles.activeBackground : undefined
]}
>
<Label style={defaultStyles.themeColor}>
{children}
</Label>
<ChevronRight
width={BUTTON_SIZE}
height={BUTTON_SIZE}
fill={defaultStyles.themeColor.color}
/>
2020-06-21 13:02:23 +02:00
</Container>
);
};
export default ListButton;