浏览代码

ref: change Chat to JitsiModal

j8
Bettenbuk Zoltan 5 年前
父节点
当前提交
3a2081ffed

+ 13
- 70
react/features/chat/components/native/Chat.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
 import React from 'react';
3
 import React from 'react';
4
-import { KeyboardAvoidingView, SafeAreaView } from 'react-native';
4
+import { KeyboardAvoidingView } from 'react-native';
5
 
5
 
6
-import { ColorSchemeRegistry } from '../../../base/color-scheme';
7
 import { translate } from '../../../base/i18n';
6
 import { translate } from '../../../base/i18n';
8
-import { HeaderWithNavigation, SlidingView } from '../../../base/react';
7
+import { JitsiModal } from '../../../base/modal';
9
 import { connect } from '../../../base/redux';
8
 import { connect } from '../../../base/redux';
10
-import { StyleType } from '../../../base/styles';
9
+
10
+import { CHAT_VIEW_MODAL_ID } from '../../constants';
11
 
11
 
12
 import AbstractChat, {
12
 import AbstractChat, {
13
     _mapDispatchToProps,
13
     _mapDispatchToProps,
14
-    _mapStateToProps as _abstractMapStateToProps,
15
-    type Props as AbstractProps
14
+    _mapStateToProps,
15
+    type Props
16
 } from '../AbstractChat';
16
 } from '../AbstractChat';
17
 
17
 
18
 import ChatInputBar from './ChatInputBar';
18
 import ChatInputBar from './ChatInputBar';
20
 import MessageRecipient from './MessageRecipient';
20
 import MessageRecipient from './MessageRecipient';
21
 import styles from './styles';
21
 import styles from './styles';
22
 
22
 
23
-type Props = AbstractProps & {
24
-
25
-    /**
26
-     * The color-schemed stylesheet of the feature.
27
-     */
28
-    _styles: StyleType
29
-};
30
-
31
 /**
23
 /**
32
  * Implements a React native component that renders the chat window (modal) of
24
  * Implements a React native component that renders the chat window (modal) of
33
  * the mobile client.
25
  * the mobile client.
34
  */
26
  */
35
 class Chat extends AbstractChat<Props> {
27
 class Chat extends AbstractChat<Props> {
36
-    /**
37
-     * Instantiates a new instance.
38
-     *
39
-     * @inheritdoc
40
-     */
41
-    constructor(props: Props) {
42
-        super(props);
43
-
44
-        this._onClose = this._onClose.bind(this);
45
-    }
46
-
47
     /**
28
     /**
48
      * Implements React's {@link Component#render()}.
29
      * Implements React's {@link Component#render()}.
49
      *
30
      *
50
      * @inheritdoc
31
      * @inheritdoc
51
      */
32
      */
52
     render() {
33
     render() {
53
-        const { _styles } = this.props;
54
-
55
         return (
34
         return (
56
-            <SlidingView
57
-                onHide = { this._onClose }
58
-                position = 'bottom'
59
-                show = { this.props._isOpen } >
35
+            <JitsiModal
36
+                headerLabelKey = 'chat.title'
37
+                modalId = { CHAT_VIEW_MODAL_ID }>
60
                 <KeyboardAvoidingView
38
                 <KeyboardAvoidingView
61
                     behavior = 'padding'
39
                     behavior = 'padding'
62
                     style = { styles.chatContainer }>
40
                     style = { styles.chatContainer }>
63
-                    <HeaderWithNavigation
64
-                        headerLabelKey = 'chat.title'
65
-                        onPressBack = { this._onClose } />
66
-                    <SafeAreaView style = { _styles.backdrop }>
67
-                        <MessageContainer messages = { this.props._messages } />
68
-                        <MessageRecipient />
69
-                        <ChatInputBar onSend = { this.props._onSendMessage } />
70
-                    </SafeAreaView>
41
+                    <MessageContainer messages = { this.props._messages } />
42
+                    <MessageRecipient />
43
+                    <ChatInputBar onSend = { this.props._onSendMessage } />
71
                 </KeyboardAvoidingView>
44
                 </KeyboardAvoidingView>
72
-            </SlidingView>
45
+            </JitsiModal>
73
         );
46
         );
74
     }
47
     }
75
-
76
-    _onClose: () => boolean
77
-
78
-    /**
79
-     * Closes the chat window.
80
-     *
81
-     * @returns {boolean}
82
-     */
83
-    _onClose() {
84
-        if (this.props._isOpen) {
85
-            this.props._onToggleChat();
86
-
87
-            return true;
88
-        }
89
-
90
-        return false;
91
-    }
92
-}
93
-
94
-/**
95
- * Maps part of the redux state to the props of this component.
96
- *
97
- * @param {Object} state - The Redux state.
98
- * @returns {Props}
99
- */
100
-function _mapStateToProps(state) {
101
-    return {
102
-        ..._abstractMapStateToProps(state),
103
-        _styles: ColorSchemeRegistry.get(state, 'Chat')
104
-    };
105
 }
48
 }
106
 
49
 
107
 export default translate(connect(_mapStateToProps, _mapDispatchToProps)(Chat));
50
 export default translate(connect(_mapStateToProps, _mapDispatchToProps)(Chat));

