Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LIVE-16732): Swipe right gesture navigates back on swap #9136

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-pumas-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Swipe right gesture navigates back on swap
41 changes: 31 additions & 10 deletions apps/ledger-live-mobile/src/components/Web3AppWebview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import React, { forwardRef } from "react";
import { WalletAPIWebview } from "./WalletAPIWebview";
import { PlatformAPIWebview } from "./PlatformAPIWebview";
import { WebviewAPI, WebviewProps } from "./types";
import {
HandlerStateChangeEvent,
PanGestureHandler,
PanGestureHandlerEventPayload,
State,
} from "react-native-gesture-handler";
import { View } from "react-native";
import { useNavigation } from "@react-navigation/core";

export const Web3AppWebview = forwardRef<WebviewAPI, WebviewProps>(
(
Expand All @@ -18,18 +26,31 @@ export const Web3AppWebview = forwardRef<WebviewAPI, WebviewProps>(
},
ref,
) => {
const navigation = useNavigation();

const onGesture = (event: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {
// PanGestureHandler callback for swiping left to right to fix issue with <Tab.Navigator>
if (event.nativeEvent.state === State.END && event.nativeEvent.translationX > 10) {
navigation.goBack();
}
};

if (semver.satisfies(WALLET_API_VERSION, manifest.apiVersion)) {
return (
<WalletAPIWebview
ref={ref}
onScroll={onScroll}
manifest={manifest}
currentAccountHistDb={currentAccountHistDb}
inputs={inputs}
customHandlers={customHandlers}
onStateChange={onStateChange}
allowsBackForwardNavigationGestures={allowsBackForwardNavigationGestures}
/>
<PanGestureHandler onHandlerStateChange={onGesture} activeOffsetX={[0, 10]}>
<View style={{ flex: 1 }}>
<WalletAPIWebview
ref={ref}
onScroll={onScroll}
manifest={manifest}
currentAccountHistDb={currentAccountHistDb}
inputs={inputs}
customHandlers={customHandlers}
onStateChange={onStateChange}
allowsBackForwardNavigationGestures={allowsBackForwardNavigationGestures}
/>
</View>
</PanGestureHandler>
);
}
return (
Expand Down
Loading