From 48637490ed16063a1cca267aae60a27298449373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fonkam?= Date: Sat, 14 Dec 2024 14:20:18 -0500 Subject: [PATCH] fix: duplicate interface definition for class 'NoScreenshotPlugin'fixed test --- example/ios/Podfile.lock | 29 +++++++++++++++++++ .../Flutter/GeneratedPluginRegistrant.swift | 2 +- example/pubspec.lock | 2 +- ...ugin.swift => IOSNoScreenshotPlugin.swift} | 24 +++++++-------- ios/Classes/NoScreenshotPlugin.m | 2 +- ...in.swift => MacOSNoScreenshotPlugin.swift} | 20 ++++++------- pubspec.yaml | 6 ++-- 7 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 example/ios/Podfile.lock rename ios/Classes/{NoScreenshotPlugin.swift => IOSNoScreenshotPlugin.swift} (83%) rename macos/Classes/{NoScreenshotPlugin.swift => MacOSNoScreenshotPlugin.swift} (85%) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 0000000..50c33d5 --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,29 @@ +PODS: + - Flutter (1.0.0) + - no_screenshot (0.3.2-beta.1): + - Flutter + - ScreenProtectorKit (~> 1.3.1) + - ScreenProtectorKit (1.3.1) + +DEPENDENCIES: + - Flutter (from `Flutter`) + - no_screenshot (from `.symlinks/plugins/no_screenshot/ios`) + +SPEC REPOS: + trunk: + - ScreenProtectorKit + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + no_screenshot: + :path: ".symlinks/plugins/no_screenshot/ios" + +SPEC CHECKSUMS: + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + no_screenshot: 908a71edc63ea17016f46537e0f420bc3856ce2c + ScreenProtectorKit: 83a6281b02c7a5902ee6eac4f5045f674e902ae4 + +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 + +COCOAPODS: 1.15.2 diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index 57055bb..e565dec 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,5 +8,5 @@ import Foundation import no_screenshot func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - NoScreenshotPlugin.register(with: registry.registrar(forPlugin: "NoScreenshotPlugin")) + MacOSNoScreenshotPlugin.register(with: registry.registrar(forPlugin: "MacOSNoScreenshotPlugin")) } diff --git a/example/pubspec.lock b/example/pubspec.lock index 5baad98..3177986 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -137,7 +137,7 @@ packages: path: ".." relative: true source: path - version: "0.3.2-beta.1" + version: "0.3.2-beta.2" path: dependency: transitive description: diff --git a/ios/Classes/NoScreenshotPlugin.swift b/ios/Classes/IOSNoScreenshotPlugin.swift similarity index 83% rename from ios/Classes/NoScreenshotPlugin.swift rename to ios/Classes/IOSNoScreenshotPlugin.swift index e9744a7..ae360d6 100644 --- a/ios/Classes/NoScreenshotPlugin.swift +++ b/ios/Classes/IOSNoScreenshotPlugin.swift @@ -2,7 +2,7 @@ import Flutter import UIKit import ScreenProtectorKit -public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { +public class IOSNoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private var screenProtectorKit: ScreenProtectorKit? = nil private static var methodChannel: FlutterMethodChannel? = nil private static var eventChannel: FlutterEventChannel? = nil @@ -24,7 +24,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { super.init() // Restore the saved state from UserDefaults - var fetchVal = UserDefaults.standard.bool(forKey: NoScreenshotPlugin.preventScreenShotKey) + var fetchVal = UserDefaults.standard.bool(forKey: IOSNoScreenshotPlugin.preventScreenShotKey) updateScreenshotState(isScreenshotBlocked: fetchVal) } @@ -36,7 +36,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { let screenProtectorKit = ScreenProtectorKit(window: window as? UIWindow) screenProtectorKit.configurePreventionScreenshot() - let instance = NoScreenshotPlugin(screenProtectorKit: screenProtectorKit) + let instance = IOSNoScreenshotPlugin(screenProtectorKit: screenProtectorKit) registrar.addMethodCallDelegate(instance, channel: methodChannel!) eventChannel?.setStreamHandler(instance) registrar.addApplicationDelegate(instance) @@ -64,16 +64,16 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { func persistState() { // Persist the state when changed - UserDefaults.standard.set(NoScreenshotPlugin.preventScreenShot, forKey: NoScreenshotPlugin.preventScreenShotKey) - print("Persisted state: \(NoScreenshotPlugin.preventScreenShot)") + UserDefaults.standard.set(IOSNoScreenshotPlugin.preventScreenShot, forKey: IOSNoScreenshotPlugin.preventScreenShotKey) + print("Persisted state: \(IOSNoScreenshotPlugin.preventScreenShot)") updateSharedPreferencesState("") } func fetchPersistedState() { // Restore the saved state from UserDefaults - var fetchVal = UserDefaults.standard.bool(forKey: NoScreenshotPlugin.preventScreenShotKey) ? NoScreenshotPlugin.DISABLESCREENSHOT :NoScreenshotPlugin.ENABLESCREENSHOT + var fetchVal = UserDefaults.standard.bool(forKey: IOSNoScreenshotPlugin.preventScreenShotKey) ? IOSNoScreenshotPlugin.DISABLESCREENSHOT :IOSNoScreenshotPlugin.ENABLESCREENSHOT updateScreenshotState(isScreenshotBlocked: fetchVal) - print("Fetched state: \(NoScreenshotPlugin.preventScreenShot)") + print("Fetched state: \(IOSNoScreenshotPlugin.preventScreenShot)") } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { @@ -85,7 +85,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { shotOn() result(true) case "toggleScreenshot": - NoScreenshotPlugin.preventScreenShot ? shotOn(): shotOff() + IOSNoScreenshotPlugin.preventScreenShot ? shotOn(): shotOff() result(true) case "startScreenshotListening": startListening() @@ -99,13 +99,13 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { } private func shotOff() { - NoScreenshotPlugin.preventScreenShot = NoScreenshotPlugin.DISABLESCREENSHOT + IOSNoScreenshotPlugin.preventScreenShot = IOSNoScreenshotPlugin.DISABLESCREENSHOT screenProtectorKit?.enabledPreventScreenshot() persistState() } private func shotOn() { - NoScreenshotPlugin.preventScreenShot = NoScreenshotPlugin.ENABLESCREENSHOT + IOSNoScreenshotPlugin.preventScreenShot = IOSNoScreenshotPlugin.ENABLESCREENSHOT screenProtectorKit?.disablePreventScreenshot() persistState() } @@ -122,7 +122,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { @objc private func screenshotDetected() { print("Screenshot detected") - updateSharedPreferencesState(NoScreenshotPlugin.screenshotPathPlaceholder) + updateSharedPreferencesState(IOSNoScreenshotPlugin.screenshotPathPlaceholder) } private func updateScreenshotState(isScreenshotBlocked: Bool) { @@ -135,7 +135,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private func updateSharedPreferencesState(_ screenshotData: String) { let map: [String: Any] = [ - "is_screenshot_on": NoScreenshotPlugin.preventScreenShot, + "is_screenshot_on": IOSNoScreenshotPlugin.preventScreenShot, "screenshot_path": screenshotData, "was_screenshot_taken": !screenshotData.isEmpty ] diff --git a/ios/Classes/NoScreenshotPlugin.m b/ios/Classes/NoScreenshotPlugin.m index baddc99..f639229 100644 --- a/ios/Classes/NoScreenshotPlugin.m +++ b/ios/Classes/NoScreenshotPlugin.m @@ -10,6 +10,6 @@ @implementation NoScreenshotPlugin + (void)registerWithRegistrar:(NSObject*)registrar { - [NoScreenshotPlugin registerWithRegistrar:registrar]; + [IOSNoScreenshotPlugin registerWithRegistrar:registrar]; } @end diff --git a/macos/Classes/NoScreenshotPlugin.swift b/macos/Classes/MacOSNoScreenshotPlugin.swift similarity index 85% rename from macos/Classes/NoScreenshotPlugin.swift rename to macos/Classes/MacOSNoScreenshotPlugin.swift index aba6b7e..2316985 100644 --- a/macos/Classes/NoScreenshotPlugin.swift +++ b/macos/Classes/MacOSNoScreenshotPlugin.swift @@ -1,7 +1,7 @@ import Cocoa import FlutterMacOS -public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { +public class MacOSNoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private static var methodChannel: FlutterMethodChannel? = nil private static var eventChannel: FlutterEventChannel? = nil private static var preventScreenShot: Bool = false @@ -21,7 +21,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { methodChannel = FlutterMethodChannel(name: methodChannelName, binaryMessenger: registrar.messenger) eventChannel = FlutterEventChannel(name: eventChannelName, binaryMessenger: registrar.messenger) - let instance = NoScreenshotPlugin() + let instance = MacOSNoScreenshotPlugin() registrar.addMethodCallDelegate(instance, channel: methodChannel!) eventChannel?.setStreamHandler(instance) @@ -39,15 +39,15 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { } func persistState() { - UserDefaults.standard.set(NoScreenshotPlugin.preventScreenShot, forKey: NoScreenshotPlugin.preventScreenShotKey) - print("Persisted state: \(NoScreenshotPlugin.preventScreenShot)") + UserDefaults.standard.set(MacOSNoScreenshotPlugin.preventScreenShot, forKey: MacOSNoScreenshotPlugin.preventScreenShotKey) + print("Persisted state: \(MacOSNoScreenshotPlugin.preventScreenShot)") updateSharedPreferencesState("") } func fetchPersistedState() { - let fetchVal = UserDefaults.standard.bool(forKey: NoScreenshotPlugin.preventScreenShotKey) ? NoScreenshotPlugin.DISABLESCREENSHOT : NoScreenshotPlugin.ENABLESCREENSHOT + let fetchVal = UserDefaults.standard.bool(forKey: MacOSNoScreenshotPlugin.preventScreenShotKey) ? MacOSNoScreenshotPlugin.DISABLESCREENSHOT : MacOSNoScreenshotPlugin.ENABLESCREENSHOT updateScreenshotState(isScreenshotBlocked: fetchVal) - print("Fetched state: \(NoScreenshotPlugin.preventScreenShot)") + print("Fetched state: \(MacOSNoScreenshotPlugin.preventScreenShot)") } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { @@ -59,7 +59,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { shotOn() result(true) case "toggleScreenshot": - NoScreenshotPlugin.preventScreenShot ? shotOn() : shotOff() + MacOSNoScreenshotPlugin.preventScreenShot ? shotOn() : shotOff() result(true) case "startScreenshotListening": startListening() @@ -73,7 +73,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { } private func shotOff() { - NoScreenshotPlugin.preventScreenShot = NoScreenshotPlugin.DISABLESCREENSHOT + MacOSNoScreenshotPlugin.preventScreenShot = MacOSNoScreenshotPlugin.DISABLESCREENSHOT print("Screenshot and screen recording prevention activated.") DispatchQueue.main.async { @@ -85,7 +85,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { } private func shotOn() { - NoScreenshotPlugin.preventScreenShot = NoScreenshotPlugin.ENABLESCREENSHOT + MacOSNoScreenshotPlugin.preventScreenShot = MacOSNoScreenshotPlugin.ENABLESCREENSHOT print("Screenshot and screen recording prevention deactivated.") DispatchQueue.main.async { @@ -118,7 +118,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private func updateSharedPreferencesState(_ screenshotData: String) { let map: [String: Any] = [ - "is_screenshot_on": NoScreenshotPlugin.preventScreenShot, + "is_screenshot_on": MacOSNoScreenshotPlugin.preventScreenShot, "screenshot_path": screenshotData, "was_screenshot_taken": !screenshotData.isEmpty ] diff --git a/pubspec.yaml b/pubspec.yaml index d5e7588..92a8da8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ name: no_screenshot description: Flutter plugin to enable, disable, toggle or stream screenshot activities in your application. -version: 0.3.2-beta.1 +version: 0.3.2-beta.2 homepage: https://flutterplaza.com -repository: https://github.com/FlutterPlaza/no_screenshot/releases/tag/v0.3.2-beta.1 +repository: https://github.com/FlutterPlaza/no_screenshot/releases/tag/v0.3.2-beta.2 environment: sdk: '>=3.0.0 <4.0.0' @@ -29,4 +29,4 @@ flutter: ios: pluginClass: NoScreenshotPlugin macos: - pluginClass: NoScreenshotPlugin + pluginClass: MacOSNoScreenshotPlugin