* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
114 lines
3 KiB
JavaScript
114 lines
3 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {PureComponent} from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import {
|
|
Animated,
|
|
Platform,
|
|
StyleSheet,
|
|
TouchableWithoutFeedback,
|
|
View,
|
|
} from 'react-native';
|
|
|
|
import EventEmitter from '@mm-redux/utils/event_emitter';
|
|
|
|
import {NavigationTypes} from 'app/constants';
|
|
import {emptyFunction} from 'app/utils/general';
|
|
import {dismissModal} from 'app/actions/navigation';
|
|
|
|
import OptionsModalList from './options_modal_list';
|
|
|
|
const {View: AnimatedView} = Animated;
|
|
const DURATION = 200;
|
|
|
|
export default class OptionsModal extends PureComponent {
|
|
static propTypes = {
|
|
items: PropTypes.array.isRequired,
|
|
deviceHeight: PropTypes.number.isRequired,
|
|
deviceWidth: PropTypes.number.isRequired,
|
|
onCancelPress: PropTypes.func,
|
|
title: PropTypes.oneOfType([
|
|
PropTypes.string,
|
|
PropTypes.object,
|
|
]),
|
|
isLandscape: PropTypes.bool.isRequired,
|
|
};
|
|
|
|
static defaultProps = {
|
|
onCancelPress: emptyFunction,
|
|
};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
top: new Animated.Value(props.deviceHeight),
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
EventEmitter.on(NavigationTypes.NAVIGATION_CLOSE_MODAL, this.close);
|
|
Animated.timing(this.state.top, {
|
|
toValue: 0,
|
|
duration: DURATION,
|
|
}).start();
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
EventEmitter.off(NavigationTypes.NAVIGATION_CLOSE_MODAL, this.close);
|
|
}
|
|
|
|
handleCancel = () => {
|
|
this.props.onCancelPress();
|
|
this.close();
|
|
};
|
|
|
|
close = () => {
|
|
Animated.timing(this.state.top, {
|
|
toValue: this.props.deviceHeight,
|
|
duration: DURATION,
|
|
}).start(() => {
|
|
dismissModal();
|
|
});
|
|
};
|
|
|
|
onItemPress = () => {
|
|
if (Platform.OS === 'android') {
|
|
this.close();
|
|
} else {
|
|
dismissModal();
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
items,
|
|
title,
|
|
isLandscape,
|
|
} = this.props;
|
|
|
|
return (
|
|
<TouchableWithoutFeedback onPress={this.handleCancel}>
|
|
<View style={style.wrapper}>
|
|
<AnimatedView style={{height: this.props.deviceHeight, left: 0, top: this.state.top, width: this.props.deviceWidth}}>
|
|
<OptionsModalList
|
|
items={items}
|
|
onCancelPress={this.handleCancel}
|
|
onItemPress={this.onItemPress}
|
|
title={title}
|
|
isLandscape={isLandscape}
|
|
/>
|
|
</AnimatedView>
|
|
</View>
|
|
</TouchableWithoutFeedback>
|
|
);
|
|
}
|
|
}
|
|
|
|
const style = StyleSheet.create({
|
|
wrapper: {
|
|
backgroundColor: Platform.select({ios: 'rgba(0, 0, 0, 0.5)'}),
|
|
flex: 1,
|
|
},
|
|
});
|