From f8af9c4fae4fb4652ac34e8b5e2eb89a795f42fa Mon Sep 17 00:00:00 2001 From: Calinteodor Date: Tue, 21 Feb 2023 11:26:04 +0200 Subject: [PATCH] feat(notifications): native UI updates (#12798) * feat(notifications): native notifications UI updates --- .../base/ui/components/native/Button.tsx | 39 ++- .../base/ui/components/native/IconButton.tsx | 2 +- .../base/ui/components/native/buttonStyles.ts | 10 + react/features/base/ui/constants.any.ts | 4 +- react/features/chat/actions.native.ts | 18 +- react/features/chat/actions.web.ts | 24 +- .../components/native/PrivateMessageButton.js | 2 +- .../components/native/Conference.js | 11 +- .../components/web/RaisedHandsCountLabel.tsx | 2 +- .../native/KnockingParticipantList.js | 173 ----------- .../features/lobby/components/native/index.js | 1 - react/features/lobby/middleware.ts | 112 ++++---- .../components/AbstractNotification.js | 5 + .../components/native/Notification.js | 99 ------- .../components/native/Notification.tsx | 270 ++++++++++++++++++ .../native/NotificationsContainer.js | 45 ++- .../notifications/components/native/styles.js | 93 ++++-- react/features/notifications/middleware.ts | 38 ++- react/features/notifications/reducer.ts | 24 +- react/features/notifications/types.ts | 1 + .../features/participants-pane/actions.any.ts | 16 +- .../participants-pane/actions.native.ts | 20 +- .../features/participants-pane/actions.web.ts | 13 + .../ContextMenuLobbyParticipantReject.js | 1 - .../components/native/ParticipantItem.js | 1 - react/features/participants-pane/hooks.web.ts | 2 +- .../toolbox/components/web/Toolbox.tsx | 2 +- .../web/PrivateMessageMenuButton.js | 2 +- 28 files changed, 547 insertions(+), 483 deletions(-) delete mode 100644 react/features/lobby/components/native/KnockingParticipantList.js delete mode 100644 react/features/notifications/components/native/Notification.js create mode 100644 react/features/notifications/components/native/Notification.tsx diff --git a/react/features/base/ui/components/native/Button.tsx b/react/features/base/ui/components/native/Button.tsx index 07515cb366..327669eda6 100644 --- a/react/features/base/ui/components/native/Button.tsx +++ b/react/features/base/ui/components/native/Button.tsx @@ -13,10 +13,12 @@ import { IButtonProps } from '../types'; import styles from './buttonStyles'; export interface IProps extends IButtonProps { - color?: string; + color?: string | undefined; contentStyle?: Object | undefined; labelStyle?: Object | undefined; + mode?: any; style?: Object | undefined; + useRippleColor?: boolean; } const Button: React.FC = ({ @@ -27,31 +29,36 @@ const Button: React.FC = ({ icon, labelKey, labelStyle, + mode = BUTTON_MODES.CONTAINED, onClick: onPress, style, - type + type, + useRippleColor = true }: IProps) => { const { t } = useTranslation(); - const { CONTAINED } = BUTTON_MODES; const { DESTRUCTIVE, PRIMARY, SECONDARY, TERTIARY } = BUTTON_TYPES; + const { CONTAINED, TEXT } = BUTTON_MODES; + + const rippleColor + = useRippleColor ? BaseTheme.palette.action03Active : 'transparent'; let buttonLabelStyles; let buttonStyles; let color; - let mode; if (type === PRIMARY) { - buttonLabelStyles = styles.buttonLabelPrimary; - color = BaseTheme.palette.action01; - mode = CONTAINED; + buttonLabelStyles = mode === TEXT + ? styles.buttonLabelPrimaryText + : styles.buttonLabelPrimary; + color = mode === CONTAINED && BaseTheme.palette.action01; } else if (type === SECONDARY) { buttonLabelStyles = styles.buttonLabelSecondary; - color = BaseTheme.palette.action02; - mode = CONTAINED; + color = mode === CONTAINED && BaseTheme.palette.action02; } else if (type === DESTRUCTIVE) { - color = BaseTheme.palette.actionDanger; - buttonLabelStyles = styles.buttonLabelDestructive; - mode = CONTAINED; + buttonLabelStyles = mode === TEXT + ? styles.buttonLabelDestructiveText + : styles.buttonLabelDestructive; + color = mode === CONTAINED && BaseTheme.palette.actionDanger; } else { color = buttonColor; buttonLabelStyles = styles.buttonLabel; @@ -65,15 +72,17 @@ const Button: React.FC = ({ } if (type === TERTIARY) { - buttonLabelStyles - = disabled ? styles.buttonLabelTertiaryDisabled : styles.buttonLabelTertiary; + if (useRippleColor && disabled) { + buttonLabelStyles = styles.buttonLabelTertiaryDisabled; + } + buttonLabelStyles = styles.buttonLabelTertiary; return ( = ({ iconButtonContainerStyles = styles.iconButtonContainerSecondary; rippleColor = BaseTheme.palette.action02; } else if (type === TERTIARY) { - color = BaseTheme.palette.icon01; + color = iconColor; iconButtonContainerStyles = styles.iconButtonContainer; rippleColor = BaseTheme.palette.action03; } else { diff --git a/react/features/base/ui/components/native/buttonStyles.ts b/react/features/base/ui/components/native/buttonStyles.ts index 81e0c61a2c..ccad66e878 100644 --- a/react/features/base/ui/components/native/buttonStyles.ts +++ b/react/features/base/ui/components/native/buttonStyles.ts @@ -42,6 +42,11 @@ export default { color: BaseTheme.palette.text01 }, + buttonLabelPrimaryText: { + ...buttonLabel, + color: BaseTheme.palette.action01 + }, + buttonLabelSecondary: { ...buttonLabel, color: BaseTheme.palette.text04 @@ -52,6 +57,11 @@ export default { color: BaseTheme.palette.text01 }, + buttonLabelDestructiveText: { + ...buttonLabel, + color: BaseTheme.palette.actionDanger + }, + buttonLabelTertiary: { ...buttonLabel, color: BaseTheme.palette.text01, diff --git a/react/features/base/ui/constants.any.ts b/react/features/base/ui/constants.any.ts index 916f541e0b..8e634954b9 100644 --- a/react/features/base/ui/constants.any.ts +++ b/react/features/base/ui/constants.any.ts @@ -13,6 +13,8 @@ export enum BUTTON_TYPES { */ export const BUTTON_MODES: { CONTAINED: 'contained'; + TEXT: 'text'; } = { - CONTAINED: 'contained' + CONTAINED: 'contained', + TEXT: 'text' }; diff --git a/react/features/chat/actions.native.ts b/react/features/chat/actions.native.ts index b803e755f3..04b16b79a1 100644 --- a/react/features/chat/actions.native.ts +++ b/react/features/chat/actions.native.ts @@ -1,3 +1,11 @@ +/* eslint-disable lines-around-comment, max-len */ + +import { navigate } +// @ts-ignore + from '../mobile/navigation/components/conference/ConferenceNavigationContainerRef'; +// @ts-ignore +import { screen } from '../mobile/navigation/routes'; + import { OPEN_CHAT } from './actionTypes'; export * from './actions.any'; @@ -6,13 +14,19 @@ export * from './actions.any'; * Displays the chat panel. * * @param {Object} participant - The recipient for the private chat. + * @param {boolean} disablePolls - Checks if polls are disabled. * * @returns {{ - * participant: Participant, + * participant: participant, * type: OPEN_CHAT * }} */ -export function openChat(participant: Object) { +export function openChat(participant: Object, disablePolls: boolean) { + if (disablePolls) { + navigate(screen.conference.chat); + } + navigate(screen.conference.chatandpolls.main); + return { participant, type: OPEN_CHAT diff --git a/react/features/chat/actions.web.ts b/react/features/chat/actions.web.ts index f7163c6e6e..e5c53b6326 100644 --- a/react/features/chat/actions.web.ts +++ b/react/features/chat/actions.web.ts @@ -1,7 +1,6 @@ -// @ts-expect-error +// @ts-ignore import VideoLayout from '../../../modules/UI/videolayout/VideoLayout'; import { IStore } from '../app/types'; -import { getParticipantById } from '../base/participants/functions'; import { OPEN_CHAT } from './actionTypes'; import { closeChat } from './actions.any'; @@ -26,27 +25,6 @@ export function openChat(participant?: Object) { }; } -/** - * Displays the chat panel for a participant identified by an id. - * - * @param {string} id - The id of the participant. - * @returns {{ - * participant: Participant, - * type: OPEN_CHAT - * }} - */ -export function openChatById(id: string) { - return function(dispatch: IStore['dispatch'], getState: IStore['getState']) { - const participant = getParticipantById(getState(), id); - - return dispatch({ - participant, - type: OPEN_CHAT - }); - }; -} - - /** * Toggles display of the chat panel. * diff --git a/react/features/chat/components/native/PrivateMessageButton.js b/react/features/chat/components/native/PrivateMessageButton.js index 032d3b593a..8260f9e5c2 100644 --- a/react/features/chat/components/native/PrivateMessageButton.js +++ b/react/features/chat/components/native/PrivateMessageButton.js @@ -4,7 +4,7 @@ import { IconMessage, IconReply } from '../../../base/icons'; import { getParticipantById } from '../../../base/participants'; import { connect } from '../../../base/redux'; import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components'; -import { handleLobbyChatInitialized, openChat } from '../../../chat/actions'; +import { handleLobbyChatInitialized, openChat } from '../../../chat/actions.native'; import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef'; import { screen } from '../../../mobile/navigation/routes'; diff --git a/react/features/conference/components/native/Conference.js b/react/features/conference/components/native/Conference.js index 15f01fc644..ccecd4105a 100644 --- a/react/features/conference/components/native/Conference.js +++ b/react/features/conference/components/native/Conference.js @@ -24,7 +24,6 @@ import { import { CalleeInfoContainer } from '../../../invite'; import { LargeVideo } from '../../../large-video'; import { startKnocking } from '../../../lobby/actions.any'; -import { KnockingParticipantList } from '../../../lobby/components/native'; import { getIsLobbyVisible } from '../../../lobby/functions'; import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef'; @@ -433,7 +432,13 @@ class Conference extends AbstractConference { - { _shouldDisplayTileView || <> } + { + _shouldDisplayTileView + || <> + + + + } { { this._renderNotificationsContainer() } - + { this._renderConferenceNotification() } {_shouldDisplayTileView && } diff --git a/react/features/conference/components/web/RaisedHandsCountLabel.tsx b/react/features/conference/components/web/RaisedHandsCountLabel.tsx index e4bb0d064d..13c202fb18 100644 --- a/react/features/conference/components/web/RaisedHandsCountLabel.tsx +++ b/react/features/conference/components/web/RaisedHandsCountLabel.tsx @@ -9,7 +9,7 @@ import Label from '../../../base/label/components/web/Label'; // eslint-disable-next-line lines-around-comment // @ts-ignore import { Tooltip } from '../../../base/tooltip'; -import { open as openParticipantsPane } from '../../../participants-pane/actions'; +import { open as openParticipantsPane } from '../../../participants-pane/actions.web'; const useStyles = makeStyles()(theme => { return { diff --git a/react/features/lobby/components/native/KnockingParticipantList.js b/react/features/lobby/components/native/KnockingParticipantList.js deleted file mode 100644 index 28f8edd8ee..0000000000 --- a/react/features/lobby/components/native/KnockingParticipantList.js +++ /dev/null @@ -1,173 +0,0 @@ -import React, { PureComponent } from 'react'; -import { View } from 'react-native'; - -import { translate } from '../../../base/i18n/functions'; -import { isLocalParticipantModerator } from '../../../base/participants/functions'; -import { connect } from '../../../base/redux'; -import Button from '../../../base/ui/components/native/Button'; -import { BUTTON_TYPES } from '../../../base/ui/constants.native'; -import { handleLobbyChatInitialized } from '../../../chat/actions.native'; -import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef'; -import { screen } from '../../../mobile/navigation/routes'; -import ParticipantItem - from '../../../participants-pane/components/native/ParticipantItem'; -import { setKnockingParticipantApproval } from '../../actions.native'; -import { getKnockingParticipants, getLobbyEnabled, showLobbyChatButton } from '../../functions'; - -import styles from './styles'; - - -/** - * Props type of the component. - */ -export type Props = { - - /** - * The list of participants. - */ - _participants: Array, - - /** - * True if the list should be rendered. - */ - _visible: boolean, - - /** - * True if the polls feature is disabled. - */ - _isPollsDisabled: boolean, - - /** - * Returns true if the lobby chat button should be shown. - */ - _showChatButton: Function, - - /** - * The Redux Dispatch function. - */ - dispatch: Function -}; - -/** - * Component to render a list for the actively knocking participants. - */ -class KnockingParticipantList extends PureComponent { - /** - * Instantiates a new component. - * - * @param {Object} props - The read-only properties with which the new - * instance is to be initialized. - */ - constructor(props: Props) { - super(props); - - this._onRespondToParticipant = this._onRespondToParticipant.bind(this); - } - - /** - * Implements {@code PureComponent#render}. - * - * @inheritdoc - */ - render() { - const { _participants, _visible, _showChatButton } = this.props; - - if (!_visible) { - return null; - } - - return ( - <> - { _participants.map(p => ( - - -