[IMPROVE] - migrate KeyboardView presentation layer
This commit is contained in:
parent
9d312bd9a6
commit
91e6566542
|
@ -1,20 +1,17 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { KeyboardAwareScrollView } from '@codler/react-native-keyboard-aware-scroll-view';
|
import { KeyboardAwareScrollView } from '@codler/react-native-keyboard-aware-scroll-view';
|
||||||
import scrollPersistTaps from '../utils/scrollPersistTaps';
|
import scrollPersistTaps from '../utils/scrollPersistTaps';
|
||||||
|
|
||||||
export default class KeyboardView extends React.PureComponent {
|
interface IKeyboardViewProps {
|
||||||
static propTypes = {
|
style: any,
|
||||||
style: PropTypes.any,
|
contentContainerStyle: any,
|
||||||
contentContainerStyle: PropTypes.any,
|
keyboardVerticalOffset: number,
|
||||||
keyboardVerticalOffset: PropTypes.number,
|
scrollEnabled: boolean,
|
||||||
scrollEnabled: PropTypes.bool,
|
children: JSX.Element;
|
||||||
children: PropTypes.oneOfType([
|
|
||||||
PropTypes.arrayOf(PropTypes.node),
|
|
||||||
PropTypes.node
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default class KeyboardView extends React.PureComponent<IKeyboardViewProps, any> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
style, contentContainerStyle, scrollEnabled, keyboardVerticalOffset, children
|
style, contentContainerStyle, scrollEnabled, keyboardVerticalOffset, children
|
||||||
|
@ -28,6 +25,7 @@ export default class KeyboardView extends React.PureComponent {
|
||||||
scrollEnabled={scrollEnabled}
|
scrollEnabled={scrollEnabled}
|
||||||
alwaysBounceVertical={false}
|
alwaysBounceVertical={false}
|
||||||
extraHeight={keyboardVerticalOffset}
|
extraHeight={keyboardVerticalOffset}
|
||||||
|
// @ts-ignore
|
||||||
behavior='position'
|
behavior='position'
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { TextInput, StyleSheet, I18nManager } from 'react-native';
|
import { TextInput, StyleSheet, I18nManager } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
|
|
||||||
|
@ -12,7 +11,12 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const ThemedTextInput = React.forwardRef(({ style, theme, ...props }, ref) => (
|
interface IThemedTextInput {
|
||||||
|
style: object;
|
||||||
|
theme: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ThemedTextInput = React.forwardRef(({ style, theme, ...props }: IThemedTextInput, ref: any) => (
|
||||||
<TextInput
|
<TextInput
|
||||||
ref={ref}
|
ref={ref}
|
||||||
style={[{ color: themes[theme].titleText }, style, styles.input]}
|
style={[{ color: themes[theme].titleText }, style, styles.input]}
|
||||||
|
@ -22,9 +26,4 @@ const ThemedTextInput = React.forwardRef(({ style, theme, ...props }, ref) => (
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
ThemedTextInput.propTypes = {
|
|
||||||
style: PropTypes.object,
|
|
||||||
theme: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ThemedTextInput;
|
export default ThemedTextInput;
|
|
@ -1,8 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
// @ts-ignore
|
||||||
Text, View, StyleSheet, Pressable
|
import { Text, View, StyleSheet, Pressable } from 'react-native';
|
||||||
} from 'react-native';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import Avatar from '../containers/Avatar';
|
import Avatar from '../containers/Avatar';
|
||||||
import { CustomIcon } from '../lib/Icons';
|
import { CustomIcon } from '../lib/Icons';
|
||||||
|
@ -41,9 +39,20 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface IUserItem {
|
||||||
|
name: string;
|
||||||
|
username: string;
|
||||||
|
onPress(): void;
|
||||||
|
testID: string;
|
||||||
|
onLongPress(): void;
|
||||||
|
style: any;
|
||||||
|
icon: string;
|
||||||
|
theme: string;
|
||||||
|
}
|
||||||
|
|
||||||
const UserItem = ({
|
const UserItem = ({
|
||||||
name, username, onPress, testID, onLongPress, style, icon, theme
|
name, username, onPress, testID, onLongPress, style, icon, theme
|
||||||
}) => (
|
}: IUserItem) => (
|
||||||
<Pressable
|
<Pressable
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={onLongPress}
|
onLongPress={onLongPress}
|
||||||
|
@ -51,7 +60,7 @@ const UserItem = ({
|
||||||
android_ripple={{
|
android_ripple={{
|
||||||
color: themes[theme].bannerBackground
|
color: themes[theme].bannerBackground
|
||||||
}}
|
}}
|
||||||
style={({ pressed }) => ({
|
style={({ pressed }: any) => ({
|
||||||
backgroundColor: isIOS && pressed
|
backgroundColor: isIOS && pressed
|
||||||
? themes[theme].bannerBackground
|
? themes[theme].bannerBackground
|
||||||
: 'transparent'
|
: 'transparent'
|
||||||
|
@ -68,15 +77,4 @@ const UserItem = ({
|
||||||
</Pressable>
|
</Pressable>
|
||||||
);
|
);
|
||||||
|
|
||||||
UserItem.propTypes = {
|
|
||||||
name: PropTypes.string.isRequired,
|
|
||||||
username: PropTypes.string.isRequired,
|
|
||||||
onPress: PropTypes.func.isRequired,
|
|
||||||
testID: PropTypes.string.isRequired,
|
|
||||||
onLongPress: PropTypes.func,
|
|
||||||
style: PropTypes.any,
|
|
||||||
icon: PropTypes.string,
|
|
||||||
theme: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default UserItem;
|
export default UserItem;
|
Loading…
Reference in New Issue