Skip to content

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

rn: add HeaderWithNavigation component

Bettenbuk Zoltan3eca67e1adaa
diff --git a/react/features/base/react/components/native/HeaderWithNavigation.js b/react/features/base/react/components/native/HeaderWithNavigation.js
new file mode 100644
index 0000000000..6619c51f7c
--- /dev/null
+++ b/react/features/base/react/components/native/HeaderWithNavigation.js
@@ -0,0 +1,66 @@
+// @flow
+
+import React, { Component } from 'react';
+
+import { translate } from '../../../i18n';
+
+import BackButton from './BackButton';
+import ForwardButton from './ForwardButton';
+import Header from './Header';
+import HeaderLabel from './HeaderLabel';
+
+
+type Props = {
+
+ /**
+ * Boolean to set the forward button disabled.
+ */
+ forwardDisabled: boolean,
+
+ /**
+ * The i18n key of the the forward button label.
+ */
+ forwardLabelKey: ?string,
+
+ /**
+ * The i18n key of the header label (title)
+ */
+ headerLabelKey: ?string,
+
+ /**
+ * Callback to be invoked on pressing the back button.
+ */
+ onPressBack: ?Function,
+
+ /**
+ * Callback to be invoked on pressing the forward button.
+ */
+ onPressForward: ?Function,
+}
+
+/**
+ * Implements a header with the standard navigation content.
+ */
+class HeaderWithNavigation extends Component<Props> {
+ /**
+ * Implements {@code Component#render}.
+ *
+ * @inheritdoc
+ */
+ render() {
+ const { onPressBack, onPressForward } = this.props;
+
+ return (
+ <Header>
+ { onPressBack && <BackButton onPress = { onPressBack } /> }
+ <HeaderLabel labelKey = { this.props.headerLabelKey } />
+ { onPressForward && <ForwardButton
+ disabled = { this.props.forwardDisabled }
+ labelKey = { this.props.forwardLabelKey }
+ onPress = { onPressForward } /> }
+ </Header>
+ );
+ }
+}
+
+export default translate(HeaderWithNavigation);
diff --git a/react/features/base/react/components/native/index.js b/react/features/base/react/components/native/index.js
index 7c0afe1786..643c247723 100644
--- a/react/features/base/react/components/native/index.js
+++ b/react/features/base/react/components/native/index.js
@@ -8,6 +8,7 @@ export { default as Container } from './Container';
export { default as ForwardButton } from './ForwardButton';
export { default as Header } from './Header';
export { default as HeaderLabel } from './HeaderLabel';
+export { default as HeaderWithNavigation } from './HeaderWithNavigation';
export { default as Image } from './Image';
export { default as Link } from './Link';
export { default as LoadingIndicator } from './LoadingIndicator';
diff --git a/react/features/chat/components/native/Chat.js b/react/features/chat/components/native/Chat.js
index 1272adbadb..8109c6c9ea 100644
--- a/react/features/chat/components/native/Chat.js
+++ b/react/features/chat/components/native/Chat.js
@@ -5,12 +5,7 @@ import { KeyboardAvoidingView, SafeAreaView } from 'react-native';
import { translate } from '../../../base/i18n';
-import {
- BackButton,
- Header,
- HeaderLabel,
- SlidingView
-} from '../../../base/react';
+import { HeaderWithNavigation, SlidingView } from '../../../base/react';
import { connect } from '../../../base/redux';
import AbstractChat, {
@@ -41,10 +36,9 @@ class Chat extends AbstractChat<Props> {
<KeyboardAvoidingView
behavior = 'padding'
style = { styles.chatContainer }>
- <Header>
- <BackButton onPress = { this.props._onToggleChat } />
- <HeaderLabel labelKey = 'chat.title' />
- </Header>
+ <HeaderWithNavigation
+ headerLabelKey = 'chat.title'
+ onPressBack = { this.props._onToggleChat } />
<SafeAreaView style = { styles.backdrop }>
<MessageContainer messages = { this.props._messages } />
<ChatInputBar onSend = { this.props._onSendMessage } />
diff --git a/react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js b/react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js
index 3a94c32c54..ae0016c2be 100644
--- a/react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js
+++ b/react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js
@@ -16,10 +16,7 @@ import { Icon } from '../../../../base/font-icons';
import { translate } from '../../../../base/i18n';
import {
AvatarListItem,
- BackButton,
- ForwardButton,
- Header,
- HeaderLabel,
+ HeaderWithNavigation,
Modal,
type Item
} from '../../../../base/react';
@@ -146,14 +143,12 @@ class AddPeopleDialog extends AbstractAddPeopleDialog<Props, State> {
<Modal
onRequestClose = { this._onCloseAddPeopleDialog }
visible = { this.props._isVisible }>
- <Header>
- <BackButton onPress = { this._onCloseAddPeopleDialog } />
- <HeaderLabel labelKey = 'inviteDialog.header' />
- <ForwardButton
- disabled = { this._isAddDisabled() }
- labelKey = 'inviteDialog.send'
- onPress = { this._onInvite } />
- </Header>
+ <HeaderWithNavigation
+ forwardDisabled = { this._isAddDisabled() }
+ forwardLabelKey = 'inviteDialog.send'
+ headerLabelKey = 'inviteDialog.header'
+ onPressBack = { this._onCloseAddPeopleDialog }
+ onPressForward = { this._onInvite } />
<SafeAreaView style = { styles.dialogWrapper }>
<View
style = { styles.searchFieldWrapper }>
diff --git a/react/features/settings/components/native/SettingsView.js b/react/features/settings/components/native/SettingsView.js
index 62d5329ec2..7486533af1 100644
--- a/react/features/settings/components/native/SettingsView.js
+++ b/react/features/settings/components/native/SettingsView.js
@@ -5,7 +5,7 @@ import { Alert, NativeModules, SafeAreaView, ScrollView, Switch, Text, TextInput
import { ColorSchemeRegistry } from '../../../base/color-scheme';
import { translate } from '../../../base/i18n';
-import { BackButton, Header, Modal } from '../../../base/react';
+import { HeaderWithNavigation, Modal } from '../../../base/react';
import { connect } from '../../../base/redux';
import {
@@ -18,7 +18,6 @@ import FormRow from './FormRow';
import FormSectionHeader from './FormSectionHeader';
import { normalizeUserInputURL } from '../../functions';
import styles from './styles';
-import { HeaderLabel } from '../../../base/react/components/native';
/**
* Application information module.
@@ -213,10 +212,9 @@ class SettingsView extends AbstractSettingsView<Props> {
*/
_renderHeader() {
return (
- <Header>
- <BackButton onPress = { this._onRequestClose } />
- <HeaderLabel labelKey = 'settingsView.header' />
- </Header>
+ <HeaderWithNavigation
+ headerLabelKey = 'settingsView.header'
+ onPressBack = { this._onRequestClose } />
);
}