Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(TS) Convert some native components to TS (#13203)

Robert Pintilii13e818e1353d
diff --git a/react/features/base/icons/components/Icon.tsx b/react/features/base/icons/components/Icon.tsx
index cfea344695..fc696d1f00 100644
--- a/react/features/base/icons/components/Icon.tsx
+++ b/react/features/base/icons/components/Icon.tsx
@@ -3,7 +3,9 @@ import React, { useCallback } from 'react';
import { Container } from '../../react/components/index';
import { StyleType, styleTypeToObject } from '../../styles/functions';
-interface IProps {
+import { IIconProps } from './types';
+
+interface IProps extends IIconProps {
/**
* The id of the element this button icon controls.
@@ -60,11 +62,6 @@ interface IProps {
*/
id?: string;
- /**
- * Function to invoke on click.
- */
- onClick?: Function;
-
/**
* Keydown handler.
*/
diff --git a/react/features/base/icons/components/types.native.ts b/react/features/base/icons/components/types.native.ts
new file mode 100644
index 0000000000..9e3cf86925
--- /dev/null
+++ b/react/features/base/icons/components/types.native.ts
@@ -0,0 +1,5 @@
+import { GestureResponderEvent } from 'react-native';
+
+export interface IIconProps {
+ onClick?: (e?: GestureResponderEvent) => void;
+}
diff --git a/react/features/base/icons/components/types.web.ts b/react/features/base/icons/components/types.web.ts
new file mode 100644
index 0000000000..1646deecfa
--- /dev/null
+++ b/react/features/base/icons/components/types.web.ts
@@ -0,0 +1,5 @@
+import React from 'react';
+
+export interface IIconProps {
+ onClick?: (e?: React.MouseEvent) => void;
+}
diff --git a/react/features/base/react/components/AbstractContainer.ts b/react/features/base/react/components/AbstractContainer.ts
index 7dc1aba898..815cf80074 100644
--- a/react/features/base/react/components/AbstractContainer.ts
+++ b/react/features/base/react/components/AbstractContainer.ts
@@ -1,4 +1,4 @@
-import React, { Component, ReactNode } from 'react';
+import React, { Component, ComponentType, ReactNode } from 'react';
import { StyleType, getFixedPlatformStyle } from '../../styles/functions';
@@ -27,6 +27,8 @@ export interface IProps {
*/
className?: string;
+ id?: string;
+
/**
* The event handler/listener to be invoked when this
* {@code AbstractContainer} is clicked on Web or pressed on React
@@ -36,12 +38,20 @@ export interface IProps {
*/
onClick?: Function;
+ onKeyDown?: Function;
+
+ onKeyPress?: Function;
+
+ role?: string;
+
/**
* The style (as in stylesheet) to be applied to this
* {@code AbstractContainer}.
*/
style?: StyleType;
+ tabIndex?: number;
+
/**
* If this instance is to provide visual feedback when touched, then
* {@code true}; otherwise, {@code false}. If {@code touchFeedback} is
@@ -82,7 +92,7 @@ export default class AbstractContainer<P extends IProps> extends Component<P> {
* @protected
* @returns {ReactElement}
*/
- _render(type: string, props?: P) {
+ _render(type: string | ComponentType<any>, props?: P) {
const {
children,
style,
diff --git a/react/features/base/react/components/AbstractPage.ts b/react/features/base/react/components/AbstractPage.ts
index 279c968804..038a0de71c 100644
--- a/react/features/base/react/components/AbstractPage.ts
+++ b/react/features/base/react/components/AbstractPage.ts
@@ -12,9 +12,11 @@ export default class AbstractPage<P> extends Component<P> {
* Note: It is a static method as the {@code Component} may not be
* initialized yet when the UI invokes refresh (e.g. Tab change).
*
+ * @param {any} _p1 - Param 1.
+ * @param {any} _p2 - Param 2.
* @returns {void}
*/
- static refresh() {
+ static refresh(_p1?: any, _p2?: any) {
// No implementation in abstract class.
}
}
diff --git a/react/features/base/react/components/native/AvatarListItem.js b/react/features/base/react/components/native/AvatarListItem.tsx
similarity index 79%
rename from react/features/base/react/components/native/AvatarListItem.js
rename to react/features/base/react/components/native/AvatarListItem.tsx
index c451c32323..e48f5fde91 100644
--- a/react/features/base/react/components/native/AvatarListItem.js
+++ b/react/features/base/react/components/native/AvatarListItem.tsx
@@ -1,83 +1,81 @@
-// @flow
-
import React, { Component } from 'react';
-import { Text } from 'react-native';
+import { GestureResponderEvent, Text, TextStyle } from 'react-native';
import Avatar from '../../../avatar/components/Avatar';
-import { StyleType } from '../../../styles';
+import { StyleType } from '../../../styles/functions.native';
import { Item } from '../../types';
import Container from './Container';
import styles, { AVATAR_SIZE, UNDERLAY_COLOR } from './styles';
-type Props = {
+interface IProps {
/**
* If true, only the avatar gets rendered, no lines of text.
*/
- avatarOnly?: boolean,
+ avatarOnly?: boolean;
/**
* Preferred size of the avatar.
*/
- avatarSize?: number,
+ avatarSize?: number;
/**
* One of the expected status strings (e.g. 'available') to render a badge on the avatar, if necessary.
*/
- avatarStatus?: ?string,
+ avatarStatus?: string;
/**
* External style to be applied to the avatar (icon).
*/
- avatarStyle?: StyleType,
+ avatarStyle?: StyleType;
/**
* External style to be applied to the avatar (text).
*/
- avatarTextStyle?: StyleType,
+ avatarTextStyle?: StyleType;
/**
* Children of the component.
*/
- children?: React$Node,
+ children?: React.ReactNode;
/**
* Item containing data to be rendered.
*/
- item: Item,
+ item: Item;
/**
* External style prop to be applied to the extra lines.
*/
- linesStyle?: StyleType,
+ linesStyle?: StyleType;
/**
* Function to invoke on long press.
*/
- onLongPress: ?Function,
+ onLongPress?: (e: GestureResponderEvent) => void;
/**
* Function to invoke on press.
*/
- onPress: ?Function,
+ onPress?: (e: GestureResponderEvent) => void;
/**
* External style prop to be applied to the title.
*/
- titleStyle?: StyleType
-};
+ titleStyle?: StyleType;
+}
/**
* Implements a list item with an avatar rendered for it.
*/
-export default class AvatarListItem extends Component<Props> {
+export default class AvatarListItem extends Component<IProps> {
/**
* Constructor of the component.
*
* @inheritdoc
*/
- constructor(props: Props) {
+ constructor(props: IProps) {
super(props);
this._renderItemLine = this._renderItemLine.bind(this);
@@ -93,7 +91,6 @@ export default class AvatarListItem extends Component<Props> {
avatarOnly,
avatarSize = AVATAR_SIZE,
avatarStatus,
- avatarStyle,
onLongPress,
onPress
} = this.props;
@@ -110,14 +107,13 @@ export default class AvatarListItem extends Component<Props> {
displayName = { title }
size = { avatarSize }
status = { avatarStatus }
- style = { avatarStyle }
url = { avatar } />
{ avatarOnly || <Container style = { styles.listItemDetails }>
<Text
numberOfLines = { 1 }
style = { [
styles.listItemText,
- styles.listItemTitle,
+ styles.listItemTitle as TextStyle,
this.props.titleStyle
] }>
{ title }
@@ -129,8 +125,6 @@ export default class AvatarListItem extends Component<Props> {
);
}
- _renderItemLine: (string, number) => React$Node;
-
/**
* Renders a single line from the additional lines.
*
@@ -139,7 +133,7 @@ export default class AvatarListItem extends Component<Props> {
* @private
* @returns {React$Node}
*/
- _renderItemLine(line, index) {
+ _renderItemLine(line: string, index: number) {
if (!line) {
return null;
}
@@ -157,8 +151,6 @@ export default class AvatarListItem extends Component<Props> {
);
}
- _renderItemLines: Array<string> => Array<React$Node>;
-
/**
* Renders the additional item lines, if any.
*
@@ -166,7 +158,7 @@ export default class AvatarListItem extends Component<Props> {
* @private
* @returns {Array<React$Node>}
*/
- _renderItemLines(lines) {
- return lines && lines.length ? lines.map(this._renderItemLine) : null;
+ _renderItemLines(lines?: string[]) {
+ return lines?.length ? lines.map(this._renderItemLine) : null;
}
}
diff --git a/react/features/base/react/components/native/Container.js b/react/features/base/react/components/native/Container.tsx
similarity index 84%
rename from react/features/base/react/components/native/Container.js
rename to react/features/base/react/components/native/Container.tsx
index 8e098c9a5b..51855e8bf2 100644
--- a/react/features/base/react/components/native/Container.js
+++ b/react/features/base/react/components/native/Container.tsx
@@ -1,30 +1,32 @@
-// @flow
-
import React from 'react';
import {
+ GestureResponderEvent,
TouchableHighlight,
TouchableWithoutFeedback,
View
} from 'react-native';
-import AbstractContainer from '../AbstractContainer';
-import type { Props as AbstractProps } from '../AbstractContainer';
+import AbstractContainer, { IProps as AbstractProps } from '../AbstractContainer';
+
+interface IProps extends AbstractProps {
-type Props = AbstractProps & {
+ onClick?: (e: GestureResponderEvent) => void;
/**
* The event handler/listener to be invoked when this
* {@code AbstractContainer} is long pressed on React Native.
*/
- onLongPress?: ?Function,
-};
+ onLongPress?: (e: GestureResponderEvent) => void;
+
+ pointerEvents?: string;
+}
/**
* Represents a container of React Native/mobile {@link Component} children.
*
* @augments AbstractContainer
*/
-export default class Container<P: Props> extends AbstractContainer<P> {
+export default class Container extends AbstractContainer<IProps> {
/**
* Implements React's {@link Component#render()}.
*
@@ -40,8 +42,6 @@ export default class Container<P: Props> extends AbstractContainer<P> {
touchFeedback = Boolean(onClick || onLongPress),
underlayColor,
visible = true,
-
- // $FlowExpectedError
...props
} = this.props;
diff --git a/react/features/base/react/components/native/LoadingIndicator.js b/react/features/base/react/components/native/LoadingIndicator.tsx
similarity index 86%
rename from react/features/base/react/components/native/LoadingIndicator.js
rename to react/features/base/react/components/native/LoadingIndicator.tsx
index ca35f28bb6..226966a528 100644
--- a/react/features/base/react/components/native/LoadingIndicator.js
+++ b/react/features/base/react/components/native/LoadingIndicator.tsx
@@ -1,30 +1,28 @@
-/* @flow */
-
import React, { PureComponent } from 'react';
import { ActivityIndicator } from 'react-native';
import { ColorPalette } from '../../../styles/components/styles/ColorPalette';
-type Props = {|
+interface IProps {
/**
* The color of the spinner.
*/
- color: ?string,
+ color?: string;
/**
* Prop to set the size of the indicator. This is the same as the
* prop of the native component.
*/
- size: 'large' | 'small'
-|};
+ size?: 'large' | 'small' | 'medium';
+}
/**
* An animated, large react-native {@link ActivityIndicator} which is considered
* a suitable visualization of long-running processes with indeterminate amounts
* of work to be done.
*/
-export default class LoadingIndicator extends PureComponent<Props> {
+export default class LoadingIndicator extends PureComponent<IProps> {
/**
* Implements React's {@link Component#render()}.
*
@@ -40,7 +38,6 @@ export default class LoadingIndicator extends PureComponent<Props> {
}
const props = {
- animating: true,
color,
...this.props,
size
diff --git a/react/features/base/react/components/native/NavigateSectionList.js b/react/features/base/react/components/native/NavigateSectionList.tsx
similarity index 85%
rename from react/features/base/react/components/native/NavigateSectionList.js
rename to react/features/base/react/components/native/NavigateSectionList.tsx
index 1ff24f4ef0..65883a548a 100644
--- a/react/features/base/react/components/native/NavigateSectionList.js
+++ b/react/features/base/react/components/native/NavigateSectionList.tsx
@@ -1,61 +1,59 @@
-// @flow
-
import React, { Component } from 'react';
// TODO: Maybe try to make all NavigateSectionList components to work for both
// mobile and web, and move them to NavigateSectionList component.
-import { Section } from '../../types';
+import { Item, Section, SectionListSection } from '../../types';
import NavigateSectionListEmptyComponent from './NavigateSectionListEmptyComponent';
import NavigateSectionListItem from './NavigateSectionListItem';
import NavigateSectionListSectionHeader from './NavigateSectionListSectionHeader';
import SectionList from './SectionList';
-type Props = {
+interface IProps {
/**
* Indicates if the list is disabled or not.
*/
- disabled: boolean,
+ disabled: boolean;
/**
* Function to be invoked when an item is long pressed. The item is passed.
*/
- onLongPress: Function,
+ onLongPress?: Function;
/**
* Function to be invoked when an item is pressed. The item's URL is passed.
*/
- onPress: Function,
+ onPress: (e: string, a?: string) => void;
/**
* Function to be invoked when pull-to-refresh is performed.
*/
- onRefresh: Function,
+ onRefresh: Function;
/**
* Function to be invoked when a secondary action is performed on an item.
* The item's ID is passed.
*/
- onSecondaryAction: Function,
+ onSecondaryAction: Function;
/**
* Function to override the rendered default empty list component.
*/
- renderListEmptyComponent: Function,
+ renderListEmptyComponent: React.ReactElement<any>;
/**
* An array of sections.
*/
- sections: Array<Section>
-};
+ sections: Array<Section>;
+}
/**
* Implements a general section list to display items that have a URL property
* and navigates to (probably) meetings, such as the recent list or the meeting
* list components.
*/
-class NavigateSectionList extends Component<Props> {
+class NavigateSectionList extends Component<IProps> {
/**
* Creates an empty section object.
*
@@ -64,9 +62,11 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {Object}
*/
- static createSection(title: string, key: string) {
+ static createSection(title: string, key: string | number) {
+ const data: any[] = [];
+
return {
- data: [],
+ data,
key,
title
};
@@ -77,7 +77,7 @@ class NavigateSectionList extends Component<Props> {
*
* @inheritdoc
*/
- constructor(props: Props) {
+ constructor(props: IProps) {
super(props);
this._getItemKey = this._getItemKey.bind(this);
this._onLongPress = this._onLongPress.bind(this);
@@ -105,6 +105,8 @@ class NavigateSectionList extends Component<Props> {
<SectionList
ListEmptyComponent = { renderListEmptyComponent }
keyExtractor = { this._getItemKey }
+
+ // @ts-ignore
onItemClick = { this.props.onPress }
onRefresh = { this._onRefresh }
refreshing = { false }
@@ -114,8 +116,6 @@ class NavigateSectionList extends Component<Props> {
);
}
- _getItemKey: (Object, number) => string;
-
/**
* Generates a unique id to every item.
*
@@ -124,12 +124,10 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {string}
*/
- _getItemKey(item, index) {
+ _getItemKey(item: Item, index: number) {
return `${index}-${item.key}`;
}
- _onLongPress: string => Function;
-
/**
* Returns a function that is used in the onLongPress callback of the items.
*
@@ -137,18 +135,16 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {Function}
*/
- _onLongPress(item) {
+ _onLongPress(item: Item) {
const { disabled, onLongPress } = this.props;
if (!disabled && typeof onLongPress === 'function') {
return () => onLongPress(item);
}
- return null;
+ return;
}
- _onPress: string => Function;
-
/**
* Returns a function that is used in the onPress callback of the items.
*
@@ -156,18 +152,16 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {Function}
*/
- _onPress(url) {
+ _onPress(url: string) {
const { disabled, onPress } = this.props;
if (!disabled && url && typeof onPress === 'function') {
return () => onPress(url);
}
- return null;
+ return;
}
- _onRefresh: () => void;
-
/**
* Invokes the onRefresh callback if present.
*
@@ -182,8 +176,6 @@ class NavigateSectionList extends Component<Props> {
}
}
- _onSecondaryAction: Object => Function;
-
/**
* Returns a function that is used in the secondaryAction callback of the
* items.
@@ -193,14 +185,12 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {Function}
*/
- _onSecondaryAction(id) {
+ _onSecondaryAction(id: string) {
return () => {
this.props.onSecondaryAction(id);
};
}
- _renderItem: Object => Object;
-
/**
* Renders a single item in the list.
*
@@ -209,7 +199,7 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {Component}
*/
- _renderItem(listItem, key: string = '') {
+ _renderItem(listItem: { item: Item; }, key = '') {
const { item } = listItem;
const { id, url } = item;
@@ -219,7 +209,7 @@ class NavigateSectionList extends Component<Props> {
// execution of incorrect source code, it is undesirable to break the
// whole app because of an undefined string.
if (typeof item.title === 'undefined') {
- return null;
+ return <></>;
}
return (
@@ -233,8 +223,6 @@ class NavigateSectionList extends Component<Props> {
);
}
- _renderListEmptyComponent: () => Object;
-
/**
* Renders a component to display when the list is empty.
*
@@ -242,7 +230,7 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {React$Node}
*/
- _renderListEmptyComponent() {
+ _renderListEmptyComponent(): React.ReactElement<any> {
const { onRefresh } = this.props;
if (typeof onRefresh === 'function') {
@@ -251,11 +239,9 @@ class NavigateSectionList extends Component<Props> {
);
}
- return null;
+ return <></>;
}
- _renderSectionHeader: Object => Object;
-
/**
* Renders a section header.
*
@@ -263,7 +249,7 @@ class NavigateSectionList extends Component<Props> {
* @private
* @returns {React$Node}
*/
- _renderSectionHeader(section) {
+ _renderSectionHeader(section: SectionListSection) {
return (
<NavigateSectionListSectionHeader
section = { section } />
diff --git a/react/features/base/react/components/native/NavigateSectionListEmptyComponent.js b/react/features/base/react/components/native/NavigateSectionListEmptyComponent.tsx
similarity index 78%
rename from react/features/base/react/components/native/NavigateSectionListEmptyComponent.js
rename to react/features/base/react/components/native/NavigateSectionListEmptyComponent.tsx
index 83f888fa85..dc6def444c 100644
--- a/react/features/base/react/components/native/NavigateSectionListEmptyComponent.js
+++ b/react/features/base/react/components/native/NavigateSectionListEmptyComponent.tsx
@@ -1,7 +1,6 @@
-// @flow
-
import React, { Component } from 'react';
-import { Text, View } from 'react-native';
+import { WithTranslation } from 'react-i18next';
+import { Text, View, ViewStyle } from 'react-native';
import { translate } from '../../../i18n/functions';
import Icon from '../../../icons/components/Icon';
@@ -9,21 +8,13 @@ import { IconArrowDown } from '../../../icons/svg';
import styles from './styles';
-type Props = {
-
- /**
- * The translate function.
- */
- t: Function,
-};
-
/**
* Implements a React Native {@link Component} that is to be displayed when the
* list is empty.
*
* @augments Component
*/
-class NavigateSectionListEmptyComponent extends Component<Props> {
+class NavigateSectionListEmptyComponent extends Component<WithTranslation> {
/**
* Implements React's {@link Component#render()}.
*
@@ -34,7 +25,7 @@ class NavigateSectionListEmptyComponent extends Component<Props> {
const { t } = this.props;
return (
- <View style = { styles.pullToRefresh }>
+ <View style = { styles.pullToRefresh as ViewStyle }>
<Text style = { styles.pullToRefreshText }>
{ t('sectionList.pullToRefresh') }
</Text>
diff --git a/react/features/base/react/components/native/NavigateSectionListItem.js b/react/features/base/react/components/native/NavigateSectionListItem.tsx
similarity index 83%
rename from react/features/base/react/components/native/NavigateSectionListItem.js
rename to react/features/base/react/components/native/NavigateSectionListItem.tsx
index 930120c6fa..0ac01469f0 100644
--- a/react/features/base/react/components/native/NavigateSectionListItem.js
+++ b/react/features/base/react/components/native/NavigateSectionListItem.tsx
@@ -1,6 +1,5 @@
-// @flow
-
import React, { Component } from 'react';
+import { GestureResponderEvent } from 'react-native';
import { IconPlus } from '../../../icons/svg';
import IconButton from '../../../ui/components/native/IconButton';
@@ -11,27 +10,27 @@ import AvatarListItem from './AvatarListItem';
import Text from './Text';
import styles from './styles';
-type Props = {
+interface IProps {
/**
* Item containing data to be rendered.
*/
- item: Item,
+ item: Item;
/**
* Function to be invoked when an item is long pressed. The item is passed.
*/
- onLongPress: ?Function,
+ onLongPress?: (e?: GestureResponderEvent) => void;
/**
* Function to be invoked when an Item is pressed. The Item's URL is passed.
*/
- onPress: ?Function,
+ onPress?: (e?: GestureResponderEvent) => void;
/**
* Function to be invoked when secondary action was performed on an Item.
*/
- secondaryAction: ?Function
+ secondaryAction?: (e?: GestureResponderEvent) => void;
}
/**
@@ -40,21 +39,19 @@ type Props = {
*
* @augments Component
*/
-export default class NavigateSectionListItem extends Component<Props> {
+export default class NavigateSectionListItem extends Component<IProps> {
/**
* Constructor of the NavigateSectionList component.
*
* @inheritdoc
*/
- constructor(props: Props) {
+ constructor(props: IProps) {
super(props);
this._renderItemLine = this._renderItemLine.bind(this);
this._renderItemLines = this._renderItemLines.bind(this);
}
- _renderItemLine: (string, number) => React$Node;
-
/**
* Renders a single line from the additional lines.
*
@@ -63,7 +60,7 @@ export default class NavigateSectionListItem extends Component<Props> {
* @private
* @returns {React$Node}
*/
- _renderItemLine(line, index) {
+ _renderItemLine(line: string, index: number) {
if (!line) {
return null;
}
@@ -78,8 +75,6 @@ export default class NavigateSectionListItem extends Component<Props> {
);
}
- _renderItemLines: Array<string> => Array<React$Node>;
-
/**
* Renders the additional item lines, if any.
*
@@ -87,8 +82,8 @@ export default class NavigateSectionListItem extends Component<Props> {
* @private
* @returns {Array<React$Node>}
*/
- _renderItemLines(lines) {
- return lines && lines.length ? lines.map(this._renderItemLine) : null;
+ _renderItemLines(lines?: string[]) {
+ return lines?.length ? lines.map(this._renderItemLine) : null;
}
/**
diff --git a/react/features/base/react/components/native/NavigateSectionListSectionHeader.js b/react/features/base/react/components/native/NavigateSectionListSectionHeader.tsx
similarity index 81%
rename from react/features/base/react/components/native/NavigateSectionListSectionHeader.js
rename to react/features/base/react/components/native/NavigateSectionListSectionHeader.tsx
index 7fdd955aac..b25d49a489 100644
--- a/react/features/base/react/components/native/NavigateSectionListSectionHeader.js
+++ b/react/features/base/react/components/native/NavigateSectionListSectionHeader.tsx
@@ -1,6 +1,5 @@
-// @flow
-
import React, { Component } from 'react';
+import { TextStyle } from 'react-native';
import { SectionListSection } from '../../types';
@@ -8,12 +7,12 @@ import Container from './Container';
import Text from './Text';
import styles from './styles';
-type Props = {
+interface IProps {
/**
* A section containing the data to be rendered.
*/
- section: SectionListSection
+ section: SectionListSection;
}
/**
@@ -22,7 +21,7 @@ type Props = {
*
* @augments Component
*/
-export default class NavigateSectionListSectionHeader extends Component<Props> {
+export default class NavigateSectionListSectionHeader extends Component<IProps> {
/**
* Renders the content of this component.
*
@@ -33,7 +32,7 @@ export default class NavigateSectionListSectionHeader extends Component<Props> {
return (
<Container style = { styles.listSection }>
- <Text style = { styles.listSectionText }>
+ <Text style = { styles.listSectionText as TextStyle }>
{ section.title }
</Text>
</Container>
diff --git a/react/features/base/react/components/native/SectionList.js b/react/features/base/react/components/native/SectionList.tsx
similarity index 78%
rename from react/features/base/react/components/native/SectionList.js
rename to react/features/base/react/components/native/SectionList.tsx
index d046471e0a..2af515e593 100644
--- a/react/features/base/react/components/native/SectionList.js
+++ b/react/features/base/react/components/native/SectionList.tsx
@@ -1,63 +1,63 @@
-// @flow
-
import React, { Component } from 'react';
import {
SectionList as ReactNativeSectionList,
- SafeAreaView
+ SafeAreaView,
+ SectionListRenderItemInfo,
+ ViewStyle
} from 'react-native';
-import { Section } from '../../types';
+import { Item, Section } from '../../types';
import styles from './styles';
/**
* The type of the React {@code Component} props of {@link SectionList}.
*/
-type Props = {
+interface IProps {
/**
* Rendered when the list is empty. Can be a React Component Class, a render
* function, or a rendered element.
*/
- ListEmptyComponent: Object,
+ ListEmptyComponent: React.ReactElement<any>;
/**
*
* Used to extract a unique key for a given item at the specified index.
* Key is used for caching and as the react key to track item re-ordering.
*/
- keyExtractor: Function,
+ keyExtractor: (item: Item, index: number) => string;
/**
*
* Functions that defines what happens when the list is pulled for refresh.
*/
- onRefresh: Function,
+ onRefresh: () => void;
/**
*
* A boolean that is set true while waiting for new data from a refresh.
*/
- refreshing: ?boolean,
+ refreshing?: boolean;
/**
*
* Default renderer for every item in every section.
*/
- renderItem: Function,
+ renderItem: (info: SectionListRenderItemInfo<Item, Section>) => React.ReactElement<any>;
/**
*
* A component rendered at the top of each section. These stick to the top
* of the ScrollView by default on iOS.
*/
- renderSectionHeader: Object,
+ renderSectionHeader: any;
/**
* An array of sections.
*/
- sections: Array<Section>
-};
+ sections: Array<Section>;
+}
/**
* Implements a React Native {@link Component} that wraps the React Native
@@ -66,7 +66,7 @@ type Props = {
*
* @augments Component
*/
-export default class SectionList extends Component<Props> {
+export default class SectionList extends Component<IProps> {
/**
* Implements React's {@link Component#render()}.
*
@@ -85,7 +85,7 @@ export default class SectionList extends Component<Props> {
renderItem = { this.props.renderItem }
renderSectionHeader = { this.props.renderSectionHeader }
sections = { this.props.sections }
- style = { styles.list } />
+ style = { styles.list as ViewStyle } />
</SafeAreaView>
);
}
diff --git a/react/features/base/react/components/native/Text.js b/react/features/base/react/components/native/Text.ts
similarity index 100%
rename from react/features/base/react/components/native/Text.js
rename to react/features/base/react/components/native/Text.ts
diff --git a/react/features/base/react/components/native/styles.js b/react/features/base/react/components/native/styles.ts
similarity index 99%
rename from react/features/base/react/components/native/styles.js
rename to react/features/base/react/components/native/styles.ts
index 3c0ff14f5e..8eb22e9bff 100644
--- a/react/features/base/react/components/native/styles.js
+++ b/react/features/base/react/components/native/styles.ts
@@ -1,5 +1,3 @@
-// @flow
-
import BaseTheme from '../../../ui/components/BaseTheme.native';
const OVERLAY_FONT_COLOR = 'rgba(255, 255, 255, 0.6)';
diff --git a/react/features/base/react/components/web/MeetingsList.tsx b/react/features/base/react/components/web/MeetingsList.tsx
index 5100fcde88..5e388f1d8b 100644
--- a/react/features/base/react/components/web/MeetingsList.tsx
+++ b/react/features/base/react/components/web/MeetingsList.tsx
@@ -174,8 +174,8 @@ class MeetingsList extends Component<IProps> {
_onDelete(item: Object) {
const { onItemDelete } = this.props;
- return (evt: React.MouseEvent) => {
- evt.stopPropagation();
+ return (evt?: React.MouseEvent) => {
+ evt?.stopPropagation();
onItemDelete?.(item);
};
diff --git a/react/features/base/react/types.ts b/react/features/base/react/types.ts
index 84cc8ee7da..301c7de474 100644
--- a/react/features/base/react/types.ts
+++ b/react/features/base/react/types.ts
@@ -36,7 +36,9 @@ export type Item = {
/**
* Unique ID of the item.
*/
- id: Object | string;
+ id: string;
+
+ key?: string;
/**
* Lines[0] - date
diff --git a/react/features/base/styles/functions.any.ts b/react/features/base/styles/functions.any.ts
index f44ebbc2c8..05910aab35 100644
--- a/react/features/base/styles/functions.any.ts
+++ b/react/features/base/styles/functions.any.ts
@@ -3,7 +3,7 @@ import Platform from '../react/Platform';
import { ColorPalette } from './components/styles/ColorPalette';
declare type StyleSheet = {
- [key: string]: string | number;
+ [key: string]: string | number | { [key: string]: string | number; };
};
export type StyleType = StyleSheet | Array<StyleSheet>;
@@ -46,7 +46,7 @@ const _WELL_KNOWN_NUMBER_PROPERTIES = [ 'height', 'width' ];
* @param {Styletype} st - The complex style type.
* @returns {Object}
*/
-export function styleTypeToObject(st: StyleType): { [key: string]: string | number; } {
+export function styleTypeToObject(st: StyleType) {
if (!st) {
return {};
}
diff --git a/react/features/base/ui/components/native/Input.tsx b/react/features/base/ui/components/native/Input.tsx
index 22d69a8e61..d569225f09 100644
--- a/react/features/base/ui/components/native/Input.tsx
+++ b/react/features/base/ui/components/native/Input.tsx
@@ -47,7 +47,7 @@ interface ICustomStyles {
input?: Object;
}
-const Input = forwardRef<TextInput, IInputProps>(({
+const Input = forwardRef<TextInput, IProps>(({
accessibilityLabel,
autoCapitalize,
autoFocus,
diff --git a/react/features/calendar-sync/components/CalendarList.native.js b/react/features/calendar-sync/components/CalendarList.native.tsx
similarity index 78%
rename from react/features/calendar-sync/components/CalendarList.native.js
rename to react/features/calendar-sync/components/CalendarList.native.tsx
index 0c3097c57f..9a66919f53 100644
--- a/react/features/calendar-sync/components/CalendarList.native.js
+++ b/react/features/calendar-sync/components/CalendarList.native.tsx
@@ -1,52 +1,48 @@
-// @flow
-
import React from 'react';
+import { WithTranslation } from 'react-i18next';
import {
Text,
TouchableOpacity,
- View
+ View,
+ ViewStyle
} from 'react-native';
import { connect } from 'react-redux';
+import { IReduxState, IStore } from '../../app/types';
import { translate } from '../../base/i18n/functions';
import AbstractPage from '../../base/react/components/AbstractPage';
import { openSettings } from '../../mobile/permissions/functions';
-import { refreshCalendar } from '../actions';
+import { refreshCalendar } from '../actions.native';
-import CalendarListContent from './CalendarListContent';
+import CalendarListContent from './CalendarListContent.native';
import styles from './styles';
/**
* The tyoe of the React {@code Component} props of {@link CalendarList}.
*/
-type Props = {
+interface IProps extends WithTranslation {
/**
* The current state of the calendar access permission.
*/
- _authorization: ?string,
+ _authorization?: string;
/**
* Indicates if the list is disabled or not.
*/
- disabled: boolean,
-
- /**
- * The translate function.
- */
- t: Function
-};
+ disabled: boolean;
+}
/**
* Component to display a list of events from the (mobile) user's calendar.
*/
-class CalendarList extends AbstractPage<Props> {
+class CalendarList extends AbstractPage<IProps> {
/**
* Initializes a new {@code CalendarList} instance.
*
* @inheritdoc
*/
- constructor(props) {
+ constructor(props: IProps) {
super(props);
// Bind event handlers so they are only bound once per instance.
@@ -65,7 +61,7 @@ class CalendarList extends AbstractPage<Props> {
* @public
* @returns {void}
*/
- static refresh(dispatch, isInteractive) {
+ static refresh(dispatch: IStore['dispatch'], isInteractive: boolean) {
dispatch(refreshCalendar(false, isInteractive));
}
@@ -81,9 +77,9 @@ class CalendarList extends AbstractPage<Props> {
CalendarListContent
? <View
style = {
- disabled
+ (disabled
? styles.calendarSyncDisabled
- : styles.calendarSync }>
+ : styles.calendarSync) as ViewStyle }>
<CalendarListContent
disabled = { disabled }
listEmptyComponent
@@ -93,8 +89,6 @@ class CalendarList extends AbstractPage<Props> {
);
}
- _getRenderListEmptyComponent: () => Object;
-
/**
* Returns a list empty component if a custom one has to be rendered instead
* of the default one in the {@link NavigateSectionList}.
@@ -109,18 +103,18 @@ class CalendarList extends AbstractPage<Props> {
// the default empty component of the NavigateSectionList will be
// rendered, which (atm) is a simple "Pull to refresh" message.
if (_authorization !== 'denied') {
- return undefined;
+ return <></>;
}
return (
- <View style = { styles.noPermissionMessageView }>
- <Text style = { styles.noPermissionMessageText }>
+ <View style = { styles.noPermissionMessageView as ViewStyle }>
+ <Text style = { styles.noPermissionMessageText as ViewStyle }>
{ t('calendarSync.permissionMessage') }
</Text>
<TouchableOpacity
onPress = { openSettings }
- style = { styles.noPermissionMessageButton } >
- <Text style = { styles.noPermissionMessageButtonText }>
+ style = { styles.noPermissionMessageButton as ViewStyle } >
+ <Text style = { styles.noPermissionMessageButtonText as ViewStyle }>
{ t('calendarSync.permissionButton') }
</Text>
</TouchableOpacity>
@@ -138,7 +132,7 @@ class CalendarList extends AbstractPage<Props> {
* _eventList: Array<Object>
* }}
*/
-function _mapStateToProps(state: Object) {
+function _mapStateToProps(state: IReduxState) {
const { authorization } = state['features/calendar-sync'];
return {
diff --git a/react/features/calendar-sync/components/CalendarListContent.native.js b/react/features/calendar-sync/components/CalendarListContent.native.tsx
similarity index 85%
rename from react/features/calendar-sync/components/CalendarListContent.native.js
rename to react/features/calendar-sync/components/CalendarListContent.native.tsx
index 595a6034c1..a942c09b1a 100644
--- a/react/features/calendar-sync/components/CalendarListContent.native.js
+++ b/react/features/calendar-sync/components/CalendarListContent.native.tsx
@@ -1,52 +1,48 @@
-// @flow
-
import React, { Component } from 'react';
+import { WithTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { createCalendarClickedEvent, createCalendarSelectedEvent } from '../../analytics/AnalyticsEvents';
import { sendAnalytics } from '../../analytics/functions';
-import { appNavigate } from '../../app/actions';
-import { getLocalizedDateFormatter, translate } from '../../base/i18n/functions';
+import { appNavigate } from '../../app/actions.native';
+import { IReduxState } from '../../app/types';
+import { getLocalizedDateFormatter } from '../../base/i18n/dateUtil';
+import { translate } from '../../base/i18n/functions';
import NavigateSectionList from '../../base/react/components/native/NavigateSectionList';
-import { openUpdateCalendarEventDialog, refreshCalendar } from '../actions';
+import { openUpdateCalendarEventDialog, refreshCalendar } from '../actions.native';
/**
* The type of the React {@code Component} props of
* {@link CalendarListContent}.
*/
-type Props = {
+interface IProps extends WithTranslation {
/**
* The calendar event list.
*/
- _eventList: Array<Object>,
+ _eventList: Array<any>;
/**
* Indicates if the list is disabled or not.
*/
- disabled: boolean,
+ disabled: boolean;
/**
* The Redux dispatch function.
*/
- dispatch: Function,
+ dispatch: Function;
/**
*
*/
- listEmptyComponent: React$Node,
-
- /**
- * The translate function.
- */
- t: Function
-};
+ listEmptyComponent: React.ReactElement<any>;
+}
/**
* Component to display a list of events from a connected calendar.
*/
-class CalendarListContent extends Component<Props> {
+class CalendarListContent extends Component<IProps> {
/**
* Default values for the component's props.
*/
@@ -59,7 +55,7 @@ class CalendarListContent extends Component<Props> {
*
* @inheritdoc
*/
- constructor(props) {
+ constructor(props: IProps) {
super(props);
// Bind event handlers so they are only bound once per instance.
@@ -103,8 +99,6 @@ class CalendarListContent extends Component<Props> {
);
}
- _onPress: (string, ?string) => void;
-
/**
* Handles the list's navigate action.
*
@@ -114,14 +108,12 @@ class CalendarListContent extends Component<Props> {
* associated with this action.
* @returns {void}
*/
- _onPress(url, analyticsEventName = 'meeting.tile') {
+ _onPress(url: string, analyticsEventName = 'meeting.tile') {
sendAnalytics(createCalendarClickedEvent(analyticsEventName));
this.props.dispatch(appNavigate(url));
}
- _onRefresh: () => void;
-
/**
* Callback to execute when the list is doing a pull-to-refresh.
*
@@ -132,8 +124,6 @@ class CalendarListContent extends Component<Props> {
this.props.dispatch(refreshCalendar(true));
}
- _onSecondaryAction: string => void;
-
/**
* Handles the list's secondary action.
*
@@ -142,12 +132,10 @@ class CalendarListContent extends Component<Props> {
* performed.
* @returns {void}
*/
- _onSecondaryAction(id) {
- this.props.dispatch(openUpdateCalendarEventDialog(id, ''));
+ _onSecondaryAction(id: string) {
+ this.props.dispatch(openUpdateCalendarEventDialog(id));
}
- _toDateString: Object => string;
-
/**
* Generates a date string for a given event.
*
@@ -155,15 +143,13 @@ class CalendarListContent extends Component<Props> {
* @private
* @returns {string}
*/
- _toDateString(event) {
+ _toDateString(event: any) {
const startDateTime
= getLocalizedDateFormatter(event.startDate).format('MMM Do, YYYY');
return `${startDateTime}`;
}
- _toDisplayableItem: Object => Object;
-
/**
* Creates a displayable object from an event.
*
@@ -171,7 +157,7 @@ class CalendarListContent extends Component<Props> {
* @private
* @returns {Object}
*/
- _toDisplayableItem(event) {
+ _toDisplayableItem(event: any) {
return {
id: event.id,
key: `${event.id}-${event.startDate}`,
@@ -184,8 +170,6 @@ class CalendarListContent extends Component<Props> {
};
}
- _toDisplayableList: () => Array<Object>;
-
/**
* Transforms the event list to a displayable list with sections.
*
@@ -233,8 +217,6 @@ class CalendarListContent extends Component<Props> {
return Array.from(sectionMap.values());
}
- _toTimeString: Object => string;
-
/**
* Generates a time (interval) string for a given event.
*
@@ -242,7 +224,7 @@ class CalendarListContent extends Component<Props> {
* @private
* @returns {string}
*/
- _toTimeString(event) {
+ _toTimeString(event: any) {
const startDateTime
= getLocalizedDateFormatter(event.startDate).format('lll');
const endTime
@@ -256,9 +238,9 @@ class CalendarListContent extends Component<Props> {
* Maps redux state to component props.
*
* @param {Object} state - The redux state.
- * @returns {Props}
+ * @returns {IProps}
*/
-function _mapStateToProps(state: Object) {
+function _mapStateToProps(state: IReduxState) {
return {
_eventList: state['features/calendar-sync'].events
};
diff --git a/react/features/calendar-sync/components/styles.js b/react/features/calendar-sync/components/styles.ts
similarity index 98%
rename from react/features/calendar-sync/components/styles.js
rename to react/features/calendar-sync/components/styles.ts
index 42bd01c7f3..be730caab9 100644
--- a/react/features/calendar-sync/components/styles.js
+++ b/react/features/calendar-sync/components/styles.ts
@@ -1,6 +1,6 @@
import { ColorPalette } from '../../base/styles/components/styles/ColorPalette';
import { createStyleSheet } from '../../base/styles/functions.any';
-import BaseTheme from '../../base/ui/components/BaseTheme';
+import BaseTheme from '../../base/ui/components/BaseTheme.native';
const NOTIFICATION_SIZE = 55;
diff --git a/react/features/mobile/external-api/actions.js b/react/features/mobile/external-api/actions.ts
similarity index 98%
rename from react/features/mobile/external-api/actions.js
rename to react/features/mobile/external-api/actions.ts
index 28a76a1aff..a4fdf6d634 100644
--- a/react/features/mobile/external-api/actions.js
+++ b/react/features/mobile/external-api/actions.ts
@@ -1,5 +1,3 @@
-// @flow
-
import {
READY_TO_CLOSE,
SCREEN_SHARE_PARTICIPANTS_UPDATED
diff --git a/react/features/mobile/external-api/functions.js b/react/features/mobile/external-api/functions.ts
similarity index 92%
rename from react/features/mobile/external-api/functions.js
rename to react/features/mobile/external-api/functions.ts
index a7a3952b5c..920b4382ae 100644
--- a/react/features/mobile/external-api/functions.js
+++ b/react/features/mobile/external-api/functions.ts
@@ -1,9 +1,7 @@
-// @flow
-
import debounce from 'lodash/debounce';
import { NativeModules } from 'react-native';
-import { readyToClose } from '../external-api/actions';
+import { readyToClose } from './actions';
/**
diff --git a/react/features/mobile/navigation/components/ConnectingPage.tsx b/react/features/mobile/navigation/components/ConnectingPage.tsx
index c3d6b549ca..5abfcf3ade 100644
--- a/react/features/mobile/navigation/components/ConnectingPage.tsx
+++ b/react/features/mobile/navigation/components/ConnectingPage.tsx
@@ -2,14 +2,12 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
-import { SafeAreaView, Text, View } from 'react-native';
+import { SafeAreaView, Text, View, ViewStyle } from 'react-native';
// @ts-ignore
import JitsiScreen from '../../../base/modal/components/JitsiScreen';
-// @ts-ignore
import LoadingIndicator from '../../../base/react/components/native/LoadingIndicator';
-// @ts-ignore
import { TEXT_COLOR, navigationStyles } from './styles';
@@ -18,12 +16,11 @@ const ConnectingPage = () => {
return (
<JitsiScreen style = { navigationStyles.connectingScreenContainer }>
- <View style = { navigationStyles.connectingScreenContent }>
+ <View style = { navigationStyles.connectingScreenContent as ViewStyle }>
<SafeAreaView>
<LoadingIndicator
color = { TEXT_COLOR }
- size = 'large'
- style = { navigationStyles.connectingScreenIndicator } />
+ size = 'large' />
<Text style = { navigationStyles.connectingScreenText }>
{ t('connectingOverlay.joiningRoom') }
</Text>
diff --git a/react/features/mobile/navigation/components/HeaderNavigationButton.js b/react/features/mobile/navigation/components/HeaderNavigationButton.tsx
similarity index 88%
rename from react/features/mobile/navigation/components/HeaderNavigationButton.js
rename to react/features/mobile/navigation/components/HeaderNavigationButton.tsx
index 5724b80ba4..e1438afb39 100644
--- a/react/features/mobile/navigation/components/HeaderNavigationButton.js
+++ b/react/features/mobile/navigation/components/HeaderNavigationButton.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import { GestureResponderEvent } from 'react-native';
import Button from '../../../base/ui/components/native/Button';
import IconButton from '../../../base/ui/components/native/IconButton';
@@ -6,32 +7,32 @@ import { BUTTON_TYPES } from '../../../base/ui/constants.native';
import { navigationStyles } from './styles';
-type Props = {
+interface IProps {
/**
* Is the button disabled?
*/
- disabled?: boolean,
+ disabled?: boolean;
/**
* Label of the button.
*/
- label?: string,
+ label?: string;
/**
* Callback to invoke when the {@code HeaderNavigationButton} is clicked/pressed.
*/
- onPress?: Function,
+ onPress?: (e?: GestureResponderEvent | React.MouseEvent) => void;
/**
* The ImageSource to be rendered as image.
*/
- src?: Object,
+ src?: any;
/**
* Header has two actions.
*/
- twoActions?: boolean
+ twoActions?: boolean;
}
const HeaderNavigationButton
@@ -41,7 +42,7 @@ const HeaderNavigationButton
onPress,
src,
twoActions
- }: Props) =>
+ }: IProps) =>
(
<>
{
diff --git a/react/features/mobile/navigation/components/RootNavigationContainer.tsx b/react/features/mobile/navigation/components/RootNavigationContainer.tsx
index 604af28963..25075a7167 100644
--- a/react/features/mobile/navigation/components/RootNavigationContainer.tsx
+++ b/react/features/mobile/navigation/components/RootNavigationContainer.tsx
@@ -1,6 +1,6 @@
/* eslint-disable lines-around-comment */
-import { NavigationContainer } from '@react-navigation/native';
+import { NavigationContainer, Theme } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import React, { useCallback } from 'react';
import { StatusBar } from 'react-native';
@@ -66,7 +66,7 @@ const RootNavigationContainer = ({ dispatch, isWelcomePageAvailable }: IProps) =
independent = { true }
onReady = { onReady }
ref = { rootNavigationRef }
- theme = { navigationContainerTheme }>
+ theme = { navigationContainerTheme as Theme }>
<StatusBar
animated = { true }
backgroundColor = 'transparent'
@@ -77,7 +77,7 @@ const RootNavigationContainer = ({ dispatch, isWelcomePageAvailable }: IProps) =
{
isWelcomePageAvailable
&& <>
- <RootStack.Screen
+ <RootStack.Screen // @ts-ignore
component = { WelcomePage }
name = { screen.welcome.main }
options = { welcomeScreenOptions } />
diff --git a/react/features/mobile/navigation/components/conference/ConferenceNavigationContainerRef.js b/react/features/mobile/navigation/components/conference/ConferenceNavigationContainerRef.ts
similarity index 85%
rename from react/features/mobile/navigation/components/conference/ConferenceNavigationContainerRef.js
rename to react/features/mobile/navigation/components/conference/ConferenceNavigationContainerRef.ts
index 70a5fc047f..7aeb1dbcec 100644
--- a/react/features/mobile/navigation/components/conference/ConferenceNavigationContainerRef.js
+++ b/react/features/mobile/navigation/components/conference/ConferenceNavigationContainerRef.ts
@@ -1,6 +1,7 @@
+import { NavigationContainerRef } from '@react-navigation/native';
import React from 'react';
-export const conferenceNavigationRef = React.createRef();
+export const conferenceNavigationRef = React.createRef<NavigationContainerRef<any>>();
/**
* User defined navigation action included inside the reference to the container.
diff --git a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx
index fd62c8483c..e72cc4d76e 100644
--- a/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx
+++ b/react/features/mobile/navigation/components/conference/components/ConferenceNavigationContainer.tsx
@@ -1,6 +1,6 @@
/* eslint-disable lines-around-comment */
-import { NavigationContainer } from '@react-navigation/native';
+import { NavigationContainer, Theme } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import React from 'react';
import { useTranslation } from 'react-i18next';
@@ -92,7 +92,7 @@ const ConferenceNavigationContainer = () => {
<NavigationContainer
independent = { true }
ref = { conferenceNavigationRef }
- theme = { navigationContainerTheme }>
+ theme = { navigationContainerTheme as Theme }>
<ConferenceStack.Navigator
screenOptions = {{
presentation: 'modal'
@@ -179,6 +179,7 @@ const ConferenceNavigationContainer = () => {
title: t('documentSharing.title')
}} />
<ConferenceStack.Screen
+ // @ts-ignore
component = { SettingsNavigationContainer }
name = { screen.settings.main }
options = { settingsNavigationContainerScreenOptions } />
diff --git a/react/features/mobile/navigation/components/lobby/LobbyNavigationContainerRef.js b/react/features/mobile/navigation/components/lobby/LobbyNavigationContainerRef.ts
similarity index 80%
rename from react/features/mobile/navigation/components/lobby/LobbyNavigationContainerRef.js
rename to react/features/mobile/navigation/components/lobby/LobbyNavigationContainerRef.ts
index 57ac556b84..49534a4d2b 100644
--- a/react/features/mobile/navigation/components/lobby/LobbyNavigationContainerRef.js
+++ b/react/features/mobile/navigation/components/lobby/LobbyNavigationContainerRef.ts
@@ -1,6 +1,7 @@
+import { NavigationContainerRef } from '@react-navigation/native';
import React from 'react';
-export const lobbyNavigationContainerRef = React.createRef();
+export const lobbyNavigationContainerRef = React.createRef<NavigationContainerRef<any>>();
/**
* User defined navigation action included inside the reference to the container.
diff --git a/react/features/mobile/navigation/components/settings/SettingsNavigationContainerRef.js b/react/features/mobile/navigation/components/settings/SettingsNavigationContainerRef.ts
similarity index 80%
rename from react/features/mobile/navigation/components/settings/SettingsNavigationContainerRef.js
rename to react/features/mobile/navigation/components/settings/SettingsNavigationContainerRef.ts
index 8ded040974..02f675e23e 100644
--- a/react/features/mobile/navigation/components/settings/SettingsNavigationContainerRef.js
+++ b/react/features/mobile/navigation/components/settings/SettingsNavigationContainerRef.ts
@@ -1,6 +1,7 @@
+import { NavigationContainerRef } from '@react-navigation/native';
import React from 'react';
-export const settingsNavigationContainerRef = React.createRef();
+export const settingsNavigationContainerRef = React.createRef<NavigationContainerRef<any>>();
/**
* User defined navigation action included inside the reference to the container.
diff --git a/react/features/mobile/navigation/components/settings/components/SettingsNavigationContainer.js b/react/features/mobile/navigation/components/settings/components/SettingsNavigationContainer.tsx
similarity index 86%
rename from react/features/mobile/navigation/components/settings/components/SettingsNavigationContainer.js
rename to react/features/mobile/navigation/components/settings/components/SettingsNavigationContainer.tsx
index 41fbfab542..9fafb4e344 100644
--- a/react/features/mobile/navigation/components/settings/components/SettingsNavigationContainer.js
+++ b/react/features/mobile/navigation/components/settings/components/SettingsNavigationContainer.tsx
@@ -1,4 +1,4 @@
-import { NavigationContainer } from '@react-navigation/native';
+import { NavigationContainer, Theme } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
@@ -21,16 +21,16 @@ const SettingsStack = createStackNavigator();
/**
* The type of the React {@code Component} props of {@link SettingsNavigationContainer}.
*/
-type Props = {
+interface IProps {
/**
* Is the navigator part of Welcome page?
*/
- isInWelcomePage: boolean
-};
+ isInWelcomePage?: boolean;
+}
-const SettingsNavigationContainer = ({ isInWelcomePage }: Props) => {
+const SettingsNavigationContainer = ({ isInWelcomePage }: IProps) => {
const baseSettingsScreenOptions = isInWelcomePage ? welcomeScreenOptions : settingsScreenOptions;
const { t } = useTranslation();
@@ -39,14 +39,13 @@ const SettingsNavigationContainer = ({ isInWelcomePage }: Props) => {
<SettingsView
addBottomInset = { !isInWelcomePage }
scrollBounces = { isInWelcomePage } />
- )
- );
+ ), []);
return (
<NavigationContainer
independent = { true }
ref = { settingsNavigationContainerRef }
- theme = { navigationContainerTheme }>
+ theme = { navigationContainerTheme as Theme }>
<SettingsStack.Navigator
initialRouteName = { screen.settings.main }>
<SettingsStack.Screen
diff --git a/react/features/mobile/navigation/components/styles.js b/react/features/mobile/navigation/components/styles.ts
similarity index 100%
rename from react/features/mobile/navigation/components/styles.js
rename to react/features/mobile/navigation/components/styles.ts
diff --git a/react/features/mobile/navigation/components/welcome/components/WelcomePageTabs.js b/react/features/mobile/navigation/components/welcome/components/WelcomePageTabs.tsx
similarity index 92%
rename from react/features/mobile/navigation/components/welcome/components/WelcomePageTabs.js
rename to react/features/mobile/navigation/components/welcome/components/WelcomePageTabs.tsx
index 743ea4f140..888003d226 100644
--- a/react/features/mobile/navigation/components/welcome/components/WelcomePageTabs.js
+++ b/react/features/mobile/navigation/components/welcome/components/WelcomePageTabs.tsx
@@ -1,6 +1,7 @@
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
+import { GestureResponderEvent } from 'react-native';
import { useSelector } from 'react-redux';
import CalendarList from '../../../../../calendar-sync/components/CalendarList.native';
@@ -18,38 +19,36 @@ import SettingsNavigationContainer
const WelcomePage = createBottomTabNavigator();
-
/**
* The type of the React {@code Component} props of {@link WelcomePageTabs}.
*/
-type Props = {
+interface IProps {
/**
* Renders the lists disabled.
*/
- disabled: boolean,
+ disabled: boolean;
/**
* Callback to be invoked when pressing the list container.
*/
- onListContainerPress?: Function,
+ onListContainerPress?: (e?: GestureResponderEvent) => void;
/**
* Callback to be invoked when settings screen is focused.
*/
- onSettingsScreenFocused: Function
-};
+ onSettingsScreenFocused: Function;
+}
-const WelcomePageTabs = ({ disabled, onListContainerPress, onSettingsScreenFocused }: Props) => {
+const WelcomePageTabs = ({ disabled, onListContainerPress, onSettingsScreenFocused }: IProps) => {
const { t } = useTranslation();
const RecentListScreen = useCallback(() =>
(
<RecentList
disabled = { disabled }
onListContainerPress = { onListContainerPress } />
- )
- );
+ ), []);
const calendarEnabled = useSelector(isCalendarEnabled);
@@ -57,15 +56,13 @@ const WelcomePageTabs = ({ disabled, onListContainerPress, onSettingsScreenFocus
(
<CalendarList
disabled = { disabled } />
- )
- );
+ ), []);
const SettingsScreen = useCallback(() =>
(
<SettingsNavigationContainer
isInWelcomePage = { true } />
- )
- );
+ ), []);
return (
<WelcomePage.Navigator
diff --git a/react/features/mobile/navigation/functions.js b/react/features/mobile/navigation/functions.tsx
similarity index 86%
rename from react/features/mobile/navigation/functions.js
rename to react/features/mobile/navigation/functions.tsx
index 8c2d3fabeb..ba99babd13 100644
--- a/react/features/mobile/navigation/functions.js
+++ b/react/features/mobile/navigation/functions.tsx
@@ -1,10 +1,11 @@
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
-import { Platform } from 'react-native';
+import { GestureResponderEvent, Platform } from 'react-native';
import { useDispatch } from 'react-redux';
-import { appNavigate } from '../../app/actions';
+import { appNavigate } from '../../app/actions.native';
+import { IStateful } from '../../base/app/types';
import { PREJOIN_PAGE_ENABLED } from '../../base/flags/constants';
import { getFeatureFlag } from '../../base/flags/functions';
import { IconCloseLarge } from '../../base/icons/svg';
@@ -20,7 +21,7 @@ import HeaderNavigationButton from './components/HeaderNavigationButton';
* @param {Function} goBack - Goes back to the previous screen function.
* @returns {React.Component}
*/
-export function screenHeaderCloseButton(goBack: Function) {
+export function screenHeaderCloseButton(goBack: (e?: GestureResponderEvent | React.MouseEvent) => void) {
const { t } = useTranslation();
if (Platform.OS === 'ios') {
@@ -47,7 +48,7 @@ export function screenHeaderCloseButton(goBack: Function) {
* @returns {boolean} If the {@code Prejoin} is enabled by the app, then
* {@code true}; otherwise, {@code false}.
*/
-export function isPrejoinPageEnabled(stateful: Function | Object) {
+export function isPrejoinPageEnabled(stateful: IStateful) {
return getFeatureFlag(toState(stateful), PREJOIN_PAGE_ENABLED, true);
}
@@ -86,7 +87,7 @@ export function lobbyScreenHeaderCloseButton() {
* function.
* @returns {boolean}
*/
-export function shouldEnableAutoKnock(stateful: Function | Object) {
+export function shouldEnableAutoKnock(stateful: IStateful) {
const state = toState(stateful);
const { displayName } = state['features/base/settings'];
diff --git a/react/features/mobile/navigation/rootNavigationContainerRef.js b/react/features/mobile/navigation/rootNavigationContainerRef.ts
similarity index 80%
rename from react/features/mobile/navigation/rootNavigationContainerRef.js
rename to react/features/mobile/navigation/rootNavigationContainerRef.ts
index ea9ff1449b..e48ac7e758 100644
--- a/react/features/mobile/navigation/rootNavigationContainerRef.js
+++ b/react/features/mobile/navigation/rootNavigationContainerRef.ts
@@ -1,12 +1,15 @@
+import { NavigationContainerRef } from '@react-navigation/native';
import React from 'react';
+import { IStore } from '../../app/types';
+import { IStateful } from '../../base/app/types';
import { toState } from '../../base/redux/functions';
import { isWelcomePageEnabled } from '../../welcome/functions';
import { _sendReadyToClose } from '../external-api/functions';
import { screen } from './routes';
-export const rootNavigationRef = React.createRef();
+export const rootNavigationRef = React.createRef<NavigationContainerRef<any>>();
/**
@@ -36,7 +39,7 @@ export function goBack() {
* @param {Function} dispatch - Redux dispatch function.
* @returns {void}
*/
-export function goBackToRoot(stateful: Function | Object, dispatch: Function) {
+export function goBackToRoot(stateful: IStateful, dispatch: IStore['dispatch']) {
const state = toState(stateful);
if (isWelcomePageEnabled(state)) {
diff --git a/react/features/mobile/navigation/routes.js b/react/features/mobile/navigation/routes.ts
similarity index 100%
rename from react/features/mobile/navigation/routes.js
rename to react/features/mobile/navigation/routes.ts
diff --git a/react/features/mobile/navigation/screenOptions.js b/react/features/mobile/navigation/screenOptions.ts
similarity index 100%
rename from react/features/mobile/navigation/screenOptions.js
rename to react/features/mobile/navigation/screenOptions.ts
diff --git a/react/features/mobile/permissions/functions.js b/react/features/mobile/permissions/functions.ts
similarity index 98%
rename from react/features/mobile/permissions/functions.js
rename to react/features/mobile/permissions/functions.ts
index 802d6ea8aa..5454192962 100644
--- a/react/features/mobile/permissions/functions.js
+++ b/react/features/mobile/permissions/functions.ts
@@ -1,5 +1,3 @@
-// @flow
-
import { Alert, Linking, NativeModules } from 'react-native';
import Platform from '../../base/react/Platform.native';
diff --git a/react/features/prejoin/components/web/dialogs/CallingDialog.tsx b/react/features/prejoin/components/web/dialogs/CallingDialog.tsx
index 7c3c1e0f95..ec17b1fb9c 100644
--- a/react/features/prejoin/components/web/dialogs/CallingDialog.tsx
+++ b/react/features/prejoin/components/web/dialogs/CallingDialog.tsx
@@ -18,7 +18,7 @@ interface IProps extends WithTranslation {
/**
* Closes the dialog.
*/
- onClose: Function;
+ onClose: (e?: React.MouseEvent) => void;
/**
* The status of the call.
diff --git a/react/features/prejoin/components/web/dialogs/DialInDialog.tsx b/react/features/prejoin/components/web/dialogs/DialInDialog.tsx
index 916b3127c3..4fb7d9e31b 100644
--- a/react/features/prejoin/components/web/dialogs/DialInDialog.tsx
+++ b/react/features/prejoin/components/web/dialogs/DialInDialog.tsx
@@ -19,7 +19,7 @@ interface IProps extends WithTranslation {
/**
* Handler used when clicking the back button.
*/
- onBack: Function;
+ onBack: (e?: React.MouseEvent) => void;
/**
* Click handler for primary button.
diff --git a/react/features/prejoin/components/web/dialogs/DialOutDialog.tsx b/react/features/prejoin/components/web/dialogs/DialOutDialog.tsx
index e2586c4c2c..f7dd703ffb 100644
--- a/react/features/prejoin/components/web/dialogs/DialOutDialog.tsx
+++ b/react/features/prejoin/components/web/dialogs/DialOutDialog.tsx
@@ -14,7 +14,7 @@ interface IProps extends WithTranslation {
/**
* Closes a dialog.
*/
- onClose: Function;
+ onClose: (e?: React.MouseEvent) => void;
/**
* Submit handler.
diff --git a/react/features/presence-status/components/PresenceLabel.tsx b/react/features/presence-status/components/PresenceLabel.tsx
index 9b2cb24f32..5470255847 100644
--- a/react/features/presence-status/components/PresenceLabel.tsx
+++ b/react/features/presence-status/components/PresenceLabel.tsx
@@ -74,7 +74,7 @@ class PresenceLabel extends Component<IProps> {
const { style, className } = this.props;
return (
- <Text
+ <Text // @ts-ignore
className = { className }
{ ...style }>
{ text }
diff --git a/react/features/recent-list/components/AbstractRecentList.tsx b/react/features/recent-list/components/AbstractRecentList.tsx
index 9086cbe6e0..03cdc354b3 100644
--- a/react/features/recent-list/components/AbstractRecentList.tsx
+++ b/react/features/recent-list/components/AbstractRecentList.tsx
@@ -71,7 +71,7 @@ export default class AbstractRecentList<P extends IProps> extends AbstractPage<P
className = 'meetings-list-empty'
role = 'region'
style = { styles.emptyListContainer }>
- <Text
+ <Text // @ts-ignore
className = 'description'
id = { descriptionId }
style = { styles.emptyListText }>
diff --git a/react/features/recent-list/components/DeleteItemButton.native.js b/react/features/recent-list/components/DeleteItemButton.native.ts
similarity index 73%
rename from react/features/recent-list/components/DeleteItemButton.native.js
rename to react/features/recent-list/components/DeleteItemButton.native.ts
index 51b0695168..665ec3c719 100644
--- a/react/features/recent-list/components/DeleteItemButton.native.js
+++ b/react/features/recent-list/components/DeleteItemButton.native.ts
@@ -1,5 +1,3 @@
-// @flow
-
import { connect } from 'react-redux';
import { translate } from '../../base/i18n/functions';
@@ -7,28 +5,18 @@ import { IconTrash } from '../../base/icons/svg';
import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbox/components/AbstractButton';
import { deleteRecentListEntry } from '../actions';
-export type Props = AbstractButtonProps & {
-
- /**
- * The redux {@code dispatch} function.
- */
- dispatch: Function,
+export interface IProps extends AbstractButtonProps {
/**
* The ID of the entry to be deleted.
*/
- itemId: Object,
-
- /**
- * The function to be used to translate i18n labels.
- */
- t: Function
-};
+ itemId: Object;
+}
/**
* A recent list menu button which deletes the selected entry.
*/
-class DeleteItemButton extends AbstractButton<Props, *> {
+class DeleteItemButton extends AbstractButton<IProps> {
accessibilityLabel = 'welcomepage.recentListDelete';
icon = IconTrash;
label = 'welcomepage.recentListDelete';
diff --git a/react/features/recent-list/components/RecentList.native.js b/react/features/recent-list/components/RecentList.native.tsx
similarity index 74%
rename from react/features/recent-list/components/RecentList.native.js
rename to react/features/recent-list/components/RecentList.native.tsx
index 5dd68d7fa0..732b5d9eab 100644
--- a/react/features/recent-list/components/RecentList.native.js
+++ b/react/features/recent-list/components/RecentList.native.tsx
@@ -1,15 +1,16 @@
import React from 'react';
-import { TouchableWithoutFeedback, View } from 'react-native';
+import { WithTranslation } from 'react-i18next';
+import { GestureResponderEvent, TouchableWithoutFeedback, View, ViewStyle } from 'react-native';
import { connect } from 'react-redux';
-import type { Dispatch } from 'redux';
-import { getDefaultURL } from '../../app/functions';
+import { getDefaultURL } from '../../app/functions.native';
+import { IReduxState, IStore } from '../../app/types';
import { openSheet } from '../../base/dialog/actions';
import { translate } from '../../base/i18n/functions';
import NavigateSectionList from '../../base/react/components/native/NavigateSectionList';
-import { Section } from '../../base/react/types';
+import { Item, Section } from '../../base/react/types';
import styles from '../../welcome/components/styles';
-import { isRecentListEnabled, toDisplayableList } from '../functions';
+import { isRecentListEnabled, toDisplayableList } from '../functions.native';
import AbstractRecentList from './AbstractRecentList';
import RecentListItemMenu from './RecentListItemMenu.native';
@@ -17,50 +18,45 @@ import RecentListItemMenu from './RecentListItemMenu.native';
/**
* The type of the React {@code Component} props of {@link RecentList}.
*/
-type Props = {
+interface IProps extends WithTranslation {
/**
- * Renders the list disabled.
- */
- disabled: boolean,
-
- /**
- * The redux store's {@code dispatch} function.
+ * The default server URL.
*/
- dispatch: Dispatch<any>,
+ _defaultServerURL: string;
/**
- * Callback to be invoked when pressing the list container.
+ * The recent list from the Redux store.
*/
- onListContainerPress?: Function,
+ _recentList: Array<Section>;
/**
- * The translate function.
+ * Renders the list disabled.
*/
- t: Function,
+ disabled: boolean;
/**
- * The default server URL.
+ * The redux store's {@code dispatch} function.
*/
- _defaultServerURL: string,
+ dispatch: IStore['dispatch'];
/**
- * The recent list from the Redux store.
+ * Callback to be invoked when pressing the list container.
*/
- _recentList: Array<Section>
-};
+ onListContainerPress?: (e?: GestureResponderEvent) => void;
+}
/**
* A class that renders the list of the recently joined rooms.
*
*/
-class RecentList extends AbstractRecentList<Props> {
+class RecentList extends AbstractRecentList<IProps> {
/**
* Initializes a new {@code RecentList} instance.
*
* @inheritdoc
*/
- constructor(props: Props) {
+ constructor(props: IProps) {
super(props);
// Bind event handlers so they are only bound once per instance.
@@ -82,19 +78,21 @@ class RecentList extends AbstractRecentList<Props> {
t,
_defaultServerURL,
_recentList
- } = this.props;
+ } = this.props; // @ts-ignore
const recentList = toDisplayableList(_recentList, t, _defaultServerURL);
return (
<TouchableWithoutFeedback
onPress = { onListContainerPress }>
- <View style = { disabled ? styles.recentListDisabled : styles.recentList }>
+ <View style = { (disabled ? styles.recentListDisabled : styles.recentList) as ViewStyle }>
<NavigateSectionList
disabled = { disabled }
onLongPress = { this._onLongPress }
onPress = { this._onPress }
renderListEmptyComponent
= { this._getRenderListEmptyComponent() }
+
+ // @ts-ignore
sections = { recentList } />
</View>
</TouchableWithoutFeedback>
@@ -108,7 +106,7 @@ class RecentList extends AbstractRecentList<Props> {
* @param {Object} item - The item which was long pressed.
* @returns {void}
*/
- _onLongPress(item) {
+ _onLongPress(item: Item) {
this.props.dispatch(openSheet(RecentListItemMenu, { item }));
}
}
@@ -117,13 +115,14 @@ class RecentList extends AbstractRecentList<Props> {
* Maps redux state to component props.
*
* @param {Object} state - The redux state.
- * @returns {Props}
+ * @returns {IProps}
*/
-export function _mapStateToProps(state: Object) {
+export function _mapStateToProps(state: IReduxState) {
return {
_defaultServerURL: getDefaultURL(state),
_recentList: state['features/recent-list']
};
}
+// @ts-ignore
export default translate(connect(_mapStateToProps)(RecentList));
diff --git a/react/features/recent-list/components/RecentListItemMenu.native.js b/react/features/recent-list/components/RecentListItemMenu.native.tsx
similarity index 83%
rename from react/features/recent-list/components/RecentListItemMenu.native.js
rename to react/features/recent-list/components/RecentListItemMenu.native.tsx
index 7f0767c23e..916d1d85ee 100644
--- a/react/features/recent-list/components/RecentListItemMenu.native.js
+++ b/react/features/recent-list/components/RecentListItemMenu.native.tsx
@@ -1,7 +1,8 @@
import React, { PureComponent } from 'react';
-import { Text, View } from 'react-native';
+import { Text, TextStyle, View, ViewStyle } from 'react-native';
import { connect } from 'react-redux';
+import { IStore } from '../../app/types';
import { hideSheet } from '../../base/dialog/actions';
import BottomSheet from '../../base/dialog/components/native/BottomSheet';
import { bottomSheetStyles } from '../../base/dialog/components/native/styles';
@@ -9,31 +10,31 @@ import { Item } from '../../base/react/types';
import DeleteItemButton from './DeleteItemButton.native';
import ShowDialInInfoButton from './ShowDialInInfoButton.native';
-import styles from './styles';
+import styles from './styles.native';
-type Props = {
+interface IProps {
/**
* The Redux dispatch function.
*/
- dispatch: Function,
+ dispatch: IStore['dispatch'];
/**
* Item being rendered in this menu.
*/
- item: Item
+ item: Item;
}
/**
* Class to implement a popup menu that opens upon long pressing a recent list item.
*/
-class RecentListItemMenu extends PureComponent<Props> {
+class RecentListItemMenu extends PureComponent<IProps> {
/**
* Constructor of the component.
*
* @inheritdoc
*/
- constructor(props: Props) {
+ constructor(props: IProps) {
super(props);
this._onCancel = this._onCancel.bind(this);
@@ -85,12 +86,12 @@ class RecentListItemMenu extends PureComponent<Props> {
<View
style = { [
bottomSheetStyles.sheet,
- styles.entryNameContainer
+ styles.entryNameContainer as ViewStyle
] }>
<Text
ellipsizeMode = { 'middle' }
numberOfLines = { 1 }
- style = { styles.entryNameLabel }>
+ style = { styles.entryNameLabel as TextStyle }>
{ item.title }
</Text>
</View>
diff --git a/react/features/recent-list/components/ShowDialInInfoButton.native.js b/react/features/recent-list/components/ShowDialInInfoButton.native.tsx
similarity index 75%
rename from react/features/recent-list/components/ShowDialInInfoButton.native.js
rename to react/features/recent-list/components/ShowDialInInfoButton.native.tsx
index f0020f244c..4349a6e3f8 100644
--- a/react/features/recent-list/components/ShowDialInInfoButton.native.js
+++ b/react/features/recent-list/components/ShowDialInInfoButton.native.tsx
@@ -1,5 +1,3 @@
-// @flow
-
import { connect } from 'react-redux';
import { translate } from '../../base/i18n/functions';
@@ -8,28 +6,18 @@ import AbstractButton, { IProps as AbstractButtonProps } from '../../base/toolbo
import { navigateRoot } from '../../mobile/navigation/rootNavigationContainerRef';
import { screen } from '../../mobile/navigation/routes';
-export type Props = AbstractButtonProps & {
-
- /**
- * The redux {@code dispatch} function.
- */
- dispatch: Function,
+export interface IProps extends AbstractButtonProps {
/**
* The ID of the entry to be deleted.
*/
- itemId: Object,
-
- /**
- * The function to be used to translate i18n labels.
- */
- t: Function
-};
+ itemId: any;
+}
/**
* A recent list menu button which opens the dial-in info dialog.
*/
-class ShowDialInInfoButton extends AbstractButton<Props, *> {
+class ShowDialInInfoButton extends AbstractButton<IProps> {
accessibilityLabel = 'welcomepage.info';
icon = IconInfoCircle;
label = 'welcomepage.info';
diff --git a/react/features/recent-list/components/styles.native.js b/react/features/recent-list/components/styles.native.ts
similarity index 100%
rename from react/features/recent-list/components/styles.native.js
rename to react/features/recent-list/components/styles.native.ts
diff --git a/react/features/recording/components/Recording/native/StartRecordingDialogContent.tsx b/react/features/recording/components/Recording/native/StartRecordingDialogContent.tsx
index f0b63d06bc..a57137fe40 100644
--- a/react/features/recording/components/Recording/native/StartRecordingDialogContent.tsx
+++ b/react/features/recording/components/Recording/native/StartRecordingDialogContent.tsx
@@ -183,7 +183,6 @@ class StartRecordingDialogContent extends AbstractStartRecordingDialogContent<IP
_renderSpinner() {
return (
<LoadingIndicator
- isCompleting = { false }
size = 'small' />
);
}
diff --git a/react/features/settings/components/native/SettingsView.tsx b/react/features/settings/components/native/SettingsView.tsx
index 20b2e5ed8a..e5d764acf7 100644
--- a/react/features/settings/components/native/SettingsView.tsx
+++ b/react/features/settings/components/native/SettingsView.tsx
@@ -169,7 +169,7 @@ interface IProps extends WithTranslation {
/**
* Default prop for navigating between screen components(React Navigation).
*/
- navigation: Object;
+ navigation?: Object;
/**
* Bounce when scrolling.
diff --git a/react/features/welcome/components/AbstractWelcomePage.ts b/react/features/welcome/components/AbstractWelcomePage.ts
index dd12714264..2941755b43 100644
--- a/react/features/welcome/components/AbstractWelcomePage.ts
+++ b/react/features/welcome/components/AbstractWelcomePage.ts
@@ -59,12 +59,16 @@ export interface IProps extends WithTranslation {
}
interface IState {
+ _fieldFocused?: boolean;
animateTimeoutId?: number;
generateRoomNames?: string;
generatedRoomName: string;
+ hintBoxAnimation?: any;
insecureRoomName: boolean;
+ isSettingsScreenFocused?: boolean;
joining: boolean;
room: string;
+ roomNameInputAnimation?: any;
roomPlaceholder: string;
updateTimeoutId?: number;
}
@@ -90,7 +94,7 @@ export class AbstractWelcomePage<P extends IProps> extends Component<P, IState>
* @property {number|null} updateTimeoutId - Identifier of the timeout
* updating the generated room name.
*/
- state = {
+ state: IState = {
animateTimeoutId: undefined,
generatedRoomName: '',
generateRoomNames: undefined,
@@ -98,7 +102,11 @@ export class AbstractWelcomePage<P extends IProps> extends Component<P, IState>
joining: false,
room: '',
roomPlaceholder: '',
- updateTimeoutId: undefined
+ updateTimeoutId: undefined,
+ _fieldFocused: false,
+ isSettingsScreenFocused: false,
+ roomNameInputAnimation: 0,
+ hintBoxAnimation: 0
};
/**
diff --git a/react/features/welcome/components/WelcomePage.native.js b/react/features/welcome/components/WelcomePage.native.tsx
similarity index 88%
rename from react/features/welcome/components/WelcomePage.native.js
rename to react/features/welcome/components/WelcomePage.native.tsx
index 1176a3eca6..acadfa13c5 100644
--- a/react/features/welcome/components/WelcomePage.native.js
+++ b/react/features/welcome/components/WelcomePage.native.tsx
@@ -1,8 +1,17 @@
import React from 'react';
-import { Animated, SafeAreaView, TouchableHighlight, View } from 'react-native';
+import { Animated,
+ NativeSyntheticEvent,
+ SafeAreaView,
+ TextInputFocusEventData,
+ TextStyle,
+ TouchableHighlight,
+ View,
+ ViewStyle
+} from 'react-native';
import { connect } from 'react-redux';
-import { getName } from '../../app/functions';
+import { getName } from '../../app/functions.native';
+import { IReduxState } from '../../app/types';
import { translate } from '../../base/i18n/functions';
import Icon from '../../base/icons/components/Icon';
import { IconWarning } from '../../base/icons/svg';
@@ -16,37 +25,35 @@ import WelcomePageTabs
from '../../mobile/navigation/components/welcome/components/WelcomePageTabs';
import {
- type Props as AbstractProps,
+ IProps as AbstractProps,
AbstractWelcomePage,
_mapStateToProps as _abstractMapStateToProps
} from './AbstractWelcomePage';
import styles from './styles';
-type Props = AbstractProps & {
+interface IProps extends AbstractProps {
/**
* Default prop for navigating between screen components(React Navigation).
*/
- navigation: Object,
-
- /**
- * The translate function.
- */
- t: Function
-};
+ navigation: any;
+}
/**
* The native container rendering the welcome page.
*
* @augments AbstractWelcomePage
*/
-class WelcomePage extends AbstractWelcomePage<*> {
+class WelcomePage extends AbstractWelcomePage<IProps> {
+ _onFieldBlur: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
+ _onFieldFocus: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
+
/**
* Constructor of the Component.
*
* @inheritdoc
*/
- constructor(props: Props) {
+ constructor(props: IProps) {
super(props);
this.state._fieldFocused = false;
@@ -67,16 +74,6 @@ class WelcomePage extends AbstractWelcomePage<*> {
this._onSettingsScreenFocused = this._onSettingsScreenFocused.bind(this);
}
- _onFieldBlur: () => void;
-
- _onFieldFocus: () => void;
-
- _onJoin: () => void;
-
- _onRoomChange: (string) => void;
-
- _updateRoomName: () => void;
-
/**
* Implements React's {@link Component#componentDidMount()}. Invoked
* immediately after mounting occurs. Creates a local video track if none
@@ -148,7 +145,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
<View
style = { [
styles.messageContainer,
- styles.insecureRoomNameWarningContainer
+ styles.insecureRoomNameWarningContainer as ViewStyle
] }>
<Icon
src = { IconWarning }
@@ -176,8 +173,6 @@ class WelcomePage extends AbstractWelcomePage<*> {
];
}
- _onFieldFocusChange: (boolean) => void;
-
/**
* Callback for when the room field's focus changes so the hint box
* must be rendered or removed.
@@ -186,7 +181,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
* @param {boolean} focused - The focused state of the field.
* @returns {void}
*/
- _onFieldFocusChange(focused) {
+ _onFieldFocusChange(focused: boolean) {
if (focused) {
// Stop placeholder animation.
this._clearTimeouts();
@@ -218,8 +213,6 @@ class WelcomePage extends AbstractWelcomePage<*> {
}));
}
- _onSettingsScreenFocused: boolean => void;
-
/**
* Callback for when the settings screen is focused.
*
@@ -227,7 +220,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
* @param {boolean} focused - The focused state of the screen.
* @returns {void}
*/
- _onSettingsScreenFocused(focused) {
+ _onSettingsScreenFocused(focused: boolean) {
this.setState({
isSettingsScreenFocused: focused
});
@@ -246,8 +239,6 @@ class WelcomePage extends AbstractWelcomePage<*> {
.start();
}
- _renderHintBox: () => React.ReactElement;
-
/**
* Renders the hint box if necessary.
*
@@ -259,13 +250,13 @@ class WelcomePage extends AbstractWelcomePage<*> {
if (this.state._fieldFocused) {
return (
- <Animated.View style = { this._getHintBoxStyle() }>
+ <Animated.View style = { this._getHintBoxStyle() as ViewStyle }>
<View style = { styles.hintTextContainer } >
- <Text style = { styles.hintText }>
+ <Text style = { styles.hintText as TextStyle }>
{ t('welcomepage.roomnameHint') }
</Text>
</View>
- <View style = { styles.hintButtonContainer } >
+ <View style = { styles.hintButtonContainer as ViewStyle } >
{ this._renderJoinButton() }
</View>
</Animated.View>
@@ -295,7 +286,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
accessibilityLabel =
{ t('welcomepage.accessibilityLabel.join') }
onPress = { this._onJoin }
- style = { styles.button }>
+ style = { styles.button as ViewStyle }>
<View>
<LoadingIndicator
color = { BaseTheme.palette.icon01 }
@@ -310,7 +301,6 @@ class WelcomePage extends AbstractWelcomePage<*> {
labelKey = { 'welcomepage.join' }
labelStyle = { styles.joinButtonLabel }
onClick = { this._onJoin }
- style = { styles.buttonText }
type = { BUTTON_TYPES.PRIMARY } />
);
}
@@ -335,7 +325,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
isSettingsScreenFocused && styles.roomNameInputContainer,
{ opacity: this.state.roomNameInputAnimation }
] }>
- <SafeAreaView style = { styles.roomContainer }>
+ <SafeAreaView style = { styles.roomContainer as ViewStyle }>
<View style = { styles.joinControls } >
<Text style = { styles.enterRoomText }>
{ t('welcomepage.roomname') }
@@ -343,8 +333,6 @@ class WelcomePage extends AbstractWelcomePage<*> {
<Input
accessibilityLabel = { t(roomnameAccLabel) }
autoCapitalize = { 'none' }
- autoComplete = { 'off' }
- autoCorrect = { false }
autoFocus = { false }
customStyles = {{ input: styles.customInput }}
onBlur = { this._onFieldBlur }
@@ -375,9 +363,9 @@ class WelcomePage extends AbstractWelcomePage<*> {
return (
<>
{ this._renderRoomNameInput() }
- <View style = { styles.welcomePage }>
+ <View style = { styles.welcomePage as ViewStyle }>
<WelcomePageTabs
- disabled = { this.state._fieldFocused }
+ disabled = { Boolean(this.state._fieldFocused) } // @ts-ignore
onListContainerPress = { this._onFieldBlur }
onSettingsScreenFocused = { this._onSettingsScreenFocused } />
</View>
@@ -394,7 +382,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
const { t } = this.props;
return (
- <View style = { styles.reducedUIContainer }>
+ <View style = { styles.reducedUIContainer as ViewStyle }>
<Text style = { styles.reducedUIText }>
{ t('welcomepage.reducedUIText', { app: getName() }) }
</Text>
@@ -409,7 +397,7 @@ class WelcomePage extends AbstractWelcomePage<*> {
* @param {Object} state - The Redux state.
* @returns {Object}
*/
-function _mapStateToProps(state) {
+function _mapStateToProps(state: IReduxState) {
return {
..._abstractMapStateToProps(state)
diff --git a/react/features/welcome/components/styles.js b/react/features/welcome/components/styles.ts
similarity index 99%
rename from react/features/welcome/components/styles.js
rename to react/features/welcome/components/styles.ts
index 5088f4e95c..ed909a011e 100644
--- a/react/features/welcome/components/styles.js
+++ b/react/features/welcome/components/styles.ts
@@ -1,5 +1,3 @@
-// @flow
-
import { StyleSheet } from 'react-native';
import { BoxModel } from '../../base/styles/components/styles/BoxModel';