Browse Source

Refactor PagedList components to be independent from the lists it renders

j8
zbettenbuk 7 years ago
parent
commit
68608478f6

BIN
images/history@2x.png View File


BIN
images/history@3x.png View File


+ 1
- 0
lang/main.json View File

@@ -55,6 +55,7 @@
55 55
         "go": "GO",
56 56
         "join": "JOIN",
57 57
         "privacy": "Privacy",
58
+        "recentList": "History",
58 59
         "roomname": "Enter room name",
59 60
         "roomnameHint": "Enter the name or URL of the room you want to join. You may make a name up, just let the people you are meeting know it so that they enter the same name.",
60 61
         "sendFeedback": "Send feedback",

react/features/welcome/components/AbstractPagedList.native.js → react/features/base/react/components/native/AbstractPagedList.js View File

@@ -3,18 +3,16 @@
3 3
 import React, { Component } from 'react';
4 4
 import { View } from 'react-native';
5 5
 
6
-import { MeetingList } from '../../calendar-sync';
7
-import { RecentList } from '../../recent-list';
8
-
9 6
 import styles from './styles';
10 7
 
11
-/**
12
- * The page to be displayed on render.
13
- */
14
-export const DEFAULT_PAGE = 0;
15
-
16 8
 type Props = {
17 9
 
10
+    /**
11
+     * The index (starting from 0) of the page that should be rendered
12
+     * active as default.
13
+     */
14
+    defaultPage: number,
15
+
18 16
     /**
19 17
      * Indicates if the list is disabled or not.
20 18
      */
@@ -26,9 +24,15 @@ type Props = {
26 24
     dispatch: Function,
27 25
 
28 26
     /**
29
-     * The i18n translate function
27
+     * The pages of the PagedList component to be rendered.
28
+     * Note: page.component may be undefined and then they don't need to be
29
+     * rendered.
30 30
      */
31
-    t: Function
31
+    pages: Array<{
32
+        component: Object,
33
+        icon: string | number,
34
+        title: string
35
+    }>
32 36
 };
33 37
 
34 38
 type State = {
@@ -40,14 +44,9 @@ type State = {
40 44
 };
41 45
 
42 46
 /**
43
- * Abstract class for the platform specific paged lists.
47
+ * Abstract class containing the platform independent logic of the paged lists.
44 48
  */
45 49
 export default class AbstractPagedList extends Component<Props, State> {
46
-    /**
47
-     * The list of pages displayed in the component, referenced by page index.
48
-     */
49
-    _pages: Array<Object>;
50
-
51 50
     /**
52 51
      * Constructor of the component.
53 52
      *
@@ -56,16 +55,13 @@ export default class AbstractPagedList extends Component<Props, State> {
56 55
     constructor(props: Props) {
57 56
         super(props);
58 57
 
59
-        this._pages = [];
60
-        for (const component of [ RecentList, MeetingList ]) {
61
-            // XXX Certain pages may be contributed by optional features. For
62
-            // example, MeetingList is contributed by the calendar feature and
63
-            // apps i.e. SDK consumers may not enable the calendar feature.
64
-            component && this._pages.push(component);
65
-        }
58
+        // props.defaultPage may point to a non existing page if some of the
59
+        // pages are disabled.
60
+        const maxPageIndex
61
+            = props.pages.filter(page => page.component).length - 1;
66 62
 
67 63
         this.state = {
68
-            pageIndex: DEFAULT_PAGE
64
+            pageIndex: Math.max(0, Math.min(maxPageIndex, props.defaultPage))
69 65
         };
70 66
     }
71 67
 
@@ -75,7 +71,8 @@ export default class AbstractPagedList extends Component<Props, State> {
75 71
      * @inheritdoc
76 72
      */
77 73
     render() {
78
-        const { disabled } = this.props;
74
+        const { disabled, pages } = this.props;
75
+        const enabledPages = pages.filter(page => page.component);
79 76
 
80 77
         return (
81 78
             <View
@@ -84,14 +81,15 @@ export default class AbstractPagedList extends Component<Props, State> {
84 81
                     disabled ? styles.pagedListContainerDisabled : null
85 82
                 ] }>
86 83
                 {
87
-                    this._pages.length > 1
84
+                    enabledPages.length > 1
88 85
                         ? this._renderPagedList(disabled)
89
-                        : React.createElement(
90
-                            /* type */ this._pages[0],
91
-                            /* props */ {
92
-                                disabled,
93
-                                style: styles.pagedList
94
-                            })
86
+                        : enabledPages.length === 1
87
+                            ? React.createElement(
88
+                                /* type */ enabledPages[0].component,
89
+                                /* props */ {
90
+                                    disabled,
91
+                                    style: styles.pagedList
92
+                                }) : null
95 93
                 }
96 94
             </View>
97 95
         );
@@ -115,10 +113,10 @@ export default class AbstractPagedList extends Component<Props, State> {
115 113
 
116 114
         // The page's Component may have a refresh(dispatch) function which we
117 115
         // invoke when the page is selected.
118
-        const selectedPageComponent = this._pages[pageIndex];
116
+        const selectedPage = this.props.pages[pageIndex];
119 117
 
120
-        if (selectedPageComponent) {
121
-            const { refresh } = selectedPageComponent;
118
+        if (selectedPage && selectedPage.component) {
119
+            const { refresh } = selectedPage.component;
122 120
 
123 121
             typeof refresh === 'function' && refresh(this.props.dispatch);
124 122
         }

+ 198
- 0
react/features/base/react/components/native/PagedList.android.js View File

@@ -0,0 +1,198 @@
1
+// @flow
2
+
3
+import React from 'react';
4
+import { Text, TouchableOpacity, View, ViewPagerAndroid } from 'react-native';
5
+import { connect } from 'react-redux';
6
+
7
+import { Icon } from '../../../font-icons';
8
+
9
+import AbstractPagedList from './AbstractPagedList';
10
+import styles from './styles';
11
+
12
+/**
13
+ * An Android specific component to render a paged list.
14
+ *
15
+ * @extends PagedList
16
+ */
17
+class PagedList extends AbstractPagedList {
18
+    /**
19
+     * A reference to the viewpager.
20
+     */
21
+    _viewPager: ViewPagerAndroid;
22
+
23
+    /**
24
+     * Initializes a new {@code PagedList} instance.
25
+     *
26
+     * @inheritdoc
27
+     */
28
+    constructor(props) {
29
+        super(props);
30
+
31
+        // Bind event handlers so they are only bound once per instance.
32
+        this._onIconPress = this._onIconPress.bind(this);
33
+        this._getIndicatorStyle = this._getIndicatorStyle.bind(this);
34
+        this._onPageSelected = this._onPageSelected.bind(this);
35
+        this._setViewPager = this._setViewPager.bind(this);
36
+    }
37
+
38
+    _onIconPress: number => Function;
39
+
40
+    /**
41
+     * Constructs a function to be used as a callback for the icons in the tab
42
+     * bar.
43
+     *
44
+     * @param {number} pageIndex - The index of the page to activate via the
45
+     * callback.
46
+     * @private
47
+     * @returns {Function}
48
+     */
49
+    _onIconPress(pageIndex) {
50
+        return () => {
51
+            this._viewPager.setPage(pageIndex);
52
+            this._selectPage(pageIndex);
53
+        };
54
+    }
55
+
56
+    _getIndicatorStyle: number => Object;
57
+
58
+    /**
59
+     * Constructs the style of an indicator.
60
+     *
61
+     * @param {number} indicatorIndex - The index of the indicator.
62
+     * @private
63
+     * @returns {Object}
64
+     */
65
+    _getIndicatorStyle(indicatorIndex) {
66
+        if (this.state.pageIndex === indicatorIndex) {
67
+            return styles.pageIndicatorActive;
68
+        }
69
+
70
+        return null;
71
+    }
72
+
73
+    _onPageSelected: Object => void;
74
+
75
+    /**
76
+     * Updates the index of the currently selected page, based on the native
77
+     * event received from the {@link ViewPagerAndroid} component.
78
+     *
79
+     * @param {Object} event - The native event of the callback.
80
+     * @private
81
+     * @returns {void}
82
+     */
83
+    _onPageSelected({ nativeEvent: { position } }) {
84
+        if (this.state.pageIndex !== position) {
85
+            this._selectPage(position);
86
+        }
87
+    }
88
+
89
+    /**
90
+     * Renders a single page of the page list.
91
+     *
92
+     * @private
93
+     * @param {Object} page - The page to render.
94
+     * @param {number} index - The index of the rendered page.
95
+     * @param {boolean} disabled - Renders the page disabled.
96
+     * @returns {React$Node}
97
+     */
98
+    _renderPage(page, index, disabled) {
99
+        return page.component
100
+            ? <View key = { index }>
101
+                {
102
+                    React.createElement(
103
+                        page.component,
104
+                        {
105
+                            disabled
106
+                        })
107
+                }
108
+            </View>
109
+            : null;
110
+    }
111
+
112
+    /**
113
+     * Renders a page indicator (icon) for the page.
114
+     *
115
+     * @private
116
+     * @param {Object} page - The page the indicator is rendered for.
117
+     * @param {number} index - The index of the page the indicator is rendered
118
+     * for.
119
+     * @param {boolean} disabled - Renders the indicator disabled.
120
+     * @returns {React$Node}
121
+     */
122
+    _renderPageIndicator(page, index, disabled) {
123
+        return page.component
124
+            ? <TouchableOpacity
125
+                disabled = { disabled }
126
+                onPress = { this._onIconPress(index) }
127
+                style = { styles.pageIndicator } >
128
+                <View style = { styles.pageIndicator }>
129
+                    <Icon
130
+                        name = { page.icon }
131
+                        style = { [
132
+                            styles.pageIndicatorIcon,
133
+                            this._getIndicatorStyle(index)
134
+                        ] } />
135
+                    <Text
136
+                        style = { [
137
+                            styles.pageIndicatorText,
138
+                            this._getIndicatorStyle(index)
139
+                        ] }>
140
+                        { page.title }
141
+                    </Text>
142
+                </View>
143
+            </TouchableOpacity>
144
+            : null;
145
+    }
146
+
147
+    /**
148
+     * Renders the paged list if multiple pages are to be rendered. This is the
149
+     * platform dependent part of the component.
150
+     *
151
+     * @param {boolean} disabled - True if the rendered lists should be
152
+     * disabled.
153
+     * @returns {ReactElement}
154
+     */
155
+    _renderPagedList(disabled) {
156
+        const { defaultPage, pages } = this.props;
157
+
158
+        return (
159
+            <View style = { styles.pagedListContainer }>
160
+                <ViewPagerAndroid
161
+                    initialPage = { defaultPage }
162
+                    onPageSelected = { this._onPageSelected }
163
+                    peekEnabled = { true }
164
+                    ref = { this._setViewPager }
165
+                    style = { styles.pagedList }>
166
+                    {
167
+                        pages.map((page, index) => this._renderPage(
168
+                            page, index, disabled
169
+                        ))
170
+                    }
171
+                </ViewPagerAndroid>
172
+                <View style = { styles.pageIndicatorContainer }>
173
+                    {
174
+                        pages.map((page, index) => this._renderPageIndicator(
175
+                            page, index, disabled
176
+                        ))
177
+                    }
178
+                </View>
179
+            </View>
180
+        );
181
+    }
182
+
183
+    _setViewPager: Object => void;
184
+
185
+    /**
186
+     * Sets the {@link ViewPagerAndroid} instance.
187
+     *
188
+     * @param {ViewPagerAndroid} viewPager - The {@code ViewPagerAndroid}
189
+     * instance.
190
+     * @private
191
+     * @returns {void}
192
+     */
193
+    _setViewPager(viewPager) {
194
+        this._viewPager = viewPager;
195
+    }
196
+}
197
+
198
+export default connect()(PagedList);

+ 100
- 0
react/features/base/react/components/native/PagedList.ios.js View File

@@ -0,0 +1,100 @@
1
+// @flow
2
+
3
+import React from 'react';
4
+import { TabBarIOS } from 'react-native';
5
+import { connect } from 'react-redux';
6
+
7
+import AbstractPagedList from './AbstractPagedList';
8
+import styles from './styles';
9
+
10
+/**
11
+ * An iOS specific component to render a paged list.
12
+ *
13
+ * @extends PagedList
14
+ */
15
+class PagedList extends AbstractPagedList {
16
+
17
+    /**
18
+     * Initializes a new {@code PagedList} instance.
19
+     *
20
+     * @inheritdoc
21
+     */
22
+    constructor(props) {
23
+        super(props);
24
+
25
+        // Bind event handlers so they are only bound once per instance.
26
+        this._onTabSelected = this._onTabSelected.bind(this);
27
+    }
28
+
29
+    _onTabSelected: number => Function;
30
+
31
+    /**
32
+     * Constructs a callback to update the selected tab when the bottom bar icon
33
+     * is pressed.
34
+     *
35
+     * @param {number} tabIndex - The selected tab.
36
+     * @private
37
+     * @returns {Function}
38
+     */
39
+    _onTabSelected(tabIndex) {
40
+        return () => super._selectPage(tabIndex);
41
+    }
42
+
43
+    _renderPage: (Object, number, boolean) => React$Node
44
+
45
+    /**
46
+     * Renders a single page of the page list.
47
+     *
48
+     * @private
49
+     * @param {Object} page - The page to render.
50
+     * @param {number} index - The index of the rendered page.
51
+     * @param {boolean} disabled - Renders the page disabled.
52
+     * @returns {React$Node}
53
+     */
54
+    _renderPage(page, index, disabled) {
55
+        const { pageIndex } = this.state;
56
+
57
+        return page.component
58
+            ? <TabBarIOS.Item
59
+                icon = { page.icon }
60
+                key = { index }
61
+                onPress = { this._onTabSelected(index) }
62
+                selected = { pageIndex === index }
63
+                title = { page.title }>
64
+                {
65
+                    React.createElement(
66
+                        page.component,
67
+                        {
68
+                            disabled
69
+                        })
70
+                }
71
+            </TabBarIOS.Item>
72
+            : null;
73
+    }
74
+
75
+    /**
76
+     * Renders the paged list if multiple pages are to be rendered. This is the
77
+     * platform dependent part of the component.
78
+     *
79
+     * @param {boolean} disabled - True if the rendered lists should be
80
+     * disabled.
81
+     * @returns {ReactElement}
82
+     */
83
+    _renderPagedList(disabled) {
84
+        const { pages } = this.props;
85
+
86
+        return (
87
+            <TabBarIOS
88
+                itemPositioning = 'fill'
89
+                style = { styles.pagedList }>
90
+                {
91
+                    pages.map((page, index) => this._renderPage(
92
+                        page, index, disabled
93
+                    ))
94
+                }
95
+            </TabBarIOS>
96
+        );
97
+    }
98
+}
99
+
100
+export default connect()(PagedList);

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

@@ -3,6 +3,7 @@ export { default as Header } from './Header';
3 3
 export { default as NavigateSectionList } from './NavigateSectionList';
4 4
 export { default as Link } from './Link';
5 5
 export { default as LoadingIndicator } from './LoadingIndicator';
6
+export { default as PagedList } from './PagedList';
6 7
 export { default as Pressable } from './Pressable';
7 8
 export { default as SideBar } from './SideBar';
8 9
 export { default as Text } from './Text';

+ 72
- 0
react/features/base/react/components/native/styles.js View File

@@ -71,6 +71,77 @@ const HEADER_STYLES = {
71 71
     }
72 72
 };
73 73
 
74
+/**
75
+ * Style classes of the PagedList-based components.
76
+ */
77
+const PAGED_LIST_STYLES = {
78
+
79
+    /**
80
+     * Style of the page indicator (Android).
81
+     */
82
+    pageIndicator: {
83
+        alignItems: 'center',
84
+        flex: 1,
85
+        flexDirection: 'column',
86
+        justifyContent: 'center'
87
+    },
88
+
89
+    /**
90
+     * Additional style for the active indicator icon (Android).
91
+     */
92
+    pageIndicatorActive: {
93
+        color: ColorPalette.white
94
+    },
95
+
96
+    /**
97
+     * Container for the page indicators (Android).
98
+     */
99
+    pageIndicatorContainer: {
100
+        alignItems: 'stretch',
101
+        backgroundColor: ColorPalette.blue,
102
+        flexDirection: 'row',
103
+        height: 56,
104
+        justifyContent: 'center'
105
+    },
106
+
107
+    /**
108
+     * Icon of the page indicator (Android).
109
+     */
110
+    pageIndicatorIcon: {
111
+        color: ColorPalette.blueHighlight,
112
+        fontSize: 24
113
+    },
114
+
115
+    /**
116
+     * Label of the page indicator (Android).
117
+     */
118
+    pageIndicatorText: {
119
+        color: ColorPalette.blueHighlight
120
+    },
121
+
122
+    /**
123
+     * Top level style of the paged list.
124
+     */
125
+    pagedList: {
126
+        flex: 1
127
+    },
128
+
129
+    /**
130
+     * The paged list container View.
131
+     */
132
+    pagedListContainer: {
133
+        flex: 1,
134
+        flexDirection: 'column'
135
+    },
136
+
137
+    /**
138
+     * Disabled style for the container.
139
+     */
140
+    pagedListContainerDisabled: {
141
+        opacity: 0.2
142
+    }
143
+};
144
+
74 145
 const SECTION_LIST_STYLES = {
75 146
     /**
76 147
      * The style of the actual avatar.
@@ -248,6 +319,7 @@ const SIDEBAR_STYLES = {
248 319
  */
249 320
 export default createStyleSheet({
250 321
     ...HEADER_STYLES,
322
+    ...PAGED_LIST_STYLES,
251 323
     ...SECTION_LIST_STYLES,
252 324
     ...SIDEBAR_STYLES
253 325
 });

+ 0
- 0
react/features/welcome/components/AbstractPagedList.web.js View File


+ 0
- 173
react/features/welcome/components/PagedList.android.js View File

@@ -1,173 +0,0 @@
1
-// @flow
2
-
3
-import React from 'react';
4
-import { Text, TouchableOpacity, View, ViewPagerAndroid } from 'react-native';
5
-import { connect } from 'react-redux';
6
-
7
-import { Icon } from '../../base/font-icons';
8
-import { MeetingList } from '../../calendar-sync';
9
-import { RecentList } from '../../recent-list';
10
-
11
-import AbstractPagedList, { DEFAULT_PAGE } from './AbstractPagedList';
12
-import styles from './styles';
13
-
14
-/**
15
- * A platform specific component to render a paged or tabbed list/view.
16
- *
17
- * @extends PagedList
18
- */
19
-class PagedList extends AbstractPagedList {
20
-    /**
21
-     * A reference to the viewpager.
22
-     */
23
-    _viewPager: Object;
24
-
25
-    /**
26
-     * Initializes a new {@code PagedList} instance.
27
-     *
28
-     * @inheritdoc
29
-     */
30
-    constructor(props) {
31
-        super(props);
32
-
33
-        // Bind event handlers so they are only bound once per instance.
34
-        this._getIndicatorStyle = this._getIndicatorStyle.bind(this);
35
-        this._onPageSelected = this._onPageSelected.bind(this);
36
-        this._onSelectPage = this._onSelectPage.bind(this);
37
-        this._setViewPager = this._setViewPager.bind(this);
38
-    }
39
-
40
-    _getIndicatorStyle: number => Object;
41
-
42
-    /**
43
-     * Constructs the style of an indicator.
44
-     *
45
-     * @param {number} indicatorIndex - The index of the indicator.
46
-     * @private
47
-     * @returns {Object}
48
-     */
49
-    _getIndicatorStyle(indicatorIndex) {
50
-        if (this.state.pageIndex === indicatorIndex) {
51
-            return styles.pageIndicatorTextActive;
52
-        }
53
-
54
-        return null;
55
-    }
56
-
57
-    _onPageSelected: Object => void;
58
-
59
-    /**
60
-     * Updates the index of the currently selected page.
61
-     *
62
-     * @param {Object} event - The native event of the callback.
63
-     * @private
64
-     * @returns {void}
65
-     */
66
-    _onPageSelected({ nativeEvent: { position } }) {
67
-        if (this.state.pageIndex !== position) {
68
-            this._selectPage(position);
69
-        }
70
-    }
71
-
72
-    _onSelectPage: number => Function;
73
-
74
-    /**
75
-     * Constructs a function to be used as a callback for the tab bar.
76
-     *
77
-     * @param {number} pageIndex - The index of the page to activate via the
78
-     * callback.
79
-     * @private
80
-     * @returns {Function}
81
-     */
82
-    _onSelectPage(pageIndex) {
83
-        return () => {
84
-            this._viewPager.setPage(pageIndex);
85
-            this._selectPage(pageIndex);
86
-        };
87
-    }
88
-
89
-    /**
90
-     * Renders the entire paged list if calendar is enabled.
91
-     *
92
-     * @param {boolean} disabled - True if the rendered lists should be
93
-     * disabled.
94
-     * @returns {ReactElement}
95
-     */
96
-    _renderPagedList(disabled) {
97
-        return (
98
-            <View style = { styles.pagedListContainer }>
99
-                <ViewPagerAndroid
100
-                    initialPage = { DEFAULT_PAGE }
101
-                    onPageSelected = { this._onPageSelected }
102
-                    peekEnabled = { true }
103
-                    ref = { this._setViewPager }
104
-                    style = { styles.pagedList }>
105
-                    <View key = { 0 }>
106
-                        <RecentList disabled = { disabled } />
107
-                    </View>
108
-                    <View key = { 1 }>
109
-                        <MeetingList disabled = { disabled } />
110
-                    </View>
111
-                </ViewPagerAndroid>
112
-                <View style = { styles.pageIndicatorContainer }>
113
-                    <TouchableOpacity
114
-                        disabled = { disabled }
115
-                        onPress = { this._onSelectPage(0) }
116
-                        style = { styles.pageIndicator } >
117
-                        <View style = { styles.pageIndicator }>
118
-                            <Icon
119
-                                name = 'restore'
120
-                                style = { [
121
-                                    styles.pageIndicatorIcon,
122
-                                    this._getIndicatorStyle(0)
123
-                                ] } />
124
-                            <Text
125
-                                style = { [
126
-                                    styles.pageIndicatorText,
127
-                                    this._getIndicatorStyle(0)
128
-                                ] }>
129
-                                History
130
-                            </Text>
131
-                        </View>
132
-                    </TouchableOpacity>
133
-                    <TouchableOpacity
134
-                        disabled = { disabled }
135
-                        onPress = { this._onSelectPage(1) }
136
-                        style = { styles.pageIndicator } >
137
-                        <View style = { styles.pageIndicator }>
138
-                            <Icon
139
-                                name = 'event_note'
140
-                                style = { [
141
-                                    styles.pageIndicatorIcon,
142
-                                    this._getIndicatorStyle(1)
143
-                                ] } />
144
-                            <Text
145
-                                style = { [
146
-                                    styles.pageIndicatorText,
147
-                                    this._getIndicatorStyle(1)
148
-                                ] }>
149
-                                Calendar
150
-                            </Text>
151
-                        </View>
152
-                    </TouchableOpacity>
153
-                </View>
154
-            </View>
155
-        );
156
-    }
157
-
158
-    _setViewPager: Object => void;
159
-
160
-    /**
161
-     * Sets the {@link ViewPagerAndroid} instance.
162
-     *
163
-     * @param {ViewPagerAndroid} viewPager - The {@code ViewPagerAndroid}
164
-     * instance.
165
-     * @private
166
-     * @returns {void}
167
-     */
168
-    _setViewPager(viewPager) {
169
-        this._viewPager = viewPager;
170
-    }
171
-}
172
-
173
-export default connect()(PagedList);

+ 0
- 81
react/features/welcome/components/PagedList.ios.js View File

@@ -1,81 +0,0 @@
1
-// @flow
2
-
3
-import React from 'react';
4
-import { TabBarIOS } from 'react-native';
5
-import { connect } from 'react-redux';
6
-
7
-import { translate } from '../../base/i18n';
8
-import { MeetingList } from '../../calendar-sync';
9
-import { RecentList } from '../../recent-list';
10
-
11
-import AbstractPagedList from './AbstractPagedList';
12
-import styles from './styles';
13
-
14
-const CALENDAR_ICON = require('../../../../images/calendar.png');
15
-
16
-/**
17
- * A platform specific component to render a paged or tabbed list/view.
18
- *
19
- * @extends PagedList
20
- */
21
-class PagedList extends AbstractPagedList {
22
-
23
-    /**
24
-     * Initializes a new {@code PagedList} instance.
25
-     *
26
-     * @inheritdoc
27
-     */
28
-    constructor(props) {
29
-        super(props);
30
-
31
-        // Bind event handlers so they are only bound once per instance.
32
-        this._onTabSelected = this._onTabSelected.bind(this);
33
-    }
34
-
35
-    _onTabSelected: number => Function;
36
-
37
-    /**
38
-     * Constructs a callback to update the selected tab.
39
-     *
40
-     * @param {number} tabIndex - The selected tab.
41
-     * @private
42
-     * @returns {Function}
43
-     */
44
-    _onTabSelected(tabIndex) {
45
-        return () => super._selectPage(tabIndex);
46
-    }
47
-
48
-    /**
49
-     * Renders the entire paged list if calendar is enabled.
50
-     *
51
-     * @param {boolean} disabled - True if the rendered lists should be
52
-     * disabled.
53
-     * @returns {ReactElement}
54
-     */
55
-    _renderPagedList(disabled) {
56
-        const { pageIndex } = this.state;
57
-        const { t } = this.props;
58
-
59
-        return (
60
-            <TabBarIOS
61
-                itemPositioning = 'fill'
62
-                style = { styles.pagedList }>
63
-                <TabBarIOS.Item
64
-                    onPress = { this._onTabSelected(0) }
65
-                    selected = { pageIndex === 0 }
66
-                    systemIcon = 'history'>
67
-                    <RecentList disabled = { disabled } />
68
-                </TabBarIOS.Item>
69
-                <TabBarIOS.Item
70
-                    icon = { CALENDAR_ICON }
71
-                    onPress = { this._onTabSelected(1) }
72
-                    selected = { pageIndex === 1 }
73
-                    title = { t('welcomepage.calendar') }>
74
-                    <MeetingList disabled = { disabled } />
75
-                </TabBarIOS.Item>
76
-            </TabBarIOS>
77
-        );
78
-    }
79
-}
80
-
81
-export default translate(connect()(PagedList));

+ 2
- 2
react/features/welcome/components/WelcomePage.native.js View File

@@ -26,12 +26,12 @@ import { SettingsView } from '../../settings';
26 26
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
27 27
 import { setSideBarVisible } from '../actions';
28 28
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
29
-import PagedList from './PagedList';
30 29
 import styles, {
31 30
     PLACEHOLDER_TEXT_COLOR,
32 31
     SWITCH_THUMB_COLOR,
33 32
     SWITCH_UNDER_COLOR
34 33
 } from './styles';
34
+import WelcomePageLists from './WelcomePageLists';
35 35
 import WelcomePageSideBar from './WelcomePageSideBar';
36 36
 
37 37
 /**
@@ -139,7 +139,7 @@ class WelcomePage extends AbstractWelcomePage {
139 139
                             }
140 140
                         </View>
141 141
                     </SafeAreaView>
142
-                    <PagedList disabled = { this.state._fieldFocused } />
142
+                    <WelcomePageLists disabled = { this.state._fieldFocused } />
143 143
                     <SettingsView />
144 144
                 </View>
145 145
                 <WelcomePageSideBar />

+ 88
- 0
react/features/welcome/components/WelcomePageLists.js View File

@@ -0,0 +1,88 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+import { Platform } from 'react-native';
5
+
6
+import { translate } from '../../base/i18n';
7
+import { PagedList } from '../../base/react';
8
+import { MeetingList } from '../../calendar-sync';
9
+import { RecentList } from '../../recent-list';
10
+
11
+type Props = {
12
+
13
+    /**
14
+     * Renders the lists disabled.
15
+     */
16
+    disabled: boolean,
17
+
18
+    /**
19
+     * The i18n translate function.
20
+     */
21
+    t: Function
22
+};
23
+
24
+/**
25
+ * Icon to be used for the calendar page on iOS.
26
+ */
27
+const IOS_CALENDAR_ICON = require('../../../../images/calendar.png');
28
+
29
+/**
30
+ * Icon to be used for the recent list page on iOS.
31
+ */
32
+const IOS_RECENT_LIST_ICON = require('../../../../images/history.png');
33
+
34
+/**
35
+ * Implements the lists displayed on the mobile welcome screen.
36
+ */
37
+class WelcomePageLists extends Component<Props> {
38
+    /**
39
+     * The pages to be rendered.
40
+     * Note: The component field may be undefined if a feature (such as
41
+     * Calendar) is disabled, and that means that the page must not be rendered.
42
+     */
43
+    pages: Array<{
44
+        component: Object,
45
+        icon: string | number,
46
+        title: string
47
+    }>
48
+
49
+    /**
50
+     * Component contructor.
51
+     *
52
+     * @inheritdoc
53
+     */
54
+    constructor(props) {
55
+        super(props);
56
+
57
+        const { t } = props;
58
+        const isAndroid = Platform.OS === 'android';
59
+
60
+        this.pages = [ {
61
+            component: RecentList,
62
+            icon: isAndroid ? 'restore' : IOS_RECENT_LIST_ICON,
63
+            title: t('welcomepage.recentList')
64
+        }, {
65
+            component: MeetingList,
66
+            icon: isAndroid ? 'event_note' : IOS_CALENDAR_ICON,
67
+            title: t('welcomepage.calendar')
68
+        } ];
69
+    }
70
+
71
+    /**
72
+     * Implements React Component's render.
73
+     *
74
+     * @inheritdoc
75
+     */
76
+    render() {
77
+        const { disabled } = this.props;
78
+
79
+        return (
80
+            <PagedList
81
+                defaultPage = { 0 }
82
+                disabled = { disabled }
83
+                pages = { this.pages } />
84
+        );
85
+    }
86
+}
87
+
88
+export default translate(WelcomePageLists);

+ 0
- 47
react/features/welcome/components/styles.js View File

@@ -161,53 +161,6 @@ export default createStyleSheet({
161 161
         flexDirection: 'column'
162 162
     },
163 163
 
164
-    pageIndicator: {
165
-        alignItems: 'center',
166
-        flex: 1,
167
-        flexDirection: 'column',
168
-        justifyContent: 'center'
169
-    },
170
-
171
-    pageIndicatorContainer: {
172
-        alignItems: 'stretch',
173
-        backgroundColor: ColorPalette.blue,
174
-        flexDirection: 'row',
175
-        height: 56,
176
-        justifyContent: 'center'
177
-    },
178
-
179
-    pageIndicatorIcon: {
180
-        color: ColorPalette.blueHighlight,
181
-        fontSize: 24
182
-    },
183
-
184
-    pageIndicatorText: {
185
-        color: ColorPalette.blueHighlight
186
-    },
187
-
188
-    pageIndicatorTextActive: {
189
-        color: ColorPalette.white
190
-    },
191
-
192
-    /**
193
-     * Top level style of the paged list.
194
-     */
195
-    pagedList: {
196
-        flex: 1
197
-    },
198
-
199
-    pagedListContainer: {
200
-        flex: 1,
201
-        flexDirection: 'column'
202
-    },
203
-
204
-    /**
205
-     * Disabled style for the container.
206
-     */
207
-    pagedListContainerDisabled: {
208
-        opacity: 0.2
209
-    },
210
-
211 164
     /**
212 165
      * Container for room name input box and 'join' button.
213 166
      */

Loading…
Cancel
Save