瀏覽代碼

[RN] Add color scheme support to header

master
Bettenbuk Zoltan 6 年之前
父節點
當前提交
55a971c0fd

+ 7
- 0
react/features/base/color-scheme/defaultScheme.js 查看文件

17
         icon: ColorPalette.white,
17
         icon: ColorPalette.white,
18
         text: ColorPalette.white
18
         text: ColorPalette.white
19
     },
19
     },
20
+    'Header': {
21
+        background: ColorPalette.blue,
22
+        icon: ColorPalette.white,
23
+        statusBar: ColorPalette.blueHighlight,
24
+        statusBarContent: ColorPalette.white,
25
+        text: ColorPalette.white
26
+    },
20
     'LargeVideo': {
27
     'LargeVideo': {
21
         background: ColorPalette.black
28
         background: ColorPalette.black
22
     },
29
     },

+ 26
- 5
react/features/base/react/components/native/BackButton.js 查看文件

2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
 import { TouchableOpacity } from 'react-native';
4
 import { TouchableOpacity } from 'react-native';
5
+import { connect } from 'react-redux';
5
 
6
 
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
6
 import { Icon } from '../../../font-icons';
8
 import { Icon } from '../../../font-icons';
7
 
9
 
8
-import styles from './styles';
9
-
10
 /**
10
 /**
11
  * The type of the React {@code Component} props of {@link BackButton}
11
  * The type of the React {@code Component} props of {@link BackButton}
12
  */
12
  */
20
     /**
20
     /**
21
      * An external style object passed to the component.
21
      * An external style object passed to the component.
22
      */
22
      */
23
-    style?: Object
23
+    style?: Object,
24
+
25
+    /**
26
+     * The color schemed style of the Header component.
27
+     */
28
+    _headerStyles: Object
24
 };
29
 };
25
 
30
 
26
 /**
31
 /**
27
  * A component rendering a back button.
32
  * A component rendering a back button.
28
  */
33
  */
29
-export default class BackButton extends Component<Props> {
34
+class BackButton extends Component<Props> {
30
     /**
35
     /**
31
      * Implements React's {@link Component#render()}, renders the button.
36
      * Implements React's {@link Component#render()}, renders the button.
32
      *
37
      *
41
                 <Icon
46
                 <Icon
42
                     name = { 'arrow_back' }
47
                     name = { 'arrow_back' }
43
                     style = { [
48
                     style = { [
44
-                        styles.headerButtonIcon,
49
+                        this.props._headerStyles.headerButtonIcon,
45
                         this.props.style
50
                         this.props.style
46
                     ] } />
51
                     ] } />
47
             </TouchableOpacity>
52
             </TouchableOpacity>
48
         );
53
         );
49
     }
54
     }
50
 }
55
 }
56
+
57
+/**
58
+ * Maps part of the Redux state to the props of this component.
59
+ *
60
+ * @param {Object} state - The Redux state.
61
+ * @returns {{
62
+ *     _headerStyles: Object
63
+ * }}
64
+ */
65
+function _mapStateToProps(state) {
66
+    return {
67
+        _headerStyles: ColorSchemeRegistry.get(state, 'Header')
68
+    };
69
+}
70
+
71
+export default connect(_mapStateToProps)(BackButton);

+ 27
- 6
react/features/base/react/components/native/ForwardButton.js 查看文件

2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
 import { Text, TouchableOpacity } from 'react-native';
4
 import { Text, TouchableOpacity } from 'react-native';
5
+import { connect } from 'react-redux';
5
 
6
 
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
6
 import { translate } from '../../../i18n';
8
 import { translate } from '../../../i18n';
7
 
9
 
8
-import styles from './styles';
9
-
10
 /**
10
 /**
11
  * The type of the React {@code Component} props of {@link ForwardButton}
11
  * The type of the React {@code Component} props of {@link ForwardButton}
12
  */
12
  */
35
     /**
35
     /**
36
      * The function to be used to translate i18n labels.
36
      * The function to be used to translate i18n labels.
37
      */
37
      */
38
-    t: Function
38
+    t: Function,
39
+
40
+    /**
41
+     * The color schemed style of the Header component.
42
+     */
43
+    _headerStyles: Object
39
 };
44
 };
40
 
45
 
41
 /**
46
 /**
49
      * @returns {ReactElement}
54
      * @returns {ReactElement}
50
      */
55
      */
