mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
The Mac window's NSToolbar drops the custom .principal header, and the hidden titlebar title also hid the navigation title. Use the system title on Mac (as on the folded Duo) with a unified toolbar instead.
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
import SwiftUI
|
|
import UIKit
|
|
|
|
/// Mac window chrome: a unified toolbar (its title is the navigation title,
|
|
/// so keep it visible), and a minimum size that still fits sidebar + chat.
|
|
/// A no-op on iOS.
|
|
struct MacWindowConfigurator: UIViewRepresentable {
|
|
func makeUIView(context: Context) -> UIView { ProbeView() }
|
|
func updateUIView(_ uiView: UIView, context: Context) {}
|
|
|
|
private final class ProbeView: UIView {
|
|
override func didMoveToWindow() {
|
|
super.didMoveToWindow()
|
|
#if targetEnvironment(macCatalyst)
|
|
guard let scene = window?.windowScene else { return }
|
|
scene.sizeRestrictions?.minimumSize = CGSize(width: 480, height: 480)
|
|
scene.titlebar?.toolbarStyle = .unified
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Mac sheets default to a small fixed form size that clips long forms;
|
|
/// page sizing gives settings, new-session and pairing forms room. iOS keeps
|
|
/// its system sheet sizes and detents.
|
|
private struct MacSheetSizing: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
#if targetEnvironment(macCatalyst)
|
|
if #available(macCatalyst 18.0, *) {
|
|
content.presentationSizing(.page)
|
|
} else {
|
|
content
|
|
}
|
|
#else
|
|
content
|
|
#endif
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func macSheetSizing() -> some View { modifier(MacSheetSizing()) }
|
|
}
|