From 40b38b70a783ea0d89019e431d46084b05eb4f15 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 27 May 2020 13:32:35 -0300 Subject: [PATCH] AttachmentView header --- app/views/AttachmentView.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/app/views/AttachmentView.js b/app/views/AttachmentView.js index f00a69dc5..39cd304f1 100644 --- a/app/views/AttachmentView.js +++ b/app/views/AttachmentView.js @@ -27,22 +27,6 @@ const styles = StyleSheet.create({ }); class AttachmentView extends React.Component { - static navigationOptions = ({ navigation, route }) => { - const attachment = route.params?.attachment; - const from = route.params?.from; - const handleSave = route.params?.handleSave ?? (() => {}); - const { title } = attachment; - const options = { - title: decodeURI(title), - headerRight: () => - }; - if (from !== 'MessagesView') { - options.gesturesEnabled = false; - options.headerLeft = () => ; - } - return options; - } - static propTypes = { navigation: PropTypes.object, route: PropTypes.object, @@ -58,12 +42,11 @@ class AttachmentView extends React.Component { super(props); const attachment = props.route.params?.attachment; this.state = { attachment, loading: true }; + this.setHeader(); } componentDidMount() { const { navigation } = this.props; - navigation.setParams({ handleSave: this.handleSave }); - this.unsubscribeBlur = navigation.addListener('blur', () => { if (this.videoRef && this.videoRef.stopAsync) { this.videoRef.stopAsync(); @@ -77,6 +60,22 @@ class AttachmentView extends React.Component { } } + setHeader = () => { + const { route, navigation } = this.props; + const attachment = route.params?.attachment; + const from = route.params?.from; + const { title } = attachment; + const options = { + title: decodeURI(title), + headerRight: () => + }; + if (from !== 'MessagesView') { + options.gesturesEnabled = false; + options.headerLeft = () => ; + } + navigation.setOptions(options); + } + getVideoRef = ref => this.videoRef = ref; handleSave = async() => {