瀏覽代碼

feat(base): removed PagedList because it is not used anymore

factor2
Calin-Teodor 2 年之前
父節點
當前提交
75ddf3e75f

+ 0
- 296
react/features/base/react/components/native/PagedList.js 查看文件

@@ -1,296 +0,0 @@
1
-// @flow
2
-
3
-import React, { Component } from 'react';
4
-import { SafeAreaView, Text, TouchableOpacity, View } from 'react-native';
5
-
6
-import { Icon } from '../../../icons';
7
-import { connect } from '../../../redux';
8
-
9
-import styles from './styles';
10
-
11
-/**
12
- * The type of the React {@code Component} props of {@link PagedList}.
13
- */
14
-type Props = {
15
-
16
-    /**
17
-     * The zero-based index of the page that should be rendered (selected) by
18
-     * default.
19
-     */
20
-    defaultPage: number,
21
-
22
-    /**
23
-     * Indicates if the list is disabled or not.
24
-     */
25
-    disabled: boolean,
26
-
27
-    /**
28
-     * The Redux dispatch function.
29
-     */
30
-    dispatch: Function,
31
-
32
-    /**
33
-     * Callback to execute on page change.
34
-     */
35
-    onSelectPage: ?Function,
36
-
37
-    /**
38
-     * The pages of the PagedList component to be rendered.
39
-     *
40
-     * NOTE 1: An element's {@code component} may be {@code undefined} and then
41
-     * it won't need to be rendered.
42
-     *
43
-     * NOTE 2: There must be at least one page available and enabled.
44
-     */
45
-    pages: Array<{
46
-        component: ?Object,
47
-        icon: string | number,
48
-        title: string
49
-    }>
50
-};
51
-
52
-/**
53
- * The type of the React {@code Component} state of {@link PagedList}.
54
- */
55
-type State = {
56
-
57
-    /**
58
-     * The currently selected page.
59
-     */
60
-    pageIndex: number
61
-};
62
-
63
-/**
64
- * A component that renders a paged list.
65
- *
66
- * @augments PagedList
67
- */
68
-class PagedList extends Component<Props, State> {
69
-
70
-    /**
71
-     * Initializes a new {@code PagedList} instance.
72
-     *
73
-     * @inheritdoc
74
-     */
75
-    constructor(props: Props) {
76
-        super(props);
77
-
78
-        this.state = {
79
-            pageIndex: this._validatePageIndex(props.defaultPage)
80
-        };
81
-
82
-        // Bind event handlers so they are only bound once per instance.
83
-        this._maybeRefreshSelectedPage
84
-            = this._maybeRefreshSelectedPage.bind(this);
85
-    }
86
-
87
-    /**
88
-     * Renders the component.
89
-     *
90
-     * @inheritdoc
91
-     */
92
-    render() {
93
-        const { disabled } = this.props;
94
-        const pages = this.props.pages.filter(({ component }) => component);
95
-        let children;
96
-
97
-        if (pages.length > 1) {
98
-            children = this._renderPagedList(disabled);
99
-        } else {
100
-            children = React.createElement(
101
-
102
-                // $FlowExpectedError
103
-                /* type */ pages[0].component,
104
-                /* props */ {
105
-                    disabled,
106
-                    style: styles.pagedList
107
-                });
108
-        }
109
-
110
-        return (
111
-            <View
112
-                style = { [
113
-                    styles.pagedListContainer,
114
-                    disabled ? styles.pagedListContainerDisabled : null
115
-                ] }>
116
-                {
117
-
118
-                    // $FlowExpectedError
119
-                    children
120
-                }
121
-            </View>
122
-        );
123
-    }
124
-
125
-    /**
126
-     * Constructs the style of an indicator.
127
-     *
128
-     * @param {number} indicatorIndex - The index of the indicator.
129
-     * @private
130
-     * @returns {Object}
131
-     */
132
-    _getIndicatorStyle(indicatorIndex) {
133
-        if (this.state.pageIndex === indicatorIndex) {
134
-            return styles.pageIndicatorActive;
135
-        }
136
-
137
-        return null;
138
-    }
139
-
140
-    _maybeRefreshSelectedPage: ?boolean => void;
141
-
142
-    /**
143
-     * Components that this PagedList displays may have a refresh function to
144
-     * refresh its content when displayed (or based on custom logic). This
145
-     * function invokes this logic if it's present.
146
-     *
147
-     * @private
148
-     * @param {boolean} isInteractive - If true this refresh was caused by
149
-     * direct user interaction, false otherwise.
150
-     * @returns {void}
151
-     */
152
-    _maybeRefreshSelectedPage(isInteractive: boolean = true) {
153
-        const selectedPage = this.props.pages[this.state.pageIndex];
154
-        let component;
155
-
156
-        if (selectedPage && (component = selectedPage.component)) {
157
-            // react-i18n / react-redux wrap components and thus we cannot access
158
-            // the wrapped component's static methods directly.
159
-            const component_ = component.WrappedComponent || component;
160
-            const { refresh } = component_;
161
-
162
-            refresh.call(component, this.props.dispatch, isInteractive);
163
-        }
164
-    }
165
-
166
-    /**
167
-     * Sets the selected page.
168
-     *
169
-     * @param {number} pageIndex - The index of the selected page.
170
-     * @protected
171
-     * @returns {void}
172
-     */
173
-    _onSelectPage(pageIndex: number) {
174
-        return () => {
175
-            // eslint-disable-next-line no-param-reassign
176
-            pageIndex = this._validatePageIndex(pageIndex);
177
-
178
-            const { onSelectPage } = this.props;
179
-
180
-            onSelectPage && onSelectPage(pageIndex);
181
-
182
-            this.setState({ pageIndex }, this._maybeRefreshSelectedPage);
183
-        };
184
-    }
185
-
186
-    /**
187
-     * Renders a single page of the page list.
188
-     *
189
-     * @private
190
-     * @param {Object} page - The page to render.
191
-     * @param {boolean} disabled - Renders the page disabled.
192
-     * @returns {React$Node}
193
-     */
194
-    _renderPage(page, disabled) {
195
-        if (!page.component) {
196
-            return null;
197
-        }
198
-
199
-        return (
200
-            <View style = { styles.pageContainer }>
201
-                {
202
-                    React.createElement(
203
-                        page.component,
204
-                        {
205
-                            disabled
206
-                        })
207
-                }
208
-            </View>
209
-        );
210
-    }
211
-
212
-    /**
213
-     * Renders the paged list if multiple pages are to be rendered.
214
-     *
215
-     * @param {boolean} disabled - True if the rendered lists should be
216
-     * disabled.
217
-     * @returns {ReactElement}
218
-     */
219
-    _renderPagedList(disabled) {
220
-        const { pages } = this.props;
221
-        const { pageIndex } = this.state;
222
-
223
-        return (
224
-            <View style = { styles.pagedListContainer }>
225
-                {
226
-                    this._renderPage(pages[pageIndex], disabled)
227
-                }
228
-                <SafeAreaView style = { styles.pageIndicatorContainer }>
229
-                    {
230
-                        pages.map((page, index) => this._renderPageIndicator(
231
-                            page, index, disabled
232
-                        ))
233
-                    }
234
-                </SafeAreaView>
235
-            </View>
236
-        );
237
-    }
238
-
239
-    /**
240
-     * Renders a page indicator (icon) for the page.
241
-     *
242
-     * @private
243
-     * @param {Object} page - The page the indicator is rendered for.
244
-     * @param {number} index - The index of the page the indicator is rendered
245
-     * for.
246
-     * @param {boolean} disabled - Renders the indicator disabled.
247
-     * @returns {React$Node}
248
-     */
249
-    _renderPageIndicator(page, index, disabled) {
250
-        if (!page.component) {
251
-            return null;
252
-        }
253
-
254
-        return (
255
-            <TouchableOpacity
256
-                disabled = { disabled }
257
-                key = { index }
258
-                onPress = { this._onSelectPage(index) }
259
-                style = { styles.pageIndicator } >
260
-                <View style = { styles.pageIndicatorContent }>
261
-                    <Icon
262
-                        src = { page.icon }
263
-                        style = { [
264
-                            styles.pageIndicatorIcon,
265
-                            this._getIndicatorStyle(index)
266
-                        ] } />
267
-                    <Text
268
-                        style = { [
269
-                            styles.pageIndicatorText,
270
-                            this._getIndicatorStyle(index)
271
-                        ] }>
272
-                        { page.title }
273
-                    </Text>
274
-                </View>
275
-            </TouchableOpacity>
276
-        );
277
-    }
278
-
279
-    /**
280
-     * Validates the requested page index and returns a safe value.
281
-     *
282
-     * @private
283
-     * @param {number} pageIndex - The requested page index.
284
-     * @returns {number}
285
-     */
286
-    _validatePageIndex(pageIndex) {
287
-        // pageIndex may point to a non-existing page if some of the pages are
288
-        // disabled (their component property is undefined).
289
-        const maxPageIndex
290
-            = this.props.pages.filter(({ component }) => component).length - 1;
291
-
292
-        return Math.max(0, Math.min(maxPageIndex, pageIndex));
293
-    }
294
-}
295
-
296
-export default connect()(PagedList);

