提交 cb677d8b authored 作者: 祁增奎's avatar 祁增奎

控制截屏

上级 c972b4c2
...@@ -26,6 +26,23 @@ public class CLXListenerScreenPlugin: NSObject, FlutterPlugin { ...@@ -26,6 +26,23 @@ public class CLXListenerScreenPlugin: NSObject, FlutterPlugin {
registrar.addMethodCallDelegate(instance, channel: channel) registrar.addMethodCallDelegate(instance, channel: channel)
eventChannel.setStreamHandler(instance) eventChannel.setStreamHandler(instance)
} }
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "secureTextEntry":
guard let arguments = call.arguments as? [String: Any] else {
result(false)
return
}
guard let show = arguments["show"] as? Bool else {
result(false)
return
}
result(secureTextEntry(show))
default:
result(FlutterMethodNotImplemented)
}
}
} }
extension CLXListenerScreenPlugin { extension CLXListenerScreenPlugin {
...@@ -55,25 +72,6 @@ extension CLXListenerScreenPlugin { ...@@ -55,25 +72,6 @@ extension CLXListenerScreenPlugin {
} }
} }
extension CLXListenerScreenPlugin {
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "secureTextEntry":
guard let arguments = call.arguments as? [String: Any] else {
result(false)
return
}
guard let show = arguments["show"] as? Bool else {
result(false)
return
}
result(secureTextEntry(show))
default:
result(FlutterMethodNotImplemented)
}
}
}
extension CLXListenerScreenPlugin: FlutterStreamHandler { extension CLXListenerScreenPlugin: FlutterStreamHandler {
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
_eventSink = events _eventSink = events
...@@ -90,7 +88,7 @@ extension CLXListenerScreenPlugin: UITextFieldDelegate { ...@@ -90,7 +88,7 @@ extension CLXListenerScreenPlugin: UITextFieldDelegate {
private func secureTextEntry(_ show: Bool) -> Bool { private func secureTextEntry(_ show: Bool) -> Bool {
// 未找到解决好的方案 // 未找到解决好的方案
NotificationCenter.default.post(name: Notification.Name("CLXListenerSecure"), object: show)
return true return true
} }
...@@ -98,3 +96,4 @@ extension CLXListenerScreenPlugin: UITextFieldDelegate { ...@@ -98,3 +96,4 @@ extension CLXListenerScreenPlugin: UITextFieldDelegate {
return false return false
} }
} }
...@@ -15,7 +15,7 @@ dependencies: ...@@ -15,7 +15,7 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0 device_info_plus: ^9.1.1
flutter: flutter:
...@@ -23,6 +23,6 @@ flutter: ...@@ -23,6 +23,6 @@ flutter:
platforms: platforms:
android: android:
package: com.clx.example.clx_listener_screen package: com.clx.example.clx_listener_screen
pluginClass: ClXListenerScreenPlugin pluginClass: CLXListenerScreenPlugin
ios: ios:
pluginClass: ClXListenerScreenPlugin pluginClass: CLXListenerScreenPlugin
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论