Skip to content

Commit

Permalink
feat: broke out back and cancel button handlers in getStakingNavbar()
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt561 committed Jan 8, 2025
1 parent c117cdc commit e9d8331
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,28 @@ export function getStakingNavbar(
navigation.goBack();
}

function handleBackPress() {
if (metricsOptions?.backButtonEvent) {
withMetaMetrics(navigationPop, {
event: metricsOptions.backButtonEvent.event,
properties: metricsOptions.backButtonEvent.properties,
});
} else {
navigationPop();
}
}

function handleCancelPress() {
if (metricsOptions?.cancelButtonEvent) {
withMetaMetrics(navigationPop, {
event: metricsOptions.cancelButtonEvent.event,
properties: metricsOptions.cancelButtonEvent.properties,
});
} else {
navigationPop();
}
}

return {
headerTitle: () => (
<View style={innerStyles.headerTitle}>
Expand All @@ -1998,14 +2020,7 @@ export function getStakingNavbar(
<ButtonIcon
size={ButtonIconSizes.Lg}
iconName={IconName.ArrowLeft}
onPress={
metricsOptions?.backButtonEvent
? withMetaMetrics(navigationPop, {
event: metricsOptions.backButtonEvent.event,
properties: metricsOptions.backButtonEvent.properties,
})
: navigationPop
}
onPress={handleBackPress}
style={innerStyles.headerLeft}
/>
) : (
Expand All @@ -2014,14 +2029,7 @@ export function getStakingNavbar(
headerRight: () =>
hasCancelButton ? (
<TouchableOpacity
onPress={
metricsOptions?.cancelButtonEvent
? withMetaMetrics(navigationPop, {
event: metricsOptions.cancelButtonEvent.event,
properties: metricsOptions.cancelButtonEvent.properties,
})
: navigationPop
}
onPress={handleCancelPress}
style={styles.closeButton}
>
<Text style={innerStyles.headerButtonText}>
Expand Down

0 comments on commit e9d8331

Please sign in to comment.