+ 0
- 1
react/features/base/react/components/native/index.js 查看文件

@@ -15,7 +15,6 @@ export { default as NavigateSectionListItem }
15 15
     from './NavigateSectionListItem';
16 16
 export { default as NavigateSectionListSectionHeader }
17 17
     from './NavigateSectionListSectionHeader';
18
-export { default as PagedList } from './PagedList';
19 18
 export { default as Pressable } from './Pressable';
20 19
 export { default as SectionList } from './SectionList';
21 20
 export { default as SlidingView } from './SlidingView';

+ 0
- 84
react/features/base/react/components/native/styles.js 查看文件

@@ -9,89 +9,6 @@ const SECONDARY_ACTION_BUTTON_SIZE = 30;
9 9
 export const AVATAR_SIZE = 65;
10 10
 export const UNDERLAY_COLOR = 'rgba(255, 255, 255, 0.2)';
11 11
 
12
-/**
13
- * Style classes of the PagedList-based components.
14
- */
15
-const PAGED_LIST_STYLES = {
16
-
17
-    /**
18
-     * Outermost container of a page in {@code PagedList}.
19
-     */
20
-    pageContainer: {
21
-        flex: 1
22
-    },
23
-
24
-    /**
25
-     * Style of the page indicator (Android).
26
-     */
27
-    pageIndicator: {
28
-        alignItems: 'center',
29
-        flexDirection: 'column',
30
-        justifyContent: 'center',
31
-        padding: BoxModel.padding / 2
32
-    },
33
-
34
-    /**
35
-     * Additional style for the active indicator icon (Android).
36
-     */
37
-    pageIndicatorActive: {
38
-        color: ColorPalette.white
39
-    },
40
-
41
-    /**
42
-     * Container for the page indicators (Android).
43
-     */
44
-    pageIndicatorContainer: {
45
-        alignItems: 'center',
46
-        backgroundColor: ColorPalette.blue,
47
-        flexDirection: 'row',
48
-        justifyContent: 'space-around'
49
-    },
50
-
51
-    pageIndicatorContent: {
52
-        alignItems: 'center',
53
-        flexDirection: 'column',
54
-        justifyContent: 'center'
55
-    },
56
-
57
-    /**
58
-     * Icon of the page indicator (Android).
59
-     */
60
-    pageIndicatorIcon: {
61
-        color: ColorPalette.blueHighlight,
62
-        fontSize: 24
63
-    },
64
-
65
-    /**
66
-     * Label of the page indicator (Android).
67
-     */
68
-    pageIndicatorText: {
69
-        color: ColorPalette.blueHighlight
70
-    },
71
-
72
-    /**
73
-     * Top level style of the paged list.
74
-     */
75
-    pagedList: {
76
-        flex: 1
77
-    },
78
-
79
-    /**
80
-     * The paged list container View.
81
-     */
82
-    pagedListContainer: {
83
-        flex: 1,
84
-        flexDirection: 'column'
85
-    },
86
-
87
-    /**
88
-     * Disabled style for the container.
89
-     */
90
-    pagedListContainerDisabled: {
91
-        opacity: 0.2
92
-    }
93
-};
94
-
95 12
 const SECTION_LIST_STYLES = {
96 13
     /**
97 14
      * The style of the avatar container that makes the avatar rounded.
@@ -222,6 +139,5 @@ export const BASE_INDICATOR = {
222 139
  * base/react.
223 140
  */
224 141
 export default {
225
-    ...PAGED_LIST_STYLES,
226 142
     ...SECTION_LIST_STYLES
227 143
 };

Loading…
取消
儲存