refactor: chat input

This commit is contained in:
cogwheel0
2025-09-18 15:01:21 +05:30
parent ac12eca6b5
commit dea14dfdcf
3 changed files with 377 additions and 526 deletions

View File

@@ -145,24 +145,16 @@ class BackgroundStreamingHandler: NSObject {
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
// Setup background streaming handler with scene-safe rootViewController access
var controller: FlutterViewController?
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let root = scene.windows.first?.rootViewController as? FlutterViewController {
controller = root
} else if let legacy = window?.rootViewController as? FlutterViewController {
controller = legacy
}
if let controller {
// Setup background streaming handler using the plugin registry messenger
if let registrar = self.registrar(forPlugin: "BackgroundStreamingHandler") {
let channel = FlutterMethodChannel(
name: "conduit/background_streaming",
binaryMessenger: controller.binaryMessenger
binaryMessenger: registrar.messenger()
)
backgroundStreamingHandler = BackgroundStreamingHandler()
backgroundStreamingHandler?.setup(with: channel)
// Register method call handler
channel.setMethodCallHandler { [weak self] (call, result) in
self?.backgroundStreamingHandler?.handle(call, result: result)