capacitor-swipe-gestures-plugin 4.2.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,68 +1,19 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
|
-
import WebKit
|
|
4
3
|
|
|
5
4
|
@objc(CapacitorSwipeGesturesPlugin)
|
|
6
5
|
public class CapacitorSwipeGesturesPlugin: CAPPlugin {
|
|
7
|
-
private var refreshControl: UIRefreshControl?
|
|
8
|
-
|
|
9
|
-
override public func load() {
|
|
10
|
-
// Plugin initialization code if needed
|
|
11
|
-
}
|
|
12
|
-
|
|
13
6
|
@objc func enable(_ call: CAPPluginCall) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// Enable pull-to-refresh
|
|
19
|
-
if let webView = self.bridge?.webView as? WKWebView {
|
|
20
|
-
self.setupRefreshControl(webView)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
call.resolve([
|
|
24
|
-
"status": "enable"
|
|
25
|
-
])
|
|
26
|
-
}
|
|
7
|
+
webView?.allowsBackForwardNavigationGestures = true;
|
|
8
|
+
call.resolve([
|
|
9
|
+
"status": "enable"
|
|
10
|
+
])
|
|
27
11
|
}
|
|
28
12
|
|
|
29
13
|
@objc func disable(_ call: CAPPluginCall) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Disable pull-to-refresh
|
|
35
|
-
self.removeRefreshControl()
|
|
36
|
-
|
|
37
|
-
call.resolve([
|
|
38
|
-
"status": "disable"
|
|
39
|
-
])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private func setupRefreshControl(_ webView: WKWebView) {
|
|
44
|
-
// Remove existing refresh control if any
|
|
45
|
-
removeRefreshControl()
|
|
46
|
-
|
|
47
|
-
// Create new refresh control
|
|
48
|
-
refreshControl = UIRefreshControl()
|
|
49
|
-
refreshControl?.addTarget(self, action: #selector(self.refreshWebView(_:)), for: .valueChanged)
|
|
50
|
-
|
|
51
|
-
// Add refresh control to webView's scrollView
|
|
52
|
-
webView.scrollView.refreshControl = refreshControl
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private func removeRefreshControl() {
|
|
56
|
-
if let webView = self.bridge?.webView as? WKWebView {
|
|
57
|
-
webView.scrollView.refreshControl = nil
|
|
58
|
-
refreshControl = nil
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@objc private func refreshWebView(_ sender: UIRefreshControl) {
|
|
63
|
-
if let webView = self.bridge?.webView {
|
|
64
|
-
webView.reload()
|
|
65
|
-
}
|
|
66
|
-
sender.endRefreshing()
|
|
14
|
+
webView?.allowsBackForwardNavigationGestures = false;
|
|
15
|
+
call.resolve([
|
|
16
|
+
"status": "disable"
|
|
17
|
+
])
|
|
67
18
|
}
|
|
68
|
-
}
|
|
19
|
+
}
|