[IMPROVE] - migrate serverItem presentation layer
This commit is contained in:
parent
3f5f309643
commit
72df0aef7e
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
// @ts-ignore
|
||||||
import { View, Text, Pressable } from 'react-native';
|
import { View, Text, Pressable } from 'react-native';
|
||||||
import FastImage from '@rocket.chat/react-native-fast-image';
|
import FastImage from '@rocket.chat/react-native-fast-image';
|
||||||
|
|
||||||
|
@ -11,11 +11,23 @@ import { withTheme } from '../../theme';
|
||||||
|
|
||||||
export { ROW_HEIGHT };
|
export { ROW_HEIGHT };
|
||||||
|
|
||||||
|
interface IServerItem {
|
||||||
|
item: {
|
||||||
|
id: string;
|
||||||
|
iconURL: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
onPress(): void;
|
||||||
|
onLongPress(): void;
|
||||||
|
hasCheck: boolean;
|
||||||
|
theme: string;
|
||||||
|
}
|
||||||
|
|
||||||
const defaultLogo = require('../../static/images/logo.png');
|
const defaultLogo = require('../../static/images/logo.png');
|
||||||
|
|
||||||
const ServerItem = React.memo(({
|
const ServerItem = React.memo(({
|
||||||
item, onPress, onLongPress, hasCheck, theme
|
item, onPress, onLongPress, hasCheck, theme
|
||||||
}) => (
|
}: IServerItem) => (
|
||||||
<Pressable
|
<Pressable
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={() => onLongPress?.()}
|
onLongPress={() => onLongPress?.()}
|
||||||
|
@ -23,7 +35,7 @@ const ServerItem = React.memo(({
|
||||||
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
|
||||||
: themes[theme].backgroundColor
|
: themes[theme].backgroundColor
|
||||||
|
@ -37,6 +49,7 @@ const ServerItem = React.memo(({
|
||||||
uri: item.iconURL,
|
uri: item.iconURL,
|
||||||
priority: FastImage.priority.high
|
priority: FastImage.priority.high
|
||||||
}}
|
}}
|
||||||
|
// @ts-ignore
|
||||||
defaultSource={defaultLogo}
|
defaultSource={defaultLogo}
|
||||||
style={styles.serverIcon}
|
style={styles.serverIcon}
|
||||||
onError={() => console.log('err_loading_server_icon')}
|
onError={() => console.log('err_loading_server_icon')}
|
||||||
|
@ -58,12 +71,4 @@ const ServerItem = React.memo(({
|
||||||
</Pressable>
|
</Pressable>
|
||||||
));
|
));
|
||||||
|
|
||||||
ServerItem.propTypes = {
|
|
||||||
item: PropTypes.object.isRequired,
|
|
||||||
onPress: PropTypes.func.isRequired,
|
|
||||||
onLongPress: PropTypes.func,
|
|
||||||
hasCheck: PropTypes.bool,
|
|
||||||
theme: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withTheme(ServerItem);
|
export default withTheme(ServerItem);
|
Loading…
Reference in New Issue