Browse Source

feat(toolbox): Fixed background color prop custom buttons (#15529)

* feat(toolbox): fixed backgroundColor prop for custom menu buttons
factor2
Calinteodor 8 months ago
parent
commit
75c43fc8f2
No account linked to committer's email address

+ 24
- 12
react/features/toolbox/components/native/CustomOptionButton.tsx View File

@@ -1,10 +1,11 @@
1 1
 import React from 'react';
2
-import { Image } from 'react-native';
2
+import { Image, View, ViewStyle } from 'react-native';
3 3
 import { SvgCssUri } from 'react-native-svg';
4 4
 import { connect } from 'react-redux';
5 5
 
6 6
 import { translate } from '../../../base/i18n/functions';
7 7
 import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
8
+import BaseTheme from '../../../base/ui/components/BaseTheme.native';
8 9
 
9 10
 import styles from './styles';
10 11
 
@@ -13,6 +14,7 @@ interface IProps extends AbstractButtonProps {
13 14
     backgroundColor?: string;
14 15
     icon: any;
15 16
     id?: string;
17
+    isToolboxButton?: boolean;
16 18
     text?: string;
17 19
 }
18 20
 
@@ -40,20 +42,30 @@ class CustomOptionButton extends AbstractButton<IProps> {
40 42
         }
41 43
 
42 44
         if (this.iconSrc?.includes('svg')) {
43
-            iconComponent
44
-                = (
45
-                    <SvgCssUri
46
-                        style = { styles.iconImageStyles }
47
-                        uri = { this.iconSrc } />);
45
+            iconComponent = (
46
+                <SvgCssUri
47
+                    height = { BaseTheme.spacing[4] }
48
+                    uri = { this.iconSrc }
49
+                    width = { BaseTheme.spacing[4] } />
50
+            );
48 51
         } else {
49
-            iconComponent
50
-                = (
51
-                    <Image
52
-                        source = {{ uri: this.iconSrc }}
53
-                        style = { styles.iconImageStyles } />);
52
+            iconComponent = (
53
+                <Image
54
+                    height = { BaseTheme.spacing[4] }
55
+                    resizeMode = { 'contain' }
56
+                    source = {{ uri: this.iconSrc }}
57
+                    width = { BaseTheme.spacing[4] } />
58
+            );
54 59
         }
55 60
 
56
-        return iconComponent;
61
+        return (
62
+            <View
63
+                style = { this.props.isToolboxButton && [
64
+                    styles.toolboxButtonIconContainer,
65
+                    { backgroundColor: this.backgroundColor } ] as ViewStyle }>
66
+                { iconComponent }
67
+            </View>
68
+        );
57 69
     };
58 70
 
59 71
     label = this.text || '';

+ 1
- 0
react/features/toolbox/components/native/OverflowMenu.tsx View File

@@ -237,6 +237,7 @@ class OverflowMenu extends PureComponent<IProps, IState> {
237 237
                                 dispatch(customButtonPressed(id, text))
238 238
                             }
239 239
                             icon = { icon }
240
+                            isToolboxButton = { false }
240 241
                             key = { id }
241 242
                             text = { text } />
242 243
                     ))

+ 7
- 1
react/features/toolbox/components/native/Toolbox.tsx View File

@@ -126,6 +126,7 @@ function Toolbox(props: IProps) {
126 126
                             /* eslint-disable react/jsx-no-bind */
127 127
                             handleClick = { () => dispatch(customButtonPressed(id, text)) }
128 128
                             icon = { icon }
129
+                            isToolboxButton = { true }
129 130
                             key = { id } />
130 131
                     ))
131 132
                 }
@@ -145,7 +146,12 @@ function Toolbox(props: IProps) {
145 146
                 style = { style as ViewStyle }>
146 147
                 {
147 148
                     _customToolbarButtons
148
-                        ? renderCustomToolboxButtons()
149
+                        ? <>
150
+                            { renderCustomToolboxButtons() }
151
+                            { !_iAmVisitor && <OverflowMenuButton
152
+                                styles = { buttonStylesBorderless }
153
+                                toggledStyles = { toggledButtonStyles } /> }
154
+                        </>
149 155
                         : <>
150 156
                             {!_iAmVisitor && <AudioMuteButton
151 157
                                 styles = { buttonStylesBorderless }

+ 7
- 4
react/features/toolbox/components/native/styles.ts View File

@@ -101,13 +101,16 @@ const styles = {
101 101
         maxWidth: 580,
102 102
         marginHorizontal: 'auto',
103 103
         marginVertical: BaseTheme.spacing[0],
104
-        paddingHorizontal: BaseTheme.spacing[1],
104
+        paddingHorizontal: BaseTheme.spacing[2],
105 105
         width: '100%'
106 106
     },
107 107
 
108
-    iconImageStyles: {
109
-        height: BaseTheme.spacing[4],
110
-        width: BaseTheme.spacing[4]
108
+    toolboxButtonIconContainer: {
109
+        alignItems: 'center',
110
+        borderRadius: BaseTheme.shape.borderRadius,
111
+        height: BaseTheme.spacing[7],
112
+        justifyContent: 'center',
113
+        width: BaseTheme.spacing[7]
111 114
     }
112 115
 };
113 116
 

Loading…
Cancel
Save