From 2759c95518eaea7e6add0382c2916f0fd9a005d4 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Sat, 1 Apr 2023 00:43:36 -0400 Subject: [PATCH] components/Header: add onBack prop for extra functionality --- components/Header.tsx | 28 ++++++++++++++++++---------- views/Receive.tsx | 23 +++++------------------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/components/Header.tsx b/components/Header.tsx index 462e51811..94700230e 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -9,22 +9,29 @@ interface HeaderProps { containerStyle?: any; placement?: 'left' | 'center' | 'right' | undefined; navigation?: any; + onBack?: () => void; } function ZeusHeader(props: HeaderProps) { - const BackButton = () => ( + const BackButton = (onBack?: () => void) => ( props.navigation.goBack()} + onPress={() => { + if (onBack) onBack(); + props.navigation.goBack(); + }} color={themeColor('text')} underlayColor="transparent" /> ); - const CloseButton = () => ( + const CloseButton = (onBack?: () => void) => ( props.navigation.goBack()} + onPress={() => { + if (onBack) onBack(); + props.navigation.goBack(); + }} color={themeColor('text')} underlayColor="transparent" /> @@ -35,21 +42,22 @@ function ZeusHeader(props: HeaderProps) { centerComponent, rightComponent, containerStyle, - placement + placement, + onBack } = props; return (
{ - const { InvoicesStore, navigation } = this.props; + onBack = () => { + const { InvoicesStore } = this.props; const { reset } = InvoicesStore; // kill all listeners and pollers before navigating back this.clearListeners(); @@ -235,10 +235,6 @@ export default class Receive extends React.Component< // clear invoice reset(); - - navigation.navigate('Wallet', { - refresh: true - }); }; autoGenerateInvoice = ( @@ -645,17 +641,6 @@ export default class Receive extends React.Component< const lnurl: LNURLWithdrawParams | undefined = navigation.getParam('lnurlParams'); - const BackButton = () => ( - { - this.navBack(); - }} - color={themeColor('text')} - underlayColor="transparent" - /> - ); - const ClearButton = () => (
} + leftComponent="Back" + onBack={this.onBack} centerComponent={{ text: posStatus === 'active' @@ -847,6 +833,7 @@ export default class Receive extends React.Component< ) ) } + navigation={navigation} />