import Foundation #if canImport(SwiftUI) import SwiftUI #endif #if canImport(CoreGraphics) import CoreGraphics #endif #if canImport(UIKit) import UIKit #endif #if canImport(AppKit) import AppKit #endif #if !canImport(UIKit) struct UIDevice { static let topNotch = 0.0 static let bottomNotch = 0.0 var modelName: String { "android" } } #endif #if !(canImport(LCEssentials) && os(iOS)) func printLog(title: String, msg: String) { print("[\(title)] \(msg)") } func printError(title: String, msg: String) { print("[\(title)] \(msg)") } #endif func appReadClipboardText() -> String? { #if canImport(UIKit) return UIPasteboard.general.string #elseif canImport(AppKit) return NSPasteboard.general.string(forType: .string) #elseif os(Android) return UIPasteboard.general.string #else return nil #endif } func appWriteClipboardText(_ value: String) { #if canImport(UIKit) UIPasteboard.general.string = value #elseif canImport(AppKit) NSPasteboard.general.clearContents() NSPasteboard.general.setString(value, forType: .string) #elseif os(Android) UIPasteboard.general.string = value #else _ = value #endif } extension View { @ViewBuilder func appInlineNavigationTitle() -> some View { #if os(macOS) self #else self.navigationBarTitleDisplayMode(.inline) #endif } @ViewBuilder func appHiddenNavigationBar() -> some View { #if os(macOS) self #else self .toolbar(.hidden, for: .navigationBar) .toolbarBackground(.hidden, for: .navigationBar) #endif } @ViewBuilder func appTopBarTrailingToolbar(@ViewBuilder content: () -> Content) -> some View { #if os(macOS) self.toolbar { ToolbarItem { content() } } #else self.toolbar { ToolbarItem(placement: .topBarTrailing) { content() } } #endif } @ViewBuilder func appContentShape(_ shape: S) -> some View { #if os(Android) self #else self.contentShape(shape) #endif } @ViewBuilder func appBottomSafeAreaInset(@ViewBuilder content: () -> Content) -> some View { #if os(Android) self.overlay(alignment: .bottom) { content() } #else self.safeAreaInset(edge: .bottom) { content() } #endif } @ViewBuilder func appLayoutPriority(_ value: Double) -> some View { #if os(Android) self #else self.layoutPriority(value) #endif } @ViewBuilder func appNamedCoordinateSpace(_ name: String) -> some View { #if os(Android) self #else self.coordinateSpace(name: name) #endif } }