mattermost-mobile/app/components/interactive_dialog_controller/interactive_dialog_controller.js
Miguel Alatzar b65ce5d283 [MM-16136] Update channel related screens (#2915)
* Update screens

* Update login tests

* Remove done

* Fix failing tests

* Update screens and components

* Check styles fix

* Update tests

* Prevent setState call after component unmounts

* Add empty setButtons func to dummy navigator

* Remove platform check

* Remove Platform import

* Update react-native-navigation version

* Add separate showModalOverCurrentContext function

* check-style fixes

* Remove overriding of AppDelegate's window

* Fix modal over current context animation

* Add showSearchModal navigation action

* Check-style fix

* Address review comments

* Update SettingsSidebar and children

* Update EditProfile screen

* Update SettingsSidebar

* Keep track of latest componentId to appear

* Track componentId in state to use in navigation actions

* Update FlaggedPosts and children

* Update RecentMentions

* Update Settings

* Store componentIds in ephemeral store

* Update AttachmentButton

* Remove unnecessary dismissModal

* Fix typo

* Upate NotificationSettings

* Update NotificationSettingsAutoResponder

* Update NotificationSettingsMentions

* Update NotificationSettingsMobile

* Update CreateChannel and children

* Update MoreChannels

* Update ChannelPeek and children

* Update ChannelNavBar and children

* Update ChannelPostList and children

* Update ChannelInfo and children

* Update ChannelAddMembers

* Update ChannelMembers

* Update EditChannel

* Fix setting of top bar buttons

* Update Channel screen and children

* Fix typo

* Use goToScreen for Android too

* Remove navigationComponentId
2019-06-26 16:46:05 -04:00

69 lines
1.9 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {PureComponent} from 'react';
import PropTypes from 'prop-types';
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
export default class InteractiveDialogController extends PureComponent {
static propTypes = {
actions: PropTypes.shape({
showModal: PropTypes.func.isRequired,
}).isRequired,
triggerId: PropTypes.string,
dialog: PropTypes.object,
theme: PropTypes.object,
};
constructor(props) {
super(props);
MaterialIcon.getImageSource('close', 20, props.theme.sidebarHeaderTextColor).then((source) => {
this.closeButton = source;
});
}
componentDidUpdate(prevProps) {
const {actions, triggerId} = this.props;
if (!triggerId) {
return;
}
const dialogData = this.props.dialog || {};
const prevDialogData = prevProps.dialog || {};
if (prevProps.triggerId === triggerId && dialogData.trigger_id === prevDialogData.trigger_id) {
return;
}
if (dialogData.trigger_id !== triggerId) {
return;
}
if (!dialogData.trigger_id || !dialogData.dialog) {
return;
}
const screen = 'InteractiveDialog';
const title = dialogData.dialog.title;
const passProps = {};
const options = {
topBar: {
leftButtons: [{
id: 'close-dialog',
icon: this.closeButton,
}],
rightButtons: [{
id: 'submit-dialog',
showAsAction: 'always',
text: dialogData.dialog.submit_label,
}],
},
};
actions.showModal(screen, title, passProps, options);
}
render() {
return null;
}
}