// @flow import * as React from 'react'; import {IconButton, Text} from 'react-native-paper'; import ImageViewer from 'react-native-image-zoom-viewer'; import {StackNavigationProp} from '@react-navigation/stack'; import * as Animatable from 'react-native-animatable'; type PropsType = { navigation: StackNavigationProp, route: {params: {images: Array<{url: string}>}}, }; class ImageGalleryScreen extends React.Component { images: Array<{url: string}>; closeButtonRef: {current: null | Animatable.View}; indicatorRef: {current: null | Animatable.View}; controlsShown: boolean; constructor(props: PropsType) { super(props); this.closeButtonRef = React.createRef(); this.indicatorRef = React.createRef(); this.controlsShown = true; if (props.route.params != null) this.images = props.route.params.images; } goBack = () => { const {navigation} = this.props; navigation.goBack(); }; getRenderHeader = (): React.Node => { return ( ); }; getRenderIndicator = ( currentIndex?: number, allSize?: number, ): React.Node => { if (currentIndex != null && allSize != null && allSize !== 1) return ( {currentIndex}/{allSize} ); return null; }; onImageClick = () => { if (this.controlsShown) this.hideControls(); else this.showControls(); this.controlsShown = !this.controlsShown; }; hideControls() { if (this.closeButtonRef.current != null) this.closeButtonRef.current.fadeOutUp(200); if (this.indicatorRef.current != null) this.indicatorRef.current.fadeOutUp(300); } showControls() { if (this.closeButtonRef.current != null) this.closeButtonRef.current.fadeInDown(300); if (this.indicatorRef.current != null) this.indicatorRef.current.fadeInDown(400); } render(): React.Node { return ( ); } } export default ImageGalleryScreen;