* 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 * Update PinnedPosts * Update LongPost * Update PostOptions * Update PostTextboxBase * Update EditPost * Check-styles fix * Update DisplaySettings * Update Timezone * Update SelectTimezone * Update IntlWrapper and Notification * Update InteractiveDialog and children * Update ExpandedAnnouncementBanner * Update ClientUpgradeListener * Update MoreDirectMessages * Update SelectorScreen * Update UserProfile * Update Thread * Update About * Update ImagePreview * Update TextPreview * Update AddReaction * Update ReactionList and children * Update Code * Update TermsOfService * Update Permalink * Update Permalink * Update ErrorTeamsList * Update Search * Remove navigator prop * Fix setButtons calls * Remove navigationComponentId * Fix test * Handle in-app notifs in global event handler * Fix in-app notification handling * Fix typo * Fix tests * Auto dismiss in-app notif after 5 seconds * Fix typo * Update overlay dismissal * Animate in-app notif dismissal and allow gesture dismissal
361 lines
11 KiB
JavaScript
361 lines
11 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Platform} from 'react-native';
|
|
import {Navigation} from 'react-native-navigation';
|
|
|
|
import merge from 'deepmerge';
|
|
|
|
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
|
|
|
import EphemeralStore from 'app/store/ephemeral_store';
|
|
|
|
export function resetToChannel(passProps = {}) {
|
|
return (dispatch, getState) => {
|
|
const theme = getTheme(getState());
|
|
|
|
Navigation.setRoot({
|
|
root: {
|
|
stack: {
|
|
children: [{
|
|
component: {
|
|
name: 'Channel',
|
|
passProps,
|
|
options: {
|
|
layout: {
|
|
backgroundColor: 'transparent',
|
|
},
|
|
statusBar: {
|
|
visible: true,
|
|
},
|
|
topBar: {
|
|
visible: false,
|
|
height: 0,
|
|
backButton: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
title: '',
|
|
},
|
|
background: {
|
|
color: theme.sidebarHeaderBg,
|
|
},
|
|
title: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}],
|
|
},
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function resetToSelectServer(allowOtherServers) {
|
|
return (dispatch, getState) => {
|
|
const theme = getTheme(getState());
|
|
|
|
Navigation.setRoot({
|
|
root: {
|
|
stack: {
|
|
children: [{
|
|
component: {
|
|
name: 'SelectServer',
|
|
passProps: {
|
|
allowOtherServers,
|
|
},
|
|
options: {
|
|
statusBar: {
|
|
visible: true,
|
|
},
|
|
topBar: {
|
|
backButton: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
title: '',
|
|
},
|
|
background: {
|
|
color: theme.sidebarHeaderBg,
|
|
},
|
|
visible: false,
|
|
height: 0,
|
|
},
|
|
},
|
|
},
|
|
}],
|
|
},
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function resetToTeams(name, title, passProps = {}, options = {}) {
|
|
return (dispatch, getState) => {
|
|
const theme = getTheme(getState());
|
|
const defaultOptions = {
|
|
layout: {
|
|
backgroundColor: theme.centerChannelBg,
|
|
},
|
|
statusBar: {
|
|
visible: true,
|
|
},
|
|
topBar: {
|
|
visible: true,
|
|
title: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
text: title,
|
|
},
|
|
backButton: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
title: '',
|
|
},
|
|
background: {
|
|
color: theme.sidebarHeaderBg,
|
|
},
|
|
},
|
|
};
|
|
|
|
Navigation.setRoot({
|
|
root: {
|
|
stack: {
|
|
children: [{
|
|
component: {
|
|
name,
|
|
passProps,
|
|
options: merge(defaultOptions, options),
|
|
},
|
|
}],
|
|
},
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function goToScreen(name, title, passProps = {}, options = {}) {
|
|
return (dispatch, getState) => {
|
|
const state = getState();
|
|
const componentId = EphemeralStore.getTopComponentId();
|
|
const theme = getTheme(state);
|
|
const defaultOptions = {
|
|
layout: {
|
|
backgroundColor: theme.centerChannelBg,
|
|
},
|
|
topBar: {
|
|
animate: true,
|
|
visible: true,
|
|
backButton: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
title: '',
|
|
},
|
|
background: {
|
|
color: theme.sidebarHeaderBg,
|
|
},
|
|
title: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
text: title,
|
|
},
|
|
},
|
|
};
|
|
|
|
Navigation.push(componentId, {
|
|
component: {
|
|
name,
|
|
passProps,
|
|
options: merge(defaultOptions, options),
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function popTopScreen() {
|
|
return () => {
|
|
const componentId = EphemeralStore.getTopComponentId();
|
|
|
|
Navigation.pop(componentId);
|
|
};
|
|
}
|
|
|
|
export function popToRoot() {
|
|
return () => {
|
|
const componentId = EphemeralStore.getTopComponentId();
|
|
|
|
Navigation.popToRoot(componentId).catch(() => {
|
|
// RNN returns a promise rejection if there are no screens
|
|
// atop the root screen to pop. We'll do nothing in this
|
|
// case but we will catch the rejection here so that the
|
|
// caller doesn't have to.
|
|
});
|
|
};
|
|
}
|
|
|
|
export function showModal(name, title, passProps = {}, options = {}) {
|
|
return (dispatch, getState) => {
|
|
const theme = getTheme(getState());
|
|
const defaultOptions = {
|
|
layout: {
|
|
backgroundColor: theme.centerChannelBg,
|
|
},
|
|
statusBar: {
|
|
visible: true,
|
|
},
|
|
topBar: {
|
|
animate: true,
|
|
visible: true,
|
|
backButton: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
title: '',
|
|
},
|
|
background: {
|
|
color: theme.sidebarHeaderBg,
|
|
},
|
|
title: {
|
|
color: theme.sidebarHeaderTextColor,
|
|
text: title,
|
|
},
|
|
leftButtonColor: theme.sidebarHeaderTextColor,
|
|
rightButtonColor: theme.sidebarHeaderTextColor,
|
|
},
|
|
};
|
|
|
|
Navigation.showModal({
|
|
stack: {
|
|
children: [{
|
|
component: {
|
|
name,
|
|
passProps,
|
|
options: merge(defaultOptions, options),
|
|
},
|
|
}],
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function showModalOverCurrentContext(name, passProps = {}, options = {}) {
|
|
return (dispatch) => {
|
|
const title = '';
|
|
const animationsEnabled = (Platform.OS === 'android').toString();
|
|
const defaultOptions = {
|
|
modalPresentationStyle: 'overCurrentContext',
|
|
layout: {
|
|
backgroundColor: 'transparent',
|
|
},
|
|
topBar: {
|
|
visible: false,
|
|
height: 0,
|
|
},
|
|
animations: {
|
|
showModal: {
|
|
enabled: animationsEnabled,
|
|
alpha: {
|
|
from: 0,
|
|
to: 1,
|
|
duration: 250,
|
|
},
|
|
},
|
|
dismissModal: {
|
|
enabled: animationsEnabled,
|
|
alpha: {
|
|
from: 1,
|
|
to: 0,
|
|
duration: 250,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
const mergeOptions = merge(defaultOptions, options);
|
|
|
|
dispatch(showModal(name, title, passProps, mergeOptions));
|
|
};
|
|
}
|
|
|
|
export function showSearchModal(initialValue = '') {
|
|
return (dispatch) => {
|
|
const name = 'Search';
|
|
const title = '';
|
|
const passProps = {initialValue};
|
|
const options = {
|
|
topBar: {
|
|
visible: false,
|
|
height: 0,
|
|
},
|
|
};
|
|
|
|
dispatch(showModal(name, title, passProps, options));
|
|
};
|
|
}
|
|
|
|
export function dismissModal(options = {}) {
|
|
return () => {
|
|
const componentId = EphemeralStore.getTopComponentId();
|
|
|
|
Navigation.dismissModal(componentId, options);
|
|
};
|
|
}
|
|
|
|
export function dismissAllModals(options = {}) {
|
|
return () => {
|
|
Navigation.dismissAllModals(options).catch(() => {
|
|
// RNN returns a promise rejection if there are no modals to
|
|
// dismiss. We'll do nothing in this case but we will catch
|
|
// the rejection here so that the caller doesn't have to.
|
|
});
|
|
};
|
|
}
|
|
|
|
export function peek(name, passProps = {}, options = {}) {
|
|
return () => {
|
|
const componentId = EphemeralStore.getTopComponentId();
|
|
const defaultOptions = {
|
|
preview: {
|
|
commit: false,
|
|
},
|
|
};
|
|
|
|
Navigation.push(componentId, {
|
|
component: {
|
|
name,
|
|
passProps,
|
|
options: merge(defaultOptions, options),
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function setButtons(componentId, buttons = {leftButtons: [], rightButtons: []}) {
|
|
return () => {
|
|
Navigation.mergeOptions(componentId, {
|
|
topBar: {
|
|
...buttons,
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function showOverlay(name, passProps, options = {}) {
|
|
return () => {
|
|
const defaultOptions = {
|
|
overlay: {
|
|
interceptTouchOutside: false,
|
|
},
|
|
};
|
|
|
|
Navigation.showOverlay({
|
|
component: {
|
|
name,
|
|
passProps,
|
|
options: merge(defaultOptions, options),
|
|
},
|
|
});
|
|
};
|
|
}
|
|
|
|
export function dismissOverlay(componentId) {
|
|
return () => {
|
|
return Navigation.dismissOverlay(componentId).catch(() => {
|
|
// RNN returns a promise rejection if there is no modal with
|
|
// this componentId to dismiss. We'll do nothing in this case
|
|
// but we will catch the rejection here so that the caller
|
|
// doesn't have to.
|
|
});
|
|
};
|
|
}
|