@hanwha-ss1/plugin 0.1.5 → 0.1.7

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.
@@ -32,7 +32,7 @@ public class Plugin: CAPPlugin {
32
32
  }
33
33
 
34
34
  @objc func setScreenCaptureDisabled(_ call: CAPPluginCall) {
35
- screenCapture.screenCapturePrevent(webview: (self.bridge?.webView)!, completion:{ success in
35
+ screenCapture.screenCapturePrevent(view: self.bridge?.viewController!.view ?? self.webView!) { success in
36
36
  if success {
37
37
  call.resolve([
38
38
  "result": true,
@@ -44,7 +44,9 @@ public class Plugin: CAPPlugin {
44
44
  "message": "실패"
45
45
  ])
46
46
  }
47
- })
47
+ }
48
+
49
+
48
50
  }
49
51
 
50
52
  }
@@ -0,0 +1,30 @@
1
+ import Foundation
2
+ import UIKit
3
+ import WebKit
4
+
5
+ @objc public class PreventCapture: NSObject {
6
+
7
+ @objc public func screenCapturePrevent(view: UIView, completion: @escaping (Bool) -> Void) {
8
+ view.makeSecure()
9
+ completion(true)
10
+ }
11
+ }
12
+
13
+ extension UIView {
14
+ @objc public func makeSecure() {
15
+ DispatchQueue.main.async {
16
+ let textField = UITextField()
17
+ textField.isSecureTextEntry = true
18
+ self.addSubview(textField)
19
+
20
+ if UIDevice.current.userInterfaceIdiom == .phone {
21
+ textField.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
22
+ textField.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
23
+ }
24
+
25
+ self.layer.superlayer?.insertSublayer(textField.layer, at: 0)
26
+ textField.layer.sublayers?.last?.addSublayer(self.layer)
27
+
28
+ }
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanwha-ss1/plugin",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,38 +0,0 @@
1
- import Foundation
2
- import UIKit
3
- import WebKit
4
-
5
- @objc public class PreventCapture: NSObject {
6
-
7
- @objc public func screenCapturePrevent(webview: WKWebView, completion: @escaping (Bool) -> Void) {
8
- webview.makeSecure()
9
- completion(true)
10
- }
11
- }
12
-
13
- extension UIView {
14
- func makeSecure() {
15
- DispatchQueue.main.async {
16
- let textField = UITextField()
17
- textField.isSecureTextEntry = true
18
- self.addSubview(textField)
19
-
20
- textField.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
21
- textField.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
22
-
23
- let backView = UIView(frame: self.frame)
24
- let image = UIImageView(image: UIImage(named: "background", in: Bundle(for: PreventCapture.self), compatibleWith: nil))
25
- image.frame = backView.bounds
26
-
27
- backView.backgroundColor = UIColor.lightGray
28
- backView.addSubview(image)
29
-
30
- textField.insertSubview(backView, at: 0)
31
-
32
- textField.layer.removeFromSuperlayer()
33
- self.layer.superlayer?.insertSublayer(textField.layer, at: 0)
34
- textField.layer.sublayers?.last?.addSublayer(self.layer)
35
-
36
- }
37
- }
38
- }
File without changes
File without changes
File without changes