Selaa lähdekoodia

[RN] Add color scheme support to header

master
Bettenbuk Zoltan 6 vuotta sitten
vanhempi
commit
55a971c0fd

+ 7
- 0
react/features/base/color-scheme/defaultScheme.js Näytä tiedosto

@@ -17,6 +17,13 @@ export default {
17 17
         icon: ColorPalette.white,
18 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 27
     'LargeVideo': {
21 28
         background: ColorPalette.black
22 29
     },

+ 26
- 5
react/features/base/react/components/native/BackButton.js Näytä tiedosto

@@ -2,11 +2,11 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 import { TouchableOpacity } from 'react-native';
5
+import { connect } from 'react-redux';
5 6
 
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
6 8
 import { Icon } from '../../../font-icons';
7 9
 
8
-import styles from './styles';
9
-
10 10
 /**
11 11
  * The type of the React {@code Component} props of {@link BackButton}
12 12
  */
@@ -20,13 +20,18 @@ type Props = {
20 20
     /**
21 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 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 36
      * Implements React's {@link Component#render()}, renders the button.
32 37
      *
@@ -41,10 +46,26 @@ export default class BackButton extends Component<Props> {
41 46
                 <Icon
42 47
                     name = { 'arrow_back' }
43 48
                     style = { [
44
-                        styles.headerButtonIcon,
49
+                        this.props._headerStyles.headerButtonIcon,
45 50
                         this.props.style
46 51
                     ] } />
47 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 Näytä tiedosto

@@ -2,11 +2,11 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 import { Text, TouchableOpacity } from 'react-native';
5
+import { connect } from 'react-redux';
5 6
 
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
6 8
 import { translate } from '../../../i18n';
7 9
 
8
-import styles from './styles';
9
-
10 10
 /**
11 11
  * The type of the React {@code Component} props of {@link ForwardButton}
12 12
  */
@@ -35,7 +35,12 @@ type Props = {
35 35
     /**
36 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,6 +54,8 @@ class ForwardButton extends Component<Props> {
49 54
      * @returns {ReactElement}
50 55
      */
51 56
     render() {
57
+        const { _headerStyles } = this.props;
58
+
52 59
         return (
53 60
             <TouchableOpacity
54 61
                 accessibilityLabel = { 'Forward' }
@@ -56,8 +63,8 @@ class ForwardButton extends Component<Props> {
56 63
                 onPress = { this.props.onPress } >
57 64
                 <Text
58 65
                     style = { [
59
-                        styles.headerButtonText,
60
-                        this.props.disabled && styles.disabledButtonText,
66
+                        _headerStyles.headerButtonText,
67
+                        this.props.disabled && _headerStyles.disabledButtonText,
61 68
                         this.props.style
62 69
                     ] }>
63 70
                     { this.props.t(this.props.labelKey) }
@@ -67,4 +74,18 @@ class ForwardButton extends Component<Props> {
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 Näytä tiedosto

@@ -2,14 +2,24 @@
2 2
 
3 3
 import React, { Component, type Node } from 'react';
4 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 13
  * Compatibility header padding size for iOS 10 (and older) devices.
10 14
  */
11 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 24
  * The type of the React {@code Component} props of {@link Header}
15 25
  */
@@ -23,43 +33,18 @@ type Props = {
23 33
     /**
24 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 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 49
      * Initializes a new {@code Header} instance.
65 50
      *
@@ -78,20 +63,22 @@ export default class Header extends Component<Props> {
78 63
      * @inheritdoc
79 64
      */
80 65
     render() {
66
+        const { _styles } = this.props;
67
+
81 68
         return (
82 69
             <View
83 70
                 style = { [
84
-                    styles.headerOverlay,
71
+                    _styles.headerOverlay,
85 72
                     this._getIOS10CompatiblePadding()
86 73
                 ] } >
87 74
                 <StatusBar
88
-                    backgroundColor = { STATUSBAR_COLOR }
89
-                    barStyle = 'light-content'
75
+                    backgroundColor = { _styles.statusBar }
76
+                    barStyle = { this._getStatusBarContentColor() }
90 77
                     translucent = { false } />
91 78
                 <SafeAreaView>
92 79
                     <View
93 80
                         style = { [
94
-                            styles.screenHeader,
81
+                            _styles.screenHeader,
95 82
                             this.props.style
96 83
                         ] }>
97 84
                         {
@@ -128,4 +115,54 @@ export default class Header extends Component<Props> {
128 115
 
129 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 Näytä tiedosto

@@ -2,11 +2,11 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 import { Text, View } from 'react-native';
5
+import { connect } from 'react-redux';
5 6
 
7
+import { ColorSchemeRegistry } from '../../../color-scheme';
6 8
 import { translate } from '../../../i18n';
7 9
 
8
-import styles from './styles';
9
-
10 10
 /**
11 11
  * The type of the React {@code Component} props of {@link HeaderLabel}
12 12
  */
@@ -20,7 +20,12 @@ type Props = {
20 20
     /**
21 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,13 +39,15 @@ class HeaderLabel extends Component<Props> {
34 39
      * @returns {ReactElement}
35 40
      */
36 41
     render() {
42
+        const { _headerStyles } = this.props;
43
+
37 44
         return (
38 45
             <View
39 46
                 pointerEvents = 'box-none'
40
-                style = { styles.headerTextWrapper }>
47
+                style = { _headerStyles.headerTextWrapper }>
41 48
                 <Text
42 49
                     style = { [
43
-                        styles.headerText
50
+                        _headerStyles.headerText
44 51
                     ] }>
45 52
                     { this.props.t(this.props.labelKey) }
46 53
                 </Text>
@@ -49,4 +56,18 @@ class HeaderLabel extends Component<Props> {
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 Näytä tiedosto

@@ -0,0 +1,87 @@
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 Näytä tiedosto

@@ -5,88 +5,13 @@ import { StyleSheet } from 'react-native';
5 5
 import { BoxModel, ColorPalette, createStyleSheet } from '../../../styles';
6 6
 
7 7
 const AVATAR_OPACITY = 0.4;
8
-const HEADER_COLOR = ColorPalette.blue;
9
-
10
-const HEADER_HEIGHT = 48;
11 8
 const OVERLAY_FONT_COLOR = 'rgba(255, 255, 255, 0.6)';
12 9
 const SECONDARY_ACTION_BUTTON_SIZE = 30;
13 10
 
14 11
 export const AVATAR_SIZE = 65;
15
-export const HEADER_PADDING = BoxModel.padding / 2;
16
-export const STATUSBAR_COLOR = ColorPalette.blueHighlight;
17 12
 export const SIDEBAR_WIDTH = 250;
18 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 16
  * Style classes of the PagedList-based components.
92 17
  */
@@ -355,7 +280,6 @@ export const TINTED_VIEW_DEFAULT = {
355 280
  * base/react.
356 281
  */
357 282
 export default createStyleSheet({
358
-    ...HEADER_STYLES,
359 283
     ...PAGED_LIST_STYLES,
360 284
     ...SECTION_LIST_STYLES,
361 285
     ...SIDEBAR_STYLES

+ 84
- 0
react/features/base/styles/functions.js Näytä tiedosto

@@ -23,6 +23,12 @@ const HEX_SHORT_COLOR_FORMAT
23 23
  */
24 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 33
  * The list of the well-known style properties which may not be numbers on Web
28 34
  * but must be numbers on React Native.
@@ -136,6 +142,23 @@ export function getRGBAFormat(color: string, alpha: number): string {
136 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 163
  * Converts an [0..1] alpha value into HEX.
141 164
  *
@@ -147,6 +170,67 @@ function _getAlphaInHex(alpha: number): string {
147 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 235
  * Shims style properties to work correctly on native. Allows us to minimize the
152 236
  * number of style declarations that need to be set or overridden for specific

+ 4
- 4
react/features/settings/components/AbstractSettingsView.js Näytä tiedosto

@@ -9,7 +9,7 @@ import { updateSettings } from '../../base/settings';
9 9
  * The type of the React {@code Component} props of
10 10
  * {@link AbstractSettingsView}.
11 11
  */
12
-type Props = {
12
+export type Props = {
13 13
 
14 14
     /**
15 15
      * The default URL for when there is no custom URL set in the settings.
@@ -47,15 +47,15 @@ type Props = {
47 47
  *
48 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 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 56
      * the component.
57 57
      */
58
-    constructor(props: Props) {
58
+    constructor(props: P) {
59 59
         super(props);
60 60
 
61 61
         // Bind event handlers so they are only bound once per instance.

+ 28
- 3
react/features/settings/components/native/SettingsView.js Näytä tiedosto

@@ -11,12 +11,14 @@ import {
11 11
 } from 'react-native';
12 12
 import { connect } from 'react-redux';
13 13
 
14
+import { ColorSchemeRegistry } from '../../../base/color-scheme';
14 15
 import { translate } from '../../../base/i18n';
15 16
 import { BackButton, Header, Modal } from '../../../base/react';
16 17
 
17 18
 import {
18 19
     AbstractSettingsView,
19
-    _mapStateToProps
20
+    _mapStateToProps as _abstractMapStateToProps,
21
+    type Props as AbstractProps
20 22
 } from '../AbstractSettingsView';
21 23
 import { setSettingsViewVisible } from '../../actions';
22 24
 import FormRow from './FormRow';
@@ -25,12 +27,20 @@ import { normalizeUserInputURL } from '../../functions';
25 27
 import styles from './styles';
26 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 39
  * The native container rendering the app settings page.
30 40
  *
31 41
  * @extends AbstractSettingsView
32 42
  */
33
-class SettingsView extends AbstractSettingsView {
43
+class SettingsView extends AbstractSettingsView<Props> {
34 44
     _urlField: Object;
35 45
 
36 46
     /**
@@ -60,7 +70,7 @@ class SettingsView extends AbstractSettingsView {
60 70
                 onRequestClose = { this._onRequestClose }
61 71
                 presentationStyle = 'overFullScreen'
62 72
                 visible = { this.props._visible }>
63
-                <View style = { Header.pageStyle }>
73
+                <View style = { this.props._headerStyles.page }>
64 74
                     { this._renderHeader() }
65 75
                     { this._renderBody() }
66 76
                 </View>
@@ -239,4 +249,19 @@ class SettingsView extends AbstractSettingsView {
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 267
 export default translate(connect(_mapStateToProps)(SettingsView));

+ 11
- 5
react/features/welcome/components/VideoSwitch.js Näytä tiedosto

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

+ 23
- 5
react/features/welcome/components/WelcomePage.native.js Näytä tiedosto

@@ -10,6 +10,7 @@ import {
10 10
 } from 'react-native';
11 11
 import { connect } from 'react-redux';
12 12
 
13
+import { ColorSchemeRegistry } from '../../base/color-scheme';
13 14
 import { translate } from '../../base/i18n';
14 15
 import { Icon } from '../../base/font-icons';
15 16
 import { MEDIA_TYPE } from '../../base/media';
@@ -21,7 +22,10 @@ import {
21 22
 } from '../../base/tracks';
22 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 29
 import { setSideBarVisible } from '../actions';
26 30
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
27 31
 import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
@@ -90,18 +94,17 @@ class WelcomePage extends AbstractWelcomePage {
90 94
      * @returns {ReactElement}
91 95
      */
92 96
     render() {
93
-        const { buttonStyle, pageStyle } = Header;
94 97
         const roomnameAccLabel = 'welcomepage.accessibilityLabel.roomname';
95
-        const { t } = this.props;
98
+        const { _headerStyles, t } = this.props;
96 99
 
97 100
         return (
98 101
             <LocalVideoTrackUnderlay style = { styles.welcomePage }>
99
-                <View style = { pageStyle }>
102
+                <View style = { _headerStyles.page }>
100 103
                     <Header style = { styles.header }>
101 104
                         <TouchableOpacity onPress = { this._onShowSideBar } >
102 105
                             <Icon
103 106
                                 name = 'menu'
104
-                                style = { buttonStyle } />
107
+                                style = { _headerStyles.headerButtonIcon } />
105 108
                         </TouchableOpacity>
106 109
                         <VideoSwitch />
107 110
                     </Header>
@@ -269,4 +272,19 @@ class WelcomePage extends AbstractWelcomePage {
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 290
 export default translate(connect(_mapStateToProps)(WelcomePage));

Loading…
Peruuta
Tallenna