浏览代码

rn: add HeaderWithNavigation component

master
Bettenbuk Zoltan 6 年前
父节点
当前提交
3eca67e1ad

+ 66
- 0
react/features/base/react/components/native/HeaderWithNavigation.js 查看文件

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 查看文件

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

+ 4
- 10
react/features/chat/components/native/Chat.js 查看文件

5
 
5
 
6
 import { translate } from '../../../base/i18n';
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
 import { connect } from '../../../base/redux';
9
 import { connect } from '../../../base/redux';
15
 
10
 
16
 import AbstractChat, {
11
 import AbstractChat, {
41
                 <KeyboardAvoidingView
36
                 <KeyboardAvoidingView
42
                     behavior = 'padding'
37
                     behavior = 'padding'
43
                     style = { styles.chatContainer }>
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
                     <SafeAreaView style = { styles.backdrop }>
42
                     <SafeAreaView style = { styles.backdrop }>
49
                         <MessageContainer messages = { this.props._messages } />
43
                         <MessageContainer messages = { this.props._messages } />
50
                         <ChatInputBar onSend = { this.props._onSendMessage } />
44
                         <ChatInputBar onSend = { this.props._onSendMessage } />

+ 7
- 12
react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js 查看文件

16
 import { translate } from '../../../../base/i18n';
16
 import { translate } from '../../../../base/i18n';
17
 import {
17
 import {
18
     AvatarListItem,
18
     AvatarListItem,
19
-    BackButton,
20
-    ForwardButton,
21
-    Header,
22
-    HeaderLabel,
19
+    HeaderWithNavigation,
23
     Modal,
20
     Modal,
24
     type Item
21
     type Item
25
 } from '../../../../base/react';
22
 } from '../../../../base/react';
146
             <Modal
143
             <Modal
147
                 onRequestClose = { this._onCloseAddPeopleDialog }
144
                 onRequestClose = { this._onCloseAddPeopleDialog }
148
                 visible = { this.props._isVisible }>
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
                 <SafeAreaView style = { styles.dialogWrapper }>
152
                 <SafeAreaView style = { styles.dialogWrapper }>
158
                     <View
153
                     <View
159
                         style = { styles.searchFieldWrapper }>
154
                         style = { styles.searchFieldWrapper }>

+ 4
- 6
react/features/settings/components/native/SettingsView.js 查看文件

5
 
5
 
6
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
6
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
7
 import { translate } from '../../../base/i18n';
7
 import { translate } from '../../../base/i18n';
8
-import { BackButton, Header, Modal } from '../../../base/react';
8
+import { HeaderWithNavigation, Modal } from '../../../base/react';
9
 import { connect } from '../../../base/redux';
9
 import { connect } from '../../../base/redux';
10
 
10
 
11
 import {
11
 import {
18
 import FormSectionHeader from './FormSectionHeader';
18
 import FormSectionHeader from './FormSectionHeader';
19
 import { normalizeUserInputURL } from '../../functions';
19
 import { normalizeUserInputURL } from '../../functions';
20
 import styles from './styles';
20
 import styles from './styles';
21
-import { HeaderLabel } from '../../../base/react/components/native';
22
 
21
 
23
 /**
22
 /**
24
  * Application information module.
23
  * Application information module.
213
      */
212
      */
214
     _renderHeader() {
213
     _renderHeader() {
215
         return (
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
 

正在加载...
取消
保存