Files
jellyfin-audio-player/src/components/Input.tsx
Lei Nelissen af3c807d5a feat: upgrade to react native 0.79
This was necessary because we had to use the newest iOS SDK, which had an issue with react-native, which was only fixed with the newest versions.

The move to new architecture has been hellish, but all appears to work. It requires more patches, and it shows which packages are currently maintained poorly. This goes especially for react-native-track-player. We're using a fork right now, but in order to make that work, we had to switch to pnpm.
2025-05-06 11:11:49 +02:00

65 lines
1.6 KiB
TypeScript

import React, { useCallback, useRef } from 'react';
import { Platform, TextInput, TextInputProps } from 'react-native';
import styled, { css } from 'styled-components/native';
import useDefaultStyles from './Colors';
export interface InputProps extends TextInputProps {
icon?: React.ReactNode;
}
const Container = styled.Pressable<{ hasIcon?: boolean }>`
position: relative;
margin: 6px 0;
border-radius: 12px;
display: flex;
${Platform.select({
ios: css`padding: 12px;`,
android: css`padding: 12px;`,
})}
${({ hasIcon }) => hasIcon && css`
padding-left: 36px;
`}
`;
const IconWrapper = styled.View`
position: absolute;
left: 0;
top: 0;
bottom: 0;
display: flex;
justify-content: center;
padding-left: 12px;
`;
function Input({ icon = null, style, testID, ...rest }: InputProps) {
const defaultStyles = useDefaultStyles();
const inputRef = useRef<TextInput | null>(null);
const handlePress = useCallback(() => inputRef.current?.focus(), []);
return (
<Container
style={[defaultStyles.input, style]}
onPress={handlePress}
testID={`${testID}-container`}
accessible={false}
hasIcon={!!icon}
>
{icon && (
<IconWrapper>
{icon}
</IconWrapper>
)}
<TextInput
{...rest}
style={[defaultStyles.text, { margin: 0, padding: 0 }]}
ref={inputRef}
testID={`${testID}-textinput`}
/>
</Container>
);
}
export default Input;