Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions react/features/toolbox/components/native/CustomOptionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { Image } from 'react-native';
import { Image, View, ViewStyle } from 'react-native';
import { SvgCssUri } from 'react-native-svg';
import { connect } from 'react-redux';

import { translate } from '../../../base/i18n/functions';
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
import BaseTheme from '../../../base/ui/components/BaseTheme.native';

import styles from './styles';

Expand All @@ -13,6 +14,7 @@ interface IProps extends AbstractButtonProps {
backgroundColor?: string;
icon: any;
id?: string;
isToolboxButton?: boolean;
text?: string;
}

Expand Down Expand Up @@ -40,20 +42,30 @@ class CustomOptionButton extends AbstractButton<IProps> {
}

if (this.iconSrc?.includes('svg')) {
iconComponent
= (
<SvgCssUri
style = { styles.iconImageStyles }
uri = { this.iconSrc } />);
iconComponent = (
<SvgCssUri
height = { BaseTheme.spacing[4] }
uri = { this.iconSrc }
width = { BaseTheme.spacing[4] } />
);
} else {
iconComponent
= (
<Image
source = {{ uri: this.iconSrc }}
style = { styles.iconImageStyles } />);
iconComponent = (
<Image
height = { BaseTheme.spacing[4] }
resizeMode = { 'contain' }
source = {{ uri: this.iconSrc }}
width = { BaseTheme.spacing[4] } />
);
}

return iconComponent;
return (
<View
style = { this.props.isToolboxButton && [
styles.toolboxButtonIconContainer,
{ backgroundColor: this.backgroundColor } ] as ViewStyle }>
{ iconComponent }
</View>
);
};

label = this.text || '';
Expand Down
1 change: 1 addition & 0 deletions react/features/toolbox/components/native/OverflowMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class OverflowMenu extends PureComponent<IProps, IState> {
dispatch(customButtonPressed(id, text))
}
icon = { icon }
isToolboxButton = { false }
key = { id }
text = { text } />
))
Expand Down
8 changes: 7 additions & 1 deletion react/features/toolbox/components/native/Toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function Toolbox(props: IProps) {
/* eslint-disable react/jsx-no-bind */
handleClick = { () => dispatch(customButtonPressed(id, text)) }
icon = { icon }
isToolboxButton = { true }
key = { id } />
))
}
Expand All @@ -145,7 +146,12 @@ function Toolbox(props: IProps) {
style = { style as ViewStyle }>
{
_customToolbarButtons
? renderCustomToolboxButtons()
? <>
{ renderCustomToolboxButtons() }
{ !_iAmVisitor && <OverflowMenuButton
styles = { buttonStylesBorderless }
toggledStyles = { toggledButtonStyles } /> }
</>
: <>
{!_iAmVisitor && <AudioMuteButton
styles = { buttonStylesBorderless }
Expand Down
11 changes: 7 additions & 4 deletions react/features/toolbox/components/native/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ const styles = {
maxWidth: 580,
marginHorizontal: 'auto',
marginVertical: BaseTheme.spacing[0],
paddingHorizontal: BaseTheme.spacing[1],
paddingHorizontal: BaseTheme.spacing[2],
width: '100%'
},

iconImageStyles: {
height: BaseTheme.spacing[4],
width: BaseTheme.spacing[4]
toolboxButtonIconContainer: {
alignItems: 'center',
borderRadius: BaseTheme.shape.borderRadius,
height: BaseTheme.spacing[7],
justifyContent: 'center',
width: BaseTheme.spacing[7]
}
};

Expand Down
Loading