Sfoglia il codice sorgente

rn: add HeaderWithNavigation component

master
Bettenbuk Zoltan 6 anni fa
parent
commit
3eca67e1ad

+ 66
- 0
react/features/base/react/components/native/HeaderWithNavigation.js Vedi File

@@ -0,0 +1,66 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+
5
+import { translate } from '../../../i18n';
6
+
7
+import BackButton from './BackButton';
8
+import ForwardButton from './ForwardButton';
9
+import Header from './Header';
10
+import HeaderLabel from './HeaderLabel';
11
+
12
+
13
+type Props = {
14
+
15
+    /**
16
+     * Boolean to set the forward button disabled.
17
+     */
18
+    forwardDisabled: boolean,
19
+
20
+    /**
21
+     * The i18n key of the the forward button label.
22
+     */
23
+    forwardLabelKey: ?string,
24
+
25
+    /**
26
+     * The i18n key of the header label (title)
27
+     */
28
+    headerLabelKey: ?string,
29
+
30
+    /**
31
+     * Callback to be invoked on pressing the back button.
32
+     */
33
+    onPressBack: ?Function,
34
+
35
+    /**
36
+     * Callback to be invoked on pressing the forward button.
37
+     */
38
+    onPressForward: ?Function,
39
+}
40
+
41
+/**
42
+ * Implements a header with the standard navigation content.
43
+ */
44
+class HeaderWithNavigation extends Component<Props> {
45
+    /**
46
+     * Implements {@code Component#render}.
47
+     *
48
+     * @inheritdoc
49
+     */
50
+    render() {
51
+        const { onPressBack, onPressForward } = this.props;
52
+
53
+        return (
54
+            <Header>
55
+                { onPressBack && <BackButton onPress = { onPressBack } /> }
56
+                <HeaderLabel labelKey = { this.props.headerLabelKey } />
57
+                { onPressForward && <ForwardButton
58
+                    disabled = { this.props.forwardDisabled }
59
+                    labelKey = { this.props.forwardLabelKey }
60
+                    onPress = { onPressForward } /> }
61
+            </Header>
62
+        );
63
+    }
64
+}
65
+
66
+export default translate(HeaderWithNavigation);

+ 1
- 0
react/features/base/react/components/native/index.js Vedi File

@@ -8,6 +8,7 @@ export { default as Container } from './Container';
8 8
 export { default as ForwardButton } from './ForwardButton';
9 9
 export { default as Header } from './Header';
10 10
 export { default as HeaderLabel } from './HeaderLabel';
11
+export { default as HeaderWithNavigation } from './HeaderWithNavigation';
11 12
 export { default as Image } from './Image';
12 13
 export { default as Link } from './Link';
13 14
 export { default as LoadingIndicator } from './LoadingIndicator';

+ 4
- 10
react/features/chat/components/native/Chat.js Vedi File

@@ -5,12 +5,7 @@ import { KeyboardAvoidingView, SafeAreaView } from 'react-native';
5 5
 
6 6
 import { translate } from '../../../base/i18n';
7 7
 
8
-import {
9
-    BackButton,
10
-    Header,
11
-    HeaderLabel,
12
-    SlidingView
13
-} from '../../../base/react';
8
+import { HeaderWithNavigation, SlidingView } from '../../../base/react';
14 9
 import { connect } from '../../../base/redux';
15 10
 
16 11
 import AbstractChat, {
@@ -41,10 +36,9 @@ class Chat extends AbstractChat<Props> {
41 36
                 <KeyboardAvoidingView
42 37
                     behavior = 'padding'
43 38
                     style = { styles.chatContainer }>
44
-                    <Header>
45
-                        <BackButton onPress = { this.props._onToggleChat } />
46
-                        <HeaderLabel labelKey = 'chat.title' />
47
-                    </Header>
39
+                    <HeaderWithNavigation
40
+                        headerLabelKey = 'chat.title'
41
+                        onPressBack = { this.props._onToggleChat } />
48 42
                     <SafeAreaView style = { styles.backdrop }>
49 43
                         <MessageContainer messages = { this.props._messages } />
50 44
                         <ChatInputBar onSend = { this.props._onSendMessage } />

+ 7
- 12
react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js Vedi File

@@ -16,10 +16,7 @@ import { Icon } from '../../../../base/font-icons';
16 16
 import { translate } from '../../../../base/i18n';
17 17
 import {
18 18
     AvatarListItem,
19
-    BackButton,
20
-    ForwardButton,
21
-    Header,
22
-    HeaderLabel,
19
+    HeaderWithNavigation,
23 20
     Modal,
24 21
     type Item
25 22
 } from '../../../../base/react';
@@ -146,14 +143,12 @@ class AddPeopleDialog extends AbstractAddPeopleDialog<Props, State> {
146 143
             <Modal
147 144
                 onRequestClose = { this._onCloseAddPeopleDialog }
148 145
                 visible = { this.props._isVisible }>
149
-                <Header>
150
-                    <BackButton onPress = { this._onCloseAddPeopleDialog } />
151
-                    <HeaderLabel labelKey = 'inviteDialog.header' />
152
-                    <ForwardButton
153
-                        disabled = { this._isAddDisabled() }
154
-                        labelKey = 'inviteDialog.send'
155
-                        onPress = { this._onInvite } />
156
-                </Header>
146
+                <HeaderWithNavigation
147
+                    forwardDisabled = { this._isAddDisabled() }
148
+                    forwardLabelKey = 'inviteDialog.send'
149
+                    headerLabelKey = 'inviteDialog.header'
150
+                    onPressBack = { this._onCloseAddPeopleDialog }
151
+                    onPressForward = { this._onInvite } />
157 152
                 <SafeAreaView style = { styles.dialogWrapper }>
158 153
                     <View
159 154
                         style = { styles.searchFieldWrapper }>

+ 4
- 6
react/features/settings/components/native/SettingsView.js Vedi File

@@ -5,7 +5,7 @@ import { Alert, NativeModules, SafeAreaView, ScrollView, Switch, Text, TextInput
5 5
 
6 6
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
7 7
 import { translate } from '../../../base/i18n';
8
-import { BackButton, Header, Modal } from '../../../base/react';
8
+import { HeaderWithNavigation, Modal } from '../../../base/react';
9 9
 import { connect } from '../../../base/redux';
10 10
 
11 11
 import {
@@ -18,7 +18,6 @@ import FormRow from './FormRow';
18 18
 import FormSectionHeader from './FormSectionHeader';
19 19
 import { normalizeUserInputURL } from '../../functions';
20 20
 import styles from './styles';
21
-import { HeaderLabel } from '../../../base/react/components/native';
22 21
 
23 22
 /**
24 23
  * Application information module.
@@ -213,10 +212,9 @@ class SettingsView extends AbstractSettingsView<Props> {
213 212
      */
214 213
     _renderHeader() {
215 214
         return (
216
-            <Header>
217
-                <BackButton onPress = { this._onRequestClose } />
218
-                <HeaderLabel labelKey = 'settingsView.header' />
219
-            </Header>
215
+            <HeaderWithNavigation
216
+                headerLabelKey = 'settingsView.header'
217
+                onPressBack = { this._onRequestClose } />
220 218
         );
221 219
     }
222 220
 

Loading…
Annulla
Salva