yattee/Backports/Badge+Backport.swift
2021-12-02 20:33:32 +01:00

17 lines
409 B
Swift

import SwiftUI
extension Backport where Content: View {
@ViewBuilder func badge(_ count: Text) -> some View {
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
content.badge(count)
} else {
HStack {
content
Spacer()
Text("\(count)")
.foregroundColor(.secondary)
}
}
}
}