51
     render() {
56
     render() {
57
+        const { _headerStyles } = this.props;
58
+
52
         return (
59
         return (
53
             <TouchableOpacity
60
             <TouchableOpacity
54
                 accessibilityLabel = { 'Forward' }
61
                 accessibilityLabel = { 'Forward' }
56
                 onPress = { this.props.onPress } >
63
                 onPress = { this.props.onPress } >
57
                 <Text
64
                 <Text
58
                     style = { [
65
                     style = { [
59
-                        styles.headerButtonText,
60
-                        this.props.disabled && styles.disabledButtonText,
66
+                        _headerStyles.headerButtonText,
67
+                        this.props.disabled && _headerStyles.disabledButtonText,
61
                         this.props.style
68
                         this.props.style
62
                     ] }>
69
                     ] }>
63
                     { this.props.t(this.props.labelKey) }
70
                     { this.props.t(this.props.labelKey) }
67
     }
74
     }
68
 }
75
 }
69
 
76
 
70
-export default translate(ForwardButton);
77
+/**
78
+ * Maps part of the Redux state to the props of the component.
79
+ *
80
+ * @param {Object} state - The Redux state.
81
+ * @returns {{
82
+ *     _headerStyles: Object
83
+ * }}
84
+ */
85
+function _mapStateToProps(state) {
86
+    return {
87
+        _headerStyles: ColorSchemeRegistry.get(state, 'Header')
88
+    };
89
+}
90
+
91
+export default translate(connect(_mapStateToProps)(ForwardButton));

+ 74
- 37
react/features/base/react/components/native/Header.js 查看文件

2
 
2
 
3
 import React, { Component, type Node } from 'react';
3
 import React, { Component, type Node } from 'react';
4
 import { Platform, SafeAreaView, StatusBar, View } from 'react-native';
4
 import { Platform, SafeAreaView, StatusBar, View } from 'react-native';
5
+import { connect } from 'react-redux';
5
 
6
 
6
-import styles, { HEADER_PADDING, STATUSBAR_COLOR } from './styles';
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
8
+import { isDarkColor } from '../../../styles';
9
+
10
+import { HEADER_PADDING } from './headerstyles';
7
 
11
 
8
 /**
12
 /**
9
  * Compatibility header padding size for iOS 10 (and older) devices.
13
  * Compatibility header padding size for iOS 10 (and older) devices.
10
  */
14
  */
11
 const IOS10_PADDING = 20;
15
 const IOS10_PADDING = 20;
12
 
16
 
17
+/**
18
+ * Constanst for the (currently) supported statusbar colors.
19
+ */
20
+const STATUSBAR_DARK = 'dark-content';
21
+const STATUSBAR_LIGHT = 'light-content';
22
+
13
 /**
23
 /**
14
  * The type of the React {@code Component} props of {@link Header}
24
  * The type of the React {@code Component} props of {@link Header}
15
  */
25
  */
23
     /**
33
     /**
24
      * The component's external style
34
      * The component's external style
25
      */
35
      */
26
-    style: Object
36
+    style: Object,
37
+
38
+    /**
39
+     * The color schemed style of the component.
40
+     */
41
+    _styles: Object
27
 }
42
 }
28
 
43
 
29
 /**
44
 /**
30
  * A generic screen header component.
45
  * A generic screen header component.
31
  */
46
  */
