add swiftUI code
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import Foundation
|
||||
|
||||
extension Bundle {
|
||||
var version: String {
|
||||
infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown"
|
||||
}
|
||||
|
||||
var versionNumber: String {
|
||||
infoDictionary?["CFBundleVersion"] as? String ?? "unknown"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
#elseif canImport(AppKit)
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
public extension Color {
|
||||
static var textColor: Color {
|
||||
#if canImport(UIKit)
|
||||
if #available(iOSApplicationExtension 15.0, *) {
|
||||
return Color(uiColor: .label)
|
||||
}else{
|
||||
return Color.black
|
||||
}
|
||||
|
||||
#elseif canImport(AppKit)
|
||||
return Color(nsColor: .textColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
static var linkColor: Color {
|
||||
#if canImport(UIKit)
|
||||
if #available(iOSApplicationExtension 15.0, *) {
|
||||
return Color(uiColor: .link)
|
||||
}else{
|
||||
return Color.black
|
||||
}
|
||||
|
||||
#elseif canImport(AppKit)
|
||||
return Color(nsColor: .linkColor)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import Foundation
|
||||
|
||||
public enum FilePath {
|
||||
public static let packageName = "com.uuvpn.apple"
|
||||
}
|
||||
|
||||
public extension FilePath {
|
||||
static let groupName = "group.\(packageName)"
|
||||
|
||||
private static let defaultSharedDirectory: URL! = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: FilePath.groupName)
|
||||
|
||||
#if os(iOS)
|
||||
static let sharedDirectory = defaultSharedDirectory!
|
||||
#elseif os(tvOS)
|
||||
static let sharedDirectory = defaultSharedDirectory
|
||||
.appendingPathComponent("Library", isDirectory: true)
|
||||
.appendingPathComponent("Caches", isDirectory: true)
|
||||
#elseif os(macOS)
|
||||
static var sharedDirectory: URL! = defaultSharedDirectory
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
static let cacheDirectory = sharedDirectory
|
||||
.appendingPathComponent("Library", isDirectory: true)
|
||||
.appendingPathComponent("Caches", isDirectory: true)
|
||||
#elseif os(tvOS)
|
||||
static let cacheDirectory = sharedDirectory
|
||||
#elseif os(macOS)
|
||||
static var cacheDirectory: URL {
|
||||
sharedDirectory
|
||||
.appendingPathComponent("Library", isDirectory: true)
|
||||
.appendingPathComponent("Caches", isDirectory: true)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
static var workingDirectory: URL {
|
||||
cacheDirectory.appendingPathComponent("Working", isDirectory: true)
|
||||
}
|
||||
#else
|
||||
static let workingDirectory = cacheDirectory.appendingPathComponent("Working", isDirectory: true)
|
||||
|
||||
#endif
|
||||
|
||||
static var iCloudDirectory = FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents", isDirectory: true) ?? URL(string: "stub")!
|
||||
}
|
||||
|
||||
public extension URL {
|
||||
var fileName: String {
|
||||
var path = relativePath
|
||||
if let index = path.lastIndex(of: "/") {
|
||||
path = String(path[path.index(index, offsetBy: 1)...])
|
||||
}
|
||||
return path
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import Foundation
|
||||
|
||||
public enum Variant {
|
||||
#if os(macOS)
|
||||
public static var useSystemExtension = false
|
||||
#else
|
||||
public static let useSystemExtension = false
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
public static let applicationName = "小熊加速器"
|
||||
#elseif os(macOS)
|
||||
public static let applicationName = "小熊加速器"
|
||||
#elseif os(tvOS)
|
||||
public static let applicationName = "小熊加速器"
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user