Files
hapi/ios/Hapi/Features/Home/MacPlatform.swift
T
weishu fa02830a60 fix(ios): show the chat title in the Mac toolbar
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.
2026-11-03 11:21:32 +08:00

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()) }
}