From 161e667678cc05371ccc1afe3074f5c88279e497 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 23:24:51 -0300 Subject: [PATCH] chore: start the RoomView migrate to typescript --- app/views/RoomView/{Banner.js => Banner.tsx} | 21 ++++++++++--------- .../RoomView/{EmptyRoom.js => EmptyRoom.tsx} | 16 +++++++------- app/views/RoomView/{styles.js => styles.ts} | 0 3 files changed, 19 insertions(+), 18 deletions(-) rename app/views/RoomView/{Banner.js => Banner.tsx} (87%) rename app/views/RoomView/{EmptyRoom.js => EmptyRoom.tsx} (61%) rename app/views/RoomView/{styles.js => styles.ts} (100%) diff --git a/app/views/RoomView/Banner.js b/app/views/RoomView/Banner.tsx similarity index 87% rename from app/views/RoomView/Banner.js rename to app/views/RoomView/Banner.tsx index 860f80b73..606c71ad7 100644 --- a/app/views/RoomView/Banner.js +++ b/app/views/RoomView/Banner.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { Text, View } from 'react-native'; -import PropTypes from 'prop-types'; import { BorderlessButton, ScrollView } from 'react-native-gesture-handler'; import Modal from 'react-native-modal'; @@ -9,8 +8,16 @@ import { CustomIcon } from '../../lib/Icons'; import { themes } from '../../constants/colors'; import styles from './styles'; +interface IRoomBannerProps { + text: string; + title: string; + theme: string; + bannerClosed: boolean; + closeBanner(): void; +} + const Banner = React.memo( - ({ text, title, theme, bannerClosed, closeBanner }) => { + ({ text, title, theme, bannerClosed, closeBanner }: IRoomBannerProps) => { const [showModal, openModal] = useState(false); const toggleModal = () => openModal(prevState => !prevState); @@ -22,6 +29,7 @@ const Banner = React.memo( style={[styles.bannerContainer, { backgroundColor: themes[theme].bannerBackground }]} testID='room-view-banner' onPress={toggleModal}> + {/* @ts-ignore*/} @@ -37,6 +45,7 @@ const Banner = React.memo( {title} + {/* @ts-ignore*/} @@ -51,12 +60,4 @@ const Banner = React.memo( prevProps.text === nextProps.text && prevProps.theme === nextProps.theme && prevProps.bannerClosed === nextProps.bannerClosed ); -Banner.propTypes = { - text: PropTypes.string, - title: PropTypes.string, - theme: PropTypes.string, - bannerClosed: PropTypes.bool, - closeBanner: PropTypes.func -}; - export default Banner; diff --git a/app/views/RoomView/EmptyRoom.js b/app/views/RoomView/EmptyRoom.tsx similarity index 61% rename from app/views/RoomView/EmptyRoom.js rename to app/views/RoomView/EmptyRoom.tsx index 1a9a248f2..69b3a3a04 100644 --- a/app/views/RoomView/EmptyRoom.js +++ b/app/views/RoomView/EmptyRoom.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { ImageBackground, StyleSheet } from 'react-native'; -import PropTypes from 'prop-types'; const styles = StyleSheet.create({ image: { @@ -10,17 +9,18 @@ const styles = StyleSheet.create({ } }); -const EmptyRoom = React.memo(({ length, mounted, theme, rid }) => { +interface IEmptyRoomProps { + length: number; + mounted: boolean; + theme: string; + rid: string; +} + +const EmptyRoom = React.memo(({ length, mounted, theme, rid }: IEmptyRoomProps) => { if ((length === 0 && mounted) || !rid) { return ; } return null; }); -EmptyRoom.propTypes = { - length: PropTypes.number.isRequired, - mounted: PropTypes.bool, - theme: PropTypes.string, - rid: PropTypes.string -}; export default EmptyRoom; diff --git a/app/views/RoomView/styles.js b/app/views/RoomView/styles.ts similarity index 100% rename from app/views/RoomView/styles.js rename to app/views/RoomView/styles.ts