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 UniformTypeIdentifiers
@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate, UIDocumentPickerDelegate {
var flutterResult: FlutterResult?
var directoryPath: URL!

View File

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

View File

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