fix(android): isolate platform-specific shared ui code

This commit is contained in:
Daniel Arantes Loverde
2026-03-19 16:11:07 -03:00
parent c49725a5f7
commit cb7bfef356
16 changed files with 413 additions and 35 deletions

View File

@@ -0,0 +1,72 @@
import Foundation
#if canImport(SwiftUI)
import SwiftUI
#endif
#if canImport(CoreGraphics)
import CoreGraphics
#endif
#if canImport(UIKit)
import UIKit
#endif
#if !canImport(UIKit)
struct UIDevice {
static let topNotch: CGFloat = 0
static let bottomNotch: CGFloat = 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
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<Content: View>(@ViewBuilder content: () -> Content) -> some View {
#if os(macOS)
self.toolbar {
ToolbarItem {
content()
}
}
#else
self.toolbar {
ToolbarItem(placement: .topBarTrailing) {
content()
}
}
#endif
}
}