fix macOS AppDelegate.swift & UI update

This commit is contained in:
deltamaya
2024-10-28 17:41:46 +08:00
parent f0c7bfd52e
commit 2025b5835b
3 changed files with 18 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ import Flutter
import UIKit import UIKit
import UniformTypeIdentifiers import UniformTypeIdentifiers
@UIApplicationMain @main
@objc class AppDelegate: FlutterAppDelegate, UIDocumentPickerDelegate { @objc class AppDelegate: FlutterAppDelegate, UIDocumentPickerDelegate {
var flutterResult: FlutterResult? var flutterResult: FlutterResult?
var directoryPath: URL! var directoryPath: URL!

View File

@@ -96,7 +96,7 @@ class WindowFrame extends StatelessWidget {
? Colors.white ? Colors.white
: Colors.black, : Colors.black,
), ),
).toAlign(Alignment.centerLeft).paddingLeft(4), ).toAlign(Alignment.centerLeft).paddingLeft(4+(App.isMacOS?25:0)),
), ),
), ),
if (kDebugMode) if (kDebugMode)

View File

@@ -1,7 +1,7 @@
import Cocoa import Cocoa
import FlutterMacOS import FlutterMacOS
@NSApplicationMain @main
class AppDelegate: FlutterAppDelegate { class AppDelegate: FlutterAppDelegate {
var flutterResult: FlutterResult? var flutterResult: FlutterResult?
var directoryPath: URL! var directoryPath: URL!
@@ -13,15 +13,21 @@ class AppDelegate: FlutterAppDelegate {
methodChannel.setMethodCallHandler { (call, result) in methodChannel.setMethodCallHandler { (call, result) in
switch call.method { switch call.method {
case "getProxy": case "getProxy":
if let proxySettings = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() as NSDictionary?, if let proxySettings = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() as NSDictionary? {
let dict = proxySettings.object(forKey: kCFNetworkProxiesHTTPProxy) as? NSDictionary, if let httpProxy = proxySettings[kCFNetworkProxiesHTTPProxy] as? String,
let host = dict.object(forKey: kCFNetworkProxiesHTTPProxy) as? String, let httpPort = proxySettings[kCFNetworkProxiesHTTPPort] as? Int {
let port = dict.object(forKey: kCFNetworkProxiesHTTPPort) as? Int { let proxyConfig = "\(httpProxy):\(httpPort)"
let proxyConfig = "\(host):\(port)" result(proxyConfig)
result(proxyConfig) } else if let socksProxy = proxySettings[kCFNetworkProxiesSOCKSProxy] as? String,
} else { let socksPort = proxySettings[kCFNetworkProxiesSOCKSPort] as? Int {
result("") let proxyConfig = "\(socksProxy):\(socksPort)"
} result(proxyConfig)
} else {
result("")
}
} else {
result("")
}
case "getDirectoryPath": case "getDirectoryPath":
self.flutterResult = result self.flutterResult = result
self.getDirectoryPath() self.getDirectoryPath()