refactor(ios): disable navigation gesture with js (#9287)
Do not toggle navigation gesture native to avoid unexpected behavior. close AF-1958, AF-1797
This commit is contained in:
@@ -5,8 +5,7 @@ import UIKit
|
|||||||
class AFFiNEViewController: CAPBridgeViewController {
|
class AFFiNEViewController: CAPBridgeViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// disable by default, enable manually when there is a "back" button in page-header
|
webView?.allowsBackForwardNavigationGestures = true
|
||||||
webView?.allowsBackForwardNavigationGestures = false
|
|
||||||
navigationController?.navigationBar.isHidden = true
|
navigationController?.navigationBar.isHidden = true
|
||||||
extendedLayoutIncludesOpaqueBars = false
|
extendedLayoutIncludesOpaqueBars = false
|
||||||
edgesForExtendedLayout = []
|
edgesForExtendedLayout = []
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
"@capacitor/ios": "^6.2.0",
|
"@capacitor/ios": "^6.2.0",
|
||||||
"@capacitor/keyboard": "^6.0.3",
|
"@capacitor/keyboard": "^6.0.3",
|
||||||
"@sentry/react": "^8.44.0",
|
"@sentry/react": "^8.44.0",
|
||||||
|
"@toeverything/infra": "workspace:^",
|
||||||
"next-themes": "^0.4.4",
|
"next-themes": "^0.4.4",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import { ModalConfigProvider } from './modal-config';
|
|||||||
import { Cookie } from './plugins/cookie';
|
import { Cookie } from './plugins/cookie';
|
||||||
import { Hashcash } from './plugins/hashcash';
|
import { Hashcash } from './plugins/hashcash';
|
||||||
import { Intelligents } from './plugins/intelligents';
|
import { Intelligents } from './plugins/intelligents';
|
||||||
import { NavigationGesture } from './plugins/navigation-gesture';
|
import { enableNavigationGesture$ } from './web-navigation-control';
|
||||||
|
|
||||||
const future = {
|
const future = {
|
||||||
v7_startTransition: true,
|
v7_startTransition: true,
|
||||||
@@ -107,9 +107,9 @@ framework.impl(VirtualKeyboardProvider, {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
framework.impl(NavigationGestureProvider, {
|
framework.impl(NavigationGestureProvider, {
|
||||||
isEnabled: () => NavigationGesture.isEnabled(),
|
isEnabled: () => enableNavigationGesture$.value,
|
||||||
enable: () => NavigationGesture.enable(),
|
enable: () => enableNavigationGesture$.next(true),
|
||||||
disable: () => NavigationGesture.disable(),
|
disable: () => enableNavigationGesture$.next(false),
|
||||||
});
|
});
|
||||||
framework.impl(HapticProvider, {
|
framework.impl(HapticProvider, {
|
||||||
impact: options => Haptics.impact(options as any),
|
impact: options => Haptics.impact(options as any),
|
||||||
|
|||||||
13
packages/frontend/apps/ios/src/web-navigation-control.tsx
Normal file
13
packages/frontend/apps/ios/src/web-navigation-control.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { LiveData } from '@toeverything/infra';
|
||||||
|
|
||||||
|
export const enableNavigationGesture$ = new LiveData(false);
|
||||||
|
|
||||||
|
const onTouchStart = (e: TouchEvent) => {
|
||||||
|
if (enableNavigationGesture$.value) return;
|
||||||
|
|
||||||
|
const clientX = e.changedTouches[0].clientX;
|
||||||
|
if (clientX <= 25) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.body.addEventListener('touchstart', onTouchStart, { passive: false });
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { createIdentifier } from '@toeverything/infra';
|
import { createIdentifier } from '@toeverything/infra';
|
||||||
|
|
||||||
export interface NavigationGestureProvider {
|
export interface NavigationGestureProvider {
|
||||||
isEnabled: () => Promise<boolean>;
|
isEnabled: () => boolean;
|
||||||
enable: () => Promise<void>;
|
enable: () => void;
|
||||||
disable: () => Promise<void>;
|
disable: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NavigationGestureProvider =
|
export const NavigationGestureProvider =
|
||||||
|
|||||||
@@ -587,6 +587,7 @@ __metadata:
|
|||||||
"@capacitor/ios": "npm:^6.2.0"
|
"@capacitor/ios": "npm:^6.2.0"
|
||||||
"@capacitor/keyboard": "npm:^6.0.3"
|
"@capacitor/keyboard": "npm:^6.0.3"
|
||||||
"@sentry/react": "npm:^8.44.0"
|
"@sentry/react": "npm:^8.44.0"
|
||||||
|
"@toeverything/infra": "workspace:^"
|
||||||
"@types/react": "npm:^19.0.1"
|
"@types/react": "npm:^19.0.1"
|
||||||
"@types/react-dom": "npm:^19.0.2"
|
"@types/react-dom": "npm:^19.0.2"
|
||||||
cross-env: "npm:^7.0.3"
|
cross-env: "npm:^7.0.3"
|
||||||
@@ -13718,7 +13719,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@toeverything/infra@workspace:*, @toeverything/infra@workspace:packages/common/infra":
|
"@toeverything/infra@workspace:*, @toeverything/infra@workspace:^, @toeverything/infra@workspace:packages/common/infra":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@toeverything/infra@workspace:packages/common/infra"
|
resolution: "@toeverything/infra@workspace:packages/common/infra"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user