mirror of
https://github.com/yattee/yattee.git
synced 2026-02-19 17:29:45 +00:00
37 lines
824 B
Swift
37 lines
824 B
Swift
//
|
|
// View+NavigationSubtitle.swift
|
|
// Yattee
|
|
//
|
|
// Conditionally applies .navigationSubtitle on iOS 26+ and macOS 26+.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct NavigationSubtitleModifier: ViewModifier {
|
|
let subtitle: String?
|
|
|
|
func body(content: Content) -> some View {
|
|
#if os(iOS)
|
|
if #available(iOS 26, *), let subtitle {
|
|
content.navigationSubtitle(subtitle)
|
|
} else {
|
|
content
|
|
}
|
|
#elseif os(macOS)
|
|
if #available(macOS 26, *), let subtitle {
|
|
content.navigationSubtitle(subtitle)
|
|
} else {
|
|
content
|
|
}
|
|
#else
|
|
content
|
|
#endif
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func navigationSubtitleIfAvailable(_ subtitle: String?) -> some View {
|
|
modifier(NavigationSubtitleModifier(subtitle: subtitle))
|
|
}
|
|
}
|