From d3902994fe73f96d28984af696dfa3ed3bc28fd9 Mon Sep 17 00:00:00 2001 From: Vigneshpillai19 <43498822+Vigneshpillai19@users.noreply.github.com> Date: Tue, 30 Jun 2020 14:02:39 +0530 Subject: [PATCH 1/3] Added Back Button Functionality --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 90f33ea..f79ac01 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, View, Modal, ViewPropTypes } from 'react-native'; +import { StyleSheet, View, Modal, ViewPropTypes, BackHandler } from 'react-native'; import PropTypes from 'prop-types'; import LottieAnimation from 'lottie-react-native'; @@ -12,6 +12,7 @@ export default class AnimatedLoader extends React.PureComponent { animationStyle: {}, speed: 1, loop: true, + backButtonPress: () => Backhandler.exitApp(), }; static propTypes = { @@ -22,6 +23,7 @@ export default class AnimatedLoader extends React.PureComponent { animationStyle: ViewPropTypes.style, speed: PropTypes.number, loop: PropTypes.bool, + backButtonPress: PropTypes.func, }; animation = React.createRef(); @@ -63,7 +65,7 @@ export default class AnimatedLoader extends React.PureComponent { visible={visible} animationType={animationType} supportedOrientations={['portrait']} - onRequestClose={() => {}} + onRequestClose={backButtonPress} > {this._renderLottie()} From 316f079aab821e79c864bd8f963ece69888eed48 Mon Sep 17 00:00:00 2001 From: Vigneshpillai19 <43498822+Vigneshpillai19@users.noreply.github.com> Date: Mon, 13 Jul 2020 17:46:28 +0530 Subject: [PATCH 2/3] Corrected BackHandler --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index f79ac01..7f0e231 100644 --- a/src/index.js +++ b/src/index.js @@ -12,7 +12,7 @@ export default class AnimatedLoader extends React.PureComponent { animationStyle: {}, speed: 1, loop: true, - backButtonPress: () => Backhandler.exitApp(), + backButtonPress: () => BackHandler.exitApp(), }; static propTypes = { From 8ef3865e6808f79c99035e79148ca57cd5ae0bde Mon Sep 17 00:00:00 2001 From: Vigneshpillai19 <43498822+Vigneshpillai19@users.noreply.github.com> Date: Mon, 13 Jul 2020 18:16:24 +0530 Subject: [PATCH 3/3] Changes done for Platform Specific(Android) --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 7f0e231..5d9f59e 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, View, Modal, ViewPropTypes, BackHandler } from 'react-native'; +import { StyleSheet, View, Modal, ViewPropTypes, BackHandler, Platform } from 'react-native'; import PropTypes from 'prop-types'; import LottieAnimation from 'lottie-react-native'; @@ -12,7 +12,7 @@ export default class AnimatedLoader extends React.PureComponent { animationStyle: {}, speed: 1, loop: true, - backButtonPress: () => BackHandler.exitApp(), + backButtonPress: () => Platform.OS === 'android' ? BackHandler.exitApp() : null, }; static propTypes = {