+ 3
- 2
react/features/chat/components/native/ChatButton.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { IconChat, IconChatUnread } from '../../../base/icons';
3
 import { IconChat, IconChatUnread } from '../../../base/icons';
4
+import { setActiveModalId } from '../../../base/modal';
4
 import { getLocalParticipant } from '../../../base/participants';
5
 import { getLocalParticipant } from '../../../base/participants';
5
 import { connect } from '../../../base/redux';
6
 import { connect } from '../../../base/redux';
6
 import {
7
 import {
9
 } from '../../../base/toolbox';
10
 } from '../../../base/toolbox';
10
 import { openDisplayNamePrompt } from '../../../display-name';
11
 import { openDisplayNamePrompt } from '../../../display-name';
11
 
12
 
12
-import { toggleChat } from '../../actions';
13
+import { CHAT_VIEW_MODAL_ID } from '../../constants';
13
 import { getUnreadCount } from '../../functions';
14
 import { getUnreadCount } from '../../functions';
14
 
15
 
15
 type Props = AbstractButtonProps & {
16
 type Props = AbstractButtonProps & {
93
          * @returns {void}
94
          * @returns {void}
94
          */
95
          */
95
         _displayChat() {
96
         _displayChat() {
96
-            dispatch(toggleChat());
97
+            dispatch(setActiveModalId(CHAT_VIEW_MODAL_ID));
97
         },
98
         },
98
 
99
 
99
         /**
100
         /**

+ 1
- 2
react/features/chat/components/native/ChatInputBar.js 查看文件

5
 
5
 
6
 import { translate } from '../../../base/i18n';
6
 import { translate } from '../../../base/i18n';
7
 import { Icon, IconChatSend } from '../../../base/icons';
7
 import { Icon, IconChatSend } from '../../../base/icons';
8
-import { Platform } from '../../../base/react';
9
 
8
 
10
 import styles from './styles';
9
 import styles from './styles';
11
 
10
 
136
      */
135
      */
137
     _onFocused(focused) {
136
     _onFocused(focused) {
138
         return () => {
137
         return () => {
139
-            Platform.OS === 'android' && this.setState({
138
+            this.setState({
140
                 addPadding: focused
139
                 addPadding: focused
141
             });
140
             });
142
         };
141
         };

+ 2
- 0
react/features/chat/constants.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
+export const CHAT_VIEW_MODAL_ID = 'chatView';
4
+
3
 /**
5
 /**
4
  * The audio ID of the audio element for which the {@link playAudio} action is
6
  * The audio ID of the audio element for which the {@link playAudio} action is
5
  * triggered when new chat message is received.
7
  * triggered when new chat message is received.

+ 25
- 7
react/features/chat/reducer.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
+import { SET_ACTIVE_MODAL_ID } from '../base/modal';
3
 import { ReducerRegistry } from '../base/redux';
4
 import { ReducerRegistry } from '../base/redux';
4
 
5
 
5
 import {
6
 import {
8
     SET_PRIVATE_MESSAGE_RECIPIENT,
9
     SET_PRIVATE_MESSAGE_RECIPIENT,
9
     TOGGLE_CHAT
10
     TOGGLE_CHAT
10
 } from './actionTypes';
11
 } from './actionTypes';
12
+import { CHAT_VIEW_MODAL_ID } from './constants';
11
 
13
 
12
 const DEFAULT_STATE = {
14
 const DEFAULT_STATE = {
13
     isOpen: false,
15
     isOpen: false,
56
             messages: []
58
             messages: []
57
         };
59
         };
58
 
60
 
61
+    case SET_ACTIVE_MODAL_ID:
62
+        if (action.activeModalId === CHAT_VIEW_MODAL_ID) {
63
+            return updateChatState(state);
64
+        }
65
+
66
+        break;
59
     case SET_PRIVATE_MESSAGE_RECIPIENT:
67
     case SET_PRIVATE_MESSAGE_RECIPIENT:
60
         return {
68
         return {
61
             ...state,
69
             ...state,
64
         };
72
         };
65
 
73
 
66
     case TOGGLE_CHAT:
74
     case TOGGLE_CHAT:
67
-        return {
68
-            ...state,
69
-            isOpen: !state.isOpen,
70
-            lastReadMessage: state.messages[
71
-                navigator.product === 'ReactNative' ? 0 : state.messages.length - 1],
72
-            privateMessageRecipient: state.isOpen ? undefined : state.privateMessageRecipient
73
-        };
75
+        return updateChatState(state);
74
     }
76
     }
75
 
77
 
76
     return state;
78
     return state;
77
 });
79
 });
80
+
81
+/**
82
+ * Updates the chat status on opening the chat view.
83
+ *
84
+ * @param {Object} state - The Redux state of the feature.
85
+ * @returns {Object}
86
+ */
87
+function updateChatState(state) {
88
+    return {
89
+        ...state,
90
+        isOpen: !state.isOpen,
91
+        lastReadMessage: state.messages[
92
+            navigator.product === 'ReactNative' ? 0 : state.messages.length - 1],
93
+        privateMessageRecipient: state.isOpen ? undefined : state.privateMessageRecipient
94
+    };
95
+}

正在加载...
取消
保存