32
-export default class Header extends Component<Props> {
33
-
34
-    /**
35
-     * The style of button-like React {@code Component}s rendered in
36
-     * {@code Header}.
37
-     *
38
-     * @returns {Object}
39
-     */
40
-    static get buttonStyle(): Object {
41
-        return styles.headerButtonIcon;
42
-    }
43
-
44
-    /**
45
-     * The style of a React {@code Component} rendering a {@code Header} as its
46
-     * child.
47
-     *
48
-     * @returns {Object}
49
-     */
50
-    static get pageStyle(): Object {
51
-        return styles.page;
52
-    }
53
-
54
-    /**
55
-     * The style of text rendered in {@code Header}.
56
-     *
57
-     * @returns {Object}
58
-     */
59
-    static get textStyle(): Object {
60
-        return styles.headerText;
61
-    }
62
-
47
+class Header extends Component<Props> {
63
     /**
48
     /**
64
      * Initializes a new {@code Header} instance.
49
      * Initializes a new {@code Header} instance.
65
      *
50
      *
78
      * @inheritdoc
63
      * @inheritdoc
79
      */
64
      */
80
     render() {
65
     render() {
66
+        const { _styles } = this.props;
67
+
81
         return (
68
         return (
82
             <View
69
             <View
83
                 style = { [
70
                 style = { [
84
-                    styles.headerOverlay,
71
+                    _styles.headerOverlay,
85
                     this._getIOS10CompatiblePadding()
72
                     this._getIOS10CompatiblePadding()
86
                 ] } >
73
                 ] } >
87
                 <StatusBar
74
                 <StatusBar
88
-                    backgroundColor = { STATUSBAR_COLOR }
89
-                    barStyle = 'light-content'
75
+                    backgroundColor = { _styles.statusBar }
76
+                    barStyle = { this._getStatusBarContentColor() }
90
                     translucent = { false } />
77
                     translucent = { false } />
91
                 <SafeAreaView>
78
                 <SafeAreaView>
92
                     <View
79
                     <View
93
                         style = { [
80
                         style = { [
94
-                            styles.screenHeader,
81
+                            _styles.screenHeader,
95
                             this.props.style
82
                             this.props.style
96
                         ] }>
83
                         ] }>
97
                         {
84
                         {
128
 
115
 
129
         return null;
116
         return null;
130
     }
117
     }
118
+
119
+    /**
120
+     * Calculates the color of the statusbar content (light or dark) based on
121
+     * certain criterias.
122
+     *
123
+     * @returns {string}
124
+     */
125
+    _getStatusBarContentColor() {
126
+        const { _styles } = this.props;
127
+        const { statusBarContent } = _styles;
128
+
129
+        if (statusBarContent) {
130
+            // We have the possibility to define the statusbar color in the
131
+            // color scheme feature, but since mobile devices (at the moment)
132
+            // only support two colors (light and dark) we need to normalize
133
+            // the value.
134
+
135
+            if (isDarkColor(statusBarContent)) {
136
+                return STATUSBAR_DARK;
137
+            }
138
+
139
+            return STATUSBAR_LIGHT;
140
+        }
141
+
142
+        // The statusbar color is not defined, so we need to base our choice
143
+        // on the header colors
144
+        const { statusBar, screenHeader } = _styles;
145
+
146
+        if (isDarkColor(statusBar || screenHeader.backgroundColor)) {
147
+            return STATUSBAR_LIGHT;
148
+        }
149
+
150
+        return STATUSBAR_DARK;
151
+    }
131
 }
152
 }
153
+
154
+/**
155
+ * Maps part of the Redux state to the props of the component.
156
+ *
157
+ * @param {Object} state - The Redux state.
158
+ * @returns {{
159
+ *     _styles: Object
160
+ * }}
161
+ */
162
+function _mapStateToProps(state) {
163
+    return {
164
+        _styles: ColorSchemeRegistry.get(state, 'Header')
165
+    };
166
+}
167
+
168
+export default connect(_mapStateToProps)(Header);

+ 27
- 6
react/features/base/react/components/native/HeaderLabel.js 查看文件

2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
 import { Text, View } from 'react-native';
4
 import { Text, View } from 'react-native';
5
+import { connect } from 'react-redux';
5
 
6
 
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
6
 import { translate } from '../../../i18n';
8
 import { translate } from '../../../i18n';
7
 
9
 
8
-import styles from './styles';
9
-
10
 /**
10
 /**
11
  * The type of the React {@code Component} props of {@link HeaderLabel}
11
  * The type of the React {@code Component} props of {@link HeaderLabel}
12
  */
12
  */
20
     /**
20
     /**
21
      * The i18n translate function.
21
      * The i18n translate function.
22
      */
22
      */
23
-    t: Function
23
+    t: Function,
24
+
25
+    /**
26
+     * The color schemed style of the Header component.
27
+     */
28
+    _headerStyles: Object
24
 };
29
 };
25
 
30
 
26
 /**
31
 /**
34
      * @returns {ReactElement}
39
      * @returns {ReactElement}
35
      */
40
      */
36
     render() {
41
     render() {
42
+        const { _headerStyles } = this.props;
43
+
37
         return (
44
         return (
38
             <View
45
             <View
39
                 pointerEvents = 'box-none'
46
                 pointerEvents = 'box-none'
40
-                style = { styles.headerTextWrapper }>
47
+                style = { _headerStyles.headerTextWrapper }>
41
                 <Text
48
                 <Text
42
                     style = { [
49
                     style = { [
43
-                        styles.headerText
50
+                        _headerStyles.headerText
44
                     ] }>
51
                     ] }>
45
                     { this.props.t(this.props.labelKey) }
52
                     { this.props.t(this.props.labelKey) }
46
                 </Text>
53
                 </Text>
49
     }
56
     }
50
 }
57
 }
51
 
58
 
52
-export default translate(HeaderLabel);
59
+/**
60
+ * Maps part of the Redux state to the props of this component.
61
+ *
62
+ * @param {Object} state - The Redux state.
63
+ * @returns {{
64
+ *     _headerStyles: Object
65
+ * }}
66
+ */
67
+function _mapStateToProps(state) {
68
+    return {
69
+        _headerStyles: ColorSchemeRegistry.get(state, 'Header')
70
+    };
71
+}
72
+
73
+export default translate(connect(_mapStateToProps)(HeaderLabel));

+ 87
- 0
react/features/base/react/components/native/headerstyles.js 查看文件

1
+// @flex
2
+
3
+import { StyleSheet } from 'react-native';
4
+
5
+import { ColorSchemeRegistry, schemeColor } from '../../../color-scheme';
6
+import { BoxModel } from '../../../styles';
7
+
8
+const HEADER_HEIGHT = 48;
9
+
10
+export const HEADER_PADDING = BoxModel.padding / 2;
11
+
12
+ColorSchemeRegistry.register('Header', {
13
+
14
+    /**
15
+     * Style of a disabled button in the header (e.g. Next).
16
+     */
17
+    disabledButtonText: {
18
+        opacity: 0.6
19
+    },
20
+
21
+    /**
22
+     * Platform specific header button (e.g. back, menu, etc).
23
+     */
24
+    headerButtonIcon: {
25
+        alignSelf: 'center',
26
+        color: schemeColor('icon'),
27
+        fontSize: 22,
28
+        marginRight: 12,
29
+        padding: 8
30
+    },
31
+
32
+    headerButtonText: {
33
+        color: schemeColor('text'),
34
+        fontSize: 20
35
+    },
36
+
37
+    /**
38
+     * Style of the header overlay to cover the unsafe areas.
39
+     */
40
+    headerOverlay: {
41
+        backgroundColor: schemeColor('background')
42
+    },
43
+
44
+    /**
45
+     * Generic style for a label placed in the header.
46
+     */
47
+    headerText: {
48
+        color: schemeColor('text'),
49
+        fontSize: 18
50
+    },
51
+
52
+    headerTextWrapper: {
53
+        alignItems: 'center',
54
+        justifyContent: 'center',
55
+        left: 0,
56
+        position: 'absolute',
57
+        right: 0
58
+    },
59
+
60
+    /**
61
+     * The top-level element of a page.
62
+     */
63
+    page: {
64
+        ...StyleSheet.absoluteFillObject,
65
+        alignItems: 'stretch',
66
+        flex: 1,
67
+        flexDirection: 'column',
68
+        overflow: 'hidden'
69
+    },
70
+
71
+    /**
72
+     * Base style of Header.
73
+     */
74
+    screenHeader: {
75
+        alignItems: 'center',
76
+        backgroundColor: schemeColor('background'),
77
+        flexDirection: 'row',
78
+        height: HEADER_HEIGHT,
79
+        justifyContent: 'space-between',
80
+        paddingHorizontal: BoxModel.padding,
81
+        paddingVertical: HEADER_PADDING
82
+    },
83
+
84
+    statusBar: schemeColor('statusBar'),
85
+
86
+    statusBarContent: schemeColor('statusBarContent')
87
+});

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

5
 import { BoxModel, ColorPalette, createStyleSheet } from '../../../styles';
5
 import { BoxModel, ColorPalette, createStyleSheet } from '../../../styles';
6
 
6
 
7
 const AVATAR_OPACITY = 0.4;
7
 const AVATAR_OPACITY = 0.4;
8
-const HEADER_COLOR = ColorPalette.blue;
9
-
10
-const HEADER_HEIGHT = 48;
11
 const OVERLAY_FONT_COLOR = 'rgba(255, 255, 255, 0.6)';
8
 const OVERLAY_FONT_COLOR = 'rgba(255, 255, 255, 0.6)';
12
 const SECONDARY_ACTION_BUTTON_SIZE = 30;
9
 const SECONDARY_ACTION_BUTTON_SIZE = 30;
13
 
10
 
14
 export const AVATAR_SIZE = 65;
11
 export const AVATAR_SIZE = 65;
15
-export const HEADER_PADDING = BoxModel.padding / 2;
16
-export const STATUSBAR_COLOR = ColorPalette.blueHighlight;
17
 export const SIDEBAR_WIDTH = 250;
12
 export const SIDEBAR_WIDTH = 250;
18
 export const UNDERLAY_COLOR = 'rgba(255, 255, 255, 0.2)';
13
 export const UNDERLAY_COLOR = 'rgba(255, 255, 255, 0.2)';
19
 
14
 
20
-const HEADER_STYLES = {
21
-
22
-    disabledButtonText: {
23
-        opacity: 0.6
24
-    },
25
-
26
-    /**
27
-     * Platform specific header button (e.g. back, menu, etc).
28
-     */
29
-    headerButtonIcon: {
30
-        alignSelf: 'center',
31
-        color: ColorPalette.white,
32
-        fontSize: 22,
33
-        marginRight: 12,
34
-        padding: 8
35
-    },
36
-
37
-    headerButtonText: {
38
-        color: ColorPalette.white,
39
-        fontSize: 20
40
-    },
41
-
42
-    /**
43
-     * Style of the header overlay to cover the unsafe areas.
44
-     */
45
-    headerOverlay: {
46
-        backgroundColor: HEADER_COLOR
47
-    },
48
-
49
-    /**
50
-     * Generic style for a label placed in the header.
51
-     */
52
-    headerText: {
53
-        color: ColorPalette.white,
54
-        fontSize: 18
55
-    },
56
-
57
-    headerTextWrapper: {
58
-        alignItems: 'center',
59
-        justifyContent: 'center',
60
-        left: 0,
61
-        position: 'absolute',
62
-        right: 0
63
-    },
64
-
65
-    /**
66
-     * The top-level element of a page.
67
-     */
68
-    page: {
69
-        ...StyleSheet.absoluteFillObject,
70
-        alignItems: 'stretch',
71
-        flex: 1,
72
-        flexDirection: 'column',
73
-        overflow: 'hidden'
74
-    },
75
-
76
-    /**
77
-     * Base style of Header.
78
-     */
79
-    screenHeader: {
80
-        alignItems: 'center',
81
-        backgroundColor: HEADER_COLOR,
82
-        flexDirection: 'row',
83
-        height: HEADER_HEIGHT,
84
-        justifyContent: 'space-between',
85
-        paddingHorizontal: BoxModel.padding,
86
-        paddingVertical: HEADER_PADDING
87
-    }
88
-};
89
-
90
 /**
15
 /**
91
  * Style classes of the PagedList-based components.
16
  * Style classes of the PagedList-based components.
92
  */
17
  */
355
  * base/react.
280
  * base/react.
356
  */
281
  */
357
 export default createStyleSheet({
282
 export default createStyleSheet({
358
-    ...HEADER_STYLES,
359
     ...PAGED_LIST_STYLES,
283
     ...PAGED_LIST_STYLES,
360
     ...SECTION_LIST_STYLES,
284
     ...SECTION_LIST_STYLES,
361
     ...SIDEBAR_STYLES
285
     ...SIDEBAR_STYLES

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

23
  */
23
  */
24
 const RGB_COLOR_FORMAT = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i;
24
 const RGB_COLOR_FORMAT = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i;
25
 
25
 
26
+/**
27
+ * RegExp pattern for RGBA color format.
28
+ */
29
+const RGBA_COLOR_FORMAT
30
+    = /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*([0-9.]+)\)$/i;
31
+
26
 /**
32
 /**
27
  * The list of the well-known style properties which may not be numbers on Web
33
  * The list of the well-known style properties which may not be numbers on Web
28
  * but must be numbers on React Native.
34
  * but must be numbers on React Native.
136
     return color;
142
     return color;
137
 }
143
 }
138
 
144
 
145
+/**
146
+ * Decides if a color is light or dark based on the ITU-R BT.709 and W3C
147
+ * recommendations.
148
+ *
149
+ * NOTE: Please see https://www.w3.org/TR/WCAG20/#relativeluminancedef.
150
+ *
151
+ * @param {string} color - The color in rgb, rgba or hex format.
152
+ * @returns {boolean}
153
+ */
154
+export function isDarkColor(color: string): boolean {
155
+    const rgb = _getRGBObjectFormat(color);
156
+
157
+    return ((_getColorLuminance(rgb.r) * 0.2126)
158
+    + (_getColorLuminance(rgb.g) * 0.7152)
159
+    + (_getColorLuminance(rgb.b) * 0.0722)) <= 0.179;
160
+}
161
+
139
 /**
162
 /**
140
  * Converts an [0..1] alpha value into HEX.
163
  * Converts an [0..1] alpha value into HEX.
141
  *
164
  *
147
         .padStart(2, '0');
170
         .padStart(2, '0');
148
 }
171
 }
149
 
172
 
173
+/**
174
+ * Calculated the color luminance component for an individual color channel.
175
+ *
176
+ * NOTE: Please see https://www.w3.org/TR/WCAG20/#relativeluminancedef.
177
+ *
178
+ * @param {number} c - The color which we need the individual luminance
179
+ * for.
180
+ * @returns {number}
181
+ */
182
+function _getColorLuminance(c: number): number {
183
+    return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
184
+}
185
+
186
+/**
187
+ * Parses a color string into an object containing the RGB values as numbers.
188
+ *
189
+ * NOTE: Object properties are not alpha-sorted for sanity.
190
+ *
191
+ * @param {string} color - The color to convert.
192
+ * @returns {{
193
+ *     r: number,
194
+ *     g: number,
195
+ *     b: number
196
+ * }}
197
+ */
198
+function _getRGBObjectFormat(color: string): {r: number, g: number, b: number} {
199
+    let match = color.match(HEX_LONG_COLOR_FORMAT);
200
+
201
+    if (match) {
202
+        return {
203
+            r: parseInt(match[1], 16) / 255.0,
204
+            g: parseInt(match[2], 16) / 255.0,
205
+            b: parseInt(match[3], 16) / 255.0
206
+        };
207
+    }
208
+
209
+    match = color.match(HEX_SHORT_COLOR_FORMAT);
210
+    if (match) {
211
+        return {
212
+            r: parseInt(`${match[1]}${match[1]}`, 16) / 255.0,
213
+            g: parseInt(`${match[2]}${match[2]}`, 16) / 255.0,
214
+            b: parseInt(`${match[3]}${match[3]}`, 16) / 255.0
215
+        };
216
+    }
217
+
218
+    match = color.match(RGB_COLOR_FORMAT) || color.match(RGBA_COLOR_FORMAT);
219
+    if (match) {
220
+        return {
221
+            r: parseInt(match[1], 10) / 255.0,
222
+            g: parseInt(match[2], 10) / 255.0,
223
+            b: parseInt(match[3], 10) / 255.0
224
+        };
225
+    }
226
+
227
+    return {
228
+        r: 0,
229
+        g: 0,
230
+        b: 0
231
+    };
232
+}
233
+
150
 /**
234
 /**
151
  * Shims style properties to work correctly on native. Allows us to minimize the
235
  * Shims style properties to work correctly on native. Allows us to minimize the
152
  * number of style declarations that need to be set or overridden for specific
236
  * number of style declarations that need to be set or overridden for specific

+ 4
- 4
react/features/settings/components/AbstractSettingsView.js 查看文件

9
  * The type of the React {@code Component} props of
9
  * The type of the React {@code Component} props of
10
  * {@link AbstractSettingsView}.
10
  * {@link AbstractSettingsView}.
11
  */
11
  */
12
-type Props = {
12
+export type Props = {
13
 
13
 
14
     /**
14
     /**
15
      * The default URL for when there is no custom URL set in the settings.
15
      * The default URL for when there is no custom URL set in the settings.
47
  *
47
  *
48
  * @abstract
48
  * @abstract
49
  */
49
  */
50
-export class AbstractSettingsView extends Component<Props> {
50
+export class AbstractSettingsView<P: Props> extends Component<P> {
51
 
51
 
52
     /**
52
     /**
53
      * Initializes a new {@code AbstractSettingsView} instance.
53
      * Initializes a new {@code AbstractSettingsView} instance.
54
      *
54
      *
55
-     * @param {Props} props - The React {@code Component} props to initialize
55
+     * @param {P} props - The React {@code Component} props to initialize
56
      * the component.
56
      * the component.
57
      */
57
      */
58
-    constructor(props: Props) {
58
+    constructor(props: P) {
59
         super(props);
59
         super(props);
60
 
60
 
61
         // Bind event handlers so they are only bound once per instance.
61
         // Bind event handlers so they are only bound once per instance.

+ 28
- 3
react/features/settings/components/native/SettingsView.js 查看文件

11
 } from 'react-native';
11
 } from 'react-native';
12
 import { connect } from 'react-redux';
12
 import { connect } from 'react-redux';
13
 
13
 
14
+import { ColorSchemeRegistry } from '../../../base/color-scheme';
14
 import { translate } from '../../../base/i18n';
15
 import { translate } from '../../../base/i18n';
15
 import { BackButton, Header, Modal } from '../../../base/react';
16
 import { BackButton, Header, Modal } from '../../../base/react';
16
 
17
 
17
 import {
18
 import {
18
     AbstractSettingsView,
19
     AbstractSettingsView,
19
-    _mapStateToProps
20
+    _mapStateToProps as _abstractMapStateToProps,
21
+    type Props as AbstractProps
20
 } from '../AbstractSettingsView';
22
 } from '../AbstractSettingsView';
21
 import { setSettingsViewVisible } from '../../actions';
23
 import { setSettingsViewVisible } from '../../actions';
22
 import FormRow from './FormRow';
24
 import FormRow from './FormRow';
25
 import styles from './styles';
27
 import styles from './styles';
26
 import { HeaderLabel } from '../../../base/react/components/native';
28
 import { HeaderLabel } from '../../../base/react/components/native';
27
 
29
 
30
+type Props = AbstractProps & {
31
+
32
+    /**
33
+     * Color schemed style of the header component.
34
+     */
35
+    _headerStyles: Object
36
+}
37
+
28
 /**
38
 /**
29
  * The native container rendering the app settings page.
39
  * The native container rendering the app settings page.
30
  *
40
  *
31
  * @extends AbstractSettingsView
41
  * @extends AbstractSettingsView
32
  */
42
  */
33
-class SettingsView extends AbstractSettingsView {
43
+class SettingsView extends AbstractSettingsView<Props> {
34
     _urlField: Object;
44
     _urlField: Object;
35
 
45
 
36
     /**
46
     /**
60
                 onRequestClose = { this._onRequestClose }
70
                 onRequestClose = { this._onRequestClose }
61
                 presentationStyle = 'overFullScreen'
71
                 presentationStyle = 'overFullScreen'
62
                 visible = { this.props._visible }>
72
                 visible = { this.props._visible }>
63
-                <View style = { Header.pageStyle }>
73
+                <View style = { this.props._headerStyles.page }>
64
                     { this._renderHeader() }
74
                     { this._renderHeader() }
65
                     { this._renderBody() }
75
                     { this._renderBody() }
66
                 </View>
76
                 </View>
239
     }
249
     }
240
 }
250
 }
241
 
251
 
252
+/**
253
+ * Maps part of the Redux state to the props of this component.
254
+ *
255
+ * @param {Object} state - The Redux state.
256
+ * @returns {{
257
+ *     _headerStyles: Object
258
+ * }}
259
+ */
260
+function _mapStateToProps(state) {
261
+    return {
262
+        ..._abstractMapStateToProps(state),
263
+        _headerStyles: ColorSchemeRegistry.get(state, 'Header')
264
+    };
265
+}
266
+
242
 export default translate(connect(_mapStateToProps)(SettingsView));
267
 export default translate(connect(_mapStateToProps)(SettingsView));

+ 11
- 5
react/features/welcome/components/VideoSwitch.js 查看文件

4
 import { Switch, TouchableWithoutFeedback, View } from 'react-native';
4
 import { Switch, TouchableWithoutFeedback, View } from 'react-native';
5
 import { connect } from 'react-redux';
5
 import { connect } from 'react-redux';
6
 
6
 
7
+import { ColorSchemeRegistry } from '../../base/color-scheme';
7
 import { translate } from '../../base/i18n';
8
 import { translate } from '../../base/i18n';
8
-import { Header, Text } from '../../base/react';
9
+import { Text } from '../../base/react';
9
 import { updateSettings } from '../../base/settings';
10
 import { updateSettings } from '../../base/settings';
10
 
11
 
11
 import styles, { SWITCH_THUMB_COLOR, SWITCH_UNDER_COLOR } from './styles';
12
 import styles, { SWITCH_THUMB_COLOR, SWITCH_UNDER_COLOR } from './styles';
25
      */
26
      */
26
     t: Function,
27
     t: Function,
27
 
28
 
29
+    /**
30
+     * Color schemed style of the header component.
31
+     */
32
+    _headerStyles: Object,
33
+
28
     /**
34
     /**
29
      * The current settings from redux.
35
      * The current settings from redux.
30
      */
36
      */
55
      * @inheritdoc
61
      * @inheritdoc
56
      */
62
      */
57
     render() {
63
     render() {
58
-        const { t, _settings } = this.props;
59
-        const { textStyle } = Header;
64
+        const { t, _headerStyles, _settings } = this.props;
60
 
65
 
61
         return (
66
         return (
62
             <View style = { styles.audioVideoSwitchContainer }>
67
             <View style = { styles.audioVideoSwitchContainer }>
63
                 <TouchableWithoutFeedback
68
                 <TouchableWithoutFeedback
64
                     onPress = { this._onStartAudioOnlyFalse }>
69
                     onPress = { this._onStartAudioOnlyFalse }>
65
                     <View style = { styles.switchLabel }>
70
                     <View style = { styles.switchLabel }>
66
-                        <Text style = { textStyle }>
71
+                        <Text style = { _headerStyles.headerText }>
67
                             { t('welcomepage.audioVideoSwitch.video') }
72
                             { t('welcomepage.audioVideoSwitch.video') }
68
                         </Text>
73
                         </Text>
69
                     </View>
74
                     </View>
77
                 <TouchableWithoutFeedback
82
                 <TouchableWithoutFeedback
78
                     onPress = { this._onStartAudioOnlyTrue }>
83
                     onPress = { this._onStartAudioOnlyTrue }>
79
                     <View style = { styles.switchLabel }>
84
                     <View style = { styles.switchLabel }>
80
-                        <Text style = { textStyle }>
85
+                        <Text style = { _headerStyles.headerText }>
81
                             { t('welcomepage.audioVideoSwitch.audio') }
86
                             { t('welcomepage.audioVideoSwitch.audio') }
82
                         </Text>
87
                         </Text>
83
                     </View>
88
                     </View>
132
  */
137
  */
133
 export function _mapStateToProps(state: Object) {
138
 export function _mapStateToProps(state: Object) {
134
     return {
139
     return {
140
+        _headerStyles: ColorSchemeRegistry.get(state, 'Header'),
135
         _settings: state['features/base/settings']
141
         _settings: state['features/base/settings']
136
     };
142
     };
137
 }
143
 }

+ 23
- 5
react/features/welcome/components/WelcomePage.native.js 查看文件

10
 } from 'react-native';
10
 } from 'react-native';
11
 import { connect } from 'react-redux';
11
 import { connect } from 'react-redux';
12
 
12
 
13
+import { ColorSchemeRegistry } from '../../base/color-scheme';
13
 import { translate } from '../../base/i18n';
14
 import { translate } from '../../base/i18n';
14
 import { Icon } from '../../base/font-icons';
15
 import { Icon } from '../../base/font-icons';
15
 import { MEDIA_TYPE } from '../../base/media';
16
 import { MEDIA_TYPE } from '../../base/media';
21
 } from '../../base/tracks';
22
 } from '../../base/tracks';
22
 import { SettingsView } from '../../settings';
23
 import { SettingsView } from '../../settings';
23
 
24
 
24
-import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
25
+import {
26
+    AbstractWelcomePage,
27
+    _mapStateToProps as _abstractMapStateToProps
28
+} from './AbstractWelcomePage';
25
 import { setSideBarVisible } from '../actions';
29
 import { setSideBarVisible } from '../actions';
26
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
30
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
27
 import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
31
 import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
90
      * @returns {ReactElement}
94
      * @returns {ReactElement}
91
      */
95
      */
92
     render() {
96
     render() {
93
-        const { buttonStyle, pageStyle } = Header;
94
         const roomnameAccLabel = 'welcomepage.accessibilityLabel.roomname';
97
         const roomnameAccLabel = 'welcomepage.accessibilityLabel.roomname';
95
-        const { t } = this.props;
98
+        const { _headerStyles, t } = this.props;
96
 
99
 
97
         return (
100
         return (
98
             <LocalVideoTrackUnderlay style = { styles.welcomePage }>
101
             <LocalVideoTrackUnderlay style = { styles.welcomePage }>
99
-                <View style = { pageStyle }>
102
+                <View style = { _headerStyles.page }>
100
                     <Header style = { styles.header }>
103
                     <Header style = { styles.header }>
101
                         <TouchableOpacity onPress = { this._onShowSideBar } >
104
                         <TouchableOpacity onPress = { this._onShowSideBar } >
102
                             <Icon
105
                             <Icon
103
                                 name = 'menu'
106
                                 name = 'menu'
104
-                                style = { buttonStyle } />
107
+                                style = { _headerStyles.headerButtonIcon } />
105
                         </TouchableOpacity>
108
                         </TouchableOpacity>
106
                         <VideoSwitch />
109
                         <VideoSwitch />
107
                     </Header>
110
                     </Header>
269
     }
272
     }
270
 }
273
 }
271
 
274
 
275
+/**
276
+ * Maps part of the Redux state to the props of this component.
277
+ *
278
+ * @param {Object} state - The Redux state.
279
+ * @returns {{
280
+ *     _headerStyles: Object
281
+ * }}
282
+ */
283
+function _mapStateToProps(state) {
284
+    return {
285
+        ..._abstractMapStateToProps(state),
286
+        _headerStyles: ColorSchemeRegistry.get(state, 'Header')
287
+    };
288
+}
289
+
272
 export default translate(connect(_mapStateToProps)(WelcomePage));
290
 export default translate(connect(_mapStateToProps)(WelcomePage));

Loading…
取消
儲存