mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
feat(mobile): disable swipe back gesture when there is no back in header (#8876)
close AF-1663, AF-1756 - new global `ModalConfigContext` - new logic to judge whether inside modal - render `✕` for PageHeader back if inside modal - only enable `NavigationGesture` when there is `<` in PageHeader
This commit is contained in:
@@ -5,11 +5,13 @@ class AFFiNEViewController: CAPBridgeViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
webView?.allowsBackForwardNavigationGestures = true
|
||||
// disable by default, enable manually when there is a "back" button in page-header
|
||||
webView?.allowsBackForwardNavigationGestures = false
|
||||
}
|
||||
|
||||
override func capacitorDidLoad() {
|
||||
bridge?.registerPluginInstance(CookiePlugin())
|
||||
bridge?.registerPluginInstance(HashcashPlugin())
|
||||
bridge?.registerPluginInstance(NavigationGesturePlugin())
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import Foundation
|
||||
import Capacitor
|
||||
|
||||
@objc(NavigationGesturePlugin)
|
||||
public class NavigationGesturePlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
public let identifier = "NavigationGesturePlugin"
|
||||
public let jsName = "NavigationGesture"
|
||||
public let pluginMethods: [CAPPluginMethod] = [
|
||||
CAPPluginMethod(name: "isEnabled", returnType: CAPPluginReturnPromise),
|
||||
CAPPluginMethod(name: "enable", returnType: CAPPluginReturnPromise),
|
||||
CAPPluginMethod(name: "disable", returnType: CAPPluginReturnPromise)
|
||||
]
|
||||
|
||||
@objc func isEnabled(_ call: CAPPluginCall) {
|
||||
let enabled = self.bridge?.webView?.allowsBackForwardNavigationGestures ?? true
|
||||
call.resolve(["value": enabled])
|
||||
}
|
||||
|
||||
@objc func enable(_ call: CAPPluginCall) {
|
||||
DispatchQueue.main.sync {
|
||||
self.bridge?.webView?.allowsBackForwardNavigationGestures = true
|
||||
call.resolve([:])
|
||||
}
|
||||
}
|
||||
|
||||
@objc func disable(_ call: CAPPluginCall) {
|
||||
DispatchQueue.main.sync {
|
||||
self.bridge?.webView?.allowsBackForwardNavigationGestures = false
|
||||
call.resolve([:])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user