mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-11 13:54:06 -06:00
23 lines
615 B
Swift
23 lines
615 B
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
struct EmptyStateViewModifier<EmptyContent>: ViewModifier where EmptyContent: View {
|
|
var isEmpty: Bool
|
|
let emptyContent: () -> EmptyContent
|
|
|
|
func body(content: Content) -> some View {
|
|
if isEmpty {
|
|
emptyContent()
|
|
} else {
|
|
content
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func emptyState<EmptyContent>(_ isEmpty: Bool,
|
|
emptyContent: @escaping () -> EmptyContent) -> some View where EmptyContent: View {
|
|
modifier(EmptyStateViewModifier(isEmpty: isEmpty, emptyContent: emptyContent))
|
|
}
|
|
}
|