chore: Migrate LeftButtons room to ts
This commit is contained in:
parent
87f7c15dfa
commit
9b746cf1e0
|
@ -1,5 +1,4 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
import { HeaderBackButton } from '@react-navigation/stack';
|
import { HeaderBackButton } from '@react-navigation/stack';
|
||||||
|
|
||||||
|
@ -13,11 +12,37 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface IRoomLeftButtons {
|
||||||
|
tmid: string;
|
||||||
|
unreadsCount: number;
|
||||||
|
navigation: any; // TODO - change this after merge react navigation
|
||||||
|
baseUrl: string;
|
||||||
|
userId: string;
|
||||||
|
token: string;
|
||||||
|
title: string;
|
||||||
|
t: string;
|
||||||
|
theme: string;
|
||||||
|
goRoomActionsView: Function;
|
||||||
|
isMasterDetail: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const LeftButtons = React.memo(
|
const LeftButtons = React.memo(
|
||||||
({ tmid, unreadsCount, navigation, baseUrl, userId, token, title, t, theme, goRoomActionsView, isMasterDetail }) => {
|
({
|
||||||
|
tmid,
|
||||||
|
unreadsCount,
|
||||||
|
navigation,
|
||||||
|
baseUrl,
|
||||||
|
userId,
|
||||||
|
token,
|
||||||
|
title,
|
||||||
|
t,
|
||||||
|
theme,
|
||||||
|
goRoomActionsView,
|
||||||
|
isMasterDetail
|
||||||
|
}: IRoomLeftButtons) => {
|
||||||
if (!isMasterDetail || tmid) {
|
if (!isMasterDetail || tmid) {
|
||||||
const onPress = useCallback(() => navigation.goBack());
|
const onPress = useCallback(() => navigation.goBack(), []);
|
||||||
const label = unreadsCount > 99 ? '+99' : unreadsCount || ' ';
|
const label: any = unreadsCount > 99 ? '+99' : unreadsCount || ' ';
|
||||||
const labelLength = label.length ? label.length : 1;
|
const labelLength = label.length ? label.length : 1;
|
||||||
const marginLeft = -2 * labelLength;
|
const marginLeft = -2 * labelLength;
|
||||||
const fontSize = labelLength > 1 ? 14 : 17;
|
const fontSize = labelLength > 1 ? 14 : 17;
|
||||||
|
@ -39,18 +64,4 @@ const LeftButtons = React.memo(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
LeftButtons.propTypes = {
|
|
||||||
tmid: PropTypes.string,
|
|
||||||
unreadsCount: PropTypes.number,
|
|
||||||
navigation: PropTypes.object,
|
|
||||||
baseUrl: PropTypes.string,
|
|
||||||
userId: PropTypes.string,
|
|
||||||
token: PropTypes.string,
|
|
||||||
title: PropTypes.string,
|
|
||||||
t: PropTypes.string,
|
|
||||||
theme: PropTypes.string,
|
|
||||||
goRoomActionsView: PropTypes.func,
|
|
||||||
isMasterDetail: PropTypes.bool
|
|
||||||
};
|
|
||||||
|
|
||||||
export default LeftButtons;
|
export default LeftButtons;
|
Loading…
Reference in